PostgreSQL Source Code  git master
connect-test2.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for connect-test2.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Functions

int main (void)
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file connect-test2.c.

Referenced by main().

Function Documentation

◆ main()

int main ( void  )

Definition at line 32 of file connect-test2.c.

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGsetconn(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, and ECPGt_NO_INDICATOR.

33 {
34 /* exec sql begin declare section */
35 
36 
37 
38 #line 17 "test2.pgc"
39  char id [ 200 ] ;
40 
41 #line 18 "test2.pgc"
42  char res [ 200 ] ;
43 /* exec sql end declare section */
44 #line 19 "test2.pgc"
45 
46 
47  ECPGdebug(1, stderr);
48 
49  strcpy(id, "first");
50  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , id, 0); }
51 #line 24 "test2.pgc"
52 
53  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "second", 0); }
54 #line 25 "test2.pgc"
55 
56 
57  /* this selects from "second" which was opened last */
58  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
59  ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
60  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
61 #line 28 "test2.pgc"
62 
63  { ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
64  ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
65  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
66 #line 29 "test2.pgc"
67 
68  { ECPGdo(__LINE__, 0, 1, "second", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
69  ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
70  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
71 #line 30 "test2.pgc"
72 
73 
74  { ECPGsetconn(__LINE__, "first");}
75 #line 32 "test2.pgc"
76 
77  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
78  ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
79  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
80 #line 33 "test2.pgc"
81 
82 
83  /* this will disconnect from "first" */
84  { ECPGdisconnect(__LINE__, "CURRENT");}
85 #line 36 "test2.pgc"
86 
87  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
88  ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
89  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
90 #line 37 "test2.pgc"
91 
92 
93  /* error here since "first" is already disconnected */
94  { ECPGdisconnect(__LINE__, id);}
95 #line 40 "test2.pgc"
96 
97 
98  /* disconnect from "second" */
99  { ECPGdisconnect(__LINE__, "CURRENT");}
100 #line 43 "test2.pgc"
101 
102 
103  return 0;
104 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
#define ECPGdebug(X, Y)
Definition: connect-test2.c:7
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2037
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
bool ECPGsetconn(int lineno, const char *connection_name)
Definition: connect.c:202