Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6392518

Browse files
committed
Add a HINT per suggestion from Michael Glaesemann. Also, tweak OLD/NEW
test to avoid expensive contain_vars_of_level() scan in the normal casewhere we're not inside a rule.
1 parentb737f85 commit6392518

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/backend/parser/analyze.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.341 2006/08/0201:59:46 joe Exp $
9+
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.342 2006/08/0213:58:52 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -745,10 +745,12 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
745745
* construct to ensure that the values would be available while
746746
* evaluating the VALUES RTE. This is a shame. FIXME
747747
*/
748-
if (contain_vars_of_level((Node*)exprsLists,0))
748+
if (pstate->p_rtable!=NIL&&
749+
contain_vars_of_level((Node*)exprsLists,0))
749750
ereport(ERROR,
750751
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
751-
errmsg("VALUES must not contain OLD or NEW references")));
752+
errmsg("VALUES must not contain OLD or NEW references"),
753+
errhint("Use SELECT ... UNION ALL ... instead.")));
752754

753755
/*
754756
* Generate the VALUES RTE
@@ -2264,10 +2266,12 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
22642266
* construct to ensure that the values would be available while
22652267
* evaluating the VALUES RTE. This is a shame. FIXME
22662268
*/
2267-
if (contain_vars_of_level((Node*)newExprsLists,0))
2269+
if (list_length(pstate->p_rtable)!=1&&
2270+
contain_vars_of_level((Node*)newExprsLists,0))
22682271
ereport(ERROR,
22692272
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2270-
errmsg("VALUES must not contain OLD or NEW references")));
2273+
errmsg("VALUES must not contain OLD or NEW references"),
2274+
errhint("Use SELECT ... UNION ALL ... instead.")));
22712275

22722276
qry->rtable=pstate->p_rtable;
22732277
qry->jointree=makeFromExpr(pstate->p_joinlist,NULL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp