On 09.02.2018 11:02, Konstantin Knizhnik wrote:
On 09.02.2018 10:47, Sergei Kornilov wrote:
Hello
select into b from my_insert('from func atx');
You missed select something into b. For example,
select ret into b from my_insert('from func atx') as ret;
Using scalar function in from is not bug.
Silent assigning NULL for variables in "into" not matches same in
"select"... I think better would be raise warning.
regards, Sergei
Thank you.
Really the problem is caused by empty source list for INTO.
If I rewrite query as
select my_insert into b from my_insert('from func atx');
then it works as expected.
But I wonder if the original statement should be considered as error
or at least we should produce warning for such empty projections?
Attached please find patch reporting error in case of empty attribute
list for SELECT INTO.
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y
index 7f52849..c43d572 100644
--- a/src/pl/plpgsql/src/pl_gram.y
+++ b/src/pl/plpgsql/src/pl_gram.y
@@ -2853,6 +2853,7 @@ make_execsql_stmt(int firsttoken, int location)
int prev_tok;
bool have_into = false;
bool have_strict = false;
+ bool have_attributes = false;
int into_start_loc = -1;
int into_end_loc = -1;
@@ -2907,6 +2908,8 @@ make_execsql_stmt(int firsttoken, int location)
continue; /* INSERT INTO is not an INTO-target */
if (firsttoken == K_IMPORT)
continue; /* IMPORT ... INTO is not an INTO-target */
+ if (!have_attributes)
+ yyerror("Empty list for INTO-target");
if (have_into)
yyerror("INTO specified more than once");
have_into = true;
@@ -2915,6 +2918,8 @@ make_execsql_stmt(int firsttoken, int location)
read_into_target(&rec, &row, &have_strict);
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
}
+ else
+ have_attributes = true;
}
plpgsql_IdentifierLookup = save_IdentifierLookup;