mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 00:02:04 -04:00
Clean up some warnings and bugs and make things build easier.
This commit is contained in:
parent
dfb8e3f115
commit
f419de8a7f
@ -1,28 +1,22 @@
|
||||
all: test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.31 2001/08/11 10:52:09 petere Exp $
|
||||
|
||||
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq
|
||||
LDFLAGS=-g -I ../include
|
||||
LDLIBS=-L ../lib -lecpg -L ../../libpq -lpq
|
||||
subdir = src/interfaces/ecpg/test
|
||||
top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
#ECPG=/usr/local/pgsql/bin/ecpg -I../include
|
||||
ECPG=../preproc/ecpg -I../include
|
||||
override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS)
|
||||
|
||||
.SUFFIXES: .pgc .c
|
||||
ECPG = ../preproc/ecpg -I$(srcdir)/../include
|
||||
|
||||
test1: test1.c
|
||||
test2: test2.c
|
||||
test3: test3.c
|
||||
test4: test4.c
|
||||
perftest: perftest.c
|
||||
dyntest: dyntest.c
|
||||
dyntest2: dyntest2.c
|
||||
test_code100: test_code100.c
|
||||
test_notice: test_notice.c
|
||||
test_init: test_init.c
|
||||
test_text: test_text.c
|
||||
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init
|
||||
|
||||
.pgc.c:
|
||||
$(ECPG) $?
|
||||
all: $(TESTS)
|
||||
|
||||
%: %.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -L../lib -L../../libpq $^ $(LIBS) -lecpg -lpq -o $@
|
||||
|
||||
%.c: %.pgc
|
||||
$(ECPG) $<
|
||||
|
||||
clean:
|
||||
rm -f test1 test2 test3 test4 perftest *.c log dyntest dyntest2 test_notice test_code100 test_init test_text *.exe
|
||||
rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) log
|
||||
|
@ -2,16 +2,18 @@
|
||||
*
|
||||
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.7 2000/10/16 19:53:04 meskes Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.8 2001/08/11 10:52:09 petere Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
exec sql include sql3types;
|
||||
exec sql include sqlca;
|
||||
|
||||
void error()
|
||||
{ printf("#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
|
||||
static void error()
|
||||
{ printf("#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -60,11 +62,12 @@ int main(int argc,char **argv)
|
||||
if (!done)
|
||||
{ printf("%d Columns\n",COUNT);
|
||||
for (INDEX=1;INDEX<=COUNT;++INDEX)
|
||||
{ exec sql get descriptor MYDESC value :INDEX
|
||||
{ exec sql get descriptor MYDESC value :INDEX
|
||||
:TYPE = type,
|
||||
:LENGTH = length, :OCTET_LENGTH=octet_length,
|
||||
:PRECISION = precision, :SCALE=scale,
|
||||
:NULLABLE=nullable, :NAME=name;
|
||||
:NULLABLE=nullable, :NAME=name,
|
||||
:RETURNED_OCTET_LENGTH=returned_octet_length;
|
||||
printf("%s ",NAME);
|
||||
switch (TYPE)
|
||||
{ case SQL3_BOOLEAN:
|
||||
|
@ -2,17 +2,18 @@
|
||||
*
|
||||
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.1 2000/03/03 13:24:06 meskes Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest2.pgc,v 1.2 2001/08/11 10:52:09 petere Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
exec sql include sql3types;
|
||||
exec sql include sqlca;
|
||||
|
||||
void error()
|
||||
static void error()
|
||||
{
|
||||
printf("\n#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
|
||||
printf("\n#%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
exec sql include sqlca;
|
||||
|
||||
void
|
||||
Finish(msg)
|
||||
#include "stdlib.h"
|
||||
|
||||
static void
|
||||
Finish(char *msg)
|
||||
{
|
||||
fprintf(stderr, "Error in statement '%s':\n", msg);
|
||||
sqlprint();
|
||||
@ -18,7 +20,7 @@ Finish(msg)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
warn(void)
|
||||
{
|
||||
fprintf(stderr, "Warning: At least one column was truncated\n");
|
||||
|
@ -1,16 +1,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
exec sql include sqlca;
|
||||
|
||||
exec sql whenever sqlerror do PrintAndStop(msg);
|
||||
exec sql whenever sqlwarning do warn();
|
||||
|
||||
void PrintAndStop(msg)
|
||||
static void PrintAndStop(char *msg)
|
||||
{
|
||||
fprintf(stderr, "Error in statement '%s':\n", msg);
|
||||
sqlprint();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void warn(void)
|
||||
static void warn(void)
|
||||
{
|
||||
fprintf(stderr, "Warning: At least one column was truncated\n");
|
||||
}
|
||||
@ -61,7 +64,7 @@ exec sql end declare section;
|
||||
strcpy(msg, "execute insert 1");
|
||||
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: ''mm''', 1, 'f')");
|
||||
exec sql execute immediate :command;
|
||||
printf("New tuple got OID = %d\n", sqlca.sqlerrd[1]);
|
||||
printf("New tuple got OID = %ld\n", sqlca.sqlerrd[1]);
|
||||
|
||||
sprintf(command, "insert into \"Test\" (name, amount, letter) values ('db: \\\'mm\\\'', 2, 't')");
|
||||
exec sql execute immediate :command;
|
||||
@ -74,14 +77,14 @@ exec sql end declare section;
|
||||
sprintf(command, "insert into \"Test\" (name, amount, letter) select name, amount+10, letter from \"Test\"");
|
||||
exec sql execute immediate :command;
|
||||
|
||||
printf("Inserted %d tuples via execute immediate\n", sqlca.sqlerrd[2]);
|
||||
printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
|
||||
|
||||
strcpy(msg, "execute insert 4");
|
||||
sprintf(command, "insert into \"Test\" (name, amount, letter) select name, amount+?, letter from \"Test\"");
|
||||
exec sql prepare I from :command;
|
||||
exec sql at pm execute I using :increment;
|
||||
|
||||
printf("Inserted %d tuples via prepared execute\n", sqlca.sqlerrd[2]);
|
||||
printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
|
||||
|
||||
strcpy(msg, "commit");
|
||||
exec sql commit;
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
exec sql include header_test;
|
||||
|
||||
@ -35,14 +36,14 @@ exec sql end declare section;
|
||||
exec sql declare cur cursor for
|
||||
select name, born, age, married, children from meskes;
|
||||
|
||||
char msg[128], command[128];
|
||||
char msg[128];
|
||||
FILE *dbgs;
|
||||
|
||||
if ((dbgs = fopen("log", "w")) != NULL)
|
||||
ECPGdebug(1, dbgs);
|
||||
|
||||
strcpy(msg, "connect");
|
||||
exec sql connect to unix:postgresql://127.0.0.1:5432/mm;
|
||||
exec sql connect to tcp:postgresql://127.0.0.1:5432/mm;
|
||||
|
||||
strcpy(msg, "create");
|
||||
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;
|
||||
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
printf(", born %ld", personal.birth.born);
|
||||
if (ind_personal.ind_birth.age >= 0)
|
||||
printf(", age = %d", personal.birth.age);
|
||||
if ((long)ind_married >= 0)
|
||||
@ -97,7 +98,7 @@ exec sql end declare section;
|
||||
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
printf(", born %ld", personal.birth.born);
|
||||
if (ind_personal.ind_birth.age >= 0)
|
||||
printf(", age = %d", personal.birth.age);
|
||||
if ((long)ind_married >= 0)
|
||||
|
@ -5,6 +5,9 @@ exec sql include header_test;
|
||||
|
||||
exec sql type str is varchar[10];
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@ -28,7 +31,7 @@ exec sql end declare section;
|
||||
exec sql declare cur cursor for
|
||||
select name, born, age, married, children from meskes;
|
||||
|
||||
char msg[128], command[128];
|
||||
char msg[128];
|
||||
FILE *dbgs;
|
||||
|
||||
if ((dbgs = fopen("log", "w")) != NULL)
|
||||
@ -63,7 +66,7 @@ exec sql end declare section;
|
||||
exec sql fetch from cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
printf(", born %ld", personal.birth.born);
|
||||
if (ind_personal.ind_birth.age >= 0)
|
||||
printf(", age = %d", personal.birth.age);
|
||||
if (ind_married >= 0)
|
||||
@ -93,7 +96,7 @@ exec sql end declare section;
|
||||
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
printf(", born %ld", personal.birth.born);
|
||||
if (ind_personal.ind_birth.age >= 0)
|
||||
printf(", age = %d", personal.birth.age);
|
||||
if (ind_married >= 0)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
||||
exec sql whenever sqlerror sqlprint;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
// $Id: test_notice.pgc,v 1.1 2000/09/20 13:25:52 meskes Exp $
|
||||
// $Id: test_notice.pgc,v 1.2 2001/08/11 10:52:09 petere Exp $
|
||||
|
||||
exec sql include sqlca;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void printwarning(void)
|
||||
static void printwarning(void)
|
||||
{
|
||||
if (sqlca.sqlwarn[0]) printf("sqlca.sqlwarn: %c",sqlca.sqlwarn[0]);
|
||||
else return;
|
||||
@ -18,7 +18,7 @@ void printwarning(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
exec sql begin declare section;
|
||||
int index,payload;
|
||||
int payload;
|
||||
exec sql end declare section;
|
||||
FILE *dbgs;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user