Clean up whitespace and indentation in parser and scanner files

These are not touched by pgindent, so clean them up a bit manually.
This commit is contained in:
Peter Eisentraut 2011-11-01 21:50:00 +02:00
parent f3ebaad45b
commit 654e1f96b0
12 changed files with 701 additions and 580 deletions

View File

@ -47,165 +47,167 @@ static NDBOX * write_point_as_box(char *s, int dim);
/* Grammar follows */
%%
box:
O_BRACKET paren_list COMMA paren_list C_BRACKET {
box: O_BRACKET paren_list COMMA paren_list C_BRACKET
{
int dim;
int dim;
dim = delim_count($2, ',') + 1;
if ((delim_count($4, ',') + 1) != dim)
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("Different point dimensions in (%s) and (%s).",
$2, $4)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
dim = delim_count($2, ',') + 1;
if ( (delim_count($4, ',') + 1) != dim ) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("Different point dimensions in (%s) and (%s).",
$2, $4)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_box( dim, $2, $4 );
*((void **)result) = write_box( dim, $2, $4 );
}
}
|
paren_list COMMA paren_list {
int dim;
| paren_list COMMA paren_list
{
int dim;
dim = delim_count($1, ',') + 1;
dim = delim_count($1, ',') + 1;
if ( (delim_count($3, ',') + 1) != dim ) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("Different point dimensions in (%s) and (%s).",
$1, $3)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
if ( (delim_count($3, ',') + 1) != dim ) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("Different point dimensions in (%s) and (%s).",
$1, $3)));
YYABORT;
}
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_box( dim, $1, $3 );
}
|
*((void **)result) = write_box( dim, $1, $3 );
}
paren_list {
int dim;
| paren_list
{
int dim;
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
}
*((void **)result) = write_point_as_box($1, dim);
}
|
| list
{
int dim;
list {
int dim;
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
}
;
dim = delim_count($1, ',') + 1;
if (dim > CUBE_MAX_DIM) {
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"),
errdetail("A cube cannot have more than %d dimensions.",
CUBE_MAX_DIM)));
YYABORT;
}
*((void **)result) = write_point_as_box($1, dim);
}
;
paren_list: O_PAREN list C_PAREN
{
$$ = $2;
}
;
paren_list:
O_PAREN list C_PAREN {
$$ = $2;
}
;
list:
CUBEFLOAT {
/* alloc enough space to be sure whole list will fit */
$$ = palloc(scanbuflen + 1);
strcpy($$, $1);
}
|
list COMMA CUBEFLOAT {
$$ = $1;
strcat($$, ",");
strcat($$, $3);
}
;
list: CUBEFLOAT
{
/* alloc enough space to be sure whole list will fit */
$$ = palloc(scanbuflen + 1);
strcpy($$, $1);
}
| list COMMA CUBEFLOAT
{
$$ = $1;
strcat($$, ",");
strcat($$, $3);
}
;
%%
static int
delim_count(char *s, char delim)
{
int ndelim = 0;
int ndelim = 0;
while ((s = strchr(s, delim)) != NULL)
{
ndelim++;
s++;
}
return (ndelim);
while ((s = strchr(s, delim)) != NULL)
{
ndelim++;
s++;
}
return (ndelim);
}
static NDBOX *
write_box(unsigned int dim, char *str1, char *str2)
{
NDBOX * bp;
char * s;
int i;
int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
NDBOX *bp;
char *s;
int i;
int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
bp = palloc0(size);
SET_VARSIZE(bp, size);
bp->dim = dim;
bp = palloc0(size);
SET_VARSIZE(bp, size);
bp->dim = dim;
s = str1;
bp->x[i=0] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL) {
s++; i++;
bp->x[i] = strtod(s, NULL);
}
s = str1;
bp->x[i=0] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL)
{
s++; i++;
bp->x[i] = strtod(s, NULL);
}
s = str2;
bp->x[i=dim] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL) {
s++; i++;
bp->x[i] = strtod(s, NULL);
}
s = str2;
bp->x[i=dim] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL)
{
s++; i++;
bp->x[i] = strtod(s, NULL);
}
return(bp);
return(bp);
}
static NDBOX *
write_point_as_box(char *str, int dim)
{
NDBOX * bp;
int i, size;
double x;
char * s = str;
NDBOX *bp;
int i,
size;
double x;
char *s = str;
size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
@ -217,11 +219,12 @@ write_point_as_box(char *str, int dim)
x = strtod(s, NULL);
bp->x[0] = x;
bp->x[dim] = x;
while ((s = strchr(s, ',')) != NULL) {
s++; i++;
x = strtod(s, NULL);
bp->x[i] = x;
bp->x[i+dim] = x;
while ((s = strchr(s, ',')) != NULL)
{
s++; i++;
x = strtod(s, NULL);
bp->x[i] = x;
bp->x[i+dim] = x;
}
return(bp);

View File

@ -20,22 +20,22 @@
#define YYMALLOC palloc
#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);
int seg_yyparse(void *result);
void seg_yyerror(const char *message);
int seg_yyparse(void *result);
static float seg_atof(char *value);
static float seg_atof(char *value);
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'
};
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'
};
%}
@ -44,12 +44,12 @@
%name-prefix="seg_yy"
%union {
struct BND {
float val;
char ext;
char sigd;
} bnd;
char * text;
struct BND {
float val;
char ext;
char sigd;
} bnd;
char * text;
}
%token <text> SEGFLOAT
%token <text> RANGE
@ -63,90 +63,94 @@
%%
range:
boundary PLUMIN deviation {
((SEG *)result)->lower = $1.val - $3.val;
((SEG *)result)->upper = $1.val + $3.val;
sprintf(strbuf, "%g", ((SEG *)result)->lower);
((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
sprintf(strbuf, "%g", ((SEG *)result)->upper);
((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
((SEG *)result)->l_ext = '\0';
((SEG *)result)->u_ext = '\0';
}
|
boundary RANGE boundary {
((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = $3.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("swapped boundaries: %g is greater than %g",
((SEG *)result)->lower, ((SEG *)result)->upper)));
range: boundary PLUMIN deviation
{
((SEG *)result)->lower = $1.val - $3.val;
((SEG *)result)->upper = $1.val + $3.val;
sprintf(strbuf, "%g", ((SEG *)result)->lower);
((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
sprintf(strbuf, "%g", ((SEG *)result)->upper);
((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
((SEG *)result)->l_ext = '\0';
((SEG *)result)->u_ext = '\0';
}
YYERROR;
}
((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->u_sigd = $3.sigd;
((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;
((SEG *)result)->upper = HUGE_VAL;
((SEG *)result)->l_sigd = $1.sigd;
((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;
((SEG *)result)->l_sigd = 0;
((SEG *)result)->u_sigd = $2.sigd;
((SEG *)result)->l_ext = '-';
((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
}
|
boundary {
((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 RANGE boundary
{
((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = $3.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("swapped boundaries: %g is greater than %g",
((SEG *)result)->lower, ((SEG *)result)->upper)));
boundary:
SEGFLOAT {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1);
YYERROR;
}
((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->u_sigd = $3.sigd;
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' );
}
$$.ext = '\0';
$$.sigd = significant_digits($1);
$$.val = val;
}
|
EXTENSION SEGFLOAT {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($2);
| boundary RANGE
{
((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = HUGE_VAL;
((SEG *)result)->l_sigd = $1.sigd;
((SEG *)result)->u_sigd = 0;
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
((SEG *)result)->u_ext = '-';
}
$$.ext = $1[0];
$$.sigd = significant_digits($2);
$$.val = val;
}
;
| RANGE boundary
{
((SEG *)result)->lower = -HUGE_VAL;
((SEG *)result)->upper = $2.val;
((SEG *)result)->l_sigd = 0;
((SEG *)result)->u_sigd = $2.sigd;
((SEG *)result)->l_ext = '-';
((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
}
deviation:
SEGFLOAT {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1);
| boundary
{
((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' );
}
;
$$.ext = '\0';
$$.sigd = significant_digits($1);
$$.val = val;
}
;
boundary: SEGFLOAT
{
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1);
$$.ext = '\0';
$$.sigd = significant_digits($1);
$$.val = val;
}
| EXTENSION SEGFLOAT
{
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($2);
$$.ext = $1[0];
$$.sigd = significant_digits($2);
$$.val = val;
}
;
deviation: SEGFLOAT
{
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1);
$$.ext = '\0';
$$.sigd = significant_digits($1);
$$.val = val;
}
;
%%

View File

@ -456,8 +456,8 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
%type <ival> document_or_content
%type <boolean> xml_whitespace_option
%type <node> common_table_expr
%type <with> with_clause opt_with_clause
%type <node> common_table_expr
%type <with> with_clause opt_with_clause
%type <list> cte_list
%type <list> window_clause window_definition_list opt_partition_clause
@ -1553,7 +1553,7 @@ ConstraintsSetStmt:
{
ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt);
n->constraints = $3;
n->deferred = $4;
n->deferred = $4;
$$ = (Node *) n;
}
;
@ -2048,7 +2048,7 @@ alter_using:
;
reloptions:
'(' reloption_list ')' { $$ = $2; }
'(' reloption_list ')' { $$ = $2; }
;
opt_reloptions: WITH reloptions { $$ = $2; }
@ -3278,7 +3278,7 @@ opt_procedural:
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/'
*
*****************************************************************************/
@ -3299,7 +3299,7 @@ OptTableSpaceOwner: OWNER name { $$ = $2; }
/*****************************************************************************
*
* QUERY :
* QUERY :
* DROP TABLESPACE <tablespace>
*
* No need for drop behaviour as we cannot implement dependencies for
@ -3315,7 +3315,7 @@ DropTableSpaceStmt: DROP TABLESPACE name
$$ = (Node *) n;
}
| DROP TABLESPACE IF_P EXISTS name
{
{
DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
n->tablespacename = $5;
n->missing_ok = true;
@ -3325,7 +3325,7 @@ DropTableSpaceStmt: DROP TABLESPACE name
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE EXTENSION extension
* [ WITH ] [ SCHEMA schema ] [ VERSION version ] [ FROM oldversion ]
*
@ -3615,7 +3615,7 @@ AlterExtensionContentsStmt:
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE FOREIGN DATA WRAPPER name options
*
*****************************************************************************/
@ -3649,7 +3649,7 @@ opt_fdw_options:
/*****************************************************************************
*
* QUERY :
* QUERY :
* DROP FOREIGN DATA WRAPPER name
*
****************************************************************************/
@ -3663,7 +3663,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
$$ = (Node *) n;
}
| DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
{
{
DropFdwStmt *n = makeNode(DropFdwStmt);
n->fdwname = $7;
n->missing_ok = true;
@ -3674,7 +3674,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
/*****************************************************************************
*
* QUERY :
* QUERY :
* ALTER FOREIGN DATA WRAPPER name options
*
****************************************************************************/
@ -3769,7 +3769,7 @@ generic_option_arg:
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE SERVER name [TYPE] [VERSION] [OPTIONS]
*
*****************************************************************************/
@ -3799,13 +3799,13 @@ foreign_server_version:
;
opt_foreign_server_version:
foreign_server_version { $$ = $1; }
foreign_server_version { $$ = $1; }
| /*EMPTY*/ { $$ = NULL; }
;
/*****************************************************************************
*
* QUERY :
* QUERY :
* DROP SERVER name
*
****************************************************************************/
@ -3819,7 +3819,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
$$ = (Node *) n;
}
| DROP SERVER IF_P EXISTS name opt_drop_behavior
{
{
DropForeignServerStmt *n = makeNode(DropForeignServerStmt);
n->servername = $5;
n->missing_ok = true;
@ -3830,7 +3830,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
/*****************************************************************************
*
* QUERY :
* QUERY :
* ALTER SERVER name [VERSION] [OPTIONS]
*
****************************************************************************/
@ -3863,7 +3863,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE FOREIGN TABLE relname (...) SERVER name (...)
*
*****************************************************************************/
@ -3923,7 +3923,7 @@ ForeignTableElement:
/*****************************************************************************
*
* QUERY:
* QUERY:
* ALTER FOREIGN TABLE relname [...]
*
*****************************************************************************/
@ -3941,7 +3941,7 @@ AlterForeignTableStmt:
/*****************************************************************************
*
* QUERY:
* QUERY:
* CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS]
*
*****************************************************************************/
@ -3958,14 +3958,14 @@ CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_gen
/* User mapping authorization identifier */
auth_ident:
CURRENT_USER { $$ = "current_user"; }
CURRENT_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
*
****************************************************************************/
@ -3979,7 +3979,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
$$ = (Node *) n;
}
| DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
{
{
DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
n->username = $7;
n->servername = $9;
@ -3990,7 +3990,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
/*****************************************************************************
*
* QUERY :
* QUERY :
* ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS
*
****************************************************************************/
@ -4395,7 +4395,7 @@ DefineStmt:
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); }
;
@ -4457,33 +4457,33 @@ enum_val_list: Sconst
*****************************************************************************/
AlterEnumStmt:
ALTER TYPE_P any_name ADD_P VALUE_P Sconst
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = NULL;
n->newValIsAfter = true;
$$ = (Node *) n;
}
ALTER TYPE_P any_name ADD_P VALUE_P Sconst
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = NULL;
n->newValIsAfter = true;
$$ = (Node *) n;
}
| ALTER TYPE_P any_name ADD_P VALUE_P Sconst BEFORE Sconst
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = $8;
n->newValIsAfter = false;
$$ = (Node *) n;
}
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = $8;
n->newValIsAfter = false;
$$ = (Node *) n;
}
| ALTER TYPE_P any_name ADD_P VALUE_P Sconst AFTER Sconst
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = $8;
n->newValIsAfter = true;
$$ = (Node *) n;
}
{
AlterEnumStmt *n = makeNode(AlterEnumStmt);
n->typeName = $3;
n->newVal = $6;
n->newValNeighbor = $8;
n->newValIsAfter = true;
$$ = (Node *) n;
}
;
@ -4708,7 +4708,7 @@ DropOpFamilyStmt:
*****************************************************************************/
DropOwnedStmt:
DROP OWNED BY name_list opt_drop_behavior
{
{
DropOwnedStmt *n = makeNode(DropOwnedStmt);
n->roles = $4;
n->behavior = $5;
@ -5001,7 +5001,7 @@ comment_type:
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
| TABLESPACE { $$ = OBJECT_TABLESPACE; }
| EXTENSION { $$ = OBJECT_EXTENSION; }
| EXTENSION { $$ = OBJECT_EXTENSION; }
| ROLE { $$ = OBJECT_ROLE; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
| SERVER { $$ = OBJECT_FOREIGN_SERVER; }
@ -5988,25 +5988,25 @@ func_type: Typename { $$ = $1; }
func_arg_with_default:
func_arg
{
$$ = $1;
}
{
$$ = $1;
}
| func_arg DEFAULT a_expr
{
$$ = $1;
$$->defexpr = $3;
}
{
$$ = $1;
$$->defexpr = $3;
}
| func_arg '=' a_expr
{
$$ = $1;
$$->defexpr = $3;
}
{
$$ = $1;
$$->defexpr = $3;
}
;
createfunc_opt_list:
/* 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); }
;
@ -7687,13 +7687,13 @@ CreateConversionStmt:
CREATE opt_default CONVERSION_P any_name FOR Sconst
TO Sconst FROM any_name
{
CreateConversionStmt *n = makeNode(CreateConversionStmt);
n->conversion_name = $4;
n->for_encoding_name = $6;
n->to_encoding_name = $8;
n->func_name = $10;
n->def = $2;
$$ = (Node *)n;
CreateConversionStmt *n = makeNode(CreateConversionStmt);
n->conversion_name = $4;
n->for_encoding_name = $6;
n->to_encoding_name = $8;
n->func_name = $10;
n->def = $2;
$$ = (Node *)n;
}
;
@ -7709,28 +7709,28 @@ CreateConversionStmt:
ClusterStmt:
CLUSTER opt_verbose qualified_name cluster_index_specification
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $3;
n->indexname = $4;
n->verbose = $2;
$$ = (Node*)n;
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $3;
n->indexname = $4;
n->verbose = $2;
$$ = (Node*)n;
}
| CLUSTER opt_verbose
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = NULL;
n->indexname = NULL;
n->verbose = $2;
$$ = (Node*)n;
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = NULL;
n->indexname = NULL;
n->verbose = $2;
$$ = (Node*)n;
}
/* kept for pre-8.3 compatibility */
| CLUSTER opt_verbose index_name ON qualified_name
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $5;
n->indexname = $3;
n->verbose = $2;
$$ = (Node*)n;
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $5;
n->indexname = $3;
n->verbose = $2;
$$ = (Node*)n;
}
;
@ -8141,7 +8141,7 @@ DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias
;
using_clause:
USING from_list { $$ = $2; }
USING from_list { $$ = $2; }
| /*EMPTY*/ { $$ = NIL; }
;
@ -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; }
;
@ -10032,12 +10032,12 @@ a_expr: c_expr { $$ = $1; }
{
$$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2),
@2),
(Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4, @2),
@2),
@2);
}
@ -10045,12 +10045,12 @@ a_expr: c_expr { $$ = $1; }
{
$$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
(Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2),
@2),
(Node *) makeA_Expr(AEXPR_OR, NIL,
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $7, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $5, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $7, @2),
(Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $5, @2),
@2),
@2);
}
@ -11739,9 +11739,9 @@ AexprConst: Iconst
if (IsA(arg, NamedArgExpr))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot have parameter name"),
parser_errposition(arg->location)));
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("type modifier cannot have parameter name"),
parser_errposition(arg->location)));
}
t->typmods = $3;
t->location = @1;
@ -12747,7 +12747,7 @@ static Node *
makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
int location)
{
XmlExpr *x = makeNode(XmlExpr);
XmlExpr *x = makeNode(XmlExpr);
x->op = op;
x->name = name;

View File

@ -122,7 +122,7 @@ base_backup:
;
base_backup_opt_list: base_backup_opt_list base_backup_opt { $$ = lappend($1, $2); }
| /* EMPTY */ { $$ = NIL; }
| /* EMPTY */ { $$ = NIL; }
base_backup_opt:
K_LABEL SCONST

View File

@ -112,13 +112,13 @@ START_REPLICATION { return K_START_REPLICATION; }
static void
startlit(void)
{
initStringInfo(&litbuf);
initStringInfo(&litbuf);
}
static char *
litbufdup(void)
{
return litbuf.data;
return litbuf.data;
}
static void
@ -130,13 +130,13 @@ addlit(char *ytext, int yleng)
static void
addlitchar(unsigned char ychar)
{
appendStringInfoChar(&litbuf, ychar);
appendStringInfoChar(&litbuf, ychar);
}
void
yyerror(const char *message)
{
ereport(ERROR,
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg_internal("%s", message)));
}

View File

@ -55,41 +55,41 @@ static char *GUC_scanstr(const char *s);
%option prefix="GUC_yy"
SIGN ("-"|"+")
DIGIT [0-9]
HEXDIGIT [0-9a-fA-F]
SIGN ("-"|"+")
DIGIT [0-9]
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}+
REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}?
EXPONENT [Ee]{SIGN}?{DIGIT}+
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]
ID {LETTER}{LETTER_OR_DIGIT}*
QUALIFIED_ID {ID}"."{ID}
ID {LETTER}{LETTER_OR_DIGIT}*
QUALIFIED_ID {ID}"."{ID}
UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])*
STRING \'([^'\\\n]|\\.|\'\')*\'
STRING \'([^'\\\n]|\\.|\'\')*\'
%%
\n ConfigFileLineno++; return GUC_EOL;
[ \t\r]+ /* eat whitespace */
#.* /* eat comment (.* matches anything until newline) */
\n ConfigFileLineno++; return GUC_EOL;
[ \t\r]+ /* eat whitespace */
#.* /* eat comment (.* matches anything until newline) */
{ID} return GUC_ID;
{QUALIFIED_ID} return GUC_QUALIFIED_ID;
{STRING} return GUC_STRING;
{ID} return GUC_ID;
{QUALIFIED_ID} return GUC_QUALIFIED_ID;
{STRING} return GUC_STRING;
{UNQUOTED_STRING} return GUC_UNQUOTED_STRING;
{INTEGER} return GUC_INTEGER;
{REAL} return GUC_REAL;
= return GUC_EQUALS;
{INTEGER} return GUC_INTEGER;
{REAL} return GUC_REAL;
= return GUC_EQUALS;
. return GUC_ERROR;
. return GUC_ERROR;
%%

View File

@ -308,8 +308,8 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
if (strcmp_fn($2, ptr->name) == 0)
{
if ($2[0] == ':')
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
}
}
@ -362,7 +362,7 @@ ECPG: into_clauseINTOOptTempTableName block
FoundInto = 1;
$$= cat2_str(mm_strdup("into"), $2);
}
| ecpg_into { $$ = EMPTY; }
| ecpg_into { $$ = EMPTY; }
ECPG: table_refselect_with_parens addon
mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
ECPG: TypenameSimpleTypenameopt_array_bounds block
@ -468,9 +468,9 @@ ECPG: FetchStmtMOVEfetch_args rule
$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
}
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
{
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
}
{
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
}
ECPG: SignedIconstIconst rule
| civar { $$ = $1; }

View File

@ -11,10 +11,10 @@
/* Location tracking support --- simpler than bison's default */
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \
if (N) \
(Current) = (Rhs)[1]; \
else \
(Current) = (Rhs)[0]; \
if (N) \
(Current) = (Rhs)[1]; \
else \
(Current) = (Rhs)[0]; \
} while (0)
/*
@ -42,10 +42,10 @@ char *input_filename = NULL;
static int FoundInto = 0;
static int initializer = 0;
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 char *actual_startline[STRUCT_DEPTH];
static int varchar_counter = 1;
static int varchar_counter = 1;
/* temporarily store struct members while creating the data structure */
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
@ -105,7 +105,7 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
fclose(yyout);
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);
}
}
@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
newvar = ptr->variable;
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;
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++);
}
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)
sprintf(temp, "%d, &(", ecpg_internal_var++);
else
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);
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++);
}
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);
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++);
}
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++);
}
}
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++);
}
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
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 */
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
original_var = ptr->indicator->name;
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);
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++);
}
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);
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++);
}
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++);
}
}
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++);
}
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++);
}
/* 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);
@ -407,14 +505,15 @@ add_additional_variables(char *name, bool insert)
}
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 */
struct typedefs *ptr, *this;
if ((type_enum == ECPGt_struct ||
type_enum == ECPGt_union) &&
initializer == 1)
type_enum == ECPGt_union) &&
initializer == 1)
mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
else if (INFORMIX_MODE && strcmp(name, "string") == 0)
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
%union {
double dval;
char *str;
int ival;
int ival;
struct when action;
struct index index;
int tagname;

View File

@ -1,22 +1,22 @@
/* src/interfaces/ecpg/preproc/ecpg.trailer */
statements: /*EMPTY*/
| statements statement
;
| statements statement
;
statement: ecpgstart at stmt ';' { connection = NULL; }
| ecpgstart stmt ';'
| ecpgstart ECPGVarDeclaration
{
fprintf(yyout, "%s", $2);
free($2);
output_line_number();
}
| ECPGDeclaration
| c_thing { fprintf(yyout, "%s", $1); free($1); }
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
| '{' { braces_open++; fputs("{", yyout); }
| '}'
statement: ecpgstart at stmt ';' { connection = NULL; }
| ecpgstart stmt ';'
| ecpgstart ECPGVarDeclaration
{
fprintf(yyout, "%s", $2);
free($2);
output_line_number();
}
| ECPGDeclaration
| c_thing { fprintf(yyout, "%s", $1); free($1); }
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
| '{' { braces_open++; fputs("{", yyout); }
| '}'
{
remove_typedefs(braces_open);
remove_variables(braces_open--);
@ -27,7 +27,7 @@ statement: ecpgstart at stmt ';' { connection = NULL; }
}
fputs("}", yyout);
}
;
;
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
$$ = cat_str(6, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7);
}
;
;
at: AT connection_object
{
connection = $2;
/*
* Do we have a variable as connection target?
* Remove the variable from the variable
* list or else it will be used twice
*/
if (argsinsert != NULL)
argsinsert = NULL;
}
;
{
connection = $2;
/*
* Do we have a variable as connection target? Remove the variable
* from the variable list or else it will be used twice.
*/
if (argsinsert != NULL)
argsinsert = NULL;
}
;
/*
* the exec sql connect statement: connect to the given database
@ -238,12 +237,14 @@ opt_options: Op connect_options
$$ = make2_str(mm_strdup("?"), $2);
}
| /*EMPTY*/ { $$ = EMPTY; }
| /*EMPTY*/ { $$ = EMPTY; }
;
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)
mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
@ -253,7 +254,7 @@ connect_options: ColId opt_opt_value
$$ = cat_str(3, make2_str($1, $2), $3, $4);
}
;
;
opt_opt_value: /*EMPTY*/
{ $$ = EMPTY; }
@ -265,21 +266,22 @@ opt_opt_value: /*EMPTY*/
{ $$ = make2_str(mm_strdup("="), $2); }
;
prepared_name: name {
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
$$ = $1;
else /* not quoted => convert to lowercase */
{
size_t i;
prepared_name: name
{
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
$$ = $1;
else /* not quoted => convert to lowercase */
{
size_t i;
for (i = 0; i< strlen($1); i++)
$1[i] = tolower((unsigned char) $1[i]);
for (i = 0; i< strlen($1); i++)
$1[i] = tolower((unsigned char) $1[i]);
$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
}
}
| char_variable { $$ = $1; }
;
$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
}
}
| char_variable { $$ = $1; }
;
/*
* 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
{
/* re-definition is a bug */
if ($2[0] == ':')
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
else
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
}
}
@ -401,8 +403,8 @@ vt_declarations: single_vt_declaration { $$ = $1; }
| vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
;
variable_declarations: var_declaration { $$ = $1; }
| variable_declarations var_declaration { $$ = cat2_str($1, $2); }
variable_declarations: var_declaration { $$ = $1; }
| variable_declarations var_declaration { $$ = cat2_str($1, $2); }
;
type_declaration: S_TYPEDEF
@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT
ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
$$ = mm_strdup("struct");
}
| UNION { $$ = mm_strdup("union"); }
| UNION
{
$$ = mm_strdup("union");
}
;
simple_type: unsigned_type { $$=$1; }
@ -838,8 +843,8 @@ variable_list: variable
variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
{
struct ECPGtype * type;
char *dimension = $3.index1; /* dimension of array */
char *length = $3.index2; /* length of string */
char *dimension = $3.index1; /* dimension of array */
char *length = $3.index2; /* length of string */
char *dim_str;
char *vcn;
@ -991,8 +996,8 @@ opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
| ecpg_using { $$ = $1; }
;
ecpg_using: USING using_list { $$ = EMPTY; }
| using_descriptor { $$ = $1; }
ecpg_using: USING using_list { $$ = EMPTY; }
| using_descriptor { $$ = $1; }
;
using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
@ -1041,10 +1046,10 @@ UsingValue: UsingConst
UsingConst: Iconst { $$ = $1; }
| '+' 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 { $$ = 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_bconst { $$ = $1; }
| ecpg_xconst { $$ = $1; }
@ -1094,7 +1099,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
;
opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
| /* EMPTY */ { $$ = EMPTY; }
| /* EMPTY */ { $$ = EMPTY; }
;
/*
@ -1106,7 +1111,7 @@ opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
/*
* allocate a descriptor
*/
ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
{
add_descriptor($3,connection);
$$ = $3;
@ -1155,16 +1160,19 @@ ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
}
;
IntConstVar: Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
IntConstVar: Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1;
}
| cvariable { $$ = $1; }
;
sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1;
}
| cvariable
{
$$ = $1;
}
;
desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
;
@ -1198,49 +1206,56 @@ ECPGSetDescItem: descriptor_item '=' AllConstVar
}
;
AllConstVar: ecpg_fconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
AllConstVar: ecpg_fconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1;
}
| IntConstVar { $$ = $1; }
| '-' ecpg_fconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(mm_strdup("-"), $2);
sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1;
}
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
| '-' Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(mm_strdup("-"), $2);
| IntConstVar
{
$$ = $1;
}
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
| ecpg_sconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = $1 + 1;
| '-' ecpg_fconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(mm_strdup("-"), $2);
var[strlen(var) - 1] = '\0';
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
| '-' Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(mm_strdup("-"), $2);
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
| ecpg_sconst
{
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; }
| DATA_P { $$ = ECPGd_data; }
| 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_KEY_MEMBER { $$ = ECPGd_key_member; }
| SQL_LENGTH { $$ = ECPGd_length; }
@ -1295,8 +1310,8 @@ ECPGTypedef: TYPE_P
}
;
opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
| /*EMPTY*/ { $$ = EMPTY; }
opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
| /*EMPTY*/ { $$ = EMPTY; }
;
/*
@ -1452,7 +1467,7 @@ action : CONTINUE_P
/* additional unreserved keywords */
ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
;
ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); }
@ -1730,8 +1745,8 @@ ecpg_sconst:
$$[strlen($1)+3]='\0';
free($1);
}
| UCONST { $$ = $1; }
| DOLCONST { $$ = $1; }
| UCONST { $$ = $1; }
| DOLCONST { $$ = $1; }
;
ecpg_xconst: XCONST { $$ = make_name(); } ;
@ -1832,7 +1847,7 @@ c_anything: ecpg_ident { $$ = $1; }
| '[' { $$ = mm_strdup("["); }
| ']' { $$ = mm_strdup("]"); }
| '=' { $$ = mm_strdup("="); }
| ':' { $$ = mm_strdup(":"); }
| ':' { $$ = mm_strdup(":"); }
;
DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
@ -1855,12 +1870,12 @@ Iresult: Iconst { $$ = $1; }
execute_rest: /* EMPTY */ { $$ = EMPTY; }
| ecpg_using ecpg_into { $$ = EMPTY; }
| ecpg_into ecpg_using { $$ = EMPTY; }
| ecpg_using { $$ = EMPTY; }
| ecpg_into { $$ = EMPTY; }
| ecpg_using { $$ = EMPTY; }
| ecpg_into { $$ = EMPTY; }
;
ecpg_into: INTO into_list { $$ = EMPTY; }
| into_descriptor { $$ = $1; }
| into_descriptor { $$ = $1; }
;
ecpg_fetch_into: ecpg_into { $$ = $1; }

