*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.148 2006/08/02 13:43:23 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.149 2006/08/18 15:59:35 meskes Exp $
*
*-------------------------------------------------------------------------
*/
%option yylineno
-%s C SQL incl def def_ident undef
+%x C SQL incl def def_ident undef
/*
* OK, here is a short description of lex/flex rules behavior.
%x xe
%x xq
%x xdolq
-%x xpre
%x xcond
%x xskip
<SQL>{whitespace} { /* ignore */ }
-{xcstart} {
+<C,SQL>{xcstart} {
token_start = yytext;
state_before = YYSTATE;
xcdepth = 0;
* This is not an EOL marker.
*/
if (yytext[0] == ';' && struct_level == 0)
- BEGIN C;
+ BEGIN(C);
return yytext[0];
}
<SQL>{operator} {
}
}
<SQL>{other} { return yytext[0]; }
-<C>{exec_sql} { BEGIN SQL; return SQL_START; }
+<C>{exec_sql} { BEGIN(SQL); return SQL_START; }
<C>{informix_special} {
/* are we simulating Informix? */
if (INFORMIX_MODE)
{
- BEGIN SQL;
+ BEGIN(SQL);
return SQL_START;
}
else
BEGIN(C);
}
-<undef>{other} {
+<undef>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL UNDEF' command");
yyterminate();
}
}
if (stacked_if_value[preproc_tos].condition)
- BEGIN C;
+ BEGIN(C);
else
BEGIN(xskip);
}
-<xcond>{other} {
- mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL IFDEF' command");
- yyterminate();
- }
+<xcond>{other}|\n {
+ mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL IFDEF' command");
+ yyterminate();
+ }
<def_ident>{identifier} {
old = mm_strdup(yytext);
BEGIN(def);
startlit();
}
-<def_ident>{other} {
- mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL DEFINE' command");
- yyterminate();
- }
+<def_ident>{other}|\n {
+ mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL DEFINE' command");
+ yyterminate();
+ }
<def>{space}*";" {
struct _defines *ptr, *this;
<incl>\<[^\>]+\>{space}*";"? { parse_include(); }
<incl>{dquote}{xdinside}{dquote}{space}*";"? { parse_include(); }
<incl>[^;\<\>\"]+";" { parse_include(); }
-<incl>{other} {
- mmerror(PARSE_ERROR, ET_FATAL, "Incorrect 'EXEC SQL INCLUDE' command");
- yyterminate();
- }
+<incl>{other}|\n {
+ mmerror(PARSE_ERROR, ET_FATAL, "Incorrect 'EXEC SQL INCLUDE' command");
+ yyterminate();
+ }
<<EOF>> {
if (yy_buffer == NULL)
}
}
+<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "Internal error: unreachable state, please inform pgsql-bugs@postgresql.org"); }
%%
void
lex_init(void)
}
startlit();
- BEGIN C;
+ BEGIN(C);
}
static void
yylineno = 1;
output_line_number();
- BEGIN C;
+ BEGIN(C);
}
static void
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.328 2006/08/08 11:51:24 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.329 2006/08/18 15:59:35 meskes Exp $ */
/* Copyright comment */
%{
QUOTE
READ REAL REASSIGN RECHECK REFERENCES REINDEX RELATIVE_P RELEASE RENAME
- REPEATABLE REPLACE RESET RESTART RESTRICT RETURNS REVOKE RIGHT
+ REPEATABLE REPLACE RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT
ROLE ROLLBACK ROW ROWS RULE
SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
%type <str> columnList DeleteStmt UpdateStmt DeclareCursorStmt
%type <str> NotifyStmt columnElem UnlistenStmt TableElement
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
-%type <str> FetchStmt from_in CreateOpClassStmt
+%type <str> FetchStmt from_in CreateOpClassStmt returning_clause
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
%type <str> opt_full func_arg OptWith opt_freeze alter_table_cmd
%type <str> analyze_keyword opt_name_list ExplainStmt index_params
*
*****************************************************************************/
-InsertStmt: INSERT INTO qualified_name insert_rest
- { $$ = cat_str(3, make_str("insert into"), $3, $4); }
+InsertStmt: INSERT INTO qualified_name insert_rest returning_clause
+ { $$ = cat_str(4, make_str("insert into"), $3, $4, $5); }
;
insert_rest:
{ $$ = cat2_str($1, $2); }
;
+returning_clause: RETURNING target_list { $$ = cat2_str(make_str("returning"), $2); }
+ | /* EMPTY */ { $$ = EMPTY; }
+ ;
/*****************************************************************************
*
*
*****************************************************************************/
-DeleteStmt: DELETE_P FROM relation_expr_opt_alias using_clause where_clause
- { $$ = cat_str(4, make_str("delete from"), $3, $4, $5); }
+DeleteStmt: DELETE_P FROM relation_expr_opt_alias using_clause where_clause returning_clause
+ { $$ = cat_str(5, make_str("delete from"), $3, $4, $5, $6); }
;
using_clause: USING from_list { cat2_str(make_str("using"), $2); }
SET update_target_list
from_clause
where_clause
- {$$ = cat_str(6, make_str("update"), $2, make_str("set"), $4, $5, $6); }
+ returning_clause
+ {$$ = cat_str(7, make_str("update"), $2, make_str("set"), $4, $5, $6, $7); }
;
/* old style: dbname[@server][:port] */
if (strlen($2) > 0 && *($2) != '@')
mmerror(PARSE_ERROR, ET_ERROR, "Expected '@', found '%s'", $2);
-
- $$ = make3_str(make_str("\""), make3_str($1, $2, $3), make_str("\""));
+
+ /* C strings need to be handled differently */
+ if ($1[0] == '\"')
+ $$ = $1;
+ else
+ $$ = make3_str(make_str("\""), make3_str($1, $2, $3), make_str("\""));
}
| db_prefix ':' server opt_port '/' database_name opt_options
{
$$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6), $7, make_str("\"")));
}
- | Sconst
- {
- if ($1[0] == '\"')
- $$ = $1;
- else
- $$ = make3_str(make_str("\""), $1, make_str("\""));
- }
| char_variable
{
$$ = $1;
| OR { $$ = make_str("or"); }
| ORDER { $$ = make_str("order"); }
| PRIMARY { $$ = make_str("primary"); }
- | REFERENCES { $$ = make_str("references"); }
+ | REFERENCES { $$ = make_str("references"); }
+ | RETURNING { $$ = make_str("returning"); }
| SELECT { $$ = make_str("select"); }
- | SESSION_USER { $$ = make_str("session_user"); }
+ | SESSION_USER { $$ = make_str("session_user"); }
| SOME { $$ = make_str("some"); }
| SYMMETRIC { $$ = make_str("symmetric"); }
| TABLE { $$ = make_str("table"); }
}
;
ident: IDENT { $$ = $1; }
- | CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
+ | CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
;
quoted_ident_stringvar: name