Header And Logo

PostgreSQL
| The world's most advanced open source database.

connect-test5.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* End of automatic include section */
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008 
00009 #line 1 "test5.pgc"
00010 /*
00011  * this file tests all sorts of connecting to one single database.
00012  */
00013 
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include <stdlib.h>
00017 #include <stdio.h>
00018 
00019 /* do not include regression.h */
00020 
00021 int
00022 main(void)
00023 {
00024 /* exec sql begin declare section */
00025      
00026      
00027      
00028 
00029 #line 16 "test5.pgc"
00030  char db [ 200 ] ;
00031  
00032 #line 17 "test5.pgc"
00033  char id [ 200 ] ;
00034  
00035 #line 18 "test5.pgc"
00036  char * user = "connectuser" ;
00037 /* exec sql end declare section */
00038 #line 19 "test5.pgc"
00039 
00040 
00041     ECPGdebug(1, stderr);
00042 
00043     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00044 #line 23 "test5.pgc"
00045 
00046     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
00047 #line 24 "test5.pgc"
00048 
00049     { ECPGdisconnect(__LINE__, "CURRENT");}
00050 #line 25 "test5.pgc"
00051   /* <-- "main" not specified */
00052 
00053     strcpy(db, "connectdb");
00054     strcpy(id, "main");
00055     { ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); }
00056 #line 29 "test5.pgc"
00057 
00058     { ECPGdisconnect(__LINE__, id);}
00059 #line 30 "test5.pgc"
00060 
00061 
00062     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00063 #line 32 "test5.pgc"
00064 
00065     { ECPGdisconnect(__LINE__, "main");}
00066 #line 33 "test5.pgc"
00067 
00068 
00069     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00070 #line 35 "test5.pgc"
00071 
00072     { ECPGdisconnect(__LINE__, "main");}
00073 #line 36 "test5.pgc"
00074 
00075 
00076     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00077 #line 38 "test5.pgc"
00078 
00079     { ECPGdisconnect(__LINE__, "main");}
00080 #line 39 "test5.pgc"
00081 
00082 
00083     { ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
00084 #line 41 "test5.pgc"
00085 
00086     { ECPGdisconnect(__LINE__, "main");}
00087 #line 42 "test5.pgc"
00088 
00089 
00090     { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
00091 #line 44 "test5.pgc"
00092 
00093     { ECPGdisconnect(__LINE__, "main");}
00094 #line 45 "test5.pgc"
00095 
00096 
00097     { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
00098 #line 47 "test5.pgc"
00099 
00100     { ECPGdisconnect(__LINE__, "main");}
00101 #line 48 "test5.pgc"
00102 
00103 
00104     { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
00105 #line 50 "test5.pgc"
00106 
00107     { ECPGdisconnect(__LINE__, "main");}
00108 #line 51 "test5.pgc"
00109 
00110 
00111     { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , user , NULL , "main", 0); }
00112 #line 53 "test5.pgc"
00113 
00114     { ECPGdisconnect(__LINE__, "main");}
00115 #line 54 "test5.pgc"
00116 
00117 
00118     { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb?connect_timeout=14 & client_encoding=latin1" , "connectuser" , NULL , "main", 0); }
00119 #line 56 "test5.pgc"
00120 
00121     { ECPGdisconnect(__LINE__, "main");}
00122 #line 57 "test5.pgc"
00123 
00124 
00125     { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
00126 #line 59 "test5.pgc"
00127 
00128     { ECPGdisconnect(__LINE__, "main");}
00129 #line 60 "test5.pgc"
00130 
00131 
00132     { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
00133 #line 62 "test5.pgc"
00134 
00135     { ECPGdisconnect(__LINE__, "main");}
00136 #line 63 "test5.pgc"
00137 
00138 
00139     /* connect twice */
00140     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00141 #line 66 "test5.pgc"
00142 
00143     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
00144 #line 67 "test5.pgc"
00145 
00146     { ECPGdisconnect(__LINE__, "main");}
00147 #line 68 "test5.pgc"
00148 
00149 
00150     /* not connected */
00151     { ECPGdisconnect(__LINE__, "nonexistant");}
00152 #line 71 "test5.pgc"
00153 
00154 
00155     return (0);
00156 }