PostgreSQL Source Code  git master
connect-test5.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for connect-test5.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Functions

int main (void)
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file connect-test5.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 22 of file connect-test5.c.

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  /* exec sql connect to as main user regress_ecpg_user2/insecure;
90  exec sql disconnect main; */
91 
92  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
93 #line 46 "test5.pgc"
94 
95  { ECPGdisconnect(__LINE__, "main");}
96 #line 47 "test5.pgc"
97 
98 
99  { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
100 #line 49 "test5.pgc"
101 
102  { ECPGdisconnect(__LINE__, "main");}
103 #line 50 "test5.pgc"
104 
105 
106  { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
107 #line 52 "test5.pgc"
108 
109  { ECPGdisconnect(__LINE__, "main");}
110 #line 53 "test5.pgc"
111 
112 
113  { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , user , "connectpw" , "main", 0); }
114 #line 55 "test5.pgc"
115 
116  { ECPGdisconnect(__LINE__, "main");}
117 #line 56 "test5.pgc"
118 
119 
120  { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=180 & client_encoding=sql_ascii" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
121 #line 58 "test5.pgc"
122 
123  { ECPGdisconnect(__LINE__, "main");}
124 #line 59 "test5.pgc"
125 
126 
127  { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); }
128 #line 61 "test5.pgc"
129 
130  { ECPGdisconnect(__LINE__, "main");}
131 #line 62 "test5.pgc"
132 
133 
134  { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/?gssencmode=disable" , "regress_ecpg_user2" , "insecure" , "main", 0); }
135 #line 64 "test5.pgc"
136 
137  { ECPGdisconnect(__LINE__, "main");}
138 #line 65 "test5.pgc"
139 
140 
141  /* connect twice */
142  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
143 #line 68 "test5.pgc"
144 
145  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
146 #line 69 "test5.pgc"
147 
148  { ECPGdisconnect(__LINE__, "main");}
149 #line 70 "test5.pgc"
150 
151 
152  /* not connected */
153  { ECPGdisconnect(__LINE__, "nonexistent");}
154 #line 73 "test5.pgc"
155 
156 
157  return 0;
158 }
#define ECPGdebug(X, Y)
Definition: connect-test5.c:7
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:673
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_EORT
Definition: ecpgtype.h:63
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:2277
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:160
static char * user
Definition: pg_regress.c:120

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, ECPGtrans(), and user.