mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
*** empty log message ***
This commit is contained in:
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
Reference in New Issue
Block a user