View File

@ -27,7 +27,7 @@
extern YYSTYPE yylval;
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 char *scanbuf;
@ -37,7 +37,7 @@ static char *scanbuf;
* 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.
*/
static char *literalbuf = NULL; /* expandable buffer */
static char *literalbuf = NULL; /* expandable buffer */
static int literallen; /* actual current length */
static int literalalloc; /* current allocated buffer size */
@ -62,8 +62,8 @@ struct _yy_buffer
{
YY_BUFFER_STATE buffer;
long lineno;
char *filename;
struct _yy_buffer *next;
char *filename;
struct _yy_buffer *next;
} *yy_buffer = NULL;
static char *old;
@ -142,7 +142,7 @@ xhinside [^']*
xnstart [nN]{quote}
/* Quoted string that allows backslash escapes */
xestart [eE]{quote}
xestart [eE]{quote}
xeinside [^\\']+
xeescape [\\][^0-7]
xeoctesc [\\][0-7]{1,3}
@ -317,14 +317,14 @@ other .
/* some stuff needed for ecpg */
exec [eE][xX][eE][cC]
sql [sS][qQ][lL]
sql [sS][qQ][lL]
define [dD][eE][fF][iI][nN][eE]
include [iI][nN][cC][lL][uU][dD][eE]
include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT]
import [iI][mM][pP][oO][rR][tT]
include [iI][nN][cC][lL][uU][dD][eE]
include_next [iI][nN][cC][lL][uU][dD][eE]_[nN][eE][xX][tT]
import [iI][mM][pP][oO][rR][tT]
undef [uU][nN][dD][eE][fF]
if [iI][fF]
if [iI][fF]
ifdef [iI][fF][dD][eE][fF]
ifndef [iI][fF][nN][dD][eE][fF]
else [eE][lL][sS][eE]
@ -335,10 +335,10 @@ struct [sS][tT][rR][uU][cC][tT]
exec_sql {exec}{space}*{sql}{space}*
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 */
cppinclude {space}*#{include}{space}*
cppinclude {space}*#{include}{space}*
cppinclude_next {space}*#{include_next}{space}*
/* 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})*.
}
<xc>{xcstart} {
xcdepth++;
/* Put back any characters past slash-star; see above */
yyless(2);
/* Put back any characters past slash-star; see above */
yyless(2);
fputs("/*", yyout);
}
@ -398,7 +398,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xc>{xcinside} { ECHO; }
<xc>{op_chars} { ECHO; }
<xc>\*+ { ECHO; }
<xc>\*+ { ECHO; }
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); }
@ -431,7 +431,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
addlitchar('x');
}
<xh>{quotestop} |
<xh>{quotefail} {
<xh>{quotefail} {
yyless(1);
BEGIN(SQL);
yylval.str = mm_strdup(literalbuf);
@ -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"); }
<SQL>{xnstart} {
<SQL>{xnstart} {
/* National character.
* Transfer it as-is to the backend.
*/
@ -508,11 +508,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
<xe>{xeinside} { addlit(yytext, yyleng); }
<xe>{xeunicode} { addlit(yytext, yyleng); }
<xe>{xeescape} { addlit(yytext, yyleng); }
<xe>{xeescape} { addlit(yytext, yyleng); }
<xe>{xeoctesc} { addlit(yytext, yyleng); }
<xe>{xehexesc} { addlit(yytext, yyleng); }
<xq,xqc,xe,xn,xus>{quotecontinue} { /* ignore */ }
<xe>. {
<xe>. {
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
@ -523,14 +523,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
/* and treat it as {other} */
return yytext[0];
}
<SQL>{dolqdelim} {
<SQL>{dolqdelim} {
token_start = yytext;
dolqstart = mm_strdup(yytext);
BEGIN(xdolq);
startlit();
addlit(yytext, yyleng);
}
<xdolq>{dolqdelim} {
<xdolq>{dolqdelim} {
if (strcmp(yytext, dolqstart) == 0)
{
addlit(yytext, yyleng);
@ -541,22 +541,22 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
else
{
/*
/*
* When we fail to match $...$ to dolqstart, transfer
* the $... part to the output, but put back the final
* $ for rescanning. Consider $delim$...$junk$delim$
*/
addlit(yytext, yyleng-1);
yyless(yyleng-1);
addlit(yytext, yyleng-1);
yyless(yyleng-1);
}
}
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
<xdolq>{dolqfailed} { addlit(yytext, yyleng); }
<xdolq>{other} {
/* single quote or dollar sign */
addlitchar(yytext[0]);
}
<xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); }
<xdolq><<EOF>> { base_yyerror("unterminated dollar-quoted string"); }
<SQL>{xdstart} {
state_before = YYSTATE;
BEGIN(xd);
@ -739,7 +739,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
return(CVARIABLE);
}
<SQL>{identifier} {
const ScanKeyword *keyword;
const ScanKeyword *keyword;
if (!isdefine())
{
@ -798,10 +798,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(incl);
}
else
{
{
yylval.str = mm_strdup(yytext);
return(CPP_LINE);
}
}
}
<C>{cppinclude_next} {
if (system_includes)
@ -810,16 +810,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(incl);
}
else
{
{
yylval.str = mm_strdup(yytext);
return(CPP_LINE);
}
}
}
<C,SQL>{cppline} {
yylval.str = mm_strdup(yytext);
return(CPP_LINE);
}
<C>{identifier} {
<C>{identifier} {
const ScanKeyword *keyword;
/*
@ -893,7 +893,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
}
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{informix_special}{undef}{space}* {
<C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
{
@ -937,9 +937,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(C);
}
<undef>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
yyterminate();
<undef>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command");
yyterminate();
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{informix_special}{include}{space}* {
@ -1171,17 +1171,17 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
}
<<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;\"");
}
}
yyterminate();
}
else
{
else
{
struct _yy_buffer *yb = yy_buffer;
int i;
struct _defines *ptr;
@ -1213,9 +1213,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (i != 0)
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
lex_init(void)
@ -1278,24 +1278,24 @@ parse_include(void)
{
/* got the include file name */
struct _yy_buffer *yb;
struct _include_path *ip;
char inc_file[MAXPGPATH];
unsigned int i;
struct _include_path *ip;
char inc_file[MAXPGPATH];
unsigned int i;
yb = mm_alloc(sizeof(struct _yy_buffer));
yb = mm_alloc(sizeof(struct _yy_buffer));
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = input_filename;
yb->next = yy_buffer;
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = input_filename;
yb->next = yy_buffer;
yy_buffer = yb;
yy_buffer = yb;
/*
/*
* skip the ";" if there is one and trailing whitespace. Note that
* 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--)
;
@ -1310,7 +1310,7 @@ parse_include(void)
/* If file name is enclosed in '"' remove these and look only in '.' */
/* Informix does look into all include paths though, except filename starts with '/' */
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';
memmove(yytext, yytext+1, strlen(yytext));
@ -1335,8 +1335,8 @@ parse_include(void)
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)
{
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)
yylineno = 1;
output_line_number();
BEGIN(C);
BEGIN(C);
}
/*
@ -1421,9 +1421,9 @@ static bool isinformixdefine(void)
if (strcmp(yytext, "dec_t") == 0)
new = "decimal";
else if (strcmp(yytext, "intrvl_t") == 0)
new = "interval";
new = "interval";
else if (strcmp(yytext, "dtime_t") == 0)
new = "timestamp";
new = "timestamp";
if (new)
{

View File

@ -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_next_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);
static char *NameOfDatum(PLwdatum *wdatum);
static void check_assignable(PLpgSQL_datum *datum, int location);
@ -102,7 +102,7 @@ static PLpgSQL_type *parse_datatype(const char *string, int location);
static void check_labels(const char *start_label,
const char *end_label,
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);
static List *read_raise_options(void);
@ -134,8 +134,8 @@ static List *read_raise_options(void);
char *name;
int lineno;
PLpgSQL_datum *scalar;
PLpgSQL_rec *rec;
PLpgSQL_row *row;
PLpgSQL_rec *rec;
PLpgSQL_row *row;
} forvariable;
struct
{
@ -1069,7 +1069,7 @@ opt_expr_until_when :
plpgsql_push_back_token(K_WHEN);
$$ = expr;
}
;
;
case_when_list : case_when_list case_when
{
@ -1859,7 +1859,7 @@ stmt_open : K_OPEN cursor_variable
if ($2->cursor_explicit_expr == NULL)
{
/* be nice if we could use opt_scrollable here */
tok = yylex();
tok = yylex();
if (tok_is_keyword(tok, &yylval,
K_NO, "no"))
{
@ -2077,9 +2077,9 @@ proc_exception : K_WHEN proc_conditions K_THEN proc_sect
PLpgSQL_exception *new;
new = palloc0(sizeof(PLpgSQL_exception));
new->lineno = plpgsql_location_to_lineno(@1);
new->lineno = plpgsql_location_to_lineno(@1);
new->conditions = $2;
new->action = $4;
new->action = $4;
$$ = new;
}
@ -2451,7 +2451,7 @@ read_sql_construct(int until,
expr->query = pstrdup(ds.data);
expr->plan = NULL;
expr->paramnos = NULL;
expr->ns = plpgsql_ns_top();
expr->ns = plpgsql_ns_top();
pfree(ds.data);
if (valid_sql)
@ -2651,7 +2651,7 @@ make_execsql_stmt(int firsttoken, int location)
expr->query = pstrdup(ds.data);
expr->plan = NULL;
expr->paramnos = NULL;
expr->ns = plpgsql_ns_top();
expr->ns = plpgsql_ns_top();
pfree(ds.data);
check_sql_expr(expr->query, location, 0);
@ -2688,7 +2688,7 @@ read_fetch_direction(void)
/* set direction defaults: */
fetch->direction = FETCH_FORWARD;
fetch->how_many = 1;
fetch->expr = NULL;
fetch->expr = NULL;
fetch->returns_multiple_rows = false;
tok = yylex();
@ -3478,7 +3478,7 @@ static PLpgSQL_stmt *
make_case(int location, PLpgSQL_expr *t_expr,
List *case_when_list, List *else_stmts)
{
PLpgSQL_stmt_case *new;
PLpgSQL_stmt_case *new;
new = palloc(sizeof(PLpgSQL_stmt_case));
new->cmd_type = PLPGSQL_STMT_CASE;

View File

@ -96,12 +96,12 @@ teardown { return(TEARDOWN); }
static void
addlitchar(char c)
{
if (litbufpos >= sizeof(litbuf) - 1)
{
fprintf(stderr, "SQL step too long\n");
exit(1);
}
litbuf[litbufpos++] = c;
if (litbufpos >= sizeof(litbuf) - 1)
{
fprintf(stderr, "SQL step too long\n");
exit(1);
}
litbuf[litbufpos++] = c;
}
void