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

Commit f419de8

Browse files
committed
Clean up some warnings and bugs and make things build easier.
1 parent dfb8e3f commit f419de8

File tree

9 files changed

+56
-48
lines changed

9 files changed

+56
-48
lines changed

src/interfaces/ecpg/test/Makefile

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
all: test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.31 2001/08/11 10:52:09 petere Exp $
22

3-
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq
4-
LDFLAGS=-g -I ../include
5-
LDLIBS=-L ../lib -lecpg -L ../../libpq -lpq
3+
subdir = src/interfaces/ecpg/test
4+
top_builddir = ../../../..
5+
include $(top_builddir)/src/Makefile.global
66

7-
#ECPG=/usr/local/pgsql/bin/ecpg -I../include
8-
ECPG=../preproc/ecpg -I../include
7+
override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS)
98

10-
.SUFFIXES: .pgc .c
9+
ECPG = ../preproc/ecpg -I$(srcdir)/../include
1110

12-
test1: test1.c
13-
test2: test2.c
14-
test3: test3.c
15-
test4: test4.c
16-
perftest: perftest.c
17-
dyntest: dyntest.c
18-
dyntest2: dyntest2.c
19-
test_code100: test_code100.c
20-
test_notice: test_notice.c
21-
test_init: test_init.c
22-
test_text: test_text.c
11+
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
2312

24-
.pgc.c:
25-
$(ECPG) $?
13+
all: $(TESTS)
14+
15+
%: %.o
16+
$(CC) $(CFLAGS) $(LDFLAGS) -L../lib -L../../libpq $^ $(LIBS) -lecpg -lpq -o $@
17+
18+
%.c: %.pgc
19+
$(ECPG) $<
2620

2721
clean:
28-
rm -f test1 test2 test3 test4 perftest *.c log dyntest dyntest2 test_notice test_code100 test_init test_text *.exe
22+
rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) log

src/interfaces/ecpg/test/dyntest.pgc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.7 2000/10/16 19:53:04 meskes Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.8 2001/08/11 10:52:09 petere Exp $
66
*/
77

88
#include <stdio.h>
9+
#include <stdlib.h>
10+
#include <string.h>
911

1012
exec sql include sql3types;
1113
exec sql include sqlca;
1214

