Commit 1fa6be6f authored by Michael Meskes's avatar Michael Meskes

ynced parser and keyword list.

Implemented EXEC SQL UNDEF.
Applied first version of the regression test patch by Joachim Wieland <joe@mcknight.de>.
parent 97eefd69
...@@ -2052,5 +2052,17 @@ Fr Jul 28 11:00:51 CEST 2006 ...@@ -2052,5 +2052,17 @@ Fr Jul 28 11:00:51 CEST 2006
- COPY TO STDOUT works - COPY TO STDOUT works
- Connection identifier has to be unique - Connection identifier has to be unique
- Variables should be free'ed only once. - Variables should be free'ed only once.
Tu Aug 1 15:04:52 CEST 2006
- Applied patch by Joachim Wieland <joe@mcknight.de> to fix segfault
occuring when using --enable-thread-safety.
We Aug 2 13:15:25 CEST 2006
- Synced parser and keyword list.
- Implemented EXEC SQL UNDEF.
- Applied first version of the regression test patch by Joachim
Wieland <joe@mcknight.de>.
- Set ecpg library version to 5.2. - Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1. - Set ecpg version to 4.2.1.
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.31 2006/07/28 10:10:42 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.32 2006/08/02 13:43:22 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -26,6 +26,11 @@ ecpg_actual_connection_init(void) ...@@ -26,6 +26,11 @@ ecpg_actual_connection_init(void)
{ {
pthread_key_create(&actual_connection_key, NULL); pthread_key_create(&actual_connection_key, NULL);
} }
void ecpg_pthreads_init(void)
{
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
}
#endif #endif
static struct connection * static struct connection *
...@@ -43,13 +48,10 @@ ecpg_get_connection_nr(const char *connection_name) ...@@ -43,13 +48,10 @@ ecpg_get_connection_nr(const char *connection_name)
* connection and hope the user knows what they're doing (i.e. using * connection and hope the user knows what they're doing (i.e. using
* their own mutex to protect that connection from concurrent accesses * their own mutex to protect that connection from concurrent accesses
*/ */
/* if !ret then we got the connection from TSD */
if (NULL == ret) if (NULL == ret)
{ /* no TSD connection, going for global */
ECPGlog("no TSD connection, going for global\n");
ret = actual_connection; ret = actual_connection;
}
else
ECPGlog("got the TSD connection\n");
#else #else
ret = actual_connection; ret = actual_connection;
#endif #endif
...@@ -84,13 +86,10 @@ ECPGget_connection(const char *connection_name) ...@@ -84,13 +86,10 @@ ECPGget_connection(const char *connection_name)
* connection and hope the user knows what they're doing (i.e. using * connection and hope the user knows what they're doing (i.e. using
* their own mutex to protect that connection from concurrent accesses * their own mutex to protect that connection from concurrent accesses
*/ */
/* if !ret then we got the connection from TSD */
if (NULL == ret) if (NULL == ret)
{ /* no TSD connection here either, using global */
ECPGlog("no TSD connection here either, using global\n");
ret = actual_connection; ret = actual_connection;
}
else
ECPGlog("got TSD connection\n");
#else #else
ret = actual_connection; ret = actual_connection;
#endif #endif
...@@ -298,6 +297,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ...@@ -298,6 +297,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (dbname == NULL && connection_name == NULL) if (dbname == NULL && connection_name == NULL)
connection_name = "DEFAULT"; connection_name = "DEFAULT";
#if ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
#endif
/* check if the identifier is unique */ /* check if the identifier is unique */
if (ECPGget_connection(connection_name)) if (ECPGget_connection(connection_name))
{ {
...@@ -450,7 +453,6 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ...@@ -450,7 +453,6 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
all_connections = this; all_connections = this;
#ifdef ENABLE_THREAD_SAFETY #ifdef ENABLE_THREAD_SAFETY
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
pthread_setspecific(actual_connection_key, all_connections); pthread_setspecific(actual_connection_key, all_connections);
#endif #endif
actual_connection = all_connections; actual_connection = all_connections;
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.13 2006/07/14 05:28:28 tgl Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.14 2006/08/02 13:43:23 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -189,8 +189,8 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat) ...@@ -189,8 +189,8 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
else else
sqlca->sqlcode = ECPG_PGSQL; sqlca->sqlcode = ECPG_PGSQL;
ECPGlog("raising sqlstate %.*s in line %d, '%s'.\n", ECPGlog("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n",
sizeof(sqlca->sqlstate), sqlca->sqlstate, line, sqlca->sqlerrm.sqlerrmc); sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc);
/* free all memory we have allocated for the user */ /* free all memory we have allocated for the user */
ECPGfree_auto_mem(); ECPGfree_auto_mem();
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.55 2006/07/28 11:49:36 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.56 2006/08/02 13:43:23 meskes Exp $ */
/* /*
* The aim is to get a simpler inteface to the database routines. * The aim is to get a simpler inteface to the database routines.
...@@ -1465,7 +1465,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, ...@@ -1465,7 +1465,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
{ {
va_list args; va_list args;
struct statement *stmt; struct statement *stmt;
struct connection *con = ECPGget_connection(connection_name); struct connection *con;
bool status; bool status;
char *oldlocale; char *oldlocale;
...@@ -1474,6 +1474,12 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, ...@@ -1474,6 +1474,12 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno); oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
#endif
con = ECPGget_connection(connection_name);
if (!ECPGinit(con, connection_name, lineno)) if (!ECPGinit(con, connection_name, lineno))
{ {
setlocale(LC_NUMERIC, oldlocale); setlocale(LC_NUMERIC, oldlocale);
......
/* /*
* this is a small part of c.h since we don't want to leak all postgres * this is a small part of c.h since we don't want to leak all postgres
* definitions into ecpg programs * definitions into ecpg programs
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.67 2006/07/11 13:54:25 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.68 2006/08/02 13:43:23 meskes Exp $
*/ */
#ifndef _ECPGLIB_H #ifndef _ECPGLIB_H
...@@ -85,6 +85,10 @@ bool ECPGdescribe(int, bool, const char *,...); ...@@ -85,6 +85,10 @@ bool ECPGdescribe(int, bool, const char *,...);
/* dynamic result allocation */ /* dynamic result allocation */
void ECPGfree_auto_mem(void); void ECPGfree_auto_mem(void);
#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init();
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.73 2006/03/05 15:59:08 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.74 2006/08/02 13:43:23 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -167,6 +167,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -167,6 +167,7 @@ static ScanKeyword ScanKeywords[] = {
{"including", INCLUDING}, {"including", INCLUDING},
{"increment", INCREMENT}, {"increment", INCREMENT},
{"index", INDEX}, {"index", INDEX},
{"indexes", INDEXES},
{"inherit", INHERIT}, {"inherit", INHERIT},
{"inherits", INHERITS}, {"inherits", INHERITS},
{"initially", INITIALLY}, {"initially", INITIALLY},
...@@ -324,7 +325,6 @@ static ScanKeyword ScanKeywords[] = { ...@@ -324,7 +325,6 @@ static ScanKeyword ScanKeywords[] = {
{"time", TIME}, {"time", TIME},
{"timestamp", TIMESTAMP}, {"timestamp", TIMESTAMP},
{"to", TO}, {"to", TO},
{"toast", TOAST},
{"trailing", TRAILING}, {"trailing", TRAILING},
{"transaction", TRANSACTION}, {"transaction", TRANSACTION},
{"treat", TREAT}, {"treat", TREAT},
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.147 2006/07/14 05:28:28 tgl Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.148 2006/08/02 13:43:23 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -79,7 +79,7 @@ static struct _if_value ...@@ -79,7 +79,7 @@ static struct _if_value
%option yylineno %option yylineno
%s C SQL incl def def_ident %s C SQL incl def def_ident undef
/* /*
* OK, here is a short description of lex/flex rules behavior. * OK, here is a short description of lex/flex rules behavior.
...@@ -285,6 +285,7 @@ exec [eE][xX][eE][cC] ...@@ -285,6 +285,7 @@ exec [eE][xX][eE][cC]
sql [sS][qQ][lL] sql [sS][qQ][lL]
define [dD][eE][fF][iI][nN][eE] define [dD][eE][fF][iI][nN][eE]
include [iI][nN][cC][lL][uU][dD][eE] include [iI][nN][cC][lL][uU][dD][eE]
undef [uU][nN][dD][eE][fF]
ifdef [iI][fF][dD][eE][fF] ifdef [iI][fF][dD][eE][fF]
ifndef [iI][fF][nN][dD][eE][fF] ifndef [iI][fF][nN][dD][eE][fF]
...@@ -837,7 +838,6 @@ cppline {space}*#(.*\\{space})*.*{newline} ...@@ -837,7 +838,6 @@ cppline {space}*#(.*\\{space})*.*{newline}
<C>"->*" { return(S_MEMPOINT); } <C>"->*" { return(S_MEMPOINT); }
<C>".*" { return(S_DOTPOINT); } <C>".*" { return(S_DOTPOINT); }
<C>{other} { return S_ANYTHING; } <C>{other} { return S_ANYTHING; }
<C>{exec_sql}{define}{space}* { BEGIN(def_ident); } <C>{exec_sql}{define}{space}* { BEGIN(def_ident); }
<C>{informix_special}{define}{space}* { <C>{informix_special}{define}{space}* {
/* are we simulating Informix? */ /* are we simulating Informix? */
...@@ -851,6 +851,55 @@ cppline {space}*#(.*\\{space})*.*{newline} ...@@ -851,6 +851,55 @@ cppline {space}*#(.*\\{space})*.*{newline}
return (S_ANYTHING); return (S_ANYTHING);
} }
} }
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
{
BEGIN(undef);
}
else
{
yyless(1);
return (S_ANYTHING);
}
}
<undef>{identifier}{space}*";" {
struct _defines *ptr, *ptr2 = NULL;
int i;
/*
* Skip the ";" and trailing whitespace. Note that yytext
* contains at least one non-space character plus the ";"
*/
for (i = strlen(yytext)-2;
i > 0 && isspace((unsigned char) yytext[i]);
i-- )
;
yytext[i+1] = '\0';
for (ptr = defines; ptr != NULL; ptr2 = ptr, ptr = ptr->next)
{
if (strcmp(yytext, ptr->old) == 0)
{
if (ptr2 == NULL)
defines = ptr->next;
else
ptr2->next = ptr->next;
free(ptr->new);
free(ptr->old);
free(ptr);
break;
}
}
BEGIN(C);
}
<undef>{other} {
mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL UNDEF' command");
yyterminate();
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); } <C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{informix_special}{include}{space}* { <C>{informix_special}{include}{space}* {
/* are we simulating Informix? */ /* are we simulating Informix? */
......
This diff is collapsed.
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.53 2006/02/08 09:10:05 meskes Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.54 2006/08/02 13:43:23 meskes Exp $
subdir = src/interfaces/ecpg/test subdir = src/interfaces/ecpg/test
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) # port number for temp-installation test postmaster
override CFLAGS += $(PTHREAD_CFLAGS) TEMP_PORT = 5$(DEF_PGPORT)
ECPG = ../preproc/ecpg -I$(srcdir)/../include # default encoding
MULTIBYTE = SQL_ASCII
TESTS = test1 test2 test3 test4 test5 perftest dyntest dyntest2 test_notice \ # locale
test_code100 test_init testdynalloc num_test dt_test test_informix \ NOLOCALE :=
test_informix2 test_desc test_func ifdef NO_LOCALE
ifeq ($(enable_thread_safety), yes) NOLOCALE += --no-locale
TESTS += test_thread test_thread_implicit
endif endif
all: $(TESTS) all clean install installdirs uninstall dep depend distprep:
$(MAKE) -C connect $@
$(MAKE) -C sql $@
$(MAKE) -C pgtypeslib $@
$(MAKE) -C errors $@
$(MAKE) -C compat_informix $@
$(MAKE) -C complex $@
$(MAKE) -C thread $@
# for some reason I couldn't figure out, ifeq($@,clean) ... does not work
if [ $@ = clean ]; then rm -f results/*.stdout results/*.stderr results/*.c; rm -rf tmp_check/; rm -f log/*.log; rm -f pg_regress.inc.sh regression.diff; fi
all: pg_regress.sh
pg_regress.sh: pg_regress.inc.sh
pg_regress.inc.sh: pg_regress.inc.sh.in $(top_builddir)/src/Makefile.global
sed -e 's,@bindir@,$(bindir),g' \
-e 's,@libdir@,$(libdir),g' \
-e 's,@pkglibdir@,$(pkglibdir),g' \
-e 's,@datadir@,$(datadir),g' \
-e 's/@VERSION@/$(VERSION)/g' \
-e 's/@host_tuple@/$(host_tuple)/g' \
-e 's,@GMAKE@,$(MAKE),g' \
-e 's/@enable_shared@/$(enable_shared)/g' \
-e 's/@GCC@/$(GCC)/g' \
$< >$@
test: all pg_regress.inc.sh
sh ./pg_regress.sh --dbname=regress1 --debug --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --listen-on-tcp --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
check: all test
%: %.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq $(PTHREAD_LIBS) -o $@
test_informix: test_informix.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq $(PTHREAD_LIBS) -o $@
test_informix2: test_informix2.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq $(PTHREAD_LIBS) -o $@
test4: test4.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq $(PTHREAD_LIBS) -o $@
%.c: %.pgc
$(ECPG) -o $@ -I$(srcdir) $<
test_informix.c: test_informix.pgc
$(ECPG) -o $@ -C INFORMIX -r no_indicator $<
test_informix2.c: test_informix2.pgc
$(ECPG) -o $@ -C INFORMIX $<
test4.c: test4.pgc
$(ECPG) -o $@ -c $<
clean:
rm -f $(TESTS) $(TESTS:%=%.o) $(TESTS:%=%.c) log
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment