diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/interfaces/ecpg/test/connect/test5.pgc | |
parent | Initial commit. (diff) | |
download | postgresql-14-upstream.tar.xz postgresql-14-upstream.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/interfaces/ecpg/test/connect/test5.pgc')
-rw-r--r-- | src/interfaces/ecpg/test/connect/test5.pgc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/connect/test5.pgc b/src/interfaces/ecpg/test/connect/test5.pgc new file mode 100644 index 0000000..de29160 --- /dev/null +++ b/src/interfaces/ecpg/test/connect/test5.pgc @@ -0,0 +1,76 @@ +/* + * this file tests all sorts of connecting to one single database. + */ + +#include <stdlib.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +/* do not include regression.h */ + +int +main(void) +{ +exec sql begin declare section; + char db[200]; + char id[200]; + char *user="regress_ecpg_user1"; +exec sql end declare section; + + ECPGdebug(1, stderr); + + exec sql connect to ecpg2_regression as main; + exec sql alter user regress_ecpg_user2 ENCRYPTED PASSWORD 'insecure'; + exec sql alter user regress_ecpg_user1 ENCRYPTED PASSWORD 'connectpw'; + exec sql commit; + exec sql disconnect; /* <-- "main" not specified */ + + strcpy(db, "ecpg2_regression"); + strcpy(id, "main"); + exec sql connect to :db as :id; + exec sql disconnect :id; + + exec sql connect to ecpg2_regression as main; + exec sql disconnect main; + + exec sql connect to "ecpg2_regression" as main; + exec sql disconnect main; + + exec sql connect to 'ecpg2_regression' as main; + exec sql disconnect main; + + /* exec sql connect to as main user regress_ecpg_user2/insecure; + exec sql disconnect main; */ + + exec sql connect to ecpg2_regression as main user regress_ecpg_user1/connectpw; + exec sql disconnect main; + + exec sql connect to unix:postgresql://localhost/ecpg2_regression as main user regress_ecpg_user1/connectpw; + exec sql disconnect main; + + exec sql connect to "unix:postgresql://localhost/ecpg2_regression" as main user regress_ecpg_user1/connectpw; + exec sql disconnect main; + + exec sql connect to 'unix:postgresql://localhost/ecpg2_regression' as main user :user USING "connectpw"; + exec sql disconnect main; + + exec sql connect to unix:postgresql://localhost/ecpg2_regression?connect_timeout=180&client_encoding=latin1 as main user regress_ecpg_user1/connectpw; + exec sql disconnect main; + + exec sql connect to "unix:postgresql://200.46.204.71/ecpg2_regression" as main user regress_ecpg_user1/connectpw; + exec sql disconnect main; + + exec sql connect to "unix:postgresql://localhost/?gssencmode=disable" as main user regress_ecpg_user2 IDENTIFIED BY insecure; + exec sql disconnect main; + + /* connect twice */ + exec sql connect to ecpg2_regression as main; + exec sql connect to ecpg2_regression as main; + exec sql disconnect main; + + /* not connected */ + exec sql disconnect nonexistent; + + return 0; +} |