13-
void error()
14-
{ printf("#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
15+
static void error()
16+
{ printf("#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
1517
exit(1);
1618
}
1719

@@ -60,11 +62,12 @@ int main(int argc,char **argv)
6062
if (!done)
6163
{ printf("%d Columns\n",COUNT);
6264
for (INDEX=1;INDEX<=COUNT;++INDEX)
63-
{ exec sql get descriptor MYDESC value :INDEX
65+
{ exec sql get descriptor MYDESC value :INDEX
6466
:TYPE = type,
6567
:LENGTH = length, :OCTET_LENGTH=octet_length,
6668
:PRECISION = precision, :SCALE=scale,
67-
:NULLABLE=nullable, :NAME=name;
69+
:NULLABLE=nullable, :NAME=name,
70+
:RETURNED_OCTET_LENGTH=returned_octet_length;
6871
printf("%s ",NAME);
6972
switch (TYPE)
7073
{ case SQL3_BOOLEAN:

src/interfaces/ecpg/test/dyntest2.pgc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.1 2000/03/03 13:24:06 meskes Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.2 2001/08/11 10:52:09 petere Exp $
66
*/
77

88
#include <stdio.h>
9+
#include <stdlib.h>
910

1011
exec sql include sql3types;
1112
exec sql include sqlca;
1213

13-
void error()
14+
static void error()
1415
{
15-
printf("\n#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
16+
printf("\n#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
1617
exit(1);
1718
}
1819

src/interfaces/ecpg/test/header_test.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
exec sql include sqlca;
22

3-
void
4-
Finish(msg)
3+
#include "stdlib.h"
4+
5+
static void
6+
Finish(char *msg)
57
{
68
fprintf(stderr, "Error in statement '%s':\n", msg);
79
sqlprint();
@@ -18,7 +20,7 @@ Finish(msg)
1820
exit(-1);
1921
}
2022

21-
void
23+
static void
2224
warn(void)
2325
{
2426
fprintf(stderr, "Warning: At least one column was truncated\n");

src/interfaces/ecpg/test/test1.pgc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
#include <stdlib.h>
2+
#include <string.h>
3+
14
exec sql include sqlca;
25

36
exec sql whenever sqlerror do PrintAndStop(msg);
47
exec sql whenever sqlwarning do warn();
58

6-
void PrintAndStop(msg)
9+
static void PrintAndStop(char *msg)
710
{
811
fprintf(stderr, "Error in statement '%s':\n", msg);
912
sqlprint();
1013
exit(-1);
1114
}
1215

13-
void warn(void)
16+
static void warn(void)
1417
{
1518
fprintf(stderr, "Warning: At least one column was truncated\n");
1619
}
@@ -61,7 +64,7 @@ exec sql end declare section;
6164
strcpy(msg, "execute insert 1");
6265
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: ''mm''', 1, 'f')");
6366
exec sql execute immediate :command;
64-
printf("New tuple got OID = %d\n", sqlca.sqlerrd[1]);
67+
printf("New tuple got OID = %ld\n", sqlca.sqlerrd[1]);
6568

6669
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: \\\'mm\\\'', 2, 't')");
6770
exec sql execute immediate :command;
@@ -74,14 +77,14 @@ exec sql end declare section;
7477
sprintf(command, "insert into \"Test\" (name, amount, letter) select name, amount+10, letter from \"Test\"");
7578
exec sql execute immediate :command;
7679

77-
printf("Inserted %d tuples via execute immediate\n", sqlca.sqlerrd[2]);
80+
printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
7881

7982
strcpy(msg, "execute insert 4");
8083
sprintf(command, "insert into \"Test\" (name, amount, letter) select name, amount+?, letter from \"Test\"");
8184
exec sql prepare I from :command;
8285
exec sql at pm execute I using :increment;
8386

84-
printf("Inserted %d tuples via prepared execute\n", sqlca.sqlerrd[2]);
87+
printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
8588

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

src/interfaces/ecpg/test/test2.pgc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
#include <stdlib.h>
2+
#include <string.h>
23

34
exec sql include header_test;
45

@@ -35,14 +36,14 @@ exec sql end declare section;
3536
exec sql declare cur cursor for
3637
select name, born, age, married, children from meskes;
3738

38-
char msg[128], command[128];
39+
char msg[128];
3940
FILE *dbgs;
4041

4142
if ((dbgs = fopen("log", "w")) != NULL)
4243
ECPGdebug(1, dbgs);
4344

4445
strcpy(msg, "connect");
45-
exec sql connect to unix:postgresql://127.0.0.1:5432/mm;
46+
exec sql connect to tcp:postgresql://127.0.0.1:5432/mm;
4647

4748
strcpy(msg, "create");
4849
exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer);
@@ -67,7 +68,7 @@ exec sql end declare section;
6768
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
6869
printf("%8.8s", personal.name.arr);
6970
if (ind_personal.ind_birth.born >= 0)
70-
printf(", born %d", personal.birth.born);
71+
printf(", born %ld", personal.birth.born);
7172
if (ind_personal.ind_birth.age >= 0)
7273
printf(", age = %d", personal.birth.age);
7374
if ((long)ind_married >= 0)
@@ -97,7 +98,7 @@ exec sql end declare section;
9798
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
9899
printf("%8.8s", personal.name.arr);
99100
if (ind_personal.ind_birth.born >= 0)
100-
printf(", born %d", personal.birth.born);
101+
printf(", born %ld", personal.birth.born);
101102
if (ind_personal.ind_birth.age >= 0)
102103
printf(", age = %d", personal.birth.age);
103104
if ((long)ind_married >= 0)

src/interfaces/ecpg/test/test3.pgc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ exec sql include header_test;
55

66
exec sql type str is varchar[10];
77

8+
#include <stdlib.h>
9+
#include <string.h>
10+
811
int
912
main ()
1013
{
@@ -28,7 +31,7 @@ exec sql end declare section;
2831
exec sql declare cur cursor for
2932
select name, born, age, married, children from meskes;
3033

31-
char msg[128], command[128];
34+
char msg[128];
3235
FILE *dbgs;
3336

3437
if ((dbgs = fopen("log", "w")) != NULL)
@@ -63,7 +66,7 @@ exec sql end declare section;
6366
exec sql fetch from cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
6467
printf("%8.8s", personal.name.arr);
6568
if (ind_personal.ind_birth.born >= 0)
66-
printf(", born %d", personal.birth.born);
69+
printf(", born %ld", personal.birth.born);
6770
if (ind_personal.ind_birth.age >= 0)
6871
printf(", age = %d", personal.birth.age);
6972
if (ind_married >= 0)
@@ -93,7 +96,7 @@ exec sql end declare section;
9396
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
9497
printf("%8.8s", personal.name.arr);
9598
if (ind_personal.ind_birth.born >= 0)
96-
printf(", born %d", personal.birth.born);
99+
printf(", born %ld", personal.birth.born);
97100
if (ind_personal.ind_birth.age >= 0)
98101
printf(", age = %d", personal.birth.age);
99102
if (ind_married >= 0)

src/interfaces/ecpg/test/test4.pgc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <locale.h>
2+
#include <string.h>
23

34
exec sql whenever sqlerror sqlprint;
45

src/interfaces/ecpg/test/test_notice.pgc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// $Id: test_notice.pgc,v 1.1 2000/09/20 13:25:52 meskes Exp $
1+
// $Id: test_notice.pgc,v 1.2 2001/08/11 10:52:09 petere Exp $
22

33
exec sql include sqlca;
44

55
#include <stdio.h>
66

7-
void printwarning(void)
7+
static void printwarning(void)
88
{
99
if (sqlca.sqlwarn[0]) printf("sqlca.sqlwarn: %c",sqlca.sqlwarn[0]);
1010
else return;
@@ -18,7 +18,7 @@ void printwarning(void)
1818
int main(int argc, char **argv)
1919
{
2020
exec sql begin declare section;
21-
int index,payload;
21+
int payload;
2222
exec sql end declare section;
2323
FILE *dbgs;
2424

0 commit comments

Comments
 (0)