summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2000-02-23 19:26:05 +0000
committerMichael Meskes <meskes@postgresql.org>2000-02-23 19:26:05 +0000
commit9f74608f4756aa9735ebceee2f29b6ddc830cccc (patch)
tree28152b925d5bb4f6b44d2f80906a33a8af4f5598 /src/interfaces/ecpg/test
parentc969e2662fd7cdb5521c1570082c6b55b5ce6e89 (diff)
*** empty log message ***
Diffstat (limited to 'src/interfaces/ecpg/test')
-rw-r--r--src/interfaces/ecpg/test/Makefile10
-rw-r--r--src/interfaces/ecpg/test/dyntest.pgc24
-rw-r--r--src/interfaces/ecpg/test/stp.pgc26
-rw-r--r--src/interfaces/ecpg/test/test5.pgc62
4 files changed, 17 insertions, 105 deletions
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index 50217b52aea..a4238fcc383 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -1,4 +1,4 @@
-all: stp.so test1 test2 test3 test4 test5 perftest dyntest
+all: test1 test2 test3 test4 perftest dyntest
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
LDFLAGS=-g -I../include -I/usr/include/postgresql -L/usr/lib/postgresql -L../lib -lecpg -lpq -lcrypt
@@ -14,17 +14,11 @@ test1: test1.c
test2: test2.c
test3: test3.c
test4: test4.c
-test5: test5.c
perftest: perftest.c
dyntest: dyntest.c
.pgc.c:
$(ECPG) $?
-stp.so: stp.c
- cc -fPIC -I../include -I/usr/include/postgresql -c -o stp.o stp.c
- ld -Bdynamic -shared -soname stp.so -o stp.so stp.o -lpq -lecpg -lc
-
-
clean:
- -/bin/rm test1 test2 test3 test4 test5 perftest *.c log stp.o stp.so dyntest
+ -/bin/rm test1 test2 test3 test4 perftest *.c log dyntest
diff --git a/src/interfaces/ecpg/test/dyntest.pgc b/src/interfaces/ecpg/test/dyntest.pgc
index 3698cf685f5..f7c9ee4798b 100644
--- a/src/interfaces/ecpg/test/dyntest.pgc
+++ b/src/interfaces/ecpg/test/dyntest.pgc
@@ -2,7 +2,7 @@
*
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
*
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.3 2000/02/22 19:57:12 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.4 2000/02/23 19:26:04 meskes Exp $
*/
#include <stdio.h>
@@ -11,14 +11,16 @@ exec sql include sql3types;
exec sql include sqlca;
void error()
-{ printf("#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
+{
+ printf("\n#%d:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
exit(1);
}
int main(int argc,char **argv)
-{ exec sql begin declare section;
+{
+exec sql begin declare section;
int COUNT;
- int INTVAR;
+ int INTVAR, BOOLVAR;
int INDEX;
int INDICATOR;
int TYPE,LENGTH,OCTET_LENGTH,PRECISION,SCALE,NULLABLE,RETURNED_OCTET_LENGTH;
@@ -28,10 +30,12 @@ int main(int argc,char **argv)
float FLOATVAR;
double DOUBLEVAR;
char QUERY[1024];
- exec sql end declare section;
+exec sql end declare section;
int done=0;
FILE *dbgs;
+ exec sql var BOOLVAR is bool;
+
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
@@ -67,14 +71,16 @@ int main(int argc,char **argv)
:PRECISION = precision, :SCALE=scale,
:NULLABLE=nullable, :NAME=name,
:INDICATOR=indicator;
- printf("%2d %s %d(%d)(%d,%d) %d,%d %d = "
+ printf("%2d\t%s (type: %d length: %d precision: %d scale: %d
+ \toctet_length: %d returned_octet_length: %d nullable: %d)\n\t= "
,INDEX,NAME,TYPE,LENGTH,PRECISION,SCALE
,OCTET_LENGTH,RETURNED_OCTET_LENGTH,NULLABLE);
if (INDICATOR==-1) printf("NULL\n");
else switch (TYPE)
- { case SQL3_BOOLEAN:
- exec sql get descriptor MYDESC value :INDEX :INTVAR=data;
- printf("%s\n",INTVAR?"true":"false");
+ {
+ case SQL3_BOOLEAN:
+ exec sql get descriptor MYDESC value :INDEX :BOOLVAR=data;
+ printf("%s\n",BOOLVAR ? "true":"false");
break;
case SQL3_NUMERIC:
case SQL3_DECIMAL:
diff --git a/src/interfaces/ecpg/test/stp.pgc b/src/interfaces/ecpg/test/stp.pgc
deleted file mode 100644
index ac80b883bf6..00000000000
--- a/src/interfaces/ecpg/test/stp.pgc
+++ /dev/null
@@ -1,26 +0,0 @@
-EXEC SQL INCLUDE sqlca;
-
-int my_fun (void)
- {
- EXEC SQL BEGIN DECLARE SECTION;
- int sql_index = 0;
- EXEC SQL END DECLARE SECTION;
- FILE *dbgs;
-
- if ((dbgs = fopen("log", "w")) != NULL)
- ECPGdebug(1, dbgs);
-
- EXEC SQL WHENEVER SQLERROR GOTO Error;
-
- EXEC SQL CONNECT TO 'mm';
- EXEC SQL SELECT MIN(index) INTO :sql_index FROM tab;
- EXEC SQL DISCONNECT;
-
- if (dbgs != NULL)
- fclose(dbgs);
-
- return (sql_index);
-
-Error:
- return (sqlca.sqlcode);
- }
diff --git a/src/interfaces/ecpg/test/test5.pgc b/src/interfaces/ecpg/test/test5.pgc
deleted file mode 100644
index 1c9289a77d5..00000000000
--- a/src/interfaces/ecpg/test/test5.pgc
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-EXEC SQL INCLUDE sqlca;
-
-static void ErrorExit (void);
-
-int main (void)
- {
- EXEC SQL BEGIN DECLARE SECTION;
- int result;
- int values[2], i;
- EXEC SQL END DECLARE SECTION;
- FILE *dbgs;
-
- if ((dbgs = fopen("log", "w")) != NULL)
- ECPGdebug(1, dbgs);
-
- EXEC SQL WHENEVER SQLERROR DO ErrorExit();
- EXEC SQL CONNECT TO 'mm';
- EXEC SQL CREATE TABLE tab (index int);
- EXEC SQL INSERT INTO tab(index) values(14);
- EXEC SQL INSERT INTO tab(index) values(7);
- EXEC SQL COMMIT;
-
- EXEC SQL CREATE FUNCTION my_fun () RETURNS int AS
- '/home/postgres/pgsql/src/interfaces/ecpg.mm/test/stp.so' LANGUAGE 'C';
- EXEC SQL COMMIT;
-
- EXEC SQL SELECT index INTO :values FROM tab;
- for (i = 0; i < 2; i++)
- printf("tab[%d] = %d\n", i, values[i]);
-
- EXEC SQL SELECT my_fun () INTO :result;
- printf ("result = %d\n", result);
-
- EXEC SQL DROP TABLE tab;
- EXEC SQL DROP FUNCTION my_fun ();
- EXEC SQL COMMIT;
- EXEC SQL DISCONNECT;
-
- if (dbgs != NULL)
- fclose(dbgs);
- exit (0);
- }
-
-
-static void ErrorExit (void)
- {
- EXEC SQL WHENEVER SQLERROR CONTINUE;
-
- sqlprint();
-
- EXEC SQL ROLLBACK;
-
- EXEC SQL DROP TABLE tab;
- EXEC SQL DROP FUNCTION my_fun ();
- EXEC SQL COMMIT;
-
- EXEC SQL DISCONNECT;
- exit (-1);
- }