Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f419de8a
Commit
f419de8a
authored
Aug 11, 2001
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some warnings and bugs and make things build easier.
parent
dfb8e3f1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
48 deletions
+56
-48
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/Makefile
+15
-21
src/interfaces/ecpg/test/dyntest.pgc
src/interfaces/ecpg/test/dyntest.pgc
+8
-5
src/interfaces/ecpg/test/dyntest2.pgc
src/interfaces/ecpg/test/dyntest2.pgc
+4
-3
src/interfaces/ecpg/test/header_test.h
src/interfaces/ecpg/test/header_test.h
+5
-3
src/interfaces/ecpg/test/test1.pgc
src/interfaces/ecpg/test/test1.pgc
+8
-5
src/interfaces/ecpg/test/test2.pgc
src/interfaces/ecpg/test/test2.pgc
+6
-5
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test3.pgc
+6
-3
src/interfaces/ecpg/test/test4.pgc
src/interfaces/ecpg/test/test4.pgc
+1
-0
src/interfaces/ecpg/test/test_notice.pgc
src/interfaces/ecpg/test/test_notice.pgc
+3
-3
No files found.
src/interfaces/ecpg/test/Makefile
View file @
f419de8a
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
src/interfaces/ecpg/test/dyntest.pgc
View file @
f419de8a
...
...
@@ -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("#%
l
d:%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:
...
...
src/interfaces/ecpg/test/dyntest2.pgc
View file @
f419de8a
...
...
@@ -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#%
l
d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
}
...
...
src/interfaces/ecpg/test/header_test.h
View file @
f419de8a
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
"
);
...
...
src/interfaces/ecpg/test/test1.pgc
View file @
f419de8a
#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 = %
l
d\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 %
l
d 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 %
l
d tuples via prepared execute\n", sqlca.sqlerrd[2]);
strcpy(msg, "commit");
exec sql commit;
...
...
src/interfaces/ecpg/test/test2.pgc
View file @
f419de8a
#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 %
l
d", 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 %
l
d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if ((long)ind_married >= 0)
...
...
src/interfaces/ecpg/test/test3.pgc
View file @
f419de8a
...
...
@@ -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 %
l
d", 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 %
l
d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
...
...
src/interfaces/ecpg/test/test4.pgc
View file @
f419de8a
#include <locale.h>
#include <string.h>
exec sql whenever sqlerror sqlprint;
...
...
src/interfaces/ecpg/test/test_notice.pgc
View file @
f419de8a
// $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;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment