diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-09-29 18:21:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-09-29 18:21:41 +0000 |
commit | 3a94e789f5c9537d804210be3cb26f7fb08e3b9e (patch) | |
tree | f1eac12405e3c0ded881d7dd7e59cec35b30c335 /src/backend/rewrite/rewriteSupport.c | |
parent | 6f64c2e54a0b14154a335249f4dca91a39c61c50 (diff) | |
download | postgresql-3a94e789f5c9537d804210be3cb26f7fb08e3b9e.tar.gz postgresql-3a94e789f5c9537d804210be3cb26f7fb08e3b9e.zip |
Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.
(Don't forget that an alias is required.) Views reimplemented as expanding
to subselect-in-FROM. Grouping, aggregates, DISTINCT in views actually
work now (he says optimistically). No UNION support in subselects/views
yet, but I have some ideas about that. Rule-related permissions checking
moved out of rewriter and into executor.
INITDB REQUIRED!
Diffstat (limited to 'src/backend/rewrite/rewriteSupport.c')
-rw-r--r-- | src/backend/rewrite/rewriteSupport.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index fe87f569387..264021da223 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.43 2000/06/30 07:04:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.44 2000/09/29 18:21:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,10 +34,11 @@ IsDefinedRewriteRule(char *ruleName) } /* - * setRelhasrulesInRelation - * Set the value of the relation's relhasrules field in pg_class. + * SetRelationRuleStatus + * Set the value of the relation's relhasrules field in pg_class; + * if the relation is becoming a view, also adjust its relkind. * - * NOTE: caller should be holding an appropriate lock on the relation. + * NOTE: caller must be holding an appropriate lock on the relation. * * NOTE: an important side-effect of this operation is that an SI invalidation * message is sent out to all backends --- including me --- causing relcache @@ -47,7 +48,8 @@ IsDefinedRewriteRule(char *ruleName) * an SI message in that case. */ void -setRelhasrulesInRelation(Oid relationId, bool relhasrules) +SetRelationRuleStatus(Oid relationId, bool relHasRules, + bool relIsBecomingView) { Relation relationRelation; HeapTuple tuple; @@ -63,7 +65,10 @@ setRelhasrulesInRelation(Oid relationId, bool relhasrules) Assert(HeapTupleIsValid(tuple)); /* Do the update */ - ((Form_pg_class) GETSTRUCT(tuple))->relhasrules = relhasrules; + ((Form_pg_class) GETSTRUCT(tuple))->relhasrules = relHasRules; + if (relIsBecomingView) + ((Form_pg_class) GETSTRUCT(tuple))->relkind = RELKIND_VIEW; + heap_update(relationRelation, &tuple->t_self, tuple, NULL); /* Keep the catalog indices up to date */ |