Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 149f01c

Browse files
committed
Add ecpg thread testing file.
1 parent 630684d commit 149f01c

File tree

5 files changed

+83
-13
lines changed

5 files changed

+83
-13
lines changed

src/interfaces/ecpg/compatlib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.7 2003/08/01 16:18:04 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.8 2003/08/06 02:19:48 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,8 +16,8 @@ NAME= ecpg_compat
1616
SO_MAJOR_VERSION= 1
1717
SO_MINOR_VERSION= 0
1818

19-
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
20-
SHLIB_LINK = -L../pgtypeslib -lpgtypes -L../ecpglib -lecpg
19+
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS)
20+
SHLIB_LINK = -L../pgtypeslib -lpgtypes -L../ecpglib -lecpg $(THREAD_LIBS)
2121

2222
OBJS= informix.o
2323

src/interfaces/ecpg/pgtypeslib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.9 2003/08/01 16:18:04 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.10 2003/08/06 02:19:51 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,7 +16,7 @@ NAME= pgtypes
1616
SO_MAJOR_VERSION= 1
1717
SO_MINOR_VERSION= 0
1818

19-
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) -g
19+
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS) -g
2020

2121
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
2222
$(filter rint.o, $(LIBOBJS))

src/interfaces/ecpg/preproc/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.92 2003/06/15 04:07:58 momjian Exp $
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.93 2003/08/06 02:19:51 momjian Exp $
22

33
subdir = src/interfaces/ecpg/preproc
44
top_builddir = ../../../..
@@ -8,7 +8,7 @@ MAJOR_VERSION=3
88
MINOR_VERSION=0
99
PATCHLEVEL=0
1010

11-
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \
11+
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CFLAGS) \
1212
-DMAJOR_VERSION=$(MAJOR_VERSION) \
1313
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
1414
-DINCLUDE_PATH=\"$(includedir)\"
@@ -24,7 +24,7 @@ OBJS=preproc.o type.o ecpg.o ecpg_keywords.o output.o\
2424
all: submake-libpgport ecpg
2525

2626
ecpg: $(OBJS)
27-
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
27+
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(THREAD_LIBS) -o $@
2828

2929
# pgc is compiled as part of preproc
3030
preproc.o: $(srcdir)/pgc.c

src/interfaces/ecpg/test/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.39 2003/08/01 13:53:36 petere Exp $
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.40 2003/08/06 02:19:51 momjian Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
55
include $(top_builddir)/src/Makefile.global
66

7-
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS)
7+
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CFLAGS)
88

99
ECPG = ../preproc/ecpg -I$(srcdir)/../include
1010

11-
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test dt_test test_informix
11+
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test dt_test test_informix test_thread
1212

1313
all: $(TESTS)
1414

1515
%: %.o
16-
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq -o $@
16+
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq $(THREAD_LIBS) -o $@
1717

1818
test_informix: test_informix.o
19-
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq -o $@
19+
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq $(THREAD_LIBS) -o $@
2020

2121
%.c: %.pgc
2222
$(ECPG) $<
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* ---
2+
* Thread test program
3+
* by Philip Yarra
4+
*
5+
* To run, create this table in the 'test' database:
6+
*
7+
* CREATE TABLE foo (
8+
* message character(40)
9+
* );
10+
* ---
11+
*/
12+
13+
14+
#include <pthread.h>
15+
16+
int main(void);
17+
void ins1(void);
18+
void ins2(void);
19+
20+
int main(void)
21+
{
22+
pthread_t thread1, thread2;
23+
pthread_create(&thread1, NULL, (void *) ins1, NULL);
24+
pthread_create(&thread2, NULL, (void *) ins2, NULL);
25+
pthread_join(thread1, NULL);
26+
pthread_join(thread2, NULL);
27+
printf("Program done!\n");
28+
return 0;
29+
}
30+
31+
void ins1(void)
32+
{
33+
int i;
34+
EXEC SQL BEGIN DECLARE SECTION;
35+
char* cs = "test";
36+
char* bar = "one!";
37+
EXEC SQL END DECLARE SECTION;
38+
EXEC SQL WHENEVER sqlerror sqlprint;
39+
EXEC SQL CONNECT TO :cs AS test1;
40+
for (i = 0; i < 5; i++)
41+
{
42+
printf("thread 1 : inserting\n");
43+
EXEC SQL AT test1 INSERT INTO foo VALUES(:bar);
44+
printf("thread 1 : insert done\n");
45+
}
46+
EXEC SQL AT test1 COMMIT WORK;
47+
EXEC SQL DISCONNECT test1;
48+
printf("thread 1 : done!\n");
49+
}
50+
51+
52+
void ins2(void)
53+
{
54+
int i;
55+
EXEC SQL BEGIN DECLARE SECTION;
56+
char* cs = "test";
57+
char* bar = "two!";
58+
EXEC SQL END DECLARE SECTION;
59+
EXEC SQL WHENEVER sqlerror sqlprint;
60+
EXEC SQL CONNECT TO :cs AS test2;
61+
for (i = 0; i < 5; i++)
62+
{
63+
printf("thread 2: inserting\n");
64+
EXEC SQL AT test2 INSERT INTO foo VALUES(:bar);
65+
printf("thread 2: insert done\n");
66+
}
67+
EXEC SQL AT test2 COMMIT WORK;
68+
EXEC SQL DISCONNECT test2;
69+
printf("thread 2: done!\n");
70+
}

0 commit comments

Comments
 (0)