%token <keyword> K_GET
%token <keyword> K_HINT
%token <keyword> K_IF
+%token <keyword> K_IMPORT
%token <keyword> K_IN
%token <keyword> K_INFO
%token <keyword> K_INSERT
* assignment. Give an appropriate complaint for that, instead of letting
* the core parser throw an unhelpful "syntax error".
*/
-stmt_execsql : K_INSERT
+stmt_execsql : K_IMPORT
+ {
+ $$ = make_execsql_stmt(K_IMPORT, @1);
+ }
+ | K_INSERT
{
$$ = make_execsql_stmt(K_INSERT, @1);
}
| K_FORWARD
| K_GET
| K_HINT
+ | K_IMPORT
| K_INFO
| K_INSERT
| K_IS
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
/*
- * We have to special-case the sequence INSERT INTO, because we don't want
- * that to be taken as an INTO-variables clause. Fortunately, this is the
- * only valid use of INTO in a pl/pgsql SQL command, and INTO is already a
- * fully reserved word in the main grammar. We have to treat it that way
- * anywhere in the string, not only at the start; consider CREATE RULE
- * containing an INSERT statement.
+ * Scan to the end of the SQL command. Identify any INTO-variables
+ * clause lurking within it, and parse that via read_into_target().
+ *
+ * Because INTO is sometimes used in the main SQL grammar, we have to be
+ * careful not to take any such usage of INTO as a pl/pgsql INTO clause.
+ * There are currently three such cases:
+ *
+ * 1. SELECT ... INTO. We don't care, we just override that with the
+ * pl/pgsql definition.
+ *
+ * 2. INSERT INTO. This is relatively easy to recognize since the words
+ * must appear adjacently; but we can't assume INSERT starts the command,
+ * because it can appear in CREATE RULE or WITH. Unfortunately, INSERT is
+ * *not* fully reserved, so that means there is a chance of a false match;
+ * but it's not very likely.
+ *
+ * 3. IMPORT FOREIGN SCHEMA ... INTO. This is not allowed in CREATE RULE
+ * or WITH, so we just check for IMPORT as the command's first token.
+ * (If IMPORT FOREIGN SCHEMA returned data someone might wish to capture
+ * with an INTO-variables clause, we'd have to work much harder here.)
+ *
+ * Fortunately, INTO is a fully reserved word in the main grammar, so
+ * at least we need not worry about it appearing as an identifier.
+ *
+ * Any future additional uses of INTO in the main grammar will doubtless
+ * break this logic again ... beware!
*/
tok = firsttoken;
for (;;)
break;
if (tok == 0)
yyerror("unexpected end of function definition");
-
- if (tok == K_INTO && prev_tok != K_INSERT)
+ if (tok == K_INTO)
{
+ if (prev_tok == K_INSERT)
+ continue; /* INSERT INTO is not an INTO-target */
+ if (firsttoken == K_IMPORT)
+ continue; /* IMPORT ... INTO is not an INTO-target */
if (have_into)
yyerror("INTO specified more than once");
have_into = true;
PG_KEYWORD("forward", K_FORWARD, UNRESERVED_KEYWORD)
PG_KEYWORD("get", K_GET, UNRESERVED_KEYWORD)
PG_KEYWORD("hint", K_HINT, UNRESERVED_KEYWORD)
+ PG_KEYWORD("import", K_IMPORT, UNRESERVED_KEYWORD)
PG_KEYWORD("info", K_INFO, UNRESERVED_KEYWORD)
PG_KEYWORD("insert", K_INSERT, UNRESERVED_KEYWORD)
PG_KEYWORD("is", K_IS, UNRESERVED_KEYWORD)