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

Commite593349

Browse files
committed
Repair problem with listing rules that have a WHERE condition and
have an INSERT...SELECT as the first or only action. Per bug reportfrom Sergio Pili.
1 parent4bc8c8d commite593349

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*back to source text
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.87 2001/11/19 19:51:20 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.88 2001/11/26 00:29:15 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -178,9 +178,9 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
178178
elog(ERROR,"get_ruledef: cannot connect to SPI manager");
179179

180180
/*
181-
* On the first call prepare the plan to lookuppg_proc. We read
182-
*pg_proc over the SPI manager instead of using the syscache to be
183-
* checked for read access onpg_proc.
181+
* On the first call prepare the plan to lookuppg_rewrite. We read
182+
*pg_rewrite over the SPI manager instead of using the syscache to be
183+
* checked for read access onpg_rewrite.
184184
*/
185185
if (plan_getrule==NULL)
186186
{
@@ -271,9 +271,9 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
271271
elog(ERROR,"get_viewdef: cannot connect to SPI manager");
272272

273273
/*
274-
* On the first call prepare the plan to lookuppg_proc. We read
275-
*pg_proc over the SPI manager instead of using the syscache to be
276-
* checked for read access onpg_proc.
274+
* On the first call prepare the plan to lookuppg_rewrite. We read
275+
*pg_rewrite over the SPI manager instead of using the syscache to be
276+
* checked for read access onpg_rewrite.
277277
*/
278278
if (plan_getview==NULL)
279279
{
@@ -769,8 +769,21 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
769769
appendStringInfo(buf," WHERE ");
770770

771771
qual=stringToNode(ev_qual);
772+
773+
/*
774+
* We need to make a context for recognizing any Vars in the qual
775+
* (which can only be references to OLD and NEW). Use the rtable
776+
* of the first query in the action list for this purpose.
777+
*/
772778
query= (Query*)lfirst(actions);
773779

780+
/*
781+
* If the action is INSERT...SELECT, OLD/NEW have been pushed
782+
* down into the SELECT, and that's what we need to look at.
783+
* (Ugly kluge ... try to fix this when we redesign querytrees.)
784+
*/
785+
query=getInsertSelectQuery(query,NULL);
786+
774787
context.buf=buf;
775788
context.namespaces=makeList1(&dpns);
776789
context.varprefix= (length(query->rtable)!=1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp