Commit 654e1f96 authored by Peter Eisentraut's avatar Peter Eisentraut

Clean up whitespace and indentation in parser and scanner files

These are not touched by pgindent, so clean them up a bit manually.
parent f3ebaad4
...@@ -47,165 +47,167 @@ static NDBOX * write_point_as_box(char *s, int dim); ...@@ -47,165 +47,167 @@ static NDBOX * write_point_as_box(char *s, int dim);
/* Grammar follows */ /* Grammar follows */
%% %%
box: box: O_BRACKET paren_list COMMA paren_list C_BRACKET
O_BRACKET paren_list COMMA paren_list C_BRACKET { {
int dim;
int dim;
dim = delim_count($2, ',') + 1;
dim = delim_count($2, ',') + 1; if ((delim_count($4, ',') + 1) != dim)
if ( (delim_count($4, ',') + 1) != dim ) { {
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"), errmsg("bad cube representation"),
errdetail("Different point dimensions in (%s) and (%s).", errdetail("Different point dimensions in (%s) and (%s).",
$2, $4))); $2, $4)));
YYABORT; YYABORT;
} }
if (dim > CUBE_MAX_DIM) { if (dim > CUBE_MAX_DIM) {
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"), errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.", errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM))); CUBE_MAX_DIM)));
YYABORT; YYABORT;
} }
*((void **)result) = write_box( dim, $2, $4 ); *((void **)result) = write_box( dim, $2, $4 );
} }
|
paren_list COMMA paren_list { | paren_list COMMA paren_list
int dim; {
int dim;
dim = delim_count($1, ',') + 1;
dim = delim_count($1, ',') + 1;
if ( (delim_count($3, ',') + 1) != dim ) {
ereport(ERROR, if ( (delim_count($3, ',') + 1) != dim ) {
(errcode(ERRCODE_SYNTAX_ERROR), ereport(ERROR,
errmsg("bad cube representation"), (errcode(ERRCODE_SYNTAX_ERROR),
errdetail("Different point dimensions in (%s) and (%s).", errmsg("bad cube representation"),
$1, $3))); errdetail("Different point dimensions in (%s) and (%s).",
YYABORT; $1, $3)));
} YYABORT;
if (dim > CUBE_MAX_DIM) { }
ereport(ERROR, if (dim > CUBE_MAX_DIM) {
(errcode(ERRCODE_SYNTAX_ERROR), ereport(ERROR,
errmsg("bad cube representation"), (errcode(ERRCODE_SYNTAX_ERROR),
errdetail("A cube cannot have more than %d dimensions.", errmsg("bad cube representation"),
CUBE_MAX_DIM))); errdetail("A cube cannot have more than %d dimensions.",
YYABORT; CUBE_MAX_DIM)));
} YYABORT;
}
*((void **)result) = write_box( dim, $1, $3 );
} *((void **)result) = write_box( dim, $1, $3 );
| }
paren_list { | paren_list
int dim; {
int dim;
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) { dim = delim_count($1, ',') + 1;
ereport(ERROR, if (dim > CUBE_MAX_DIM) {
(errcode(ERRCODE_SYNTAX_ERROR), ereport(ERROR,
errmsg("bad cube representation"), (errcode(ERRCODE_SYNTAX_ERROR),
errdetail("A cube cannot have more than %d dimensions.", errmsg("bad cube representation"),
CUBE_MAX_DIM))); errdetail("A cube cannot have more than %d dimensions.",
YYABORT; CUBE_MAX_DIM)));
} YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
} *((void **)result) = write_point_as_box($1, dim);
}
|
| list
list { {
int dim; int dim;
dim = delim_count($1, ',') + 1; dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) { if (dim > CUBE_MAX_DIM) {
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"), errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.", errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM))); CUBE_MAX_DIM)));
YYABORT; YYABORT;
} }
*((void **)result) = write_point_as_box($1, dim); *((void **)result) = write_point_as_box($1, dim);
} }
; ;
paren_list: paren_list: O_PAREN list C_PAREN
O_PAREN list C_PAREN { {
$$ = $2; $$ = $2;
} }
; ;
list: list: CUBEFLOAT
CUBEFLOAT { {
/* alloc enough space to be sure whole list will fit */ /* alloc enough space to be sure whole list will fit */
$$ = palloc(scanbuflen + 1); $$ = palloc(scanbuflen + 1);
strcpy($$, $1); strcpy($$, $1);
} }
| | list COMMA CUBEFLOAT
list COMMA CUBEFLOAT { {
$$ = $1; $$ = $1;
strcat($$, ","); strcat($$, ",");
strcat($$, $3); strcat($$, $3);
} }
; ;
%% %%
static int static int
delim_count(char *s, char delim) delim_count(char *s, char delim)
{ {
int ndelim = 0; int ndelim = 0;
while ((s = strchr(s, delim)) != NULL) while ((s = strchr(s, delim)) != NULL)
{ {
ndelim++; ndelim++;
s++; s++;
} }
return (ndelim); return (ndelim);
} }
static NDBOX * static NDBOX *
write_box(unsigned int dim, char *str1, char *str2) write_box(unsigned int dim, char *str1, char *str2)
{ {
NDBOX * bp; NDBOX *bp;
char * s; char *s;
int i; int i;
int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2; int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
bp = palloc0(size); bp = palloc0(size);
SET_VARSIZE(bp, size); SET_VARSIZE(bp, size);
bp->dim = dim; bp->dim = dim;
s = str1; s = str1;
bp->x[i=0] = strtod(s, NULL); bp->x[i=0] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL) { while ((s = strchr(s, ',')) != NULL)
s++; i++; {
bp->x[i] = strtod(s, NULL); s++; i++;
} bp->x[i] = strtod(s, NULL);
}
s = str2;
bp->x[i=dim] = strtod(s, NULL); s = str2;
while ((s = strchr(s, ',')) != NULL) { bp->x[i=dim] = strtod(s, NULL);
s++; i++; while ((s = strchr(s, ',')) != NULL)
bp->x[i] = strtod(s, NULL); {
} s++; i++;
bp->x[i] = strtod(s, NULL);
return(bp); }
return(bp);
} }
static NDBOX * static NDBOX *
write_point_as_box(char *str, int dim) write_point_as_box(char *str, int dim)
{ {
NDBOX * bp; NDBOX *bp;
int i, size; int i,
double x; size;
char * s = str; double x;
char *s = str;
size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2; size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
...@@ -217,11 +219,12 @@ write_point_as_box(char *str, int dim) ...@@ -217,11 +219,12 @@ write_point_as_box(char *str, int dim)
x = strtod(s, NULL); x = strtod(s, NULL);
bp->x[0] = x; bp->x[0] = x;
bp->x[dim] = x; bp->x[dim] = x;
while ((s = strchr(s, ',')) != NULL) { while ((s = strchr(s, ',')) != NULL)
s++; i++; {
x = strtod(s, NULL); s++; i++;
bp->x[i] = x; x = strtod(s, NULL);
bp->x[i+dim] = x; bp->x[i] = x;
bp->x[i+dim] = x;
} }
return(bp); return(bp);
......
...@@ -20,22 +20,22 @@ ...@@ -20,22 +20,22 @@
#define YYMALLOC palloc #define YYMALLOC palloc
#define YYFREE pfree #define YYFREE pfree
extern int seg_yylex(void); extern int seg_yylex(void);
extern int significant_digits(char *str); /* defined in seg.c */ extern int significant_digits(char *str); /* defined in seg.c */
void seg_yyerror(const char *message); void seg_yyerror(const char *message);
int seg_yyparse(void *result); int seg_yyparse(void *result);
static float seg_atof(char *value); static float seg_atof(char *value);
static char strbuf[25] = { static char strbuf[25] = {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '\0' '0', '0', '0', '0', '\0'
}; };
%} %}
...@@ -44,12 +44,12 @@ ...@@ -44,12 +44,12 @@
%name-prefix="seg_yy" %name-prefix="seg_yy"
%union { %union {
struct BND { struct BND {
float val; float val;
char ext; char ext;
char sigd; char sigd;
} bnd; } bnd;
char * text; char * text;
} }
%token <text> SEGFLOAT %token <text> SEGFLOAT
%token <text> RANGE %token <text> RANGE
...@@ -63,90 +63,94 @@ ...@@ -63,90 +63,94 @@
%% %%
range: range: boundary PLUMIN deviation
boundary PLUMIN deviation { {
((SEG *)result)->lower = $1.val - $3.val; ((SEG *)result)->lower = $1.val - $3.val;
((SEG *)result)->upper = $1.val + $3.val; ((SEG *)result)->upper = $1.val + $3.val;
sprintf(strbuf, "%g", ((SEG *)result)->lower); sprintf(strbuf, "%g", ((SEG *)result)->lower);
((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); ((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
sprintf(strbuf, "%g", ((SEG *)result)->upper); sprintf(strbuf, "%g", ((SEG *)result)->upper);
((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd)); ((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
((SEG *)result)->l_ext = '\0'; ((SEG *)result)->l_ext = '\0';
((SEG *)result)->u_ext = '\0'; ((SEG *)result)->u_ext = '\0';
} }
|
boundary RANGE boundary { | boundary RANGE boundary
((SEG *)result)->lower = $1.val; {
((SEG *)result)->upper = $3.val; ((SEG *)result)->lower = $1.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) { ((SEG *)result)->upper = $3.val;
ereport(ERROR, if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), ereport(ERROR,
errmsg("swapped boundaries: %g is greater than %g", (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
((SEG *)result)->lower, ((SEG *)result)->upper))); errmsg("swapped boundaries: %g is greater than %g",
((SEG *)result)->lower, ((SEG *)result)->upper)));
YYERROR;
} YYERROR;
((SEG *)result)->l_sigd = $1.sigd; }
((SEG *)result)->u_sigd = $3.sigd; ((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); ((SEG *)result)->u_sigd = $3.sigd;
((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' ); ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
} ((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' );
| }
boundary RANGE {
((SEG *)result)->lower = $1.val; | boundary RANGE
((SEG *)result)->upper = HUGE_VAL; {
((SEG *)result)->l_sigd = $1.sigd; ((SEG *)result)->lower = $1.val;
((SEG *)result)->u_sigd = 0; ((SEG *)result)->upper = HUGE_VAL;
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); ((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->u_ext = '-'; ((SEG *)result)->u_sigd = 0;
} ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
| ((SEG *)result)->u_ext = '-';
RANGE boundary { }
((SEG *)result)->lower = -HUGE_VAL;
((SEG *)result)->upper = $2.val; | RANGE boundary
((SEG *)result)->l_sigd = 0; {
((SEG *)result)->u_sigd = $2.sigd; ((SEG *)result)->lower = -HUGE_VAL;
((SEG *)result)->l_ext = '-'; ((SEG *)result)->upper = $2.val;
((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' ); ((SEG *)result)->l_sigd = 0;
} ((SEG *)result)->u_sigd = $2.sigd;
| ((SEG *)result)->l_ext = '-';
boundary { ((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
((SEG *)result)->lower = ((SEG *)result)->upper = $1.val; }
((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd;
((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' ); | boundary
} {
; ((SEG *)result)->lower = ((SEG *)result)->upper = $1.val;
((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd;
boundary: ((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' );
SEGFLOAT { }
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ ;
float val = seg_atof($1);
boundary: SEGFLOAT
$$.ext = '\0'; {
$$.sigd = significant_digits($1); /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
$$.val = val; float val = seg_atof($1);
}
| $$.ext = '\0';
EXTENSION SEGFLOAT { $$.sigd = significant_digits($1);
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ $$.val = val;
float val = seg_atof($2); }
| EXTENSION SEGFLOAT
$$.ext = $1[0]; {
$$.sigd = significant_digits($2); /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
$$.val = val; float val = seg_atof($2);
}
; $$.ext = $1[0];
$$.sigd = significant_digits($2);
deviation: $$.val = val;
SEGFLOAT { }
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ ;
float val = seg_atof($1);
deviation: SEGFLOAT
$$.ext = '\0'; {
$$.sigd = significant_digits($1); /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
$$.val = val; float val = seg_atof($1);
}
; $$.ext = '\0';
$$.sigd = significant_digits($1);
$$.val = val;
}
;
%% %%
......
...@@ -456,8 +456,8 @@ static void processCASbits(int cas_bits, int location, const char *constrType, ...@@ -456,8 +456,8 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
%type <ival> document_or_content %type <ival> document_or_content
%type <boolean> xml_whitespace_option %type <boolean> xml_whitespace_option
%type <node> common_table_expr %type <node> common_table_expr
%type <with> with_clause opt_with_clause %type <with> with_clause opt_with_clause
%type <list> cte_list %type <list> cte_list
%type <list> window_clause window_definition_list opt_partition_clause %type <list> window_clause window_definition_list opt_partition_clause
...@@ -1553,7 +1553,7 @@ ConstraintsSetStmt: ...@@ -1553,7 +1553,7 @@ ConstraintsSetStmt:
{ {
ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt); ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt);
n->constraints = $3; n->constraints = $3;
n->deferred = $4; n->deferred = $4;
$$ = (Node *) n; $$ = (Node *) n;
} }
; ;
...@@ -2048,7 +2048,7 @@ alter_using: ...@@ -2048,7 +2048,7 @@ alter_using:
; ;
reloptions: reloptions:
'(' reloption_list ')' { $$ = $2; } '(' reloption_list ')' { $$ = $2; }
; ;
opt_reloptions: WITH reloptions { $$ = $2; } opt_reloptions: WITH reloptions { $$ = $2; }
...@@ -3278,7 +3278,7 @@ opt_procedural: ...@@ -3278,7 +3278,7 @@ opt_procedural:
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/' * CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/'
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3299,7 +3299,7 @@ OptTableSpaceOwner: OWNER name { $$ = $2; } ...@@ -3299,7 +3299,7 @@ OptTableSpaceOwner: OWNER name { $$ = $2; }
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* DROP TABLESPACE <tablespace> * DROP TABLESPACE <tablespace>
* *
* No need for drop behaviour as we cannot implement dependencies for * No need for drop behaviour as we cannot implement dependencies for
...@@ -3315,7 +3315,7 @@ DropTableSpaceStmt: DROP TABLESPACE name ...@@ -3315,7 +3315,7 @@ DropTableSpaceStmt: DROP TABLESPACE name
$$ = (Node *) n; $$ = (Node *) n;
} }
| DROP TABLESPACE IF_P EXISTS name | DROP TABLESPACE IF_P EXISTS name
{ {
DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
n->tablespacename = $5; n->tablespacename = $5;
n->missing_ok = true; n->missing_ok = true;
...@@ -3325,7 +3325,7 @@ DropTableSpaceStmt: DROP TABLESPACE name ...@@ -3325,7 +3325,7 @@ DropTableSpaceStmt: DROP TABLESPACE name
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE EXTENSION extension * CREATE EXTENSION extension
* [ WITH ] [ SCHEMA schema ] [ VERSION version ] [ FROM oldversion ] * [ WITH ] [ SCHEMA schema ] [ VERSION version ] [ FROM oldversion ]
* *
...@@ -3615,7 +3615,7 @@ AlterExtensionContentsStmt: ...@@ -3615,7 +3615,7 @@ AlterExtensionContentsStmt:
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE FOREIGN DATA WRAPPER name options * CREATE FOREIGN DATA WRAPPER name options
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3649,7 +3649,7 @@ opt_fdw_options: ...@@ -3649,7 +3649,7 @@ opt_fdw_options:
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* DROP FOREIGN DATA WRAPPER name * DROP FOREIGN DATA WRAPPER name
* *
****************************************************************************/ ****************************************************************************/
...@@ -3663,7 +3663,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior ...@@ -3663,7 +3663,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
$$ = (Node *) n; $$ = (Node *) n;
} }
| DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior | DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
{ {
DropFdwStmt *n = makeNode(DropFdwStmt); DropFdwStmt *n = makeNode(DropFdwStmt);
n->fdwname = $7; n->fdwname = $7;
n->missing_ok = true; n->missing_ok = true;
...@@ -3674,7 +3674,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior ...@@ -3674,7 +3674,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* ALTER FOREIGN DATA WRAPPER name options * ALTER FOREIGN DATA WRAPPER name options
* *
****************************************************************************/ ****************************************************************************/
...@@ -3769,7 +3769,7 @@ generic_option_arg: ...@@ -3769,7 +3769,7 @@ generic_option_arg:
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE SERVER name [TYPE] [VERSION] [OPTIONS] * CREATE SERVER name [TYPE] [VERSION] [OPTIONS]
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3799,13 +3799,13 @@ foreign_server_version: ...@@ -3799,13 +3799,13 @@ foreign_server_version:
; ;
opt_foreign_server_version: opt_foreign_server_version:
foreign_server_version { $$ = $1; } foreign_server_version { $$ = $1; }
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* DROP SERVER name * DROP SERVER name
* *
****************************************************************************/ ****************************************************************************/
...@@ -3819,7 +3819,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior ...@@ -3819,7 +3819,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
$$ = (Node *) n; $$ = (Node *) n;
} }
| DROP SERVER IF_P EXISTS name opt_drop_behavior | DROP SERVER IF_P EXISTS name opt_drop_behavior
{ {
DropForeignServerStmt *n = makeNode(DropForeignServerStmt); DropForeignServerStmt *n = makeNode(DropForeignServerStmt);
n->servername = $5; n->servername = $5;
n->missing_ok = true; n->missing_ok = true;
...@@ -3830,7 +3830,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior ...@@ -3830,7 +3830,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* ALTER SERVER name [VERSION] [OPTIONS] * ALTER SERVER name [VERSION] [OPTIONS]
* *
****************************************************************************/ ****************************************************************************/
...@@ -3863,7 +3863,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o ...@@ -3863,7 +3863,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE FOREIGN TABLE relname (...) SERVER name (...) * CREATE FOREIGN TABLE relname (...) SERVER name (...)
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3923,7 +3923,7 @@ ForeignTableElement: ...@@ -3923,7 +3923,7 @@ ForeignTableElement:
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* ALTER FOREIGN TABLE relname [...] * ALTER FOREIGN TABLE relname [...]
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3941,7 +3941,7 @@ AlterForeignTableStmt: ...@@ -3941,7 +3941,7 @@ AlterForeignTableStmt:
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
* CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS] * CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS]
* *
*****************************************************************************/ *****************************************************************************/
...@@ -3958,14 +3958,14 @@ CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_gen ...@@ -3958,14 +3958,14 @@ CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_gen
/* User mapping authorization identifier */ /* User mapping authorization identifier */
auth_ident: auth_ident:
CURRENT_USER { $$ = "current_user"; } CURRENT_USER { $$ = "current_user"; }
| USER { $$ = "current_user"; } | USER { $$ = "current_user"; }
| RoleId { $$ = (strcmp($1, "public") == 0) ? NULL : $1; } | RoleId { $$ = (strcmp($1, "public") == 0) ? NULL : $1; }
; ;
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* DROP USER MAPPING FOR auth_ident SERVER name * DROP USER MAPPING FOR auth_ident SERVER name
* *
****************************************************************************/ ****************************************************************************/
...@@ -3979,7 +3979,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name ...@@ -3979,7 +3979,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
$$ = (Node *) n; $$ = (Node *) n;
} }
| DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
{ {
DropUserMappingStmt *n = makeNode(DropUserMappingStmt); DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
n->username = $7; n->username = $7;
n->servername = $9; n->servername = $9;
...@@ -3990,7 +3990,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name ...@@ -3990,7 +3990,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS * ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS
* *
****************************************************************************/ ****************************************************************************/
...@@ -4395,7 +4395,7 @@ DefineStmt: ...@@ -4395,7 +4395,7 @@ DefineStmt:
definition: '(' def_list ')' { $$ = $2; } definition: '(' def_list ')' { $$ = $2; }
; ;
def_list: def_elem { $$ = list_make1($1); } def_list: def_elem { $$ = list_make1($1); }
| def_list ',' def_elem { $$ = lappend($1, $3); } | def_list ',' def_elem { $$ = lappend($1, $3); }
; ;
...@@ -4457,33 +4457,33 @@ enum_val_list: Sconst ...@@ -4457,33 +4457,33 @@ enum_val_list: Sconst
*****************************************************************************/ *****************************************************************************/
AlterEnumStmt: AlterEnumStmt:
ALTER TYPE_P any_name ADD_P VALUE_P Sconst ALTER TYPE_P any_name ADD_P VALUE_P Sconst
{ {
AlterEnumStmt *n = makeNode(AlterEnumStmt); AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3; n->typeName = $3;
n->newVal = $6; n->newVal = $6;
n->newValNeighbor = NULL; n->newValNeighbor = NULL;
n->newValIsAfter = true; n->newValIsAfter = true;
$$ = (Node *) n; $$ = (Node *) n;
} }
| ALTER TYPE_P any_name ADD_P VALUE_P Sconst BEFORE Sconst | ALTER TYPE_P any_name ADD_P VALUE_P Sconst BEFORE Sconst
{ {
AlterEnumStmt *n = makeNode(AlterEnumStmt); AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3; n->typeName = $3;
n->newVal = $6; n->newVal = $6;
n->newValNeighbor = $8; n->newValNeighbor = $8;
n->newValIsAfter = false; n->newValIsAfter = false;
$$ = (Node *) n; $$ = (Node *) n;
} }
| ALTER TYPE_P any_name ADD_P VALUE_P Sconst AFTER Sconst | ALTER TYPE_P any_name ADD_P VALUE_P Sconst AFTER Sconst
{ {
AlterEnumStmt *n = makeNode(AlterEnumStmt); AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3; n->typeName = $3;
n->newVal = $6; n->newVal = $6;
n->newValNeighbor = $8; n->newValNeighbor = $8;
n->newValIsAfter = true; n->newValIsAfter = true;
$$ = (Node *) n; $$ = (Node *) n;
} }
; ;
...@@ -4708,7 +4708,7 @@ DropOpFamilyStmt: ...@@ -4708,7 +4708,7 @@ DropOpFamilyStmt:
*****************************************************************************/ *****************************************************************************/
DropOwnedStmt: DropOwnedStmt:
DROP OWNED BY name_list opt_drop_behavior DROP OWNED BY name_list opt_drop_behavior
{ {
DropOwnedStmt *n = makeNode(DropOwnedStmt); DropOwnedStmt *n = makeNode(DropOwnedStmt);
n->roles = $4; n->roles = $4;
n->behavior = $5; n->behavior = $5;
...@@ -5001,7 +5001,7 @@ comment_type: ...@@ -5001,7 +5001,7 @@ comment_type:
| COLLATION { $$ = OBJECT_COLLATION; } | COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; } | CONVERSION_P { $$ = OBJECT_CONVERSION; }
| TABLESPACE { $$ = OBJECT_TABLESPACE; } | TABLESPACE { $$ = OBJECT_TABLESPACE; }
| EXTENSION { $$ = OBJECT_EXTENSION; } | EXTENSION { $$ = OBJECT_EXTENSION; }
| ROLE { $$ = OBJECT_ROLE; } | ROLE { $$ = OBJECT_ROLE; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; } | FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
| SERVER { $$ = OBJECT_FOREIGN_SERVER; } | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
...@@ -5988,25 +5988,25 @@ func_type: Typename { $$ = $1; } ...@@ -5988,25 +5988,25 @@ func_type: Typename { $$ = $1; }
func_arg_with_default: func_arg_with_default:
func_arg func_arg
{ {
$$ = $1; $$ = $1;
} }
| func_arg DEFAULT a_expr | func_arg DEFAULT a_expr
{ {
$$ = $1; $$ = $1;
$$->defexpr = $3; $$->defexpr = $3;
} }
| func_arg '=' a_expr | func_arg '=' a_expr
{ {
$$ = $1; $$ = $1;
$$->defexpr = $3; $$->defexpr = $3;
} }
; ;
createfunc_opt_list: createfunc_opt_list:
/* Must be at least one to prevent conflict */ /* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = list_make1($1); } createfunc_opt_item { $$ = list_make1($1); }
| createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); } | createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); }
; ;
...@@ -7687,13 +7687,13 @@ CreateConversionStmt: ...@@ -7687,13 +7687,13 @@ CreateConversionStmt:
CREATE opt_default CONVERSION_P any_name FOR Sconst CREATE opt_default CONVERSION_P any_name FOR Sconst
TO Sconst FROM any_name TO Sconst FROM any_name
{ {
CreateConversionStmt *n = makeNode(CreateConversionStmt); CreateConversionStmt *n = makeNode(CreateConversionStmt);
n->conversion_name = $4; n->conversion_name = $4;
n->for_encoding_name = $6; n->for_encoding_name = $6;
n->to_encoding_name = $8; n->to_encoding_name = $8;
n->func_name = $10; n->func_name = $10;
n->def = $2; n->def = $2;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -7709,28 +7709,28 @@ CreateConversionStmt: ...@@ -7709,28 +7709,28 @@ CreateConversionStmt:
ClusterStmt: ClusterStmt:
CLUSTER opt_verbose qualified_name cluster_index_specification CLUSTER opt_verbose qualified_name cluster_index_specification
{ {
ClusterStmt *n = makeNode(ClusterStmt); ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $3; n->relation = $3;
n->indexname = $4; n->indexname = $4;
n->verbose = $2; n->verbose = $2;
$$ = (Node*)n; $$ = (Node*)n;
} }
| CLUSTER opt_verbose | CLUSTER opt_verbose
{ {
ClusterStmt *n = makeNode(ClusterStmt); ClusterStmt *n = makeNode(ClusterStmt);
n->relation = NULL; n->relation = NULL;
n->indexname = NULL; n->indexname = NULL;
n->verbose = $2; n->verbose = $2;
$$ = (Node*)n; $$ = (Node*)n;
} }
/* kept for pre-8.3 compatibility */ /* kept for pre-8.3 compatibility */
| CLUSTER opt_verbose index_name ON qualified_name | CLUSTER opt_verbose index_name ON qualified_name
{ {
ClusterStmt *n = makeNode(ClusterStmt); ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $5; n->relation = $5;
n->indexname = $3; n->indexname = $3;
n->verbose = $2; n->verbose = $2;
$$ = (Node*)n; $$ = (Node*)n;
} }
; ;
...@@ -8141,7 +8141,7 @@ DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias ...@@ -8141,7 +8141,7 @@ DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias
; ;
using_clause: using_clause:
USING from_list { $$ = $2; } USING from_list { $$ = $2; }
| /*EMPTY*/ { $$ = NIL; } | /*EMPTY*/ { $$ = NIL; }
; ;
...@@ -8164,7 +8164,7 @@ LockStmt: LOCK_P opt_table relation_expr_list opt_lock opt_nowait ...@@ -8164,7 +8164,7 @@ LockStmt: LOCK_P opt_table relation_expr_list opt_lock opt_nowait
} }
; ;
opt_lock: IN_P lock_type MODE { $$ = $2; } opt_lock: IN_P lock_type MODE { $$ = $2; }
| /*EMPTY*/ { $$ = AccessExclusiveLock; } | /*EMPTY*/ { $$ = AccessExclusiveLock; }
; ;
...@@ -10032,12 +10032,12 @@ a_expr: c_expr { $$ = $1; } ...@@ -10032,12 +10032,12 @@ a_expr: c_expr { $$ = $1; }
{ {
$$ = (Node *) makeA_Expr(AEXPR_OR, NIL, $$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeA_Expr(AEXPR_AND, NIL, (Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2),
@2), @2),
(Node *) makeA_Expr(AEXPR_AND, NIL, (Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4, @2),
@2), @2),
@2); @2);
} }
...@@ -10045,12 +10045,12 @@ a_expr: c_expr { $$ = $1; } ...@@ -10045,12 +10045,12 @@ a_expr: c_expr { $$ = $1; }
{ {
$$ = (Node *) makeA_Expr(AEXPR_AND, NIL, $$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeA_Expr(AEXPR_OR, NIL, (Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2),
@2), @2),
(Node *) makeA_Expr(AEXPR_OR, NIL, (Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $7, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $7, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $5, @2), (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $5, @2),
@2), @2),
@2); @2);
} }
...@@ -11739,9 +11739,9 @@ AexprConst: Iconst ...@@ -11739,9 +11739,9 @@ AexprConst: Iconst
if (IsA(arg, NamedArgExpr)) if (IsA(arg, NamedArgExpr))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot have parameter name"), errmsg("type modifier cannot have parameter name"),
parser_errposition(arg->location))); parser_errposition(arg->location)));
} }
t->typmods = $3; t->typmods = $3;
t->location = @1; t->location = @1;
...@@ -12747,7 +12747,7 @@ static Node * ...@@ -12747,7 +12747,7 @@ static Node *
makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args, makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
int location) int location)
{ {
XmlExpr *x = makeNode(XmlExpr); XmlExpr *x = makeNode(XmlExpr);
x->op = op; x->op = op;
x->name = name; x->name = name;
......
...@@ -122,7 +122,7 @@ base_backup: ...@@ -122,7 +122,7 @@ base_backup:
; ;
base_backup_opt_list: base_backup_opt_list base_backup_opt { $$ = lappend($1, $2); } base_backup_opt_list: base_backup_opt_list base_backup_opt { $$ = lappend($1, $2); }
| /* EMPTY */ { $$ = NIL; } | /* EMPTY */ { $$ = NIL; }
base_backup_opt: base_backup_opt:
K_LABEL SCONST K_LABEL SCONST
......
...@@ -112,13 +112,13 @@ START_REPLICATION { return K_START_REPLICATION; } ...@@ -112,13 +112,13 @@ START_REPLICATION { return K_START_REPLICATION; }
static void static void
startlit(void) startlit(void)
{ {
initStringInfo(&litbuf); initStringInfo(&litbuf);
} }
static char * static char *
litbufdup(void) litbufdup(void)
{ {
return litbuf.data; return litbuf.data;
} }
static void static void
...@@ -130,13 +130,13 @@ addlit(char *ytext, int yleng) ...@@ -130,13 +130,13 @@ addlit(char *ytext, int yleng)
static void static void
addlitchar(unsigned char ychar) addlitchar(unsigned char ychar)
{ {
appendStringInfoChar(&litbuf, ychar); appendStringInfoChar(&litbuf, ychar);
} }
void void
yyerror(const char *message) yyerror(const char *message)
{ {
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg_internal("%s", message))); errmsg_internal("%s", message)));
} }
......
...@@ -55,41 +55,41 @@ static char *GUC_scanstr(const char *s); ...@@ -55,41 +55,41 @@ static char *GUC_scanstr(const char *s);
%option prefix="GUC_yy" %option prefix="GUC_yy"
SIGN ("-"|"+") SIGN ("-"|"+")
DIGIT [0-9] DIGIT [0-9]
HEXDIGIT [0-9a-fA-F] HEXDIGIT [0-9a-fA-F]
UNIT_LETTER [a-zA-Z] UNIT_LETTER [a-zA-Z]
INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+){UNIT_LETTER}* INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+){UNIT_LETTER}*
EXPONENT [Ee]{SIGN}?{DIGIT}+ EXPONENT [Ee]{SIGN}?{DIGIT}+
REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}? REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}?
LETTER [A-Za-z_\200-\377] LETTER [A-Za-z_\200-\377]
LETTER_OR_DIGIT [A-Za-z_0-9\200-\377] LETTER_OR_DIGIT [A-Za-z_0-9\200-\377]
ID {LETTER}{LETTER_OR_DIGIT}* ID {LETTER}{LETTER_OR_DIGIT}*
QUALIFIED_ID {ID}"."{ID} QUALIFIED_ID {ID}"."{ID}
UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])* UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])*
STRING \'([^'\\\n]|\\.|\'\')*\' STRING \'([^'\\\n]|\\.|\'\')*\'
%% %%
\n ConfigFileLineno++; return GUC_EOL; \n ConfigFileLineno++; return GUC_EOL;
[ \t\r]+ /* eat whitespace */ [ \t\r]+ /* eat whitespace */
#.* /* eat comment (.* matches anything until newline) */ #.* /* eat comment (.* matches anything until newline) */
{ID} return GUC_ID; {ID} return GUC_ID;
{QUALIFIED_ID} return GUC_QUALIFIED_ID; {QUALIFIED_ID} return GUC_QUALIFIED_ID;
{STRING} return GUC_STRING; {STRING} return GUC_STRING;
{UNQUOTED_STRING} return GUC_UNQUOTED_STRING; {UNQUOTED_STRING} return GUC_UNQUOTED_STRING;
{INTEGER} return GUC_INTEGER; {INTEGER} return GUC_INTEGER;
{REAL} return GUC_REAL; {REAL} return GUC_REAL;
= return GUC_EQUALS; = return GUC_EQUALS;
. return GUC_ERROR; . return GUC_ERROR;
%% %%
......
...@@ -308,8 +308,8 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt ...@@ -308,8 +308,8 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
if (strcmp_fn($2, ptr->name) == 0) if (strcmp_fn($2, ptr->name) == 0)
{ {
if ($2[0] == ':') if ($2[0] == ':')
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1); mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else else
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2); mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
} }
} }
...@@ -362,7 +362,7 @@ ECPG: into_clauseINTOOptTempTableName block ...@@ -362,7 +362,7 @@ ECPG: into_clauseINTOOptTempTableName block
FoundInto = 1; FoundInto = 1;
$$= cat2_str(mm_strdup("into"), $2); $$= cat2_str(mm_strdup("into"), $2);
} }
| ecpg_into { $$ = EMPTY; } | ecpg_into { $$ = EMPTY; }
ECPG: table_refselect_with_parens addon ECPG: table_refselect_with_parens addon
mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias"); mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
ECPG: TypenameSimpleTypenameopt_array_bounds block ECPG: TypenameSimpleTypenameopt_array_bounds block
...@@ -468,9 +468,9 @@ ECPG: FetchStmtMOVEfetch_args rule ...@@ -468,9 +468,9 @@ ECPG: FetchStmtMOVEfetch_args rule
$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker); $$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
} }
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
{ {
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server"); mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4); $$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
} }
ECPG: SignedIconstIconst rule ECPG: SignedIconstIconst rule
| civar { $$ = $1; } | civar { $$ = $1; }
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
/* Location tracking support --- simpler than bison's default */ /* Location tracking support --- simpler than bison's default */
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \ do { \
if (N) \ if (N) \
(Current) = (Rhs)[1]; \ (Current) = (Rhs)[1]; \
else \ else \
(Current) = (Rhs)[0]; \ (Current) = (Rhs)[0]; \
} while (0) } while (0)
/* /*
...@@ -42,10 +42,10 @@ char *input_filename = NULL; ...@@ -42,10 +42,10 @@ char *input_filename = NULL;
static int FoundInto = 0; static int FoundInto = 0;
static int initializer = 0; static int initializer = 0;
static int pacounter = 1; static int pacounter = 1;
static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */ static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */
static struct this_type actual_type[STRUCT_DEPTH]; static struct this_type actual_type[STRUCT_DEPTH];
static char *actual_startline[STRUCT_DEPTH]; static char *actual_startline[STRUCT_DEPTH];
static int varchar_counter = 1; static int varchar_counter = 1;
/* temporarily store struct members while creating the data structure */ /* temporarily store struct members while creating the data structure */
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL }; struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
...@@ -105,7 +105,7 @@ mmerror(int error_code, enum errortype type, const char *error, ...) ...@@ -105,7 +105,7 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
fclose(yyout); fclose(yyout);
if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0) if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename); fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
exit(error_code); exit(error_code);
} }
} }
...@@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur) ...@@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
newvar = ptr->variable; newvar = ptr->variable;
skip_set_var = true; skip_set_var = true;
} }
else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement")))) else if ((ptr->variable->type->type == ECPGt_char_variable)
&& (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
{ {
newvar = ptr->variable; newvar = ptr->variable;
skip_set_var = true; skip_set_var = true;
} }
else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1) else if ((ptr->variable->type->type != ECPGt_varchar
&& ptr->variable->type->type != ECPGt_char
&& ptr->variable->type->type != ECPGt_unsigned_char
&& ptr->variable->type->type != ECPGt_string)
&& atoi(ptr->variable->type->size) > 1)
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, mm_strdup("1"), ptr->variable->type->u.element->counter), ptr->variable->type->size), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
mm_strdup("1"),
ptr->variable->type->u.element->counter),
ptr->variable->type->size),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1) else if ((ptr->variable->type->type == ECPGt_varchar
|| ptr->variable->type->type == ECPGt_char
|| ptr->variable->type->type == ECPGt_unsigned_char
|| ptr->variable->type->type == ECPGt_string)
&& atoi(ptr->variable->type->size) > 1)
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,
ptr->variable->type->counter),
0);
if (ptr->variable->type->type == ECPGt_varchar) if (ptr->variable->type->type == ECPGt_varchar)
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
else else
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union) else if (ptr->variable->type->type == ECPGt_struct
|| ptr->variable->type->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0); newvar = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->variable->type->type_name),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.members,
ptr->variable->type->type,
ptr->variable->type->type_name,
ptr->variable->type->struct_sizeof),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
else if (ptr->variable->type->type == ECPGt_array) else if (ptr->variable->type->type == ECPGt_array)
{ {
if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union) if (ptr->variable->type->u.element->type == ECPGt_struct
|| ptr->variable->type->u.element->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0); newvar = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->variable->type->u.element->type_name),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.element->u.members,
ptr->variable->type->u.element->type,
ptr->variable->type->u.element->type_name,
ptr->variable->type->u.element->struct_sizeof),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->counter), ptr->variable->type->size), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
ptr->variable->type->u.element->size,
ptr->variable->type->u.element->counter),
ptr->variable->type->size),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
} }
else else
{ {
newvar = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0); newvar = new_variable(cat_str(4, mm_strdup("*("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */ /* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
if (!skip_set_var) if (!skip_set_var)
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n")); result = cat_str(5, result, mm_strdup("ECPGset_var("),
mm_strdup(temp), mm_strdup(original_var),
mm_strdup("), __LINE__);\n"));
/* now the indicator if there is one and it's not a global variable */ /* now the indicator if there is one and it's not a global variable */
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0)) if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
...@@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur) ...@@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
original_var = ptr->indicator->name; original_var = ptr->indicator->name;
sprintf(temp, "%d))", ecpg_internal_var); sprintf(temp, "%d))", ecpg_internal_var);
if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union) if (ptr->indicator->type->type == ECPGt_struct
|| ptr->indicator->type->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0); newind = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->indicator->type->type_name),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.members,
ptr->indicator->type->type,
ptr->indicator->type->type_name,
ptr->indicator->type->struct_sizeof),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
else if (ptr->indicator->type->type == ECPGt_array) else if (ptr->indicator->type->type == ECPGt_array)
{ {
if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union) if (ptr->indicator->type->u.element->type == ECPGt_struct
|| ptr->indicator->type->u.element->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0); newind = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->indicator->type->u.element->type_name),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,
ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->type_name,
ptr->indicator->type->u.element->struct_sizeof),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->counter), ptr->indicator->type->size), 0); newind = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->size,
ptr->indicator->type->u.element->counter),
ptr->indicator->type->size),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
} }
else if (atoi(ptr->indicator->type->size) > 1) else if (atoi(ptr->indicator->type->size) > 1)
{ {
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0); newind = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,
ptr->indicator->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newind = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0); newind = new_variable(cat_str(4, mm_strdup("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,
ptr->indicator->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */ /* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n")); result = cat_str(5, result, mm_strdup("ECPGset_var("),
mm_strdup(temp), mm_strdup(original_var),
mm_strdup("), __LINE__);\n"));
} }
add_variable_to_tail(&newlist, newvar, newind); add_variable_to_tail(&newlist, newvar, newind);
...@@ -407,14 +505,15 @@ add_additional_variables(char *name, bool insert) ...@@ -407,14 +505,15 @@ add_additional_variables(char *name, bool insert)
} }
static void static void
add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enum, char *type_dimension, char *type_index, int initializer, int array) add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
char *type_dimension, char *type_index, int initializer, int array)
{ {
/* add entry to list */ /* add entry to list */
struct typedefs *ptr, *this; struct typedefs *ptr, *this;
if ((type_enum == ECPGt_struct || if ((type_enum == ECPGt_struct ||
type_enum == ECPGt_union) && type_enum == ECPGt_union) &&
initializer == 1) initializer == 1)
mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition"); mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
else if (INFORMIX_MODE && strcmp(name, "string") == 0) else if (INFORMIX_MODE && strcmp(name, "string") == 0)
mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode"); mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode");
...@@ -462,7 +561,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu ...@@ -462,7 +561,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
%union { %union {
double dval; double dval;
char *str; char *str;
int ival; int ival;
struct when action; struct when action;
struct index index; struct index index;
int tagname; int tagname;
......
/* src/interfaces/ecpg/preproc/ecpg.trailer */ /* src/interfaces/ecpg/preproc/ecpg.trailer */
statements: /*EMPTY*/ statements: /*EMPTY*/
| statements statement | statements statement
; ;
statement: ecpgstart at stmt ';' { connection = NULL; } statement: ecpgstart at stmt ';' { connection = NULL; }
| ecpgstart stmt ';' | ecpgstart stmt ';'
| ecpgstart ECPGVarDeclaration | ecpgstart ECPGVarDeclaration
{ {
fprintf(yyout, "%s", $2); fprintf(yyout, "%s", $2);
free($2); free($2);
output_line_number(); 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); }
| '{' { braces_open++; fputs("{", yyout); } | '{' { braces_open++; fputs("{", yyout); }
| '}' | '}'
{ {
remove_typedefs(braces_open); remove_typedefs(braces_open);
remove_variables(braces_open--); remove_variables(braces_open--);
...@@ -27,7 +27,7 @@ statement: ecpgstart at stmt ';' { connection = NULL; } ...@@ -27,7 +27,7 @@ statement: ecpgstart at stmt ';' { connection = NULL; }
} }
fputs("}", yyout); fputs("}", yyout);
} }
; ;
CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
{ {
...@@ -36,20 +36,19 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectSt ...@@ -36,20 +36,19 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectSt
$$ = cat_str(6, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7); $$ = cat_str(6, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7);
} }
; ;
at: AT connection_object at: AT connection_object
{ {
connection = $2; connection = $2;
/* /*
* Do we have a variable as connection target? * Do we have a variable as connection target? Remove the variable
* Remove the variable from the variable * from the variable list or else it will be used twice.
* list or else it will be used twice */
*/ if (argsinsert != NULL)
if (argsinsert != NULL) argsinsert = NULL;
argsinsert = NULL; }
} ;
;
/* /*
* the exec sql connect statement: connect to the given database * the exec sql connect statement: connect to the given database
...@@ -238,12 +237,14 @@ opt_options: Op connect_options ...@@ -238,12 +237,14 @@ opt_options: Op connect_options
$$ = make2_str(mm_strdup("?"), $2); $$ = make2_str(mm_strdup("?"), $2);
} }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
connect_options: ColId opt_opt_value connect_options: ColId opt_opt_value
{ $$ = make2_str($1, $2); } {
| ColId opt_opt_value Op connect_options $$ = make2_str($1, $2);
}
| ColId opt_opt_value Op connect_options
{ {
if (strlen($3) == 0) if (strlen($3) == 0)
mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement"); mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
...@@ -253,7 +254,7 @@ connect_options: ColId opt_opt_value ...@@ -253,7 +254,7 @@ connect_options: ColId opt_opt_value
$$ = cat_str(3, make2_str($1, $2), $3, $4); $$ = cat_str(3, make2_str($1, $2), $3, $4);
} }
; ;
opt_opt_value: /*EMPTY*/ opt_opt_value: /*EMPTY*/
{ $$ = EMPTY; } { $$ = EMPTY; }
...@@ -265,21 +266,22 @@ opt_opt_value: /*EMPTY*/ ...@@ -265,21 +266,22 @@ opt_opt_value: /*EMPTY*/
{ $$ = make2_str(mm_strdup("="), $2); } { $$ = make2_str(mm_strdup("="), $2); }
; ;
prepared_name: name { prepared_name: name
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */ {
$$ = $1; if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
else /* not quoted => convert to lowercase */ $$ = $1;
{ else /* not quoted => convert to lowercase */
size_t i; {
size_t i;
for (i = 0; i< strlen($1); i++) for (i = 0; i< strlen($1); i++)
$1[i] = tolower((unsigned char) $1[i]); $1[i] = tolower((unsigned char) $1[i]);
$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
} }
} }
| char_variable { $$ = $1; } | char_variable { $$ = $1; }
; ;
/* /*
* Declare a prepared cursor. The syntax is different from the standard * Declare a prepared cursor. The syntax is different from the standard
...@@ -300,8 +302,8 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared ...@@ -300,8 +302,8 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
{ {
/* re-definition is a bug */ /* re-definition is a bug */
if ($2[0] == ':') if ($2[0] == ':')
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1); mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else else
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2); mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
} }
} }
...@@ -401,8 +403,8 @@ vt_declarations: single_vt_declaration { $$ = $1; } ...@@ -401,8 +403,8 @@ vt_declarations: single_vt_declaration { $$ = $1; }
| vt_declarations CPP_LINE { $$ = cat2_str($1, $2); } | vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
; ;
variable_declarations: var_declaration { $$ = $1; } variable_declarations: var_declaration { $$ = $1; }
| variable_declarations var_declaration { $$ = cat2_str($1, $2); } | variable_declarations var_declaration { $$ = cat2_str($1, $2); }
; ;
type_declaration: S_TYPEDEF type_declaration: S_TYPEDEF
...@@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT ...@@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT
ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */ ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
$$ = mm_strdup("struct"); $$ = mm_strdup("struct");
} }
| UNION { $$ = mm_strdup("union"); } | UNION
{
$$ = mm_strdup("union");
}
; ;
simple_type: unsigned_type { $$=$1; } simple_type: unsigned_type { $$=$1; }
...@@ -838,8 +843,8 @@ variable_list: variable ...@@ -838,8 +843,8 @@ variable_list: variable
variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
{ {
struct ECPGtype * type; struct ECPGtype * type;
char *dimension = $3.index1; /* dimension of array */ char *dimension = $3.index1; /* dimension of array */
char *length = $3.index2; /* length of string */ char *length = $3.index2; /* length of string */
char *dim_str; char *dim_str;
char *vcn; char *vcn;
...@@ -991,8 +996,8 @@ opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; } ...@@ -991,8 +996,8 @@ opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
| ecpg_using { $$ = $1; } | ecpg_using { $$ = $1; }
; ;
ecpg_using: USING using_list { $$ = EMPTY; } ecpg_using: USING using_list { $$ = EMPTY; }
| using_descriptor { $$ = $1; } | using_descriptor { $$ = $1; }
; ;
using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
...@@ -1041,10 +1046,10 @@ UsingValue: UsingConst ...@@ -1041,10 +1046,10 @@ UsingValue: UsingConst
UsingConst: Iconst { $$ = $1; } UsingConst: Iconst { $$ = $1; }
| '+' Iconst { $$ = cat_str(2, mm_strdup("+"), $2); } | '+' Iconst { $$ = cat_str(2, mm_strdup("+"), $2); }
| '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); } | '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); }
| ecpg_fconst { $$ = $1; } | ecpg_fconst { $$ = $1; }
| '+' ecpg_fconst { $$ = cat_str(2, mm_strdup("+"), $2); } | '+' ecpg_fconst { $$ = cat_str(2, mm_strdup("+"), $2); }
| '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); } | '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); }
| ecpg_sconst { $$ = $1; } | ecpg_sconst { $$ = $1; }
| ecpg_bconst { $$ = $1; } | ecpg_bconst { $$ = $1; }
| ecpg_xconst { $$ = $1; } | ecpg_xconst { $$ = $1; }
...@@ -1094,7 +1099,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor ...@@ -1094,7 +1099,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
; ;
opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); } opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
| /* EMPTY */ { $$ = EMPTY; } | /* EMPTY */ { $$ = EMPTY; }
; ;
/* /*
...@@ -1106,7 +1111,7 @@ opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); } ...@@ -1106,7 +1111,7 @@ opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
/* /*
* allocate a descriptor * allocate a descriptor
*/ */
ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
{ {
add_descriptor($3,connection); add_descriptor($3,connection);
$$ = $3; $$ = $3;
...@@ -1155,16 +1160,19 @@ ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar ...@@ -1155,16 +1160,19 @@ ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
} }
; ;
IntConstVar: Iconst IntConstVar: Iconst
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
sprintf(length, "%d", (int) strlen($1)); sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1; $$ = $1;
} }
| cvariable { $$ = $1; } | cvariable
; {
$$ = $1;
}
;
desc_header_item: SQL_COUNT { $$ = ECPGd_count; } desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
; ;
...@@ -1198,49 +1206,56 @@ ECPGSetDescItem: descriptor_item '=' AllConstVar ...@@ -1198,49 +1206,56 @@ ECPGSetDescItem: descriptor_item '=' AllConstVar
} }
; ;
AllConstVar: ecpg_fconst AllConstVar: ecpg_fconst
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
sprintf(length, "%d", (int) strlen($1)); sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1; $$ = $1;
} }
| IntConstVar { $$ = $1; }
| '-' ecpg_fconst | IntConstVar
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); $$ = $1;
char *var = cat2_str(mm_strdup("-"), $2); }
sprintf(length, "%d", (int) strlen(var)); | '-' ecpg_fconst
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); {
$$ = var; char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
} char *var = cat2_str(mm_strdup("-"), $2);
| '-' Iconst
{ sprintf(length, "%d", (int) strlen(var));
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
char *var = cat2_str(mm_strdup("-"), $2); $$ = var;
}
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); | '-' Iconst
$$ = var; {
} char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
| ecpg_sconst char *var = cat2_str(mm_strdup("-"), $2);
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); sprintf(length, "%d", (int) strlen(var));
char *var = $1 + 1; new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
var[strlen(var) - 1] = '\0'; }
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); | ecpg_sconst
$$ = var; {
} char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = $1 + 1;
var[strlen(var) - 1] = '\0';
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
; ;
descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; } descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
| DATA_P { $$ = ECPGd_data; } | DATA_P { $$ = ECPGd_data; }
| SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; } | SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; }
| SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; } | SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
| SQL_INDICATOR { $$ = ECPGd_indicator; } | SQL_INDICATOR { $$ = ECPGd_indicator; }
| SQL_KEY_MEMBER { $$ = ECPGd_key_member; } | SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
| SQL_LENGTH { $$ = ECPGd_length; } | SQL_LENGTH { $$ = ECPGd_length; }
...@@ -1295,8 +1310,8 @@ ECPGTypedef: TYPE_P ...@@ -1295,8 +1310,8 @@ ECPGTypedef: TYPE_P
} }
; ;
opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); } opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
/* /*
...@@ -1452,7 +1467,7 @@ action : CONTINUE_P ...@@ -1452,7 +1467,7 @@ action : CONTINUE_P
/* additional unreserved keywords */ /* additional unreserved keywords */
ECPGKeywords: ECPGKeywords_vanames { $$ = $1; } ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; } | ECPGKeywords_rest { $$ = $1; }
; ;
ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); } ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); }
...@@ -1730,8 +1745,8 @@ ecpg_sconst: ...@@ -1730,8 +1745,8 @@ ecpg_sconst:
$$[strlen($1)+3]='\0'; $$[strlen($1)+3]='\0';
free($1); free($1);
} }
| UCONST { $$ = $1; } | UCONST { $$ = $1; }
| DOLCONST { $$ = $1; } | DOLCONST { $$ = $1; }
; ;
ecpg_xconst: XCONST { $$ = make_name(); } ; ecpg_xconst: XCONST { $$ = make_name(); } ;
...@@ -1832,7 +1847,7 @@ c_anything: ecpg_ident { $$ = $1; } ...@@ -1832,7 +1847,7 @@ c_anything: ecpg_ident { $$ = $1; }
| '[' { $$ = mm_strdup("["); } | '[' { $$ = mm_strdup("["); }
| ']' { $$ = mm_strdup("]"); } | ']' { $$ = mm_strdup("]"); }
| '=' { $$ = mm_strdup("="); } | '=' { $$ = mm_strdup("="); }
| ':' { $$ = mm_strdup(":"); } | ':' { $$ = mm_strdup(":"); }
; ;
DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; } DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
...@@ -1855,12 +1870,12 @@ Iresult: Iconst { $$ = $1; } ...@@ -1855,12 +1870,12 @@ Iresult: Iconst { $$ = $1; }
execute_rest: /* EMPTY */ { $$ = EMPTY; } execute_rest: /* EMPTY */ { $$ = EMPTY; }
| ecpg_using ecpg_into { $$ = EMPTY; } | ecpg_using ecpg_into { $$ = EMPTY; }
| ecpg_into ecpg_using { $$ = EMPTY; } | ecpg_into ecpg_using { $$ = EMPTY; }
| ecpg_using { $$ = EMPTY; } | ecpg_using { $$ = EMPTY; }
| ecpg_into { $$ = EMPTY; } | ecpg_into { $$ = EMPTY; }
; ;
ecpg_into: INTO into_list { $$ = EMPTY; } ecpg_into: INTO into_list { $$ = EMPTY; }
| into_descriptor { $$ = $1; } | into_descriptor { $$ = $1; }
; ;
ecpg_fetch_into: ecpg_into { $$ = $1; } ecpg_fetch_into: ecpg_into { $$ = $1; }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
extern YYSTYPE yylval; extern YYSTYPE yylval;
static int xcdepth = 0; /* depth of nesting in slash-star comments */ static int xcdepth = 0; /* depth of nesting in slash-star comments */
static char *dolqstart; /* current $foo$ quote start string */ static char *dolqstart; /* current $foo$ quote start string */
static YY_BUFFER_STATE scanbufhandle; static YY_BUFFER_STATE scanbufhandle;
static char *scanbuf; static char *scanbuf;
...@@ -37,7 +37,7 @@ static char *scanbuf; ...@@ -37,7 +37,7 @@ static char *scanbuf;
* to empty, addlit to add text. Note that the buffer is permanently * to empty, addlit to add text. Note that the buffer is permanently
* malloc'd to the largest size needed so far in the current run. * malloc'd to the largest size needed so far in the current run.
*/ */
static char *literalbuf = NULL; /* expandable buffer */ static char *literalbuf = NULL; /* expandable buffer */
static int literallen; /* actual current length */ static int literallen; /* actual current length */
static int literalalloc; /* current allocated buffer size */ static int literalalloc; /* current allocated buffer size */
...@@ -62,8 +62,8 @@ struct _yy_buffer ...@@ -62,8 +62,8 @@ struct _yy_buffer
{ {
YY_BUFFER_STATE buffer; YY_BUFFER_STATE buffer;
long lineno; long lineno;
char *filename; char *filename;
struct _yy_buffer *next; struct _yy_buffer *next;
} *yy_buffer = NULL; } *yy_buffer = NULL;
static char *old; static char *old;
...@@ -142,7 +142,7 @@ xhinside [^']* ...@@ -142,7 +142,7 @@ xhinside [^']*
xnstart [nN]{quote} xnstart [nN]{quote}
/* Quoted string that allows backslash escapes */ /* Quoted string that allows backslash escapes */
xestart [eE]{quote} xestart [eE]{quote}
xeinside [^\\']+ xeinside [^\\']+
xeescape [\\][^0-7] xeescape [\\][^0-7]
xeoctesc [\\][0-7]{1,3} xeoctesc [\\][0-7]{1,3}
...@@ -317,14 +317,14 @@ other . ...@@ -317,14 +317,14 @@ other .
/* some stuff needed for ecpg */ /* some stuff needed for ecpg */
exec [eE][xX][eE][cC] 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]
include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT] include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT]
import [iI][mM][pP][oO][rR][tT] import [iI][mM][pP][oO][rR][tT]
undef [uU][nN][dD][eE][fF] undef [uU][nN][dD][eE][fF]
if [iI][fF] if [iI][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]
else [eE][lL][sS][eE] else [eE][lL][sS][eE]
...@@ -335,10 +335,10 @@ struct [sS][tT][rR][uU][cC][tT] ...@@ -335,10 +335,10 @@ struct [sS][tT][rR][uU][cC][tT]
exec_sql {exec}{space}*{sql}{space}* exec_sql {exec}{space}*{sql}{space}*
ipdigit ({digit}|{digit}{digit}|{digit}{digit}{digit}) ipdigit ({digit}|{digit}{digit}|{digit}{digit}{digit})
ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit} ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit}
/* we might want to parse all cpp include files */ /* we might want to parse all cpp include files */
cppinclude {space}*#{include}{space}* cppinclude {space}*#{include}{space}*
cppinclude_next {space}*#{include_next}{space}* cppinclude_next {space}*#{include_next}{space}*
/* take care of cpp lines, they may also be continuated */ /* take care of cpp lines, they may also be continuated */
...@@ -380,8 +380,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -380,8 +380,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<xc>{xcstart} { <xc>{xcstart} {
xcdepth++; xcdepth++;
/* Put back any characters past slash-star; see above */ /* Put back any characters past slash-star; see above */
yyless(2); yyless(2);
fputs("/*", yyout); fputs("/*", yyout);
} }
...@@ -398,7 +398,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -398,7 +398,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xc>{xcinside} { ECHO; } <xc>{xcinside} { ECHO; }
<xc>{op_chars} { ECHO; } <xc>{op_chars} { ECHO; }
<xc>\*+ { ECHO; } <xc>\*+ { ECHO; }
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); } <xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); }
...@@ -431,7 +431,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -431,7 +431,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
addlitchar('x'); addlitchar('x');
} }
<xh>{quotestop} | <xh>{quotestop} |
<xh>{quotefail} { <xh>{quotefail} {
yyless(1); yyless(1);
BEGIN(SQL); BEGIN(SQL);
yylval.str = mm_strdup(literalbuf); yylval.str = mm_strdup(literalbuf);
...@@ -439,7 +439,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -439,7 +439,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated hexadecimal string literal"); } <xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated hexadecimal string literal"); }
<SQL>{xnstart} { <SQL>{xnstart} {
/* National character. /* National character.
* Transfer it as-is to the backend. * Transfer it as-is to the backend.
*/ */
...@@ -508,11 +508,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -508,11 +508,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); } <xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
<xe>{xeinside} { addlit(yytext, yyleng); } <xe>{xeinside} { addlit(yytext, yyleng); }
<xe>{xeunicode} { addlit(yytext, yyleng); } <xe>{xeunicode} { addlit(yytext, yyleng); }
<xe>{xeescape} { addlit(yytext, yyleng); } <xe>{xeescape} { addlit(yytext, yyleng); }
<xe>{xeoctesc} { addlit(yytext, yyleng); } <xe>{xeoctesc} { addlit(yytext, yyleng); }
<xe>{xehexesc} { addlit(yytext, yyleng); } <xe>{xehexesc} { addlit(yytext, yyleng); }
<xq,xqc,xe,xn,xus>{quotecontinue} { /* ignore */ } <xq,xqc,xe,xn,xus>{quotecontinue} { /* ignore */ }
<xe>. { <xe>. {
/* This is only needed for \ just before EOF */ /* This is only needed for \ just before EOF */
addlitchar(yytext[0]); addlitchar(yytext[0]);
} }
...@@ -523,14 +523,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -523,14 +523,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
/* and treat it as {other} */ /* and treat it as {other} */
return yytext[0]; return yytext[0];
} }
<SQL>{dolqdelim} { <SQL>{dolqdelim} {
token_start = yytext; token_start = yytext;
dolqstart = mm_strdup(yytext); dolqstart = mm_strdup(yytext);
BEGIN(xdolq); BEGIN(xdolq);
startlit(); startlit();
addlit(yytext, yyleng); addlit(yytext, yyleng);
} }
<xdolq>{dolqdelim} { <xdolq>{dolqdelim} {
if (strcmp(yytext, dolqstart) == 0) if (strcmp(yytext, dolqstart) == 0)
{ {
addlit(yytext, yyleng); addlit(yytext, yyleng);
...@@ -541,22 +541,22 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -541,22 +541,22 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
else else
{ {
/* /*
* When we fail to match $...$ to dolqstart, transfer * When we fail to match $...$ to dolqstart, transfer
* the $... part to the output, but put back the final * the $... part to the output, but put back the final
* $ for rescanning. Consider $delim$...$junk$delim$ * $ for rescanning. Consider $delim$...$junk$delim$
*/ */
addlit(yytext, yyleng-1); addlit(yytext, yyleng-1);
yyless(yyleng-1); yyless(yyleng-1);
} }
} }
<xdolq>{dolqinside} { addlit(yytext, yyleng); } <xdolq>{dolqinside} { addlit(yytext, yyleng); }
<xdolq>{dolqfailed} { addlit(yytext, yyleng); } <xdolq>{dolqfailed} { addlit(yytext, yyleng); }
<xdolq>{other} { <xdolq>{other} {
/* single quote or dollar sign */ /* single quote or dollar sign */
addlitchar(yytext[0]); addlitchar(yytext[0]);
} }
<xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); } <xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); }
<SQL>{xdstart} { <SQL>{xdstart} {
state_before = YYSTATE; state_before = YYSTATE;
BEGIN(xd); BEGIN(xd);
...@@ -739,7 +739,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -739,7 +739,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
return(CVARIABLE); return(CVARIABLE);
} }
<SQL>{identifier} { <SQL>{identifier} {
const ScanKeyword *keyword; const ScanKeyword *keyword;
if (!isdefine()) if (!isdefine())
{ {
...@@ -798,10 +798,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -798,10 +798,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(incl); BEGIN(incl);
} }
else else
{ {
yylval.str = mm_strdup(yytext); yylval.str = mm_strdup(yytext);
return(CPP_LINE); return(CPP_LINE);
} }
} }
<C>{cppinclude_next} { <C>{cppinclude_next} {
if (system_includes) if (system_includes)
...@@ -810,16 +810,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -810,16 +810,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(incl); BEGIN(incl);
} }
else else
{ {
yylval.str = mm_strdup(yytext); yylval.str = mm_strdup(yytext);
return(CPP_LINE); return(CPP_LINE);
} }
} }
<C,SQL>{cppline} { <C,SQL>{cppline} {
yylval.str = mm_strdup(yytext); yylval.str = mm_strdup(yytext);
return(CPP_LINE); return(CPP_LINE);
} }
<C>{identifier} { <C>{identifier} {
const ScanKeyword *keyword; const ScanKeyword *keyword;
/* /*
...@@ -893,7 +893,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -893,7 +893,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
} }
<C>{exec_sql}{undef}{space}* { BEGIN(undef); } <C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{informix_special}{undef}{space}* { <C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */ /* are we simulating Informix? */
if (INFORMIX_MODE) if (INFORMIX_MODE)
{ {
...@@ -937,9 +937,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -937,9 +937,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(C); BEGIN(C);
} }
<undef>{other}|\n { <undef>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command"); mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
yyterminate(); 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}* {
...@@ -1171,17 +1171,17 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1171,17 +1171,17 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<<EOF>> { <<EOF>> {
if (yy_buffer == NULL) if (yy_buffer == NULL)
{ {
if ( preproc_tos > 0 ) if ( preproc_tos > 0 )
{ {
preproc_tos = 0; preproc_tos = 0;
mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\""); mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\"");
} }
yyterminate(); yyterminate();
} }
else else
{ {
struct _yy_buffer *yb = yy_buffer; struct _yy_buffer *yb = yy_buffer;
int i; int i;
struct _defines *ptr; struct _defines *ptr;
...@@ -1213,9 +1213,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1213,9 +1213,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (i != 0) if (i != 0)
output_line_number(); output_line_number();
} }
} }
<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); } <INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
%% %%
void void
lex_init(void) lex_init(void)
...@@ -1278,24 +1278,24 @@ parse_include(void) ...@@ -1278,24 +1278,24 @@ parse_include(void)
{ {
/* got the include file name */ /* got the include file name */
struct _yy_buffer *yb; struct _yy_buffer *yb;
struct _include_path *ip; struct _include_path *ip;
char inc_file[MAXPGPATH]; char inc_file[MAXPGPATH];
unsigned int i; unsigned int i;
yb = mm_alloc(sizeof(struct _yy_buffer)); yb = mm_alloc(sizeof(struct _yy_buffer));
yb->buffer = YY_CURRENT_BUFFER; yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno; yb->lineno = yylineno;
yb->filename = input_filename; yb->filename = input_filename;
yb->next = yy_buffer; yb->next = yy_buffer;
yy_buffer = yb; yy_buffer = yb;
/* /*
* skip the ";" if there is one and trailing whitespace. Note that * skip the ";" if there is one and trailing whitespace. Note that
* yytext contains at least one non-space character plus the ";" * yytext contains at least one non-space character plus the ";"
*/ */
for (i = strlen(yytext)-2; for (i = strlen(yytext)-2;
i > 0 && ecpg_isspace(yytext[i]); i > 0 && ecpg_isspace(yytext[i]);
i--) i--)
; ;
...@@ -1310,7 +1310,7 @@ parse_include(void) ...@@ -1310,7 +1310,7 @@ parse_include(void)
/* If file name is enclosed in '"' remove these and look only in '.' */ /* If file name is enclosed in '"' remove these and look only in '.' */
/* Informix does look into all include paths though, except filename starts with '/' */ /* Informix does look into all include paths though, except filename starts with '/' */
if (yytext[0] == '"' && yytext[i] == '"' && if (yytext[0] == '"' && yytext[i] == '"' &&
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/')) ((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
{ {
yytext[i] = '\0'; yytext[i] = '\0';
memmove(yytext, yytext+1, strlen(yytext)); memmove(yytext, yytext+1, strlen(yytext));
...@@ -1335,8 +1335,8 @@ parse_include(void) ...@@ -1335,8 +1335,8 @@ parse_include(void)
memmove(yytext, yytext+1, strlen(yytext)); memmove(yytext, yytext+1, strlen(yytext));
} }
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)
{ {
fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno); fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno);
...@@ -1368,7 +1368,7 @@ parse_include(void) ...@@ -1368,7 +1368,7 @@ parse_include(void)
yylineno = 1; yylineno = 1;
output_line_number(); output_line_number();
BEGIN(C); BEGIN(C);
} }
/* /*
...@@ -1421,9 +1421,9 @@ static bool isinformixdefine(void) ...@@ -1421,9 +1421,9 @@ static bool isinformixdefine(void)
if (strcmp(yytext, "dec_t") == 0) if (strcmp(yytext, "dec_t") == 0)
new = "decimal"; new = "decimal";
else if (strcmp(yytext, "intrvl_t") == 0) else if (strcmp(yytext, "intrvl_t") == 0)
new = "interval"; new = "interval";
else if (strcmp(yytext, "dtime_t") == 0) else if (strcmp(yytext, "dtime_t") == 0)
new = "timestamp"; new = "timestamp";
if (new) if (new)
{ {
......
...@@ -83,7 +83,7 @@ static void complete_direction(PLpgSQL_stmt_fetch *fetch, ...@@ -83,7 +83,7 @@ static void complete_direction(PLpgSQL_stmt_fetch *fetch,
static PLpgSQL_stmt *make_return_stmt(int location); static PLpgSQL_stmt *make_return_stmt(int location);
static PLpgSQL_stmt *make_return_next_stmt(int location); static PLpgSQL_stmt *make_return_next_stmt(int location);
static PLpgSQL_stmt *make_return_query_stmt(int location); static PLpgSQL_stmt *make_return_query_stmt(int location);
static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr, static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr,
List *case_when_list, List *else_stmts); List *case_when_list, List *else_stmts);
static char *NameOfDatum(PLwdatum *wdatum); static char *NameOfDatum(PLwdatum *wdatum);
static void check_assignable(PLpgSQL_datum *datum, int location); static void check_assignable(PLpgSQL_datum *datum, int location);
...@@ -102,7 +102,7 @@ static PLpgSQL_type *parse_datatype(const char *string, int location); ...@@ -102,7 +102,7 @@ static PLpgSQL_type *parse_datatype(const char *string, int location);
static void check_labels(const char *start_label, static void check_labels(const char *start_label,
const char *end_label, const char *end_label,
int end_location); int end_location);
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor, static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor,
int until, const char *expected); int until, const char *expected);
static List *read_raise_options(void); static List *read_raise_options(void);
...@@ -134,8 +134,8 @@ static List *read_raise_options(void); ...@@ -134,8 +134,8 @@ static List *read_raise_options(void);
char *name; char *name;
int lineno; int lineno;
PLpgSQL_datum *scalar; PLpgSQL_datum *scalar;
PLpgSQL_rec *rec; PLpgSQL_rec *rec;
PLpgSQL_row *row; PLpgSQL_row *row;
} forvariable; } forvariable;
struct struct
{ {
...@@ -1069,7 +1069,7 @@ opt_expr_until_when : ...@@ -1069,7 +1069,7 @@ opt_expr_until_when :
plpgsql_push_back_token(K_WHEN); plpgsql_push_back_token(K_WHEN);
$$ = expr; $$ = expr;
} }
; ;
case_when_list : case_when_list case_when case_when_list : case_when_list case_when
{ {
...@@ -1859,7 +1859,7 @@ stmt_open : K_OPEN cursor_variable ...@@ -1859,7 +1859,7 @@ stmt_open : K_OPEN cursor_variable
if ($2->cursor_explicit_expr == NULL) if ($2->cursor_explicit_expr == NULL)
{ {
/* be nice if we could use opt_scrollable here */ /* be nice if we could use opt_scrollable here */
tok = yylex(); tok = yylex();
if (tok_is_keyword(tok, &yylval, if (tok_is_keyword(tok, &yylval,
K_NO, "no")) K_NO, "no"))
{ {
...@@ -2077,9 +2077,9 @@ proc_exception : K_WHEN proc_conditions K_THEN proc_sect ...@@ -2077,9 +2077,9 @@ proc_exception : K_WHEN proc_conditions K_THEN proc_sect
PLpgSQL_exception *new; PLpgSQL_exception *new;
new = palloc0(sizeof(PLpgSQL_exception)); new = palloc0(sizeof(PLpgSQL_exception));
new->lineno = plpgsql_location_to_lineno(@1); new->lineno = plpgsql_location_to_lineno(@1);
new->conditions = $2; new->conditions = $2;
new->action = $4; new->action = $4;
$$ = new; $$ = new;
} }
...@@ -2451,7 +2451,7 @@ read_sql_construct(int until, ...@@ -2451,7 +2451,7 @@ read_sql_construct(int until,
expr->query = pstrdup(ds.data); expr->query = pstrdup(ds.data);
expr->plan = NULL; expr->plan = NULL;
expr->paramnos = NULL; expr->paramnos = NULL;
expr->ns = plpgsql_ns_top(); expr->ns = plpgsql_ns_top();
pfree(ds.data); pfree(ds.data);
if (valid_sql) if (valid_sql)
...@@ -2651,7 +2651,7 @@ make_execsql_stmt(int firsttoken, int location) ...@@ -2651,7 +2651,7 @@ make_execsql_stmt(int firsttoken, int location)
expr->query = pstrdup(ds.data); expr->query = pstrdup(ds.data);
expr->plan = NULL; expr->plan = NULL;
expr->paramnos = NULL; expr->paramnos = NULL;
expr->ns = plpgsql_ns_top(); expr->ns = plpgsql_ns_top();
pfree(ds.data); pfree(ds.data);
check_sql_expr(expr->query, location, 0); check_sql_expr(expr->query, location, 0);
...@@ -2688,7 +2688,7 @@ read_fetch_direction(void) ...@@ -2688,7 +2688,7 @@ read_fetch_direction(void)
/* set direction defaults: */ /* set direction defaults: */
fetch->direction = FETCH_FORWARD; fetch->direction = FETCH_FORWARD;
fetch->how_many = 1; fetch->how_many = 1;
fetch->expr = NULL; fetch->expr = NULL;
fetch->returns_multiple_rows = false; fetch->returns_multiple_rows = false;
tok = yylex(); tok = yylex();
...@@ -3478,7 +3478,7 @@ static PLpgSQL_stmt * ...@@ -3478,7 +3478,7 @@ static PLpgSQL_stmt *
make_case(int location, PLpgSQL_expr *t_expr, make_case(int location, PLpgSQL_expr *t_expr,
List *case_when_list, List *else_stmts) List *case_when_list, List *else_stmts)
{ {
PLpgSQL_stmt_case *new; PLpgSQL_stmt_case *new;
new = palloc(sizeof(PLpgSQL_stmt_case)); new = palloc(sizeof(PLpgSQL_stmt_case));
new->cmd_type = PLPGSQL_STMT_CASE; new->cmd_type = PLPGSQL_STMT_CASE;
......
...@@ -96,12 +96,12 @@ teardown { return(TEARDOWN); } ...@@ -96,12 +96,12 @@ teardown { return(TEARDOWN); }
static void static void
addlitchar(char c) addlitchar(char c)
{ {
if (litbufpos >= sizeof(litbuf) - 1) if (litbufpos >= sizeof(litbuf) - 1)
{ {
fprintf(stderr, "SQL step too long\n"); fprintf(stderr, "SQL step too long\n");
exit(1); exit(1);
} }
litbuf[litbufpos++] = c; litbuf[litbufpos++] = c;
} }
void void
......
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