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 "test1.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
22 main(void)
23 {
24 /* exec sql begin declare section */
25
26
27
28 #line 16 "test1.pgc"
29 char db [ 200 ] ;
30
cb_slack_init(struct flb_output_instance * ins,struct flb_config * config,void * data)31 #line 17 "test1.pgc"
32 char pw [ 200 ] ;
33 /* exec sql end declare section */
34 #line 18 "test1.pgc"
35
36
37 ECPGdebug(1, stderr);
38
39 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
40 #line 22 "test1.pgc"
41
42 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user1 encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
43 #line 23 "test1.pgc"
44
45 { ECPGdisconnect(__LINE__, "CURRENT");}
46 #line 24 "test1.pgc"
47 /* <-- "main" not specified */
48
49 { ECPGconnect(__LINE__, 0, "ecpg2_regression@localhost" , NULL, NULL , "main", 0); }
50 #line 26 "test1.pgc"
51
52 { ECPGdisconnect(__LINE__, "main");}
53 #line 27 "test1.pgc"
54
55
56 { ECPGconnect(__LINE__, 0, "@localhost" , "regress_ecpg_user2" , NULL , "main", 0); }
57 #line 29 "test1.pgc"
58
59 { ECPGdisconnect(__LINE__, "main");}
60 #line 30 "test1.pgc"
61
62
63 /* exec sql connect to :@TEMP_PORT@ as main user regress_ecpg_user2;
64 exec sql disconnect main; */
65
66 { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); }
67 #line 35 "test1.pgc"
68
69 { ECPGdisconnect(__LINE__, "CURRENT");}
70 #line 36 "test1.pgc"
71
72
73 { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/" , "regress_ecpg_user2" , NULL , NULL, 0); }
74 #line 38 "test1.pgc"
75
76 { ECPGdisconnect(__LINE__, "CURRENT");}
77 #line 39 "test1.pgc"
78
79
80 strcpy(pw, "connectpw");
81 strcpy(db, "tcp:postgresql://localhost/ecpg2_regression");
82 { ECPGconnect(__LINE__, 0, db , "regress_ecpg_user1" , pw , NULL, 0); }
83 #line 43 "test1.pgc"
84
85 { ECPGdisconnect(__LINE__, "CURRENT");}
86 #line 44 "test1.pgc"
87
88
89 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); }
90 #line 46 "test1.pgc"
91
92 { ECPGdisconnect(__LINE__, "CURRENT");}
93 #line 47 "test1.pgc"
94
95
96 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=180" , "regress_ecpg_user1" , NULL , NULL, 0); }
97 #line 49 "test1.pgc"
98
99 { ECPGdisconnect(__LINE__, "CURRENT");}
100 #line 50 "test1.pgc"
101
102
103 /* wrong db */
104 { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/nonexistent" , "regress_ecpg_user1" , "connectpw" , NULL, 0); }
105 #line 53 "test1.pgc"
106
107 { ECPGdisconnect(__LINE__, "CURRENT");}
108 #line 54 "test1.pgc"
109
110
111 /* wrong port */
112 { ECPGconnect(__LINE__, 0, "tcp:postgresql://127.0.0.1:20/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); }
113 #line 57 "test1.pgc"
114
115 /* no disconnect necessary */
116
117 /* wrong password */
118 { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "wrongpw" , NULL, 0); }
119 #line 61 "test1.pgc"
120
121 /* no disconnect necessary */
122
123 return 0;
124 }
125