mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Add a HINT per suggestion from Michael Glaesemann. Also, tweak OLD/NEW
test to avoid expensive contain_vars_of_level() scan in the normal case where we're not inside a rule.
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.341 2006/08/02 01:59:46 joe Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.342 2006/08/02 13:58:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -745,10 +745,12 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
|||||||
* construct to ensure that the values would be available while
|
* construct to ensure that the values would be available while
|
||||||
* evaluating the VALUES RTE. This is a shame. FIXME
|
* evaluating the VALUES RTE. This is a shame. FIXME
|
||||||
*/
|
*/
|
||||||
if (contain_vars_of_level((Node *) exprsLists, 0))
|
if (pstate->p_rtable != NIL &&
|
||||||
|
contain_vars_of_level((Node *) exprsLists, 0))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("VALUES must not contain OLD or NEW references")));
|
errmsg("VALUES must not contain OLD or NEW references"),
|
||||||
|
errhint("Use SELECT ... UNION ALL ... instead.")));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the VALUES RTE
|
* Generate the VALUES RTE
|
||||||
@ -2264,10 +2266,12 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
|
|||||||
* construct to ensure that the values would be available while
|
* construct to ensure that the values would be available while
|
||||||
* evaluating the VALUES RTE. This is a shame. FIXME
|
* evaluating the VALUES RTE. This is a shame. FIXME
|
||||||
*/
|
*/
|
||||||
if (contain_vars_of_level((Node *) newExprsLists, 0))
|
if (list_length(pstate->p_rtable) != 1 &&
|
||||||
|
contain_vars_of_level((Node *) newExprsLists, 0))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("VALUES must not contain OLD or NEW references")));
|
errmsg("VALUES must not contain OLD or NEW references"),
|
||||||
|
errhint("Use SELECT ... UNION ALL ... instead.")));
|
||||||
|
|
||||||
qry->rtable = pstate->p_rtable;
|
qry->rtable = pstate->p_rtable;
|
||||||
qry->jointree = makeFromExpr(pstate->p_joinlist, NULL);
|
qry->jointree = makeFromExpr(pstate->p_joinlist, NULL);
|
||||||
|
Reference in New Issue
Block a user