| 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 |
| 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 |
/* 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 |
} |