Commit 3a335375 authored by Michael Meskes's avatar Michael Meskes

- Synced parser and keyword file.

- More work on Informix compatibility.
parent aa874ee0
...@@ -1332,5 +1332,12 @@ Thu Feb 13 14:06:28 CET 2003 ...@@ -1332,5 +1332,12 @@ Thu Feb 13 14:06:28 CET 2003
- Started working on an Informix compatibility mode. With option "-C - Started working on an Informix compatibility mode. With option "-C
INFORMIX" set, ecpg now accepts "$" as alias for "exec sql" and to INFORMIX" set, ecpg now accepts "$" as alias for "exec sql" and to
denote variables inside SQL statements. denote variables inside SQL statements.
Fri Feb 14 14:14:25 CET 2003
- Synced parser and keyword file.
- More work on Informix compatibility.
- Set ecpg version to 2.12.0. - Set ecpg version to 2.12.0.
- Set library to 3.4.2.
/*
* This file contains stuff needed to be as compatible to Informix as possible.
*/
#define SQLNOTFOUND 100
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.18 2003/02/13 18:13:22 tgl Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.19 2003/02/14 13:17:13 meskes Exp $ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* the last back-end operation. */ * the last back-end operation. */
static char *ECPGerr; static char *ECPGerr;
void void
ECPGraise(int line, int code, const char *str) ECPGraise(int line, int code, const char *str)
{ {
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
/* Here are some methods used by the lib. */ /* Here are some methods used by the lib. */
/* Stores the backend error message for client access */
void set_backend_err(const char *err, int lineon);
/* Store and retrieve the backend error message for client access */ /* Store and retrieve the backend error message for client access */
void set_backend_err(const char *err, int lineon); void set_backend_err(const char *err, int lineon);
char *ECPGerrmsg(void); char *ECPGerrmsg(void);
......
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.89 2002/12/04 18:14:11 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.90 2003/02/14 13:17:13 meskes Exp $
subdir = src/interfaces/ecpg/preproc subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
MAJOR_VERSION=2 MAJOR_VERSION=2
MINOR_VERSION=11 MINOR_VERSION=12
PATCHLEVEL=0 PATCHLEVEL=0
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \ override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.59 2003/02/13 13:11:52 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.60 2003/02/14 13:17:13 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...@@ -315,6 +315,10 @@ main(int argc, char *const argv[]) ...@@ -315,6 +315,10 @@ main(int argc, char *const argv[])
/* we need several includes */ /* we need several includes */
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename); fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
/* add some compatibility headers */
if (compat == ECPG_COMPAT_INFORMIX)
fprintf(yyout, "/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n");
/* and parse the source */ /* and parse the source */
yyparse(); yyparse();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.55 2002/10/21 13:09:31 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.56 2003/02/14 13:17:13 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
static ScanKeyword ScanKeywords[] = { static ScanKeyword ScanKeywords[] = {
/* name, value */ /* name, value */
{"abort", ABORT_TRANS}, {"abort", ABORT_P},
{"absolute", ABSOLUTE}, {"absolute", ABSOLUTE},
{"access", ACCESS}, {"access", ACCESS},
{"action", ACTION}, {"action", ACTION},
...@@ -49,7 +49,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -49,7 +49,7 @@ static ScanKeyword ScanKeywords[] = {
{"authorization", AUTHORIZATION}, {"authorization", AUTHORIZATION},
{"backward", BACKWARD}, {"backward", BACKWARD},
{"before", BEFORE}, {"before", BEFORE},
{"begin", BEGIN_TRANS}, {"begin", BEGIN_P},
{"between", BETWEEN}, {"between", BETWEEN},
{"bigint", BIGINT}, {"bigint", BIGINT},
{"binary", BINARY}, {"binary", BINARY},
...@@ -115,7 +115,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -115,7 +115,7 @@ static ScanKeyword ScanKeywords[] = {
{"else", ELSE}, {"else", ELSE},
{"encoding", ENCODING}, {"encoding", ENCODING},
{"encrypted", ENCRYPTED}, {"encrypted", ENCRYPTED},
{"end", END_TRANS}, {"end", END_P},
{"escape", ESCAPE}, {"escape", ESCAPE},
{"except", EXCEPT}, {"except", EXCEPT},
{"exclusive", EXCLUSIVE}, {"exclusive", EXCLUSIVE},
...@@ -226,6 +226,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -226,6 +226,7 @@ static ScanKeyword ScanKeywords[] = {
{"position", POSITION}, {"position", POSITION},
{"precision", PRECISION}, {"precision", PRECISION},
{"prepare", PREPARE}, {"prepare", PREPARE},
{"preserve", PRESERVE},
{"primary", PRIMARY}, {"primary", PRIMARY},
{"prior", PRIOR}, {"prior", PRIOR},
{"privileges", PRIVILEGES}, {"privileges", PRIVILEGES},
...@@ -246,6 +247,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -246,6 +247,7 @@ static ScanKeyword ScanKeywords[] = {
{"right", RIGHT}, {"right", RIGHT},
{"rollback", ROLLBACK}, {"rollback", ROLLBACK},
{"row", ROW}, {"row", ROW},
{"rows", ROWS},
{"rule", RULE}, {"rule", RULE},
{"schema", SCHEMA}, {"schema", SCHEMA},
{"scroll", SCROLL}, {"scroll", SCROLL},
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.103 2003/02/13 20:37:28 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.104 2003/02/14 13:17:13 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -423,7 +423,6 @@ cppline {space}*#(.*\\{space})*.* ...@@ -423,7 +423,6 @@ cppline {space}*#(.*\\{space})*.*
/* are we simulating Informix? */ /* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX) if (compat == ECPG_COMPAT_INFORMIX)
{ {
printf ("unput $\n");
unput(':'); unput(':');
} }
else else
...@@ -560,6 +559,12 @@ cppline {space}*#(.*\\{space})*.* ...@@ -560,6 +559,12 @@ cppline {space}*#(.*\\{space})*.*
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
/* Is it a C keyword? */
keyword = ScanCKeywordLookup(yytext);
if (keyword != NULL)
return keyword->value;
/* How about a DEFINE? */ /* How about a DEFINE? */
for (ptr = defines; ptr; ptr = ptr->next) for (ptr = defines; ptr; ptr = ptr->next)
{ {
...@@ -697,6 +702,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -697,6 +702,7 @@ cppline {space}*#(.*\\{space})*.*
<C>{exec_sql}{define}{space}* { BEGIN(def_ident); } <C>{exec_sql}{define}{space}* { BEGIN(def_ident); }
<C>{exec_sql}{include}{space}* { BEGIN(incl); } <C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{informix_special}{include}{space}* { BEGIN(incl); }
<C,xskip>{exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); } <C,xskip>{exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); }
<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); } <C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }
...@@ -832,17 +838,29 @@ cppline {space}*#(.*\\{space})*.* ...@@ -832,17 +838,29 @@ cppline {space}*#(.*\\{space})*.*
i-- ) i-- )
{} {}
/* Remove trailing '"' if it exists */
if (yytext[i] == '"')
yytext[i] = '\0';
else
yytext[i+1] = '\0'; yytext[i+1] = '\0';
yyin = NULL;
/* also remove starting '"' */ /* If file name is enclosed in '"' remove these and look only in '.' */
if (yytext[0] == '"') if (yytext[0] == '"' && yytext[i] == '"')
{
yytext[i] = '\0';
memmove(yytext, yytext+1, strlen(yytext)); memmove(yytext, yytext+1, strlen(yytext));
yyin = NULL; strncpy(inc_file, yytext, sizeof(inc_file));
yyin = fopen(inc_file, "r");
if (!yyin)
{
if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))
{
strcat(inc_file, ".h");
yyin = fopen(inc_file, "r");
}
}
}
else
{
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next) for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
{ {
if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH) if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
...@@ -851,7 +869,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -851,7 +869,7 @@ cppline {space}*#(.*\\{space})*.*
continue; continue;
} }
snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext); snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
yyin = fopen( inc_file, "r" ); yyin = fopen(inc_file, "r");
if (!yyin) if (!yyin)
{ {
if (strcmp(inc_file + strlen(inc_file) - 2, ".h")) if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))
...@@ -861,6 +879,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -861,6 +879,7 @@ cppline {space}*#(.*\\{space})*.*
} }
} }
} }
}
if (!yyin) if (!yyin)
{ {
snprintf(errortext, sizeof(errortext), "Cannot open include file %s in line %d\n", yytext, yylineno); snprintf(errortext, sizeof(errortext), "Cannot open include file %s in line %d\n", yytext, yylineno);
......
This diff is collapsed.
...@@ -23,14 +23,15 @@ exec sql begin declare section; ...@@ -23,14 +23,15 @@ exec sql begin declare section;
struct personal_indicator { int ind_name; struct personal_indicator { int ind_name;
birthinfo ind_birth; birthinfo ind_birth;
} ind_personal, *i; } ind_personal, *i;
float ind_married;
ind children;
ind ind_children; ind ind_children;
char *married = NULL;
c testname="Petra"; c testname="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1"; char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section; exec sql end declare section;
exec sql char *married = NULL;
exec sql float ind_married;
exec sql ind children;
exec sql var ind_married is long; exec sql var ind_married is long;
exec sql declare cur cursor for exec sql declare cur cursor for
......
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