- Synced parser and keyword file.

- More work on Informix compatibility.
This commit is contained in:
Michael Meskes 2003-02-14 13:17:13 +00:00
parent aa874ee0d7
commit 3a335375a9
10 changed files with 143 additions and 98 deletions

View File

@ -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.
- Set ecpg version to 2.12.0.
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 library to 3.4.2.

View File

@ -0,0 +1,6 @@
/*
* This file contains stuff needed to be as compatible to Informix as possible.
*/
#define SQLNOTFOUND 100

View File

@ -1,4 +1,4 @@
/* $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 @@
* 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)
{ {

View File

@ -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);

View File

@ -1,11 +1,11 @@
# $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) \

View File

@ -1,4 +1,4 @@
/* $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[])
/* 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();

View File

@ -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 @@
*/ */
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[] = {
{"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[] = {
{"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[] = {
{"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[] = {
{"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},

View File

@ -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})*.*
/* 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})*.*
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})*.*
<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,32 +838,45 @@ cppline {space}*#(.*\\{space})*.*
i-- ) i-- )
{} {}
/* Remove trailing '"' if it exists */ yytext[i+1] = '\0';
if (yytext[i] == '"') yyin = NULL;
/* If file name is enclosed in '"' remove these and look only in '.' */
if (yytext[0] == '"' && yytext[i] == '"')
{
yytext[i] = '\0'; yytext[i] = '\0';
else
yytext[i+1] = '\0';
/* also remove starting '"' */
if (yytext[0] == '"')
memmove(yytext, yytext+1, strlen(yytext)); memmove(yytext, yytext+1, strlen(yytext));
yyin = NULL; strncpy(inc_file, yytext, sizeof(inc_file));
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next) yyin = fopen(inc_file, "r");
{
if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
{
fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
continue;
}
snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
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"))
{ {
strcat(inc_file, ".h"); strcat(inc_file, ".h");
yyin = fopen( inc_file, "r" ); yyin = fopen(inc_file, "r");
}
}
}
else
{
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
{
if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
{
fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
continue;
}
snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
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" );
}
} }
} }
} }

View File

