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

Commit987026c

Browse files
committed
Rule dumper failed to affix '*' to inheritable RTEs.
1 parent557ca54 commit987026c

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* out of it's tuple
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.28 1999/10/04 04:37:23 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.29 1999/10/31 18:57:42 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -40,14 +40,15 @@
4040

4141
#include"postgres.h"
4242

43-
#include"executor/spi.h"
44-
#include"lib/stringinfo.h"
45-
#include"optimizer/clauses.h"
46-
#include"optimizer/tlist.h"
4743
#include"catalog/pg_index.h"
4844
#include"catalog/pg_operator.h"
4945
#include"catalog/pg_shadow.h"
5046
#include"catalog/pg_type.h"
47+
#include"executor/spi.h"
48+
#include"lib/stringinfo.h"
49+
#include"optimizer/clauses.h"
50+
#include"optimizer/tlist.h"
51+
#include"parser/parsetree.h"
5152
#include"utils/builtins.h"
5253
#include"utils/lsyscache.h"
5354

@@ -112,6 +113,8 @@ static bool check_if_rte_used(Node *node, Index rt_index, int levelsup);
112113
staticboolcheck_if_rte_used_walker(Node*node,
113114
check_if_rte_used_context*context);
114115

116+
#defineinherit_marker(rte) ((rte)->inh ? "*" : "")
117+
115118

116119
/* ----------
117120
* get_ruledef- Do it all and return a text
@@ -907,7 +910,7 @@ get_select_query_def(Query *query, deparse_context *context)
907910

908911
/* ----------
909912
* Now check if any of the used rangetable entries is different
910-
* from *NEW* and *CURRENT*. If so we mustomit the FROM clause
913+
* from *NEW* and *CURRENT*. If so we mustprovide the FROM clause
911914
* later.
912915
* ----------
913916
*/
@@ -965,13 +968,11 @@ get_select_query_def(Query *query, deparse_context *context)
965968
quote_identifier(tle->resdom->resname));
966969
}
967970

968-
/* If we need other tablesthat *NEW* or *CURRENT* add the FROM clause */
971+
/* If we need other tablesthan *NEW* or *CURRENT* add the FROM clause */
969972
if (!rt_constonly&&rt_numused>0)
970973
{
971-
appendStringInfo(buf," FROM");
972-
974+
sep=" FROM ";
973975
i=0;
974-
sep=" ";
975976
foreach(l,query->rtable)
976977
{
977978
if (rt_used[i++])
@@ -986,8 +987,9 @@ get_select_query_def(Query *query, deparse_context *context)
986987

987988
appendStringInfo(buf,sep);
988989
sep=", ";
989-
appendStringInfo(buf,"%s",
990-
quote_identifier(rte->relname));
990+
appendStringInfo(buf,"%s%s",
991+
quote_identifier(rte->relname),
992+
inherit_marker(rte));
991993
if (strcmp(rte->relname,rte->refname)!=0)
992994
appendStringInfo(buf," %s",
993995
quote_identifier(rte->refname));
@@ -1081,7 +1083,7 @@ get_insert_query_def(Query *query, deparse_context *context)
10811083
* Start the query with INSERT INTO relname
10821084
* ----------
10831085
*/
1084-
rte=(RangeTblEntry*)nth(query->resultRelation-1,query->rtable);
1086+
rte=rt_fetch(query->resultRelation,query->rtable);
10851087
appendStringInfo(buf,"INSERT INTO %s",
10861088
quote_identifier(rte->relname));
10871089

@@ -1134,9 +1136,10 @@ get_update_query_def(Query *query, deparse_context *context)
11341136
* Start the query with UPDATE relname SET
11351137
* ----------
11361138
*/
1137-
rte= (RangeTblEntry*)nth(query->resultRelation-1,query->rtable);
1138-
appendStringInfo(buf,"UPDATE %s SET ",
1139-
quote_identifier(rte->relname));
1139+
rte=rt_fetch(query->resultRelation,query->rtable);
1140+
appendStringInfo(buf,"UPDATE %s%s SET ",
1141+
quote_identifier(rte->relname),
1142+
inherit_marker(rte));
11401143

11411144
/* Add the comma separated list of 'attname = value' */
11421145
sep="";
@@ -1174,9 +1177,10 @@ get_delete_query_def(Query *query, deparse_context *context)
11741177
* Start the query with DELETE FROM relname
11751178
* ----------
11761179
*/
1177-
rte= (RangeTblEntry*)nth(query->resultRelation-1,query->rtable);
1178-
appendStringInfo(buf,"DELETE FROM %s",
1179-
quote_identifier(rte->relname));
1180+
rte=rt_fetch(query->resultRelation,query->rtable);
1181+
appendStringInfo(buf,"DELETE FROM %s%s",
1182+
quote_identifier(rte->relname),
1183+
inherit_marker(rte));
11801184

11811185
/* Add a WHERE clause if given */
11821186
if (query->qual!=NULL)
@@ -1198,7 +1202,7 @@ get_rte_for_var(Var *var, deparse_context *context)
11981202
while (sup-->0)
11991203
rtlist=lnext(rtlist);
12001204

1201-
return(RangeTblEntry*)nth(var->varno-1, (List*)lfirst(rtlist));
1205+
returnrt_fetch(var->varno, (List*)lfirst(rtlist));
12021206
}
12031207

12041208

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp