Line data Source code
1 : /* 2 : * this file tests all sorts of connecting to one single database. 3 : */ 4 : 5 : #include <stdlib.h> 6 : #include <string.h> 7 : #include <stdlib.h> 8 : #include <stdio.h> 9 : 10 : /* do not include regression.h */ 11 : 12 : int 13 4 : main(void) 14 : { 15 : exec sql begin declare section; 16 : char db[200]; 17 : char id[200]; 18 4 : char *user="regress_ecpg_user1"; 19 : exec sql end declare section; 20 : 21 4 : ECPGdebug(1, stderr); 22 : 23 4 : exec sql connect to ecpg2_regression as main; 24 4 : exec sql alter user regress_ecpg_user2 ENCRYPTED PASSWORD 'insecure'; 25 4 : exec sql alter user regress_ecpg_user1 ENCRYPTED PASSWORD 'connectpw'; 26 4 : exec sql commit; 27 4 : exec sql disconnect; /* <-- "main" not specified */ 28 : 29 4 : strcpy(db, "ecpg2_regression"); 30 4 : strcpy(id, "main"); 31 4 : exec sql connect to :db as :id; 32 4 : exec sql disconnect :id; 33 : 34 4 : exec sql connect to ecpg2_regression as main; 35 4 : exec sql disconnect main; 36 : 37 4 : exec sql connect to "ecpg2_regression" as main; 38 4 : exec sql disconnect main; 39 : 40 4 : exec sql connect to 'ecpg2_regression' as main; 41 4 : exec sql disconnect main; 42 : 43 : /* exec sql connect to as main user regress_ecpg_user2/insecure; 44 : exec sql disconnect main; */ 45 : 46 4 : exec sql connect to ecpg2_regression as main user regress_ecpg_user1/connectpw; 47 4 : exec sql disconnect main; 48 : 49 4 : exec sql connect to unix:postgresql://localhost/ecpg2_regression as main user regress_ecpg_user1/connectpw; 50 4 : exec sql disconnect main; 51 : 52 4 : exec sql connect to "unix:postgresql://localhost/ecpg2_regression" as main user regress_ecpg_user1/connectpw; 53 4 : exec sql disconnect main; 54 : 55 4 : exec sql connect to 'unix:postgresql://localhost/ecpg2_regression' as main user :user USING "connectpw"; 56 4 : exec sql disconnect main; 57 : 58 4 : exec sql connect to unix:postgresql://localhost/ecpg2_regression?connect_timeout=180&client_encoding=sql_ascii as main user regress_ecpg_user1/connectpw; 59 4 : exec sql disconnect main; 60 : 61 4 : exec sql connect to "unix:postgresql://200.46.204.71/ecpg2_regression" as main user regress_ecpg_user1/connectpw; 62 4 : exec sql disconnect main; 63 : 64 4 : exec sql connect to "unix:postgresql://localhost/?gssencmode=disable" as main user regress_ecpg_user2 IDENTIFIED BY insecure; 65 4 : exec sql disconnect main; 66 : 67 : /* connect twice */ 68 4 : exec sql connect to ecpg2_regression as main; 69 4 : exec sql connect to ecpg2_regression as main; 70 4 : exec sql disconnect main; 71 : 72 : /* not connected */ 73 4 : exec sql disconnect nonexistent; 74 : 75 4 : return 0; 76 : }