Commit 9f0ffa22 authored by Michael Meskes's avatar Michael Meskes

*** empty log message ***

parent faf7d781
...@@ -609,3 +609,11 @@ Fri Jun 25 07:17:10 CEST 1999 ...@@ -609,3 +609,11 @@ Fri Jun 25 07:17:10 CEST 1999
- Changed error message in ecpglib.c to list correct database name. - Changed error message in ecpglib.c to list correct database name.
- Set library version to 3.0.0 - Set library version to 3.0.0
- Set ecpg version to 2.6.0 - Set ecpg version to 2.6.0
Mon Jul 19 07:53:20 CEST 1999
- Synced preproc.y with gram.y.
- Synced pgc.l with scan.l.
- Fixed quoting bug in ecpglib.c
- Set ecpg version to 2.6.1
- Set library version to 3.0.1
...@@ -13,8 +13,6 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS ...@@ -13,8 +13,6 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS
The line numbering is not exact. The line numbering is not exact.
Inside an SQL statement quoting only works with SQL92 style double quotes: ''.
Missing statements: Missing statements:
- exec sql allocate - exec sql allocate
- exec sql deallocate - exec sql deallocate
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.44 1999/06/30 23:57:23 tgl Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.45 1999/07/19 12:37:46 meskes Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
NAME= ecpg NAME= ecpg
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 0.0 SO_MINOR_VERSION= 0.1
SRCDIR= @top_srcdir@ SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global include $(SRCDIR)/Makefile.global
......
...@@ -209,8 +209,8 @@ add_mem(void *ptr, int lineno) ...@@ -209,8 +209,8 @@ add_mem(void *ptr, int lineno)
auto_allocs = am; auto_allocs = am;
} }
/* This function returns a newly malloced string that has the ' and \ /* This function returns a newly malloced string that has the \
in the argument quoted with \. in the argument quoted with \ and the ' quote with ' as SQL92 says.
*/ */
static static
char * char *
...@@ -228,8 +228,11 @@ quote_postgres(char *arg, int lineno) ...@@ -228,8 +228,11 @@ quote_postgres(char *arg, int lineno)
switch (arg[i]) switch (arg[i])
{ {
case '\'': case '\'':
res[ri++] = '\'';
break;
case '\\': case '\\':
res[ri++] = '\\'; res[ri++] = '\\';
break;
default: default:
; ;
} }
......
...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global ...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2 MAJOR_VERSION=2
MINOR_VERSION=6 MINOR_VERSION=6
PATCHLEVEL=0 PATCHLEVEL=1
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......
...@@ -132,7 +132,7 @@ identifier {letter}{letter_or_digit}* ...@@ -132,7 +132,7 @@ identifier {letter}{letter_or_digit}*
typecast "::" typecast "::"
self [,()\[\].;$\:\+\-\*\/\%\<\>\=\|] self [,()\[\].;$\:\+\-\*\/\%\^\<\>\=\|]
op_and_self [\~\!\@\#\^\&\|\?\$\:\+\-\*\/\%\<\>\=] op_and_self [\~\!\@\#\^\&\|\?\$\:\+\-\*\/\%\<\>\=]
operator {op_and_self}+ operator {op_and_self}+
......
...@@ -754,6 +754,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -754,6 +754,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%nonassoc IS %nonassoc IS
%left '+' '-' %left '+' '-'
%left '*' '/' '%' %left '*' '/' '%'
%left '^'
%left '|' /* this is the relation union op, not logical or */ %left '|' /* this is the relation union op, not logical or */
/* Unary Operators */ /* Unary Operators */
%right ':' %right ':'
...@@ -772,15 +773,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -772,15 +773,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <str> ColConstraint ColConstraintElem default_list NumericOnly FloatOnly %type <str> ColConstraint ColConstraintElem default_list NumericOnly FloatOnly
%type <str> OptTableElementList OptTableElement TableConstraint %type <str> OptTableElementList OptTableElement TableConstraint
%type <str> ConstraintElem key_actions constraint_list ColPrimaryKey %type <str> ConstraintElem key_actions constraint_list ColPrimaryKey
%type <str> res_target_list res_target_el res_target_list2 %type <str> target_list target_el update_target_list
%type <str> res_target_el2 opt_id relation_name database_name %type <str> update_target_el opt_id relation_name database_name
%type <str> access_method attr_name class index_name name func_name %type <str> access_method attr_name class index_name name func_name
%type <str> file_name AexprConst ParamNo TypeId %type <str> file_name AexprConst ParamNo TypeId
%type <str> in_expr_nodes not_in_expr_nodes a_expr b_expr %type <str> in_expr_nodes not_in_expr_nodes a_expr b_expr
%type <str> opt_indirection expr_list extract_list extract_arg %type <str> opt_indirection expr_list extract_list extract_arg
%type <str> position_list position_expr substr_list substr_from %type <str> position_list substr_list substr_from
%type <str> trim_list in_expr substr_for not_in_expr attr attrs %type <str> trim_list in_expr substr_for not_in_expr attr attrs
%type <str> Typename Array Generic Numeric generic opt_float opt_numeric %type <str> Typename SimpleTypename Generic Numeric generic opt_float opt_numeric
%type <str> opt_decimal Character character opt_varying opt_charset %type <str> opt_decimal Character character opt_varying opt_charset
%type <str> opt_collate Datetime datetime opt_timezone opt_interval %type <str> opt_collate Datetime datetime opt_timezone opt_interval
%type <str> numeric a_expr_or_null row_expr row_descriptor row_list %type <str> numeric a_expr_or_null row_expr row_descriptor row_list
...@@ -848,8 +849,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -848,8 +849,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <action> action %type <action> action
%type <index> opt_array_bounds nest_array_bounds opt_type_array_bounds %type <index> opt_array_bounds opt_type_array_bounds
%type <index> nest_type_array_bounds
%type <ival> Iresult %type <ival> Iresult
%% %%
...@@ -1237,6 +1237,9 @@ ClosePortalStmt: CLOSE opt_id ...@@ -1237,6 +1237,9 @@ ClosePortalStmt: CLOSE opt_id
} }
; ;
opt_id: ColId { $$ = $1; }
| /*EMPTY*/ { $$ = NULL; }
;
/***************************************************************************** /*****************************************************************************
* *
...@@ -1442,6 +1445,8 @@ default_expr: AexprConst ...@@ -1442,6 +1445,8 @@ default_expr: AexprConst
{ $$ = cat3_str($1, make1_str("%"), $3); } { $$ = cat3_str($1, make1_str("%"), $3); }
| default_expr '*' default_expr | default_expr '*' default_expr
{ $$ = cat3_str($1, make1_str("*"), $3); } { $$ = cat3_str($1, make1_str("*"), $3); }
| default_expr '^' default_expr
{ $$ = cat3_str($1, make1_str("^"), $3); }
| default_expr '=' default_expr | default_expr '=' default_expr
{ yyerror("boolean expressions not supported in DEFAULT"); } { yyerror("boolean expressions not supported in DEFAULT"); }
| default_expr '<' default_expr | default_expr '<' default_expr
...@@ -1564,6 +1569,8 @@ constraint_expr: AexprConst ...@@ -1564,6 +1569,8 @@ constraint_expr: AexprConst
{ $$ = cat3_str($1, make1_str("%"), $3); } { $$ = cat3_str($1, make1_str("%"), $3); }
| constraint_expr '*' constraint_expr | constraint_expr '*' constraint_expr
{ $$ = cat3_str($1, make1_str("*"), $3); } { $$ = cat3_str($1, make1_str("*"), $3); }
| constraint_expr '^' constraint_expr
{ $$ = cat3_str($1, make1_str("^"), $3); }
| constraint_expr '=' constraint_expr | constraint_expr '=' constraint_expr
{ $$ = cat3_str($1, make1_str("="), $3); } { $$ = cat3_str($1, make1_str("="), $3); }
| constraint_expr '<' constraint_expr | constraint_expr '<' constraint_expr
...@@ -2631,7 +2638,7 @@ InsertStmt: INSERT INTO relation_name insert_rest ...@@ -2631,7 +2638,7 @@ InsertStmt: INSERT INTO relation_name insert_rest
} }
; ;
insert_rest: VALUES '(' res_target_list2 ')' insert_rest: VALUES '(' target_list ')'
{ {
$$ = make3_str(make1_str("values("), $3, make1_str(")")); $$ = make3_str(make1_str("values("), $3, make1_str(")"));
} }
...@@ -2643,7 +2650,7 @@ insert_rest: VALUES '(' res_target_list2 ')' ...@@ -2643,7 +2650,7 @@ insert_rest: VALUES '(' res_target_list2 ')'
{ {
$$ = $1; $$ = $1;
} }
| '(' columnList ')' VALUES '(' res_target_list2 ')' | '(' columnList ')' VALUES '(' target_list ')'
{ {
$$ = make5_str(make1_str("("), $2, make1_str(") values ("), $6, make1_str(")")); $$ = make5_str(make1_str("("), $2, make1_str(") values ("), $6, make1_str(")"));
} }
...@@ -2713,7 +2720,7 @@ opt_lmode: SHARE { $$ = make1_str("share"); } ...@@ -2713,7 +2720,7 @@ opt_lmode: SHARE { $$ = make1_str("share"); }
*****************************************************************************/ *****************************************************************************/
UpdateStmt: UPDATE relation_name UpdateStmt: UPDATE relation_name
SET res_target_list SET update_target_list
from_clause from_clause
where_clause where_clause
{ {
...@@ -2822,7 +2829,7 @@ select_clause: '(' select_clause ')' ...@@ -2822,7 +2829,7 @@ select_clause: '(' select_clause ')'
} }
; ;
SubSelect: SELECT opt_unique res_target_list2 SubSelect: SELECT opt_unique target_list
result from_clause where_clause result from_clause where_clause
group_clause having_clause group_clause having_clause
{ {
...@@ -3112,13 +3119,13 @@ relation_expr: relation_name ...@@ -3112,13 +3119,13 @@ relation_expr: relation_name
$$ = cat2_str($1, make1_str("*")); $$ = cat2_str($1, make1_str("*"));
} }
opt_array_bounds: '[' ']' nest_array_bounds opt_array_bounds: '[' ']' opt_array_bounds
{ {
$$.index1 = 0; $$.index1 = 0;
$$.index2 = $3.index1; $$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str); $$.str = cat2_str(make1_str("[]"), $3.str);
} }
| '[' Iresult ']' nest_array_bounds | '[' Iresult ']' opt_array_bounds
{ {
char *txt = mm_alloc(20L); char *txt = mm_alloc(20L);
...@@ -3135,29 +3142,6 @@ opt_array_bounds: '[' ']' nest_array_bounds ...@@ -3135,29 +3142,6 @@ opt_array_bounds: '[' ']' nest_array_bounds
} }
; ;
nest_array_bounds: '[' ']' nest_array_bounds
{
$$.index1 = 0;
$$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str);
}
| '[' Iresult ']' nest_array_bounds
{
char *txt = mm_alloc(20L);
sprintf (txt, "%d", $2);
$$.index1 = $2;
$$.index2 = $4.index1;
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
}
| /* EMPTY */
{
$$.index1 = -1;
$$.index2 = -1;
$$.str= make1_str("");
}
;
Iresult: Iconst { $$ = atol($1); } Iresult: Iconst { $$ = atol($1); }
| '(' Iresult ')' { $$ = $2; } | '(' Iresult ')' { $$ = $2; }
| Iresult '+' Iresult { $$ = $1 + $3; } | Iresult '+' Iresult { $$ = $1 + $3; }
...@@ -3178,17 +3162,17 @@ Iresult: Iconst { $$ = atol($1); } ...@@ -3178,17 +3162,17 @@ Iresult: Iconst { $$ = atol($1); }
* *
*****************************************************************************/ *****************************************************************************/
Typename: Array opt_array_bounds Typename: SimpleTypename opt_array_bounds
{ {
$$ = cat2_str($1, $2.str); $$ = cat2_str($1, $2.str);
} }
| SETOF Array | SETOF SimpleTypename
{ {
$$ = cat2_str(make1_str("setof"), $2); $$ = cat2_str(make1_str("setof"), $2);
} }
; ;
Array: Generic { $$ = $1; } SimpleTypename: Generic { $$ = $1; }
| Datetime { $$ = $1; } | Datetime { $$ = $1; }
| Numeric { $$ = $1; } | Numeric { $$ = $1; }
| Character { $$ = $1; } | Character { $$ = $1; }
...@@ -3349,7 +3333,7 @@ Character: character '(' Iconst ')' ...@@ -3349,7 +3333,7 @@ Character: character '(' Iconst ')'
yyerror(errortext); yyerror(errortext);
} }
else if (atol($3) > MaxAttrSize) { else if (atol($3) > MaxAttrSize) {
sprintf(errortext, "length for type '%s' cannot exceed %ld",$1,(long) MaxAttrSize); sprintf(errortext, "length for type '%s' cannot exceed %ld", $1, MaxAttrSize);
yyerror(errortext); yyerror(errortext);
} }
...@@ -3514,24 +3498,28 @@ row_list: row_list ',' a_expr ...@@ -3514,24 +3498,28 @@ row_list: row_list ',' a_expr
* if surrounded by parens. * if surrounded by parens.
*/ */
a_expr: attr opt_indirection a_expr: attr
{ {
$$ = cat2_str($1, $2); $$ = $1;
} }
| row_expr | row_expr
{ $$ = $1; } { $$ = $1; }
| AexprConst | AexprConst
{ $$ = $1; } { $$ = $1; }
| ColId | ColId opt_indirection
{ {
$$ = $1; $$ = cat2_str($1, $2);
} }
| '-' a_expr %prec UMINUS | '-' a_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); } { $$ = cat2_str(make1_str("-"), $2); }
| '%' a_expr | '%' a_expr
{ $$ = cat2_str(make1_str("%"), $2); } { $$ = cat2_str(make1_str("%"), $2); }
| '^' a_expr
{ $$ = cat2_str(make1_str("^"), $2); }
| a_expr '%' | a_expr '%'
{ $$ = cat2_str($1, make1_str("%")); } { $$ = cat2_str($1, make1_str("%")); }
| a_expr '^'
{ $$ = cat2_str($1, make1_str("^")); }
| a_expr '+' a_expr | a_expr '+' a_expr
{ $$ = cat3_str($1, make1_str("+"), $3); } { $$ = cat3_str($1, make1_str("+"), $3); }
| a_expr '-' a_expr | a_expr '-' a_expr
...@@ -3542,6 +3530,8 @@ a_expr: attr opt_indirection ...@@ -3542,6 +3530,8 @@ a_expr: attr opt_indirection
{ $$ = cat3_str($1, make1_str("%"), $3); } { $$ = cat3_str($1, make1_str("%"), $3); }
| a_expr '*' a_expr | a_expr '*' a_expr
{ $$ = cat3_str($1, make1_str("*"), $3); } { $$ = cat3_str($1, make1_str("*"), $3); }
| a_expr '^' a_expr
{ $$ = cat3_str($1, make1_str("^"), $3); }
| a_expr '<' a_expr | a_expr '<' a_expr
{ $$ = cat3_str($1, make1_str("<"), $3); } { $$ = cat3_str($1, make1_str("<"), $3); }
| a_expr '>' a_expr | a_expr '>' a_expr
...@@ -3826,22 +3816,26 @@ a_expr: attr opt_indirection ...@@ -3826,22 +3816,26 @@ a_expr: attr opt_indirection
* defined by a_expr. b_expr is used in BETWEEN clauses * defined by a_expr. b_expr is used in BETWEEN clauses
* to eliminate parser ambiguities stemming from the AND keyword. * to eliminate parser ambiguities stemming from the AND keyword.
*/ */
b_expr: attr opt_indirection b_expr: attr
{ {
$$ = cat2_str($1, $2); $$ = $1
} }
| AexprConst | AexprConst
{ $$ = $1; } { $$ = $1; }
| ColId | ColId opt_indirection
{ {
$$ = $1; $$ = cat2_str($1, $2);
} }
| '-' b_expr %prec UMINUS | '-' b_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); } { $$ = cat2_str(make1_str("-"), $2); }
| '%' b_expr | '%' b_expr
{ $$ = cat2_str(make1_str("%"), $2); } { $$ = cat2_str(make1_str("%"), $2); }
| '^' b_expr
{ $$ = cat2_str(make1_str("^"), $2); }
| b_expr '%' | b_expr '%'
{ $$ = cat2_str($1, make1_str("%")); } { $$ = cat2_str($1, make1_str("%")); }
| b_expr '^'
{ $$ = cat2_str($1, make1_str("^")); }
| b_expr '+' b_expr | b_expr '+' b_expr
{ $$ = cat3_str($1, make1_str("+"), $3); } { $$ = cat3_str($1, make1_str("+"), $3); }
| b_expr '-' b_expr | b_expr '-' b_expr
...@@ -3852,6 +3846,8 @@ b_expr: attr opt_indirection ...@@ -3852,6 +3846,8 @@ b_expr: attr opt_indirection
{ $$ = cat3_str($1, make1_str("%"), $3); } { $$ = cat3_str($1, make1_str("%"), $3); }
| b_expr '*' b_expr | b_expr '*' b_expr
{ $$ = cat3_str($1, make1_str("*"), $3); } { $$ = cat3_str($1, make1_str("*"), $3); }
| b_expr '^' b_expr
{ $$ = cat3_str($1, make1_str("^"), $3); }
/* not possible in embedded sql | ':' b_expr /* not possible in embedded sql | ':' b_expr
{ $$ = cat2_str(make1_str(":"), $2); } { $$ = cat2_str(make1_str(":"), $2); }
*/ */
...@@ -3979,87 +3975,13 @@ extract_arg: datetime { $$ = $1; } ...@@ -3979,87 +3975,13 @@ extract_arg: datetime { $$ = $1; }
| TIMEZONE_MINUTE { $$ = make1_str("timezone_minute"); } | TIMEZONE_MINUTE { $$ = make1_str("timezone_minute"); }
; ;
position_list: position_expr IN position_expr /* position_list uses b_expr not a_expr to avoid conflict with general IN */
position_list: b_expr IN b_expr
{ $$ = cat3_str($1, make1_str("in"), $3); } { $$ = cat3_str($1, make1_str("in"), $3); }
| /* EMPTY */ | /* EMPTY */
{ $$ = make1_str(""); } { $$ = make1_str(""); }
; ;
position_expr: attr opt_indirection
{
$$ = cat2_str($1, $2);
}
| AexprConst
{ $$ = $1; }
| '-' position_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); }
| position_expr '+' position_expr
{ $$ = cat3_str($1, make1_str("+"), $3); }
| position_expr '-' position_expr
{ $$ = cat3_str($1, make1_str("-"), $3); }
| position_expr '/' position_expr
{ $$ = cat3_str($1, make1_str("/"), $3); }
| position_expr '%' position_expr
{ $$ = cat3_str($1, make1_str("%"), $3); }
| position_expr '*' position_expr
{ $$ = cat3_str($1, make1_str("*"), $3); }
| '|' position_expr
{ $$ = cat2_str(make1_str("|"), $2); }
| position_expr TYPECAST Typename
{
$$ = cat3_str($1, make1_str("::"), $3);
}
| CAST '(' position_expr AS Typename ')'
{
$$ = cat3_str(make2_str(make1_str("cast("), $3), make1_str("as"), make2_str($5, make1_str(")")));
}
| '(' position_expr ')'
{ $$ = make3_str(make1_str("("), $2, make1_str(")")); }
| position_expr Op position_expr
{ $$ = cat3_str($1, $2, $3); }
| Op position_expr
{ $$ = cat2_str($1, $2); }
| position_expr Op
{ $$ = cat2_str($1, $2); }
| ColId
{
$$ = $1;
}
| func_name '(' ')'
{
$$ = cat2_str($1, make1_str("()"));
}
| func_name '(' expr_list ')'
{
$$ = make4_str($1, make1_str("("), $3, make1_str(")"));
}
| POSITION '(' position_list ')'
{
$$ = make3_str(make1_str("position("), $3, make1_str(")"));
}
| SUBSTRING '(' substr_list ')'
{
$$ = make3_str(make1_str("substring("), $3, make1_str(")"));
}
/* various trim expressions are defined in SQL92 - thomas 1997-07-19 */
| TRIM '(' BOTH trim_list ')'
{
$$ = make3_str(make1_str("trim(both"), $4, make1_str(")"));
}
| TRIM '(' LEADING trim_list ')'
{
$$ = make3_str(make1_str("trim(leading"), $4, make1_str(")"));
}
| TRIM '(' TRAILING trim_list ')'
{
$$ = make3_str(make1_str("trim(trailing"), $4, make1_str(")"));
}
| TRIM '(' trim_list ')'
{
$$ = make3_str(make1_str("trim("), $3, make1_str(")"));
}
;
substr_list: expr_list substr_from substr_for substr_list: expr_list substr_from substr_for
{ {
$$ = cat3_str($1, $2, $3); $$ = cat3_str($1, $2, $3);
...@@ -4163,25 +4085,20 @@ case_default: ELSE a_expr_or_null { $$ = cat2_str(make1_str("else"), $2); } ...@@ -4163,25 +4085,20 @@ case_default: ELSE a_expr_or_null { $$ = cat2_str(make1_str("else"), $2); }
| /*EMPTY*/ { $$ = make1_str(""); } | /*EMPTY*/ { $$ = make1_str(""); }
; ;
case_arg: attr opt_indirection case_arg: a_expr {
{
$$ = cat2_str($1, $2);
}
| ColId
{
$$ = $1; $$ = $1;
} }
| /*EMPTY*/ | /*EMPTY*/
{ $$ = make1_str(""); } { $$ = make1_str(""); }
; ;
attr: relation_name '.' attrs attr: relation_name '.' attrs opt_indirection
{ {
$$ = make3_str($1, make1_str("."), $3); $$ = make4_str($1, make1_str("."), $3, $4);
} }
| ParamNo '.' attrs | ParamNo '.' attrs opt_indirection
{ {
$$ = make3_str($1, make1_str("."), $3); $$ = make4_str($1, make1_str("."), $3, $4);
} }
; ;
...@@ -4200,40 +4117,15 @@ attrs: attr_name ...@@ -4200,40 +4117,15 @@ attrs: attr_name
* *
*****************************************************************************/ *****************************************************************************/
res_target_list: res_target_list ',' res_target_el /* Target lists as found in SELECT ... and INSERT VALUES ( ... ) */
{ $$ = cat3_str($1, make1_str(","),$3); } target_list: target_list ',' target_el
| res_target_el
{ $$ = $1; }
| '*' { $$ = make1_str("*"); }
;
res_target_el: ColId opt_indirection '=' a_expr_or_null
{
$$ = cat4_str($1, $2, make1_str("="), $4);
}
| attr opt_indirection
{
$$ = cat2_str($1, $2);
}
| relation_name '.' '*'
{
$$ = make2_str($1, make1_str(".*"));
}
;
/*
** target list for select.
** should get rid of the other but is still needed by the defunct select into
** and update (uses a subset)
*/
res_target_list2: res_target_list2 ',' res_target_el2
{ $$ = cat3_str($1, make1_str(","), $3); } { $$ = cat3_str($1, make1_str(","), $3); }
| res_target_el2 | target_el
{ $$ = $1; } { $$ = $1; }
; ;
/* AS is not optional because shift/red conflict with unary ops */ /* AS is not optional because shift/red conflict with unary ops */
res_target_el2: a_expr_or_null AS ColLabel target_el: a_expr_or_null AS ColLabel
{ {
$$ = cat3_str($1, make1_str("as"), $3); $$ = cat3_str($1, make1_str("as"), $3);
} }
...@@ -4251,10 +4143,26 @@ res_target_el2: a_expr_or_null AS ColLabel ...@@ -4251,10 +4143,26 @@ res_target_el2: a_expr_or_null AS ColLabel
} }
; ;
opt_id: ColId { $$ = $1; } /* Target list as found in UPDATE table SET ... */
| /* EMPTY */ { $$ = make1_str(""); } update_target_list: update_target_list ',' update_target_el
{ $$ = cat3_str($1, make1_str(","),$3); }
| update_target_el
{ $$ = $1; }
| '*' { $$ = make1_str("*"); }
;
update_target_el: ColId opt_indirection '=' a_expr_or_null
{
$$ = cat4_str($1, $2, make1_str("="), $4);
}
; ;
/*****************************************************************************
*
* Names and constants
*
*****************************************************************************/
relation_name: SpecialRuleRelation relation_name: SpecialRuleRelation
{ {
$$ = $1; $$ = $1;
...@@ -4303,7 +4211,10 @@ AexprConst: Iconst ...@@ -4303,7 +4211,10 @@ AexprConst: Iconst
{ {
$$ = $1; $$ = $1;
} }
| Typename Sconst /* this rule formerly used Typename, but that causes reduce conf licts
* with subscripted column names ...
*/
| SimpleTypename Sconst
{ {
$$ = cat2_str($1, $2); $$ = cat2_str($1, $2);
} }
...@@ -5170,19 +5081,19 @@ ECPGTypedef: TYPE_P symbol IS ctype opt_type_array_bounds opt_reference ...@@ -5170,19 +5081,19 @@ ECPGTypedef: TYPE_P symbol IS ctype opt_type_array_bounds opt_reference
$$ = cat5_str(cat3_str(make1_str("/* exec sql type"), mm_strdup($2), make1_str("is")), mm_strdup($4.type_str), mm_strdup($5.str), $6, make1_str("*/")); $$ = cat5_str(cat3_str(make1_str("/* exec sql type"), mm_strdup($2), make1_str("is")), mm_strdup($4.type_str), mm_strdup($5.str), $6, make1_str("*/"));
} }
opt_type_array_bounds: '[' ']' nest_type_array_bounds opt_type_array_bounds: '[' ']' opt_type_array_bounds
{ {
$$.index1 = 0; $$.index1 = 0;
$$.index2 = $3.index1; $$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str); $$.str = cat2_str(make1_str("[]"), $3.str);
} }
| '(' ')' nest_type_array_bounds | '(' ')' opt_type_array_bounds
{ {
$$.index1 = 0; $$.index1 = 0;
$$.index2 = $3.index1; $$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str); $$.str = cat2_str(make1_str("[]"), $3.str);
} }
| '[' Iresult ']' nest_type_array_bounds | '[' Iresult ']' opt_type_array_bounds
{ {
char *txt = mm_alloc(20L); char *txt = mm_alloc(20L);
...@@ -5191,7 +5102,7 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds ...@@ -5191,7 +5102,7 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds
$$.index2 = $4.index1; $$.index2 = $4.index1;
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str); $$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
} }
| '(' Iresult ')' nest_type_array_bounds | '(' Iresult ')' opt_type_array_bounds
{ {
char *txt = mm_alloc(20L); char *txt = mm_alloc(20L);
...@@ -5208,43 +5119,6 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds ...@@ -5208,43 +5119,6 @@ opt_type_array_bounds: '[' ']' nest_type_array_bounds
} }
; ;
nest_type_array_bounds: '[' ']' nest_type_array_bounds
{
$$.index1 = 0;
$$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str);
}
| '(' ')' nest_type_array_bounds
{
$$.index1 = 0;
$$.index2 = $3.index1;
$$.str = cat2_str(make1_str("[]"), $3.str);
}
| '[' Iresult ']' nest_type_array_bounds
{
char *txt = mm_alloc(20L);
sprintf (txt, "%d", $2);
$$.index1 = $2;
$$.index2 = $4.index1;
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
}
| '(' Iresult ')' nest_type_array_bounds
{
char *txt = mm_alloc(20L);
sprintf (txt, "%d", $2);
$$.index1 = $2;
$$.index2 = $4.index1;
$$.str = cat4_str(make1_str("["), txt, make1_str("]"), $4.str);
}
| /* EMPTY */
{
$$.index1 = -1;
$$.index2 = -1;
$$.str= make1_str("");
}
;
opt_reference: SQL_REFERENCE { $$ = make1_str("reference"); } opt_reference: SQL_REFERENCE { $$ = make1_str("reference"); }
| /* empty */ { $$ = make1_str(""); } | /* empty */ { $$ = make1_str(""); }
...@@ -5585,24 +5459,28 @@ action : SQL_CONTINUE { ...@@ -5585,24 +5459,28 @@ action : SQL_CONTINUE {
} }
/* some other stuff for ecpg */ /* some other stuff for ecpg */
ecpg_expr: attr opt_indirection ecpg_expr: attr
{ {
$$ = cat2_str($1, $2); $$ = $1;
} }
| row_expr | row_expr
{ $$ = $1; } { $$ = $1; }
| AexprConst | AexprConst
{ $$ = $1; } { $$ = $1; }
| ColId | ColId opt_indirection
{ {
$$ = $1; $$ = cat2_str($1, $2);
} }
| '-' ecpg_expr %prec UMINUS | '-' ecpg_expr %prec UMINUS
{ $$ = cat2_str(make1_str("-"), $2); } { $$ = cat2_str(make1_str("-"), $2); }
| '%' ecpg_expr | '%' ecpg_expr
{ $$ = cat2_str(make1_str("%"), $2); } { $$ = cat2_str(make1_str("%"), $2); }
| '^' ecpg_expr
{ $$ = cat2_str(make1_str("^"), $2); }
| a_expr '%' | a_expr '%'
{ $$ = cat2_str($1, make1_str("%")); } { $$ = cat2_str($1, make1_str("%")); }
| a_expr '^'
{ $$ = cat2_str($1, make1_str("^")); }
| a_expr '+' ecpg_expr | a_expr '+' ecpg_expr
{ $$ = cat3_str($1, make1_str("+"), $3); } { $$ = cat3_str($1, make1_str("+"), $3); }
| a_expr '-' ecpg_expr | a_expr '-' ecpg_expr
...@@ -5613,6 +5491,8 @@ ecpg_expr: attr opt_indirection ...@@ -5613,6 +5491,8 @@ ecpg_expr: attr opt_indirection
{ $$ = cat3_str($1, make1_str("%"), $3); } { $$ = cat3_str($1, make1_str("%"), $3); }
| a_expr '*' ecpg_expr | a_expr '*' ecpg_expr
{ $$ = cat3_str($1, make1_str("*"), $3); } { $$ = cat3_str($1, make1_str("*"), $3); }
| a_expr '^' ecpg_expr
{ $$ = cat3_str($1, make1_str("^"), $3); }
| a_expr '<' ecpg_expr | a_expr '<' ecpg_expr
{ $$ = cat3_str($1, make1_str("<"), $3); } { $$ = cat3_str($1, make1_str("<"), $3); }
| a_expr '>' ecpg_expr | a_expr '>' ecpg_expr
......
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