summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/connect/test3.pgc
blob: 5d075f0e99d860304014ba31a6e0e2496067163a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * this file just tests the several possibilities you have for a disconnect
 */

#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

exec sql include ../regression;

int
main(void)
{
exec sql begin declare section;
	char id[200];
	char res[200];
exec sql end declare section;

	ECPGdebug(1, stderr);

	strcpy(id, "first");
	exec sql connect to ecpg2_regression as :id;
	exec sql connect to REGRESSDB1 as second;

	/* this selects from "second" which was opened last */
	exec sql select current_database() into :res;

	/* will close "second" */
	exec sql disconnect CURRENT;
	exec sql select current_database() into :res;

	exec sql connect to REGRESSDB1 as second;
	/* will close "second" */
	exec sql disconnect DEFAULT;

	exec sql connect to "ecpg2_regression" as second;
	exec sql disconnect ALL;

	exec sql disconnect CURRENT;
	exec sql disconnect DEFAULT;
	exec sql disconnect ALL;

	/*
	 * exec sql disconnect;
	 * exec sql disconnect name;
	 *
	 *     are used in other tests
	 */

	return 0;
}