diff options
| author | Michael Meskes <meskes@postgresql.org> | 2006-02-08 09:10:05 +0000 |
|---|---|---|
| committer | Michael Meskes <meskes@postgresql.org> | 2006-02-08 09:10:05 +0000 |
| commit | e3740d2c59915b6fd78b2b8aaf63b290a14423c6 (patch) | |
| tree | 54566da0bfa3e095efd92586428206a962f3542b /src/interfaces/ecpg/test | |
| parent | 115e5dd5972fa7788f6639b3d0a8b2ef65e326e4 (diff) | |
Added just another test case.
Fixed missing continuation line character.
Do not translate $-quoting.
Bit field notation belongs to a variable not a variable list.
Output of line number only done by one function.
Diffstat (limited to 'src/interfaces/ecpg/test')
| -rw-r--r-- | src/interfaces/ecpg/test/Makefile | 4 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/perftest.pgc | 2 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/test1.pgc | 3 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/test5.pgc | 5 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/test_func.pgc | 45 |
5 files changed, 55 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile index b1f51eeae88..c88f43896c1 100644 --- a/src/interfaces/ecpg/test/Makefile +++ b/src/interfaces/ecpg/test/Makefile @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.52 2006/02/04 20:54:44 meskes Exp $ +# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.53 2006/02/08 09:10:05 meskes Exp $ subdir = src/interfaces/ecpg/test top_builddir = ../../../.. @@ -11,7 +11,7 @@ ECPG = ../preproc/ecpg -I$(srcdir)/../include TESTS = test1 test2 test3 test4 test5 perftest dyntest dyntest2 test_notice \ test_code100 test_init testdynalloc num_test dt_test test_informix \ - test_informix2 test_desc + test_informix2 test_desc test_func ifeq ($(enable_thread_safety), yes) TESTS += test_thread test_thread_implicit endif diff --git a/src/interfaces/ecpg/test/perftest.pgc b/src/interfaces/ecpg/test/perftest.pgc index 0c5b1478aae..7fb22588c87 100644 --- a/src/interfaces/ecpg/test/perftest.pgc +++ b/src/interfaces/ecpg/test/perftest.pgc @@ -15,7 +15,7 @@ print_result(long sec, long usec, char *text) sec--; usec+=1000000; } - printf("I needed %ld seconds and %ld microseconds for the %s test.\n", sec, usec, text); + printf("%ld seconds and %ld microseconds for test %s\n", sec, usec, text); exec sql vacuum; sleep(1); } diff --git a/src/interfaces/ecpg/test/test1.pgc b/src/interfaces/ecpg/test/test1.pgc index 9f784ac7994..91124bbdc29 100644 --- a/src/interfaces/ecpg/test/test1.pgc +++ b/src/interfaces/ecpg/test/test1.pgc @@ -42,6 +42,9 @@ exec sql ifdef NAMELEN; int amount; char letter; } name_letter[AMOUNT]; +#if 0 + int not_used; +#endif exec sql endif; struct ind_struct { diff --git a/src/interfaces/ecpg/test/test5.pgc b/src/interfaces/ecpg/test/test5.pgc index 08fcef3e0e7..841b0e379fe 100644 --- a/src/interfaces/ecpg/test/test5.pgc +++ b/src/interfaces/ecpg/test/test5.pgc @@ -56,7 +56,10 @@ main (void) exit (sqlca.sqlcode); } - EXEC SQL select name, accs, byte into:empl.name,:empl.accs,:empl.byte from empl where idnum =:empl.idnum; + EXEC SQL select name, accs, byte + into :empl.name, :empl.accs, :empl.byte + from empl + where idnum =:empl.idnum; if (sqlca.sqlcode) { printf ("select error = %ld\n", sqlca.sqlcode); diff --git a/src/interfaces/ecpg/test/test_func.pgc b/src/interfaces/ecpg/test/test_func.pgc new file mode 100644 index 00000000000..466512a35b3 --- /dev/null +++ b/src/interfaces/ecpg/test/test_func.pgc @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(int argc, char* argv[]) { + FILE *dbgs; + + if ((dbgs = fopen("log", "w")) != NULL) + ECPGdebug(1, dbgs); + EXEC SQL CONNECT TO mm; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + + EXEC SQL CREATE TABLE My_Table ( Item1 int, Item2 text ); + + EXEC SQL CREATE FUNCTION My_Table_Check() RETURNS trigger + AS $test$ + BEGIN + RAISE NOTICE 'TG_NAME=%, TG WHEN=%', TG_NAME, TG_WHEN; + RETURN NEW; + END; $test$ + LANGUAGE 'plpgsql'; + + EXEC SQL CREATE TRIGGER My_Table_Check_Trigger + BEFORE INSERT + ON My_Table + FOR EACH ROW + EXECUTE PROCEDURE My_Table_Check(); + + EXEC SQL INSERT INTO My_Table VALUES (1234, 'Some random text'); + EXEC SQL INSERT INTO My_Table VALUES (5678, 'The Quick Brown'); + + EXEC SQL DROP TRIGGER My_Table_Check_Trigger ON My_Table; + EXEC SQL DROP FUNCTION My_Table_Check(); + EXEC SQL DROP TABLE My_Table; + + EXEC SQL DISCONNECT ALL; + if (dbgs != NULL) + fclose(dbgs); + + + return 0; +} |
