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 "test5.pgc"
10 /*
11 * this file tests all sorts of connecting to one single database.
12 */
13
14 #include <stdlib.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18
19 /* do not include regression.h */
20
21 int
main(void)22 main(void)
23 {
24 /* exec sql begin declare section */
25
26
27
28
29 #line 16 "test5.pgc"
30 char db [ 200 ] ;
31
32 #line 17 "test5.pgc"
33 char id [ 200 ] ;
34
35 #line 18 "test5.pgc"
36 char * user = "regress_ecpg_user1" ;
37 /* exec sql end declare section */
38 #line 19 "test5.pgc"
39
40
41 ECPGdebug(1, stderr);
42
43 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
44 #line 23 "test5.pgc"
45
46 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user2 encrypted password 'insecure'", ECPGt_EOIT, ECPGt_EORT);}
47 #line 24 "test5.pgc"
48
49 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user1 encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
50 #line 25 "test5.pgc"
51
52 { ECPGtrans(__LINE__, NULL, "commit");}
53 #line 26 "test5.pgc"
54
55 { ECPGdisconnect(__LINE__, "CURRENT");}
56 #line 27 "test5.pgc"
57 /* <-- "main" not specified */
58
59 strcpy(db, "ecpg2_regression");
60 strcpy(id, "main");
61 { ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); }
62 #line 31 "test5.pgc"
63
64 { ECPGdisconnect(__LINE__, id);}
65 #line 32 "test5.pgc"
66
67
68 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
69 #line 34 "test5.pgc"
70
71 { ECPGdisconnect(__LINE__, "main");}
72 #line 35 "test5.pgc"
73
74
75 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
76 #line 37 "test5.pgc"
77
78 { ECPGdisconnect(__LINE__, "main");}
79 #line 38 "test5.pgc"
80
81
82 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
83 #line 40 "test5.pgc"
84
85 { ECPGdisconnect(__LINE__, "main");}
86 #line 41 "test5.pgc"
87
88
89 { ECPGconnect(__LINE__, 0, "" , "regress_ecpg_user2" , "insecure" , "main", 0); }
90 #line 43 "test5.pgc"
91
92 { ECPGdisconnect(__LINE__, "main");}
93 #line 44 "test5.pgc"
94
95
96 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
97 #line 46 "test5.pgc"
98
99 { ECPGdisconnect(__LINE__, "main");}
100 #line 47 "test5.pgc"
101
102
103 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
104 #line 49 "test5.pgc"
105
106 { ECPGdisconnect(__LINE__, "main");}
107 #line 50 "test5.pgc"
108
109
110 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
111 #line 52 "test5.pgc"
112
113 { ECPGdisconnect(__LINE__, "main");}
114 #line 53 "test5.pgc"
115
116
117 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , user , "connectpw" , "main", 0); }
118 #line 55 "test5.pgc"
119
120 { ECPGdisconnect(__LINE__, "main");}
121 #line 56 "test5.pgc"
122
123
124 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=180 & client_encoding=latin1" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
125 #line 58 "test5.pgc"
126
127 { ECPGdisconnect(__LINE__, "main");}
128 #line 59 "test5.pgc"
129
130
131 { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
132 #line 61 "test5.pgc"
133
134 { ECPGdisconnect(__LINE__, "main");}
135 #line 62 "test5.pgc"
136
137
138 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "regress_ecpg_user2" , "insecure" , "main", 0); }
139 #line 64 "test5.pgc"
140
141 { ECPGdisconnect(__LINE__, "main");}
142 #line 65 "test5.pgc"
143
144
145 /* connect twice */
146 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
147 #line 68 "test5.pgc"
148
149 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
150 #line 69 "test5.pgc"
151
152 { ECPGdisconnect(__LINE__, "main");}
153 #line 70 "test5.pgc"
154
155
156 /* not connected */
157 { ECPGdisconnect(__LINE__, "nonexistant");}
158 #line 73 "test5.pgc"
159
160
161 return (0);
162 }
163