PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sql-twophase.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for sql-twophase.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 sql-twophase.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 29 of file sql-twophase.c.

30{
31 char msg[128];
32
33 ECPGdebug(1, stderr);
34
35 strcpy(msg, "connect");
36 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
37#line 16 "twophase.pgc"
38
39if (sqlca.sqlcode < 0) sqlprint();}
40#line 16 "twophase.pgc"
41
42 { ECPGsetcommit(__LINE__, "off", NULL);
43#line 17 "twophase.pgc"
44
45if (sqlca.sqlcode < 0) sqlprint();}
46#line 17 "twophase.pgc"
47
48
49 strcpy(msg, "create");
50 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( c int )", ECPGt_EOIT, ECPGt_EORT);
51#line 20 "twophase.pgc"
52
53if (sqlca.sqlcode < 0) sqlprint();}
54#line 20 "twophase.pgc"
55
56
57 strcpy(msg, "commit");
58 { ECPGtrans(__LINE__, NULL, "commit");
59#line 23 "twophase.pgc"
60
61if (sqlca.sqlcode < 0) sqlprint();}
62#line 23 "twophase.pgc"
63
64
65 strcpy(msg, "begin");
66 { ECPGtrans(__LINE__, NULL, "begin");
67#line 26 "twophase.pgc"
68
69if (sqlca.sqlcode < 0) sqlprint();}
70#line 26 "twophase.pgc"
71
72
73 strcpy(msg, "insert");
74 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 )", ECPGt_EOIT, ECPGt_EORT);
75#line 29 "twophase.pgc"
76
77if (sqlca.sqlcode < 0) sqlprint();}
78#line 29 "twophase.pgc"
79
80
81 strcpy(msg, "prepare transaction");
82 { ECPGtrans(__LINE__, NULL, "prepare transaction 'ecpg_twophase'");
83#line 32 "twophase.pgc"
84
85if (sqlca.sqlcode < 0) sqlprint();}
86#line 32 "twophase.pgc"
87
88
89 strcpy(msg, "commit prepared");
90 { ECPGtrans(__LINE__, NULL, "commit prepared 'ecpg_twophase'");
91#line 35 "twophase.pgc"
92
93if (sqlca.sqlcode < 0) sqlprint();}
94#line 35 "twophase.pgc"
95
96
97 strcpy(msg, "drop");
98 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
99#line 38 "twophase.pgc"
100
101if (sqlca.sqlcode < 0) sqlprint();}
102#line 38 "twophase.pgc"
103
104
105 strcpy(msg, "disconnect");
106 { ECPGdisconnect(__LINE__, "CURRENT");
107#line 41 "twophase.pgc"
108
109if (sqlca.sqlcode < 0) sqlprint();}
110#line 41 "twophase.pgc"
111
112
113 return 0;
114}
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
Definition: connect.c:153
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:676
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_EORT
Definition: ecpgtype.h:63
void sqlprint(void)
Definition: error.c:334
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:2275
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:160
#define ECPGdebug(X, Y)
Definition: sql-twophase.c:7
#define sqlca
Definition: sqlca.h:59

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGsetcommit(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, ECPGtrans(), sqlca, and sqlprint().