PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
connect-test2.c
Go to the documentation of this file.
1/* Processed by ecpg (regression mode) */
2/* These include files are added by the preprocessor */
3#include <ecpglib.h>
4#include <ecpgerrno.h>
5#include <sqlca.h>
6/* End of automatic include section */
7#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8
9#line 1 "test2.pgc"
10/*
11 * this file tests multiple connections to databases and switches
12 * between them.
13 */
14
15#include <stdlib.h>
16#include <string.h>
17#include <stdlib.h>
18#include <stdio.h>
19
20
21#line 1 "regression.h"
22
23
24
25
26
27
28#line 11 "test2.pgc"
29
30
31int
32main(void)
33{
34/* exec sql begin declare section */
35
36
37
38#line 17 "test2.pgc"
39 char id [ 200 ] ;
40
41#line 18 "test2.pgc"
42 char res [ 200 ] ;
43/* exec sql end declare section */
44#line 19 "test2.pgc"
45
46
47 ECPGdebug(1, stderr);
48
49 strcpy(id, "first");
50 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , id, 0); }
51#line 24 "test2.pgc"
52
53 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "second", 0); }
54#line 25 "test2.pgc"
55
56
57 /* this selects from "second" which was opened last */
58 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
59 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
60 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
61#line 28 "test2.pgc"
62
63 { ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
64 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
65 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
66#line 29 "test2.pgc"
67
68 { ECPGdo(__LINE__, 0, 1, "second", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
69 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
70 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
71#line 30 "test2.pgc"
72
73
74 { ECPGsetconn(__LINE__, "first");}
75#line 32 "test2.pgc"
76
77 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
78 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
79 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
80#line 33 "test2.pgc"
81
82
83 /* this will disconnect from "first" */
84 { ECPGdisconnect(__LINE__, "CURRENT");}
85#line 36 "test2.pgc"
86
87 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
88 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
89 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
90#line 37 "test2.pgc"
91
92
93 /* error here since "first" is already disconnected */
94 { ECPGdisconnect(__LINE__, id);}
95#line 40 "test2.pgc"
96
97
98 /* disconnect from "second" */
99 { ECPGdisconnect(__LINE__, "CURRENT");}
100#line 43 "test2.pgc"
101
102
103 return 0;
104}
int main(void)
Definition: connect-test2.c:32
#define ECPGdebug(X, Y)
Definition: connect-test2.c:7
bool ECPGsetconn(int lineno, const char *connection_name)
Definition: connect.c:190
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:676
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_char
Definition: ecpgtype.h:43
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2275