@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.207 2003/02/13 20:37:28 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.208 2003/02/14 13:17:13 meskes Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
@ -177,11 +177,11 @@ make_name(void)
%token TYPECAST %token TYPECAST
/* ordinary key words in alphabetical order */ /* ordinary key words in alphabetical order */
%token <keyword> ABORT_TRANS ABSOLUTE ACCESS ACTION ADD AFTER %token <keyword> ABORT_P ABSOLUTE ACCESS ACTION ADD AFTER
AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY AS ASC AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY AS ASC
ASSERTION ASSIGNMENT AT AUTHORIZATION ASSERTION ASSIGNMENT AT AUTHORIZATION
BACKWARD BEFORE BEGIN_TRANS BETWEEN BIGINT BINARY BIT BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
BOOLEAN BOTH BY BOOLEAN BOTH BY
CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P
@ -194,7 +194,7 @@ make_name(void)
DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT DATABASE DAY_P DEALLOCATE DEC DECIMAL DECLARE DEFAULT
DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS
DESC DISTINCT DO DOMAIN_P DOUBLE DROP DESC DISTINCT DO DOMAIN_P DOUBLE DROP
EACH ELSE ENCODING ENCRYPTED END_TRANS ESCAPE EXCEPT EXCLUSIVE EACH ELSE ENCODING ENCRYPTED END_P ESCAPE EXCEPT EXCLUSIVE
EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT
FALSE_P FETCH FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM FALSE_P FETCH FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM
@ -368,12 +368,12 @@ make_name(void)
%type <str> CreateConversionStmt any_operator opclass_item_list %type <str> CreateConversionStmt any_operator opclass_item_list
%type <str> iso_level type_list CharacterWithLength ConstCharacter %type <str> iso_level type_list CharacterWithLength ConstCharacter
%type <str> CharacterWithoutLength BitWithLength BitWithoutLength %type <str> CharacterWithoutLength BitWithLength BitWithoutLength
%type <str> ConstBit GenericType TableFuncElementList %type <str> ConstBit GenericType TableFuncElementList opt_analyze
%type <str> opt_sort_clause transaction_access_mode %type <str> opt_sort_clause transaction_access_mode
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen %type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
%type <str> indicator ECPGExecute ECPGPrepare opt_ecpg_using ecpg_into %type <str> indicator ECPGExecute ECPGPrepare opt_ecpg_using ecpg_into
%type <str> storage_clause opt_initializer c_anything %type <str> storage_declaration storage_clause opt_initializer c_anything
%type <str> variable_list variable c_thing c_term %type <str> variable_list variable c_thing c_term
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier %type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
%type <str> ECPGRelease execstring server_name ECPGVarDeclaration %type <str> ECPGRelease execstring server_name ECPGVarDeclaration
@ -416,6 +416,12 @@ statements: /*EMPTY*/
statement: ecpgstart opt_at stmt ';' { connection = NULL; } statement: ecpgstart opt_at stmt ';' { connection = NULL; }
| ecpgstart stmt ';' | ecpgstart stmt ';'
| ecpgstart ECPGVarDeclaration
{
fprintf(yyout, "%s", $2);
free($2);
output_line_number();
}
| ECPGDeclaration | ECPGDeclaration
| c_thing { fprintf(yyout, "%s", $1); free($1); } | c_thing { fprintf(yyout, "%s", $1); free($1); }
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); } | CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
@ -652,12 +658,6 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
output_simple_statement($1); output_simple_statement($1);
} }
| ECPGVarDeclaration
{
fprintf(yyout, "%s", $1);
free($1);
output_line_number();
}
| ECPGWhenever | ECPGWhenever
{ {
if (connection) if (connection)
@ -996,6 +996,9 @@ AlterTableStmt:
/* ALTER TABLE <relation> DROP CONSTRAINT ... */ /* ALTER TABLE <relation> DROP CONSTRAINT ... */
| ALTER TABLE relation_expr DROP CONSTRAINT name opt_drop_behavior | ALTER TABLE relation_expr DROP CONSTRAINT name opt_drop_behavior
{ $$ = cat_str(5, make_str("alter table"), $3, make_str("drop constraint"), $6, $7); } { $$ = cat_str(5, make_str("alter table"), $3, make_str("drop constraint"), $6, $7); }
/* ALTER TABLE <relation> SET WITHOUT OIDS */
| ALTER TABLE relation_expr SET WITHOUT OIDS
{ $$ = cat_str(3, make_str("alter table"), $3, make_str("set without oids")); }
/* ALTER TABLE <name> CREATE TOAST TABLE */ /* ALTER TABLE <name> CREATE TOAST TABLE */
| ALTER TABLE qualified_name CREATE TOAST TABLE | ALTER TABLE qualified_name CREATE TOAST TABLE
{ $$ = cat_str(3, make_str("alter table"), $3, make_str("create toast table")); } { $$ = cat_str(3, make_str("alter table"), $3, make_str("create toast table")); }
@ -1358,7 +1361,11 @@ OptSeqElem: CACHE NumConst
{ $$ = cat2_str(make_str("maxvalue"), $2); } { $$ = cat2_str(make_str("maxvalue"), $2); }
| MINVALUE NumConst | MINVALUE NumConst
{ $$ = cat2_str(make_str("minvalue"), $2); } { $$ = cat2_str(make_str("minvalue"), $2); }
| START opt_by NumConst | NO MAXVALUE
{ $$ = make_str("no maxvalue"); }
| NO MINVALUE
{ $$ = make_str("no minvalue"); }
| START opt_with NumConst
{ $$ = cat_str(3, make_str("start"), $2, $3); } { $$ = cat_str(3, make_str("start"), $2, $3); }
; ;
@ -1547,8 +1554,6 @@ DefineStmt: CREATE AGGREGATE func_name definition
{ $$ = cat_str(3, make_str("create type"), $3, $4); } { $$ = cat_str(3, make_str("create type"), $3, $4); }
| CREATE TYPE_P any_name AS rowdefinition | CREATE TYPE_P any_name AS rowdefinition
{ $$ = cat_str(4, make_str("create type"), $3, make_str("as"), $5); } { $$ = cat_str(4, make_str("create type"), $3, make_str("as"), $5); }
| CREATE CHARACTER SET opt_as any_name GET definition opt_collate
{ $$ = cat_str(6, make_str("create character set"), $4, $5, make_str("get"), $7, $8); }
; ;
rowdefinition: '(' TableFuncElementList ')' rowdefinition: '(' TableFuncElementList ')'
@ -1692,7 +1697,6 @@ direction: FORWARD { $$ = make_str("forward"); }
fetch_how_many: IntConst { $$ = $1; } fetch_how_many: IntConst { $$ = $1; }
| ALL { $$ = make_str("all"); } | ALL { $$ = make_str("all"); }
| LAST { $$ = make_str("last"); }
| NEXT { $$ = make_str("next"); } | NEXT { $$ = make_str("next"); }
| PRIOR { $$ = make_str("prior"); } | PRIOR { $$ = make_str("prior"); }
; ;
@ -1757,9 +1761,6 @@ GrantStmt: GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_
RevokeStmt: REVOKE opt_revoke_grant_option privileges ON privilege_target FROM grantee_list opt_drop_behavior RevokeStmt: REVOKE opt_revoke_grant_option privileges ON privilege_target FROM grantee_list opt_drop_behavior
{ {
if (strcmp($8, "drop cascade") == 0)
mmerror(PARSE_ERROR, ET_WARNING, "Not implemented REVOKE ... CASCADE will be send to backend");
$$ = cat_str(9, make_str("revoke"), $2, $3, make_str("on"), $5, make_str("from"), $7, $8); $$ = cat_str(9, make_str("revoke"), $2, $3, make_str("on"), $5, make_str("from"), $7, $8);
} }
@ -2035,10 +2036,10 @@ any_operator:
{ $$ = cat_str(3, $1, make_str("."), $3); } { $$ = cat_str(3, $1, make_str("."), $3); }
; ;
CreateCastStmt: CREATE CAST '(' ConstTypename AS ConstTypename ')' CreateCastStmt: CREATE CAST '(' Typename AS Typename ')'
WITH FUNCTION function_with_argtypes cast_context WITH FUNCTION function_with_argtypes cast_context
{ $$ = cat_str(6, make_str("create cast ("), $4, make_str("as"), $6, make_str(") with function"), $10); } { $$ = cat_str(6, make_str("create cast ("), $4, make_str("as"), $6, make_str(") with function"), $10); }
| CREATE CAST '(' ConstTypename AS ConstTypename ')' | CREATE CAST '(' Typename AS Typename ')'
WITHOUT FUNCTION cast_context WITHOUT FUNCTION cast_context
{ $$ = cat_str(6, make_str("create cast ("), $4, make_str("as"), $6, make_str(") without function"), $10); } { $$ = cat_str(6, make_str("create cast ("), $4, make_str("as"), $6, make_str(") without function"), $10); }
; ;
@ -2048,7 +2049,7 @@ cast_context: AS ASSIGNMENT { $$ = make_str("as assignment"); }
; ;
DropCastStmt: DROP CAST '(' ConstTypename AS ConstTypename ')' opt_drop_behavior DropCastStmt: DROP CAST '(' Typename AS Typename ')' opt_drop_behavior
{ $$ = cat_str(6, make_str("drop cast ("), $4, make_str("as"), $6, make_str(")"), $8); } { $$ = cat_str(6, make_str("drop cast ("), $4, make_str("as"), $6, make_str(")"), $8); }
; ;
@ -2181,11 +2182,11 @@ UnlistenStmt: UNLISTEN qualified_name
* (also older versions END / ABORT) * (also older versions END / ABORT)
* *
*****************************************************************************/ *****************************************************************************/
TransactionStmt: ABORT_TRANS opt_transaction { $$ = make_str("rollback"); } TransactionStmt: ABORT_P opt_transaction { $$ = make_str("rollback"); }
| BEGIN_TRANS opt_transaction { $$ = make_str("begin transaction"); } | BEGIN_P opt_transaction { $$ = make_str("begin transaction"); }
| START TRANSACTION transaction_mode_list_or_empty { $$ = cat2_str(make_str("start transaction"), $3); } | START TRANSACTION transaction_mode_list_or_empty { $$ = cat2_str(make_str("start transaction"), $3); }
| COMMIT opt_transaction { $$ = make_str("commit"); } | COMMIT opt_transaction { $$ = make_str("commit"); }
| END_TRANS opt_transaction { $$ = make_str("commit"); } | END_P opt_transaction { $$ = make_str("commit"); }
| ROLLBACK opt_transaction { $$ = make_str("rollback"); } | ROLLBACK opt_transaction { $$ = make_str("rollback"); }
; ;
@ -2413,12 +2414,17 @@ opt_name_list: '(' name_list ')'
* *
*****************************************************************************/ *****************************************************************************/
ExplainStmt: EXPLAIN opt_verbose OptimizableStmt ExplainStmt: EXPLAIN opt_analyze opt_verbose OptimizableStmt
{ $$ = cat_str(3, make_str("explain"), $2, $3); }
| EXPLAIN analyze_keyword opt_verbose OptimizableStmt
{ $$ = cat_str(4, make_str("explain"), $2, $3, $4); } { $$ = cat_str(4, make_str("explain"), $2, $3, $4); }
/* | EXPLAIN opt_analyze opt_verbose ExecuteStmt
{ $$ = cat_str(4, make_str("explain"), $2, $3, $4); }*/
; ;
opt_analyze:
analyze_keyword { $$ = $1; }
| /* EMPTY */ { $$ = EMPTY; }
;
/* /*
conflicts with ecpg conflicts with ecpg
@ -2939,8 +2945,8 @@ TableFuncElement: ColId Typename { $$ = cat2_str($1, $2); }
Typename: SimpleTypename opt_array_bounds Typename: SimpleTypename opt_array_bounds
{ $$ = cat2_str($1, $2.str); } { $$ = cat2_str($1, $2.str); }
| SETOF SimpleTypename | SETOF SimpleTypename opt_array_bounds
{ $$ = cat2_str(make_str("setof"), $2); } { $$ = cat_str(3, make_str("setof"), $2, $3); }
; ;
@ -3628,7 +3634,7 @@ in_expr: select_with_parens
* same as CASE WHEN a IS NOT NULL THEN a WHEN b IS NOT NULL THEN b ... END * same as CASE WHEN a IS NOT NULL THEN a WHEN b IS NOT NULL THEN b ... END
* - thomas 1998-11-09 * - thomas 1998-11-09
*/ */
case_expr: CASE case_arg when_clause_list case_default END_TRANS case_expr: CASE case_arg when_clause_list case_default END_P
{ $$ = cat_str(5, make_str("case"), $2, $3, $4, make_str("end")); } { $$ = cat_str(5, make_str("case"), $2, $3, $4, make_str("end")); }
| NULLIF '(' a_expr ',' a_expr ')' | NULLIF '(' a_expr ',' a_expr ')'
{ $$ = cat_str(5, make_str("nullif("), $3, make_str(","), $5, make_str(")")); } { $$ = cat_str(5, make_str("nullif("), $3, make_str(","), $5, make_str(")")); }
@ -4140,29 +4146,25 @@ single_vt_declaration: type_declaration { $$ = $1; }
| single_var_declaration { $$ = $1; } | single_var_declaration { $$ = $1; }
; ;
single_var_declaration: storage_clause storage_modifier single_var_declaration: storage_declaration
{
actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
actual_startline[struct_level] = hashline_number();
}
single_vt_type single_vt_type
{ {
actual_type[struct_level].type_enum = $4.type_enum; actual_type[struct_level].type_enum = $2.type_enum;
actual_type[struct_level].type_dimension = $4.type_dimension; actual_type[struct_level].type_dimension = $2.type_dimension;
actual_type[struct_level].type_index = $4.type_index; actual_type[struct_level].type_index = $2.type_index;
actual_type[struct_level].type_sizeof = $4.type_sizeof; actual_type[struct_level].type_sizeof = $2.type_sizeof;
/* we do not need the string "varchar" for output */ /* we do not need the string "varchar" for output */
/* so replace it with an empty string */ /* so replace it with an empty string */
if ($4.type_enum == ECPGt_varchar) if ($2.type_enum == ECPGt_varchar)
{ {
free($4.type_str); free($2.type_str);
$4.type_str=EMPTY; $2.type_str=EMPTY;
} }
} }
variable_list variable_list ';'
{ {
$$ = cat_str(6, actual_startline[struct_level], $1, $2, $4.type_str, $6, make_str(";\n")); $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, make_str(";\n"));
} }
; ;
@ -4225,9 +4227,9 @@ ECPGDeclaration: sql_startdeclare
} }
; ;
sql_startdeclare: ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {}; sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
sql_enddeclare: ecpgstart END_TRANS DECLARE SQL_SECTION ';' {}; sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
var_type_declarations: /*EMPTY*/ { $$ = EMPTY; } var_type_declarations: /*EMPTY*/ { $$ = EMPTY; }
| vt_declarations { $$ = $1; } | vt_declarations { $$ = $1; }
@ -4305,29 +4307,32 @@ type_declaration: S_TYPEDEF
$$ = make_str(""); $$ = make_str("");
}; };
var_declaration: storage_clause storage_modifier var_declaration: storage_declaration
{
actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
actual_startline[struct_level] = hashline_number();
}
type type
{ {
actual_type[struct_level].type_enum = $4.type_enum; actual_type[struct_level].type_enum = $2.type_enum;
actual_type[struct_level].type_dimension = $4.type_dimension; actual_type[struct_level].type_dimension = $2.type_dimension;
actual_type[struct_level].type_index = $4.type_index; actual_type[struct_level].type_index = $2.type_index;
actual_type[struct_level].type_sizeof = $4.type_sizeof; actual_type[struct_level].type_sizeof = $2.type_sizeof;
/* we do not need the string "varchar" for output */ /* we do not need the string "varchar" for output */
/* so replace it with an empty string */ /* so replace it with an empty string */
if ($4.type_enum == ECPGt_varchar) if ($2.type_enum == ECPGt_varchar)
{ {
free($4.type_str); free($2.type_str);
$4.type_str=EMPTY; $2.type_str=EMPTY;
} }
} }
variable_list ';' variable_list ';'
{ {
$$ = cat_str(6, actual_startline[struct_level], $1, $2, $4.type_str, $6, make_str(";\n")); $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, make_str(";\n"));
}
;
storage_declaration: storage_clause storage_modifier
{
actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
actual_startline[struct_level] = hashline_number();
} }
; ;
@ -5221,7 +5226,7 @@ ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
/* "Unreserved" keywords --- available for use as any kind of name. /* "Unreserved" keywords --- available for use as any kind of name.
*/ */
unreserved_keyword: unreserved_keyword:
ABORT_TRANS { $$ = make_str("abort"); } ABORT_P { $$ = make_str("abort"); }
| ABSOLUTE { $$ = make_str("absolute"); } | ABSOLUTE { $$ = make_str("absolute"); }
| ACCESS { $$ = make_str("access"); } | ACCESS { $$ = make_str("access"); }
| ACTION { $$ = make_str("action"); } | ACTION { $$ = make_str("action"); }
@ -5234,7 +5239,7 @@ unreserved_keyword:
| AT { $$ = make_str("at"); } | AT { $$ = make_str("at"); }
| BACKWARD { $$ = make_str("backward"); } | BACKWARD { $$ = make_str("backward"); }
| BEFORE { $$ = make_str("before"); } | BEFORE { $$ = make_str("before"); }
| BEGIN_TRANS { $$ = make_str("begin"); } | BEGIN_P { $$ = make_str("begin"); }
| BY { $$ = make_str("by"); } | BY { $$ = make_str("by"); }
| CACHE { $$ = make_str("cache"); } | CACHE { $$ = make_str("cache"); }
| CASCADE { $$ = make_str("cascade"); } | CASCADE { $$ = make_str("cascade"); }
@ -5293,7 +5298,6 @@ unreserved_keyword:
| KEY { $$ = make_str("key"); } | KEY { $$ = make_str("key"); }
| LANCOMPILER { $$ = make_str("lancompiler"); } | LANCOMPILER { $$ = make_str("lancompiler"); }
| LANGUAGE { $$ = make_str("language"); } | LANGUAGE { $$ = make_str("language"); }
| LAST { $$ = make_str("last"); }
| LEVEL { $$ = make_str("level"); } | LEVEL { $$ = make_str("level"); }
| LISTEN { $$ = make_str("listen"); } | LISTEN { $$ = make_str("listen"); }
| LOAD { $$ = make_str("load"); } | LOAD { $$ = make_str("load"); }
@ -5504,7 +5508,7 @@ reserved_keyword:
| DISTINCT { $$ = make_str("distinct"); } | DISTINCT { $$ = make_str("distinct"); }
| DO { $$ = make_str("do"); } | DO { $$ = make_str("do"); }
| ELSE { $$ = make_str("else"); } | ELSE { $$ = make_str("else"); }
| END_TRANS { $$ = make_str("end"); } | END_P { $$ = make_str("end"); }
| EXCEPT { $$ = make_str("except"); } | EXCEPT { $$ = make_str("except"); }
| FALSE_P { $$ = make_str("false"); } | FALSE_P { $$ = make_str("false"); }
| FOR { $$ = make_str("for"); } | FOR { $$ = make_str("for"); }

View File

@ -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