OSDN Git Service

- Enabled single-quoted connection targets.
authorMichael Meskes <meskes@postgresql.org>
Sun, 27 Aug 2006 16:15:42 +0000 (16:15 +0000)
committerMichael Meskes <meskes@postgresql.org>
Sun, 27 Aug 2006 16:15:42 +0000 (16:15 +0000)
- Fixed a memory leak/segfault in unsuccessful connection.
- Some changes to test files.

src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/test/connect/Makefile
src/interfaces/ecpg/test/connect/test1.pgc.in
src/interfaces/ecpg/test/connect/test5.pgc [new file with mode: 0644]
src/interfaces/ecpg/test/expected/connect-test1.c
src/interfaces/ecpg/test/expected/connect-test1.stderr
src/interfaces/ecpg/test/expected/connect-test5.c [new file with mode: 0644]
src/interfaces/ecpg/test/expected/connect-test5.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/connect-test5.stdout [new file with mode: 0644]

index 2b82753..032e997 100644 (file)
@@ -2121,5 +2121,10 @@ Th 24. Aug 11:53:29 CEST 2006
 
        - Fixed of by one variable size.
        - Synced parser.
+
+Su 27. Aug 17:54:36 CEST 2006
+
+       - Enabled single-quoted connection targets.
+       - Fixed a memory leak/segfault in unsuccessful connection.
        - Set ecpg library version to 5.2.
        - Set ecpg version to 4.2.1.
index dd85502..4ce68c2 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.33 2006/08/13 10:18:29 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.34 2006/08/27 16:15:41 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -316,25 +316,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
        if (dbname != NULL)
        {
                /* get the detail information out of dbname */
-               if (strchr(dbname, '@') != NULL)
-               {
-                       /* old style: dbname[@server][:port] */
-                       tmp = strrchr(dbname, ':');
-                       if (tmp != NULL)        /* port number given */
-                       {
-                               port = ECPGstrdup(tmp + 1, lineno);
-                               *tmp = '\0';
-                       }
-
-                       tmp = strrchr(dbname, '@');
-                       if (tmp != NULL)        /* host name given */
-                       {
-                               host = ECPGstrdup(tmp + 1, lineno);
-                               *tmp = '\0';
-                       }
-                       realname = ECPGstrdup(dbname, lineno);
-               }
-               else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
+               if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
                {
                        int                     offset = 0;
 
@@ -396,6 +378,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                                                                ECPGfree(realname);
                                                        if (dbname)
                                                                ECPGfree(dbname);
+                                                       free(this);
                                                        return false;
                                                }
                                        }
@@ -419,7 +402,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                                                        ECPGfree(realname);
                                                if (dbname)
                                                        ECPGfree(dbname);
-                                               ecpg_finish(this);
+                                               free(this);
                                                return false;
                                        }
                                }
@@ -427,11 +410,25 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                                        host = ECPGstrdup(dbname + offset, lineno);
 
                        }
-                       else
-                               realname = ECPGstrdup(dbname, lineno);
                }
                else
+               {
+                       /* old style: dbname[@server][:port] */
+                       tmp = strrchr(dbname, ':');
+                       if (tmp != NULL)        /* port number given */
+                       {
+                               port = ECPGstrdup(tmp + 1, lineno);
+                               *tmp = '\0';
+                       }
+
+                       tmp = strrchr(dbname, '@');
+                       if (tmp != NULL)        /* host name given */
+                       {
+                               host = ECPGstrdup(tmp + 1, lineno);
+                               *tmp = '\0';
+                       }
                        realname = ECPGstrdup(dbname, lineno);
+               }
        }
        else
                realname = NULL;
index 3e7b717..e2bd8c4 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.332 2006/08/24 12:31:33 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.333 2006/08/27 16:15:41 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -4640,7 +4640,7 @@ connection_target: database_name opt_server opt_port
                        if (strncmp($1, "unix", strlen("unix")) == 0 &&
                                strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
                                strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
-                               mmerror(PARSE_ERROR, ET_ERROR, "unix domain sockets only work on 'localhost' but not on '%9.9s'", $3 + strlen("//"));
+                               mmerror(PARSE_ERROR, ET_ERROR, "unix domain sockets only work on 'localhost' but not on '%s'", $3 + strlen("//"));
 
                        $$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6),    $7, make_str("\"")));
                }
@@ -4648,6 +4648,15 @@ connection_target: database_name opt_server opt_port
                {
                        $$ = $1;
                }
+               | Sconst
+               {
+                       /* We can only process double quoted strings not single quotes ones,
+                        * so we change the quotes.
+                        * Note, that the rule for Sconst adds these single quotes. */
+                       $1[0] = '\"';
+                       $1[strlen($1)-1] = '\"';
+                       $$ = $1;
+               }
                ;
 
 db_prefix: ident cvariable
index abb2cd9..ab3750a 100644 (file)
@@ -14,7 +14,8 @@ test1.pgc: test1.pgc.in
 TESTS = test1 test1.c \
         test2 test2.c \
         test3 test3.c \
-        test4 test4.c
+        test4 test4.c \
+        test5 test5.c
 
 all: $(TESTS)
 
index 0300e6a..b2141d1 100644 (file)
@@ -14,7 +14,6 @@ main(void)
 {
 exec sql begin declare section;
        char db[200];
-       char id[200];
        char pw[200];
 exec sql end declare section;
 
@@ -24,18 +23,13 @@ exec sql end declare section;
        exec sql alter user connectuser ENCRYPTED PASSWORD 'connectpw';
        exec sql disconnect;  /* <-- "main" not specified */
 
-       strcpy(db, "connectdb");
-       strcpy(id, "main");
-       exec sql connect to :db as :id;
-       exec sql disconnect :id;
-
        exec sql connect to connectdb@localhost as main;
        exec sql disconnect main;
 
-       exec sql connect to connectdb@localhost as main;
+       exec sql connect to connectdb@localhost:@TEMP_PORT@ as main;
        exec sql disconnect main;
 
-       exec sql connect to connectdb@localhost as main user connectuser/connectdb;
+       exec sql connect to connectdb:@TEMP_PORT@ as main;
        exec sql disconnect main;
 
        exec sql connect to tcp:postgresql://localhost:@TEMP_PORT@/connectdb user connectuser identified by connectpw;
@@ -50,6 +44,9 @@ exec sql end declare section;
        exec sql connect to unix:postgresql://localhost:@TEMP_PORT@/connectdb user connectuser using "connectpw";
        exec sql disconnect;
 
+       exec sql connect to unix:postgresql://localhost:@TEMP_PORT@/connectdb user connectuser;
+       exec sql disconnect;
+
        /* wrong db */
        exec sql connect to tcp:postgresql://localhost:@TEMP_PORT@/nonexistant user connectuser identified by connectpw;
        exec sql disconnect;
@@ -62,10 +59,5 @@ exec sql end declare section;
        exec sql connect to unix:postgresql://localhost:@TEMP_PORT@/connectdb user connectuser identified by "wrongpw";
        /* no disconnect necessary */
 
-       /* connect twice */
-       exec sql connect to connectdb as main;
-       exec sql connect to connectdb as main;
-       exec sql disconnect main;
-
        return (0);
 }
diff --git a/src/interfaces/ecpg/test/connect/test5.pgc b/src/interfaces/ecpg/test/connect/test5.pgc
new file mode 100644 (file)
index 0000000..8601196
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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];
+exec sql end declare section;
+
+       ECPGdebug(1, stderr);
+
+       exec sql connect to connectdb as main;
+       exec sql alter user connectuser ENCRYPTED PASSWORD 'connectpw';
+       exec sql disconnect;  /* <-- "main" not specified */
+
+       strcpy(db, "connectdb");
+       strcpy(id, "main");
+       exec sql connect to :db as :id;
+       exec sql disconnect :id;
+
+       exec sql connect to connectdb as main;
+       exec sql disconnect main;
+
+       exec sql connect to "connectdb" as main;
+       exec sql disconnect main;
+
+       exec sql connect to 'connectdb' as main;
+       exec sql disconnect main;
+
+       exec sql connect to connectdb as main user connectuser/connectdb;
+       exec sql disconnect main;
+
+       exec sql connect to unix:postgresql://localhost/connectdb as main user connectuser;
+       exec sql disconnect main;
+
+       exec sql connect to "unix:postgresql://localhost/connectdb" as main user connectuser;
+       exec sql disconnect main;
+
+       exec sql connect to 'unix:postgresql://localhost/connectdb' as main user connectuser;
+       exec sql disconnect main;
+
+       exec sql connect to "unix:postgresql://200.46.204.71/connectdb" as main user connectuser;
+       exec sql disconnect main;
+
+       exec sql disconnect nonexistant;
+
+       /* connect twice */
+       exec sql connect to connectdb as main;
+       exec sql connect to connectdb as main;
+       exec sql disconnect main;
+
+       return (0);
+}
index 4c94f86..e76e81f 100644 (file)
@@ -27,118 +27,101 @@ main(void)
 /* exec sql begin declare section */
         
         
-        
 
 #line 16 "test1.pgc"
  char  db [ 200 ]    ;
  
 #line 17 "test1.pgc"
- char  id [ 200 ]    ;
-#line 18 "test1.pgc"
  char  pw [ 200 ]    ;
 /* exec sql end declare section */
-#line 19 "test1.pgc"
+#line 18 "test1.pgc"
 
 
        ECPGdebug(1, stderr);
 
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
-#line 23 "test1.pgc"
+#line 22 "test1.pgc"
 
        { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
-#line 24 "test1.pgc"
+#line 23 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 25 "test1.pgc"
+#line 24 "test1.pgc"
   /* <-- "main" not specified */
 
-       strcpy(db, "connectdb");
-       strcpy(id, "main");
-       { ECPGconnect(__LINE__, 0, db , NULL,NULL , id, 0); }
-#line 29 "test1.pgc"
-
-       { ECPGdisconnect(__LINE__, id);}
-#line 30 "test1.pgc"
-
-
        { ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL,NULL , "main", 0); }
-#line 32 "test1.pgc"
+#line 26 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "main");}
-#line 33 "test1.pgc"
+#line 27 "test1.pgc"
 
 
-       { ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL,NULL , "main", 0); }
-#line 35 "test1.pgc"
+       { ECPGconnect(__LINE__, 0, "connectdb@localhost:55432" , NULL,NULL , "main", 0); }
+#line 29 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "main");}
-#line 36 "test1.pgc"
+#line 30 "test1.pgc"
 
 
-       { ECPGconnect(__LINE__, 0, "connectdb@localhost" , "connectuser" , "connectdb" , "main", 0); }
-#line 38 "test1.pgc"
+       { ECPGconnect(__LINE__, 0, "connectdb:55432" , NULL,NULL , "main", 0); }
+#line 32 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "main");}
-#line 39 "test1.pgc"
+#line 33 "test1.pgc"
 
 
        { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
-#line 41 "test1.pgc"
+#line 35 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "nonexistant");}
-#line 42 "test1.pgc"
+#line 36 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 43 "test1.pgc"
+#line 37 "test1.pgc"
 
 
        strcpy(pw, "connectpw");
        strcpy(db, "tcp:postgresql://localhost:55432/connectdb");
        { ECPGconnect(__LINE__, 0, db , "connectuser" , pw , NULL, 0); }
-#line 47 "test1.pgc"
+#line 41 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 48 "test1.pgc"
+#line 42 "test1.pgc"
 
 
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
-#line 50 "test1.pgc"
+#line 44 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 51 "test1.pgc"
+#line 45 "test1.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , NULL , NULL, 0); }
+#line 47 "test1.pgc"
+
+       { ECPGdisconnect(__LINE__, "CURRENT");}
+#line 48 "test1.pgc"
 
 
        /* wrong db */
        { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant" , "connectuser" , "connectpw" , NULL, 0); }
-#line 54 "test1.pgc"
+#line 51 "test1.pgc"
 
        { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 55 "test1.pgc"
+#line 52 "test1.pgc"
 
 
        /* wrong port */
        { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:0/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
-#line 58 "test1.pgc"
+#line 55 "test1.pgc"
 
        /* no disconnect necessary */
 
        /* wrong password */
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "wrongpw" , NULL, 0); }
-#line 62 "test1.pgc"
+#line 59 "test1.pgc"
 
        /* no disconnect necessary */
 
-       /* connect twice */
-       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
-#line 66 "test1.pgc"
-
-       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
-#line 67 "test1.pgc"
-
-       { ECPGdisconnect(__LINE__, "main");}
-#line 68 "test1.pgc"
-
-
        return (0);
 }
index 1dbb320..50ec23f 100644 (file)
@@ -5,13 +5,9 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 24: QUERY: alter user connectuser  encrypted password 'connectpw' on connection main
+[NO_PID]: ECPGexecute line 23: QUERY: alter user connectuser  encrypted password 'connectpw' on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 24 Ok: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_finish: Connection main closed.
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: ECPGexecute line 23 Ok: ALTER ROLE
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection main closed.
 [NO_PID]: sqlca: code: 0, state: 00000
@@ -19,17 +15,17 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection main closed.
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database connectdb on localhost port <DEFAULT> 
+[NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432 
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection main closed.
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database connectdb on localhost port <DEFAULT> for user connectuser
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection main closed.
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432 for user connectuser
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode -220 in line 42, 'No such connection nonexistant in line 42.'.
+[NO_PID]: raising sqlcode -220 in line 36, 'No such connection nonexistant in line 36.'.
 [NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ecpg_finish: Connection connectdb closed.
 [NO_PID]: sqlca: code: 0, state: 00000
@@ -41,21 +37,25 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection connectdb closed.
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 for user connectuser
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection connectdb closed.
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGconnect: opening database nonexistant on localhost port 55432 for user connectuser
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: connect: could not open database nonexistant on localhost port 55432 for user connectuser in line 54
+[NO_PID]: connect: could not open database nonexistant on localhost port 55432 for user connectuser in line 51
        FATAL:  database "nonexistant" does not exist
 
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection nonexistant closed.
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode -402 in line 54, 'Could not connect to database nonexistant in line 54.'.
+[NO_PID]: raising sqlcode -402 in line 51, 'Could not connect to database nonexistant in line 51.'.
 [NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 in line 55, 'No such connection CURRENT in line 55.'.
+[NO_PID]: raising sqlcode -220 in line 52, 'No such connection CURRENT in line 52.'.
 [NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database connectdb on localhost port 0 for user connectuser
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: connect: could not open database connectdb on localhost port 0 for user connectuser in line 58
+[NO_PID]: connect: could not open database connectdb on localhost port 0 for user connectuser in line 55
        could not connect to server: Connection refused
        Is the server running on host "localhost" and accepting
        TCP/IP connections on port 0?
@@ -63,13 +63,7 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: Connection connectdb closed.
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode -402 in line 58, 'Could not connect to database connectdb in line 58.'.
+[NO_PID]: raising sqlcode -402 in line 55, 'Could not connect to database connectdb in line 55.'.
 [NO_PID]: sqlca: code: -402, state: 08001
 [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432 for user connectuser
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: connect: connection identifier main is already in use
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_finish: Connection main closed.
-[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.c b/src/interfaces/ecpg/test/expected/connect-test5.c
new file mode 100644 (file)
index 0000000..31eb145
--- /dev/null
@@ -0,0 +1,130 @@
+/* Processed by ecpg (4.2.1) */
+/* These include files are added by the preprocessor */
+#include <ecpgtype.h>
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+
+#line 1 "test5.pgc"
+/*
+ * 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 */
+        
+        
+
+#line 16 "test5.pgc"
+ char  db [ 200 ]    ;
+#line 17 "test5.pgc"
+ char  id [ 200 ]    ;
+/* exec sql end declare section */
+#line 18 "test5.pgc"
+
+
+       ECPGdebug(1, stderr);
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 22 "test5.pgc"
+
+       { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
+#line 23 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "CURRENT");}
+#line 24 "test5.pgc"
+  /* <-- "main" not specified */
+
+       strcpy(db, "connectdb");
+       strcpy(id, "main");
+       { ECPGconnect(__LINE__, 0, db , NULL,NULL , id, 0); }
+#line 28 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, id);}
+#line 29 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 31 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 32 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 34 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 35 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 37 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 38 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
+#line 40 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 41 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+#line 43 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 44 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+#line 46 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 47 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+#line 49 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 50 "test5.pgc"
+
+
+       { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
+#line 52 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 53 "test5.pgc"
+
+
+       { ECPGdisconnect(__LINE__, "nonexistant");}
+#line 55 "test5.pgc"
+
+
+       /* connect twice */
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 58 "test5.pgc"
+
+       { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+#line 59 "test5.pgc"
+
+       { ECPGdisconnect(__LINE__, "main");}
+#line 60 "test5.pgc"
+
+
+       return (0);
+}
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr b/src/interfaces/ecpg/test/expected/connect-test5.stderr
new file mode 100644 (file)
index 0000000..a50cff0
--- /dev/null
@@ -0,0 +1,56 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 23: QUERY: alter user connectuser  encrypted password 'connectpw' on connection main
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 23 Ok: ALTER ROLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> for user connectuser
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> for user connectuser
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> for user connectuser
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> for user connectuser
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: connect: non-localhost access via sockets in line 52
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -402 in line 52, 'Could not connect to database connectdb in line 52.'.
+[NO_PID]: sqlca: code: -402, state: 08001
+[NO_PID]: raising sqlcode -220 in line 53, 'No such connection main in line 53.'.
+[NO_PID]: sqlca: code: -220, state: 08003
+[NO_PID]: raising sqlcode -220 in line 55, 'No such connection nonexistant in line 55.'.
+[NO_PID]: sqlca: code: -220, state: 08003
+[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: connect: connection identifier main is already in use
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection main closed.
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stdout b/src/interfaces/ecpg/test/expected/connect-test5.stdout
new file mode 100644 (file)
index 0000000..e69de29