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

Commit338c54c

Browse files
committed
From: Jan Wieck <jwieck@debis.com>Hi, as proposed here comes the first patch for the query rewrite system. <for details, see archive dated Mon, 17 Aug 1998>
1 parentfde6526 commit338c54c

File tree

8 files changed

+942
-40
lines changed

8 files changed

+942
-40
lines changed

‎src/backend/parser/analyze.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.79 1998/07/20 20:48:51 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.80 1998/08/18 00:48:54 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -742,11 +742,33 @@ static Query *
742742
transformRuleStmt(ParseState*pstate,RuleStmt*stmt)
743743
{
744744
Query*qry;
745+
Query*action;
745746
List*actions;
746747

747748
qry=makeNode(Query);
748749
qry->commandType=CMD_UTILITY;
749750

751+
/*
752+
* 'instead nothing' rules with a qualification need a
753+
* query a rangetable so the rewrite handler can add the
754+
* negated rule qualification to the original query. We
755+
* create a query with the new command type CMD_NOTHING
756+
* here that is treated special by the rewrite system.
757+
*/
758+
if (stmt->actions==NIL) {
759+
Query*nothing_qry=makeNode(Query);
760+
nothing_qry->commandType=CMD_NOTHING;
761+
762+
addRangeTableEntry(pstate,stmt->object->relname,"*CURRENT*",
763+
FALSE, FALSE);
764+
addRangeTableEntry(pstate,stmt->object->relname,"*NEW*",
765+
FALSE, FALSE);
766+
767+
nothing_qry->rtable=pstate->p_rtable;
768+
769+
stmt->actions=lappend(NIL,nothing_qry);
770+
}
771+
750772
actions=stmt->actions;
751773

752774
/*
@@ -768,7 +790,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
768790
pstate->p_is_rule= true;/* for expand all */
769791
pstate->p_hasAggs= false;
770792

771-
lfirst(actions)=transformStmt(pstate,lfirst(actions));
793+
action= (Query*)lfirst(actions);
794+
if (action->commandType!=CMD_NOTHING)
795+
lfirst(actions)=transformStmt(pstate,lfirst(actions));
772796
actions=lnext(actions);
773797
}
774798

‎src/backend/parser/gram.y

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.22 1998/08/17 16:08:34 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.23 1998/08/18 00:48:55 scrappy Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -1955,6 +1955,7 @@ RuleStmt: CREATE RULE name AS
19551955
OptStmtList: NOTHING{ $$ = NIL; }
19561956
| OptimizableStmt{ $$ = lcons($1, NIL); }
19571957
| '[' OptStmtBlock ']'{ $$ = $2; }
1958+
| '(' OptStmtBlock ')'{ $$ = $2; }
19581959
;
19591960

19601961
OptStmtBlock: OptStmtMulti

‎src/backend/parser/parse_relation.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.12 1998/07/08 14:04:11 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.13 1998/08/18 00:48:57 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -191,8 +191,13 @@ addRangeTableEntry(ParseState *pstate,
191191
if (pstate!=NULL)
192192
{
193193
if (refnameRangeTablePosn(pstate,refname,&sublevels_up)!=0&&
194-
(!inFromCl||sublevels_up==0))
194+
(!inFromCl||sublevels_up==0)) {
195+
if (!strcmp(refname,"*CURRENT*")|| !strcmp(refname,"*NEW*")) {
196+
intrt_index=refnameRangeTablePosn(pstate,refname,&sublevels_up);
197+
return (RangeTblEntry*)nth(rt_index-1,pstate->p_rtable);
198+
}
195199
elog(ERROR,"Table name %s specified more than once",refname);
200+
}
196201
}
197202

198203
rte->relname=pstrdup(relname);

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.16 1998/06/15 19:29:06 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.17 1998/08/18 00:48:58 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -155,12 +155,7 @@ ValidateRule(int event_type,
155155
"rules not allowed for insert or delete events to an attribute");
156156
}
157157

158-
if (event_qual&& !*action&&is_instead)
159-
elog(ERROR,
160-
"event_quals on 'instead nothing' rules not currently supported");
161-
162158
#if0
163-
164159
/*
165160
* on retrieve to class.attribute do instead nothing is converted to
166161
* 'on retrieve to class.attribute do instead retrieve (attribute =

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp