summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql/twophase.pgc
blob: 38913d7af2d7c78a9229e50dca877240cb9c79c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

exec sql include ../regression;

exec sql whenever sqlerror sqlprint;

int main(void)
{
	char msg[128];

	ECPGdebug(1, stderr);

	strcpy(msg, "connect");
	exec sql connect to REGRESSDB1;
	exec sql set autocommit to off;

	strcpy(msg, "create");
	exec sql create table t1(c int);

	strcpy(msg, "commit");
	exec sql commit;

	strcpy(msg, "begin");
	exec sql begin;

	strcpy(msg, "insert");
	exec sql insert into t1 values(1);

	strcpy(msg, "prepare transaction");
	exec sql prepare transaction 'gxid';

	strcpy(msg, "commit prepared");
	exec sql commit prepared 'gxid';

	strcpy(msg, "drop");
	exec sql drop table t1;

	strcpy(msg, "disconnect");
	exec sql disconnect current;

	return 0;
}