Skip to content
Snippets Groups Projects
Commit 88ce6a2b authored by Michael Meskes's avatar Michael Meskes
Browse files

Synced preproc.y with gram.y and added missing include file to pgc.l.

parent 0fada37f
No related branches found
No related tags found
No related merge requests found
...@@ -1035,8 +1035,9 @@ Fri Dec 22 13:33:31 CET 2000 ...@@ -1035,8 +1035,9 @@ Fri Dec 22 13:33:31 CET 2000
- Fixed bug in a connect statement using varchars. - Fixed bug in a connect statement using varchars.
- Synced gram.y and preproc.y. - Synced gram.y and preproc.y.
Tue Jan 9 20:24:56 CET 2001 Mon Jan 22 17:56:02 CET 2001
- Synced gram.y. - Synced gram.y and preproc.y.
- Added #include "postgres.h" to pgc.l.
- Set ecpg version to 2.8.0. - Set ecpg version to 2.8.0.
- Set library version to 3.2.0. - Set library version to 3.2.0.
...@@ -12,17 +12,16 @@ ...@@ -12,17 +12,16 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.71 2001/01/14 05:08:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.72 2001/01/22 17:05:50 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include <sys/types.h> #include <sys/types.h>
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#include "postgres.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
......
...@@ -294,7 +294,7 @@ make_name(void) ...@@ -294,7 +294,7 @@ make_name(void)
%type <str> opt_indirection expr_list extract_list extract_arg %type <str> opt_indirection expr_list extract_list extract_arg
%type <str> position_list substr_list substr_from alter_column_action %type <str> position_list substr_list substr_from alter_column_action
%type <str> trim_list in_expr substr_for attr attrs drop_behavior %type <str> trim_list in_expr substr_for attr attrs drop_behavior
%type <str> Typename SimpleTypename GenericType Numeric 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 opt_timezone opt_interval table_ref %type <str> opt_collate datetime opt_timezone opt_interval table_ref
%type <str> row_expr row_descriptor row_list ConstDatetime opt_chain %type <str> row_expr row_descriptor row_list ConstDatetime opt_chain
...@@ -313,7 +313,7 @@ make_name(void) ...@@ -313,7 +313,7 @@ make_name(void)
%type <str> index_list func_index index_elem opt_class access_method_clause %type <str> index_list func_index index_elem opt_class access_method_clause
%type <str> index_opt_unique IndexStmt func_return ConstInterval %type <str> index_opt_unique IndexStmt func_return ConstInterval
%type <str> func_args_list func_args opt_with ProcedureStmt def_arg %type <str> func_args_list func_args opt_with ProcedureStmt def_arg
%type <str> def_elem def_list definition DefineStmt %type <str> def_elem def_list definition DefineStmt select_with_parens
%type <str> opt_instead event event_object RuleActionList opt_using %type <str> opt_instead event event_object RuleActionList opt_using
%type <str> RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type %type <str> RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type
%type <str> RuleStmt opt_column opt_name oper_argtypes sysid_clause %type <str> RuleStmt opt_column opt_name oper_argtypes sysid_clause
...@@ -2066,16 +2066,7 @@ RuleActionMulti: RuleActionMulti ';' RuleActionStmtOrEmpty ...@@ -2066,16 +2066,7 @@ RuleActionMulti: RuleActionMulti ';' RuleActionStmtOrEmpty
{ $$ = cat2_str($1, make_str(";")); } { $$ = cat2_str($1, make_str(";")); }
; ;
/* RuleActionStmt: SelectStmt
* Allowing RuleActionStmt to be a SelectStmt creates an ambiguity:
* is the RuleActionList "((SELECT foo))" a standalone RuleActionStmt,
* or a one-entry RuleActionMulti list? We don't really care, but yacc
* wants to know. We use operator precedence to resolve the ambiguity:
* giving this rule a higher precedence than ')' will force a reduce
* rather than shift decision, causing the one-entry-list interpretation
* to be chosen.
*/
RuleActionStmt: SelectStmt %prec TYPECAST
| InsertStmt | InsertStmt
| UpdateStmt | UpdateStmt
| DeleteStmt | DeleteStmt
...@@ -2491,11 +2482,17 @@ opt_cursor: BINARY { $$ = make_str("binary"); } ...@@ -2491,11 +2482,17 @@ opt_cursor: BINARY { $$ = make_str("binary"); }
* *
*****************************************************************************/ *****************************************************************************/
SelectStmt: select_no_parens %prec TYPECAST SelectStmt: select_no_parens %prec UMINUS
{ $$ = $1; }
| select_with_parens %prec UMINUS
{ $$ = $1; }
;
select_with_parens: '(' select_no_parens ')'
{ {
$$ = $1; $$ = cat_str(3, make_str("("), $2, make_str(")"));
} }
| '(' SelectStmt ')' | '(' select_with_parens ')'
{ {
$$ = cat_str(3, make_str("("), $2, make_str(")")); $$ = cat_str(3, make_str("("), $2, make_str(")"));
} }
...@@ -2524,9 +2521,9 @@ select_clause: simple_select ...@@ -2524,9 +2521,9 @@ select_clause: simple_select
$$ = $1; $$ = $1;
} }
| '(' SelectStmt ')' | select_with_parens
{ {
$$ = cat_str(3, make_str("("), $2, make_str(")")); $$ = $1;
} }
; ;
...@@ -2745,10 +2742,6 @@ from_list: from_list ',' table_ref { $$ = cat_str(3, $1, make_str(","), $3); } ...@@ -2745,10 +2742,6 @@ from_list: from_list ',' table_ref { $$ = cat_str(3, $1, make_str(","), $3); }
* between table_ref := '(' joined_table ')' alias_clause * between table_ref := '(' joined_table ')' alias_clause
* and joined_table := '(' joined_table ')'. So, we must have the * and joined_table := '(' joined_table ')'. So, we must have the
* redundant-looking productions here instead. * redundant-looking productions here instead.
*
* Note that the SQL spec does not permit a subselect (<derived_table>)
* without an alias clause, so we don't either. This avoids the problem
* of needing to invent a refname for an unlabeled subselect.
*/ */
table_ref: relation_expr table_ref: relation_expr
{ {
...@@ -2758,9 +2751,13 @@ table_ref: relation_expr ...@@ -2758,9 +2751,13 @@ table_ref: relation_expr
{ {
$$= cat2_str($1, $2); $$= cat2_str($1, $2);
} }
| '(' SelectStmt ')' alias_clause | select_with_parens
{ {
$$=cat_str(4, make_str("("), $2, make_str(")"), $4); mmerror(ET_ERROR, "sub-SELECT in FROM must have an alias");
}
| select_with_parens alias_clause
{
$$=cat2_str($1, $2);
} }
| joined_table | joined_table
{ {
...@@ -2856,12 +2853,12 @@ relation_expr: relation_name ...@@ -2856,12 +2853,12 @@ relation_expr: relation_name
/* normal relations */ /* normal relations */
$$ = $1; $$ = $1;
} }
| relation_name '*' %prec '=' | relation_name '*'
{ {
/* inheritance query */ /* inheritance query */
$$ = cat2_str($1, make_str("*")); $$ = cat2_str($1, make_str("*"));
} }
| ONLY relation_name %prec '=' | ONLY relation_name
{ {
/* inheritance query */ /* inheritance query */
$$ = cat2_str(make_str("ONLY "), $2); $$ = cat2_str(make_str("ONLY "), $2);
...@@ -2928,7 +2925,7 @@ SimpleTypename: ConstTypename { $$ = $1; } ...@@ -2928,7 +2925,7 @@ SimpleTypename: ConstTypename { $$ = $1; }
| ConstInterval { $$ = $1; } | ConstInterval { $$ = $1; }
; ;
ConstTypename: GenericType { $$ = $1; } ConstTypename: Generic { $$ = $1; }
| ConstDatetime { $$ = $1; } | ConstDatetime { $$ = $1; }
| Numeric { $$ = $1; } | Numeric { $$ = $1; }
| Geometric { $$ = $1; } | Geometric { $$ = $1; }
...@@ -2936,7 +2933,14 @@ ConstTypename: GenericType { $$ = $1; } ...@@ -2936,7 +2933,14 @@ ConstTypename: GenericType { $$ = $1; }
| Character { $$ = $1; } | Character { $$ = $1; }
; ;
GenericType: ident { $$ = $1; } Generic: generic
{
$$ = $1;
}
;
generic: ident { $$ = $1; }
| TYPE_P { $$ = make_str("type"); }
| ECPGKeywords { $$ = $1; } | ECPGKeywords { $$ = $1; }
| ECPGTypeName { $$ = $1; } | ECPGTypeName { $$ = $1; }
; ;
...@@ -3170,21 +3174,21 @@ opt_interval: datetime { $$ = $1; } ...@@ -3170,21 +3174,21 @@ opt_interval: datetime { $$ = $1; }
* Define row_descriptor to allow yacc to break the reduce/reduce conflict * Define row_descriptor to allow yacc to break the reduce/reduce conflict
* with singleton expressions. * with singleton expressions.
*/ */
row_expr: '(' row_descriptor ')' IN '(' SelectStmt ')' row_expr: '(' row_descriptor ')' IN select_with_parens
{ {
$$ = cat_str(5, make_str("("), $2, make_str(") in ("), $6, make_str(")")); $$ = cat_str(4, make_str("("), $2, make_str(") in "), $5);
} }
| '(' row_descriptor ')' NOT IN '(' SelectStmt ')' | '(' row_descriptor ')' NOT IN select_with_parens
{ {
$$ = cat_str(5, make_str("("), $2, make_str(") not in ("), $7, make_str(")")); $$ = cat_str(4, make_str("("), $2, make_str(") not in "), $6);
} }
| '(' row_descriptor ')' all_Op sub_type '(' SelectStmt ')' | '(' row_descriptor ')' all_Op sub_type select_with_parens
{ {
$$ = cat_str(8, make_str("("), $2, make_str(")"), $4, $5, make_str("("), $7, make_str(")")); $$ = cat_str(6, make_str("("), $2, make_str(")"), $4, $5, $6);
} }
| '(' row_descriptor ')' all_Op '(' SelectStmt ')' | '(' row_descriptor ')' all_Op select_with_parens
{ {
$$ = cat_str(7, make_str("("), $2, make_str(")"), $4, make_str("("), $6, make_str(")")); $$ = cat_str(5, make_str("("), $2, make_str(")"), $4, $5);
} }
| '(' row_descriptor ')' all_Op '(' row_descriptor ')' | '(' row_descriptor ')' all_Op '(' row_descriptor ')'
{ {
...@@ -3349,17 +3353,17 @@ a_expr: c_expr ...@@ -3349,17 +3353,17 @@ a_expr: c_expr
{ {
$$ = cat_str(5, $1, make_str("not between"), $4, make_str("and"), $6); $$ = cat_str(5, $1, make_str("not between"), $4, make_str("and"), $6);
} }
| a_expr IN '(' in_expr ')' | a_expr IN in_expr
{ {
$$ = cat_str(4, $1, make_str(" in ("), $4, make_str(")")); $$ = cat_str(3, $1, make_str(" in"), $3);
} }
| a_expr NOT IN '(' in_expr ')' | a_expr NOT IN in_expr
{ {
$$ = cat_str(4, $1, make_str(" not in ("), $5, make_str(")")); $$ = cat_str(3, $1, make_str(" not in "), $4);
} }
| a_expr all_Op sub_type '(' SelectStmt ')' | a_expr all_Op sub_type select_with_parens
{ {
$$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); $$ = cat_str(4, $1, $2, $3, $4);
} }
| row_expr | row_expr
{ $$ = $1; } { $$ = $1; }
...@@ -3494,10 +3498,10 @@ c_expr: attr ...@@ -3494,10 +3498,10 @@ c_expr: attr
{ $$ = cat_str(3, make_str("trim(trailing"), $4, make_str(")")); } { $$ = cat_str(3, make_str("trim(trailing"), $4, make_str(")")); }
| TRIM '(' trim_list ')' | TRIM '(' trim_list ')'
{ $$ = cat_str(3, make_str("trim("), $3, make_str(")")); } { $$ = cat_str(3, make_str("trim("), $3, make_str(")")); }
| '(' select_no_parens ')' | select_with_parens %prec UMINUS
{ $$ = cat_str(3, make_str("("), $2, make_str(")")); } { $$ = $1; }
| EXISTS '(' SelectStmt ')' | EXISTS select_with_parens
{ $$ = cat_str(3, make_str("exists("), $3, make_str(")")); } { $$ = cat2_str(make_str("exists"), $2); }
; ;
/* /*
* This used to use ecpg_expr, but since there is no shift/reduce conflict * This used to use ecpg_expr, but since there is no shift/reduce conflict
...@@ -3583,12 +3587,12 @@ trim_list: a_expr FROM expr_list ...@@ -3583,12 +3587,12 @@ trim_list: a_expr FROM expr_list
{ $$ = $1; } { $$ = $1; }
; ;
in_expr: SelectStmt in_expr: select_with_parens
{ {
$$ = $1; $$ = $1;
} }
| in_expr_nodes | '(' in_expr_nodes ')'
{ $$ = $1; } { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
; ;
in_expr_nodes: a_expr in_expr_nodes: a_expr
...@@ -5069,7 +5073,6 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); } ...@@ -5069,7 +5073,6 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); }
| TRIGGER { $$ = make_str("trigger"); } | TRIGGER { $$ = make_str("trigger"); }
| TRUNCATE { $$ = make_str("truncate"); } | TRUNCATE { $$ = make_str("truncate"); }
| TRUSTED { $$ = make_str("trusted"); } | TRUSTED { $$ = make_str("trusted"); }
| TYPE_P { $$ = make_str("type"); }
| UNLISTEN { $$ = make_str("unlisten"); } | UNLISTEN { $$ = make_str("unlisten"); }
| UNTIL { $$ = make_str("until"); } | UNTIL { $$ = make_str("until"); }
| UPDATE { $$ = make_str("update"); } | UPDATE { $$ = make_str("update"); }
...@@ -5103,7 +5106,6 @@ ECPGColLabel: ECPGColId { $$ = $1; } ...@@ -5103,7 +5106,6 @@ ECPGColLabel: ECPGColId { $$ = $1; }
| ALL { $$ = make_str("all"); } | ALL { $$ = make_str("all"); }
| ANALYSE { $$ = make_str("analyse"); } | ANALYSE { $$ = make_str("analyse"); }
| ANALYZE { $$ = make_str("analyze"); } | ANALYZE { $$ = make_str("analyze"); }
| AND { $$ = make_str("and"); }
| ANY { $$ = make_str("any"); } | ANY { $$ = make_str("any"); }
| ASC { $$ = make_str("asc"); } | ASC { $$ = make_str("asc"); }
| BETWEEN { $$ = make_str("between"); } | BETWEEN { $$ = make_str("between"); }
...@@ -5198,7 +5200,6 @@ ECPGColLabel: ECPGColId { $$ = $1; } ...@@ -5198,7 +5200,6 @@ ECPGColLabel: ECPGColId { $$ = $1; }
| TABLE { $$ = make_str("table"); } | TABLE { $$ = make_str("table"); }
| THEN { $$ = make_str("then"); } | THEN { $$ = make_str("then"); }
| TO { $$ = make_str("to"); } | TO { $$ = make_str("to"); }
| TRAILING { $$ = make_str("trailing"); }
| TRANSACTION { $$ = make_str("transaction"); } | TRANSACTION { $$ = make_str("transaction"); }
| TRIM { $$ = make_str("trim"); } | TRIM { $$ = make_str("trim"); }
| TRUE_P { $$ = make_str("true"); } | TRUE_P { $$ = make_str("true"); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment