summaryrefslogtreecommitdiff
path: root/src/include/rewrite
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of the separate RULE privilege for tables: now only a table's ownerTom Lane2006-09-051-1/+3
| | | | | | | | | | | | | can create or modify rules for the table. Do setRuleCheckAsUser() while loading rules into the relcache, rather than when defining a rule. This ensures that permission checks for tables referenced in a rule are done with respect to the current owner of the rule's table, whereas formerly ALTER TABLE OWNER would fail to update the permission checking for associated rules. Removal of separate RULE privilege is needed to prevent various scenarios in which a grantee of RULE privilege could effectively have any privilege of the table owner. For backwards compatibility, GRANT/REVOKE RULE is still accepted, but it doesn't do anything. Per discussion here: http://archives.postgresql.org/pgsql-hackers/2006-04/msg01138.php
* Allow each C include file to compile on its own by including any neededBruce Momjian2006-07-111-1/+2
| | | | header files.
* DROP ... IF EXISTS for the following cases:Andrew Dunstan2006-06-161-2/+2
| | | | language, tablespace, trigger, rule, opclass, function, aggregate. operator, and cast.
* Update copyright for 2006. Update scripts.Bruce Momjian2006-03-056-12/+12
|
* Change expandRTE() and ResolveNew() back to taking just the singleTom Lane2005-06-041-2/+2
| | | | | | RTE of interest, rather than the whole rangetable list. This makes the API more understandable and avoids duplicate RTE lookups. This patch reverts no-longer-needed portions of my patch of 2004-08-19.
* Revise handling of dropped columns in JOIN alias lists to avoid aTom Lane2005-06-031-1/+2
| | | | | | | | | | | | | | | | | | | | | performance problem pointed out by phil@vodafone: to wit, we were spending O(N^2) time to check dropped-ness in an N-deep join tree, even in the case where the tree was freshly constructed and couldn't possibly mention any dropped columns. Instead of recursing in get_rte_attribute_is_dropped(), change the data structure definition: the joinaliasvars list of a JOIN RTE must have a NULL Const instead of a Var at any position that references a now-dropped column. This costs nothing during normal parse-rewrite-plan path, and instead we have a linear-time update to make when loading a stored rule that might contain now-dropped columns. While at it, move the responsibility for acquring locks on relations referenced by rules into this separate function (which I therefore chose to call AcquireRewriteLocks). This saves effort --- namely, duplicated lock grabs in parser and rewriter --- in the normal path at a cost of one extra non-locked heap_open() in the stored-rule path; seems a good tradeoff. A fringe benefit is that it is now *much* clearer that we acquire lock on relations referenced in rules before we make any rewriter decisions based on their properties. (I don't know of any bug of that ilk, but it wasn't exactly clear before.)
* Make the behavior of HAVING without GROUP BY conform to the SQL spec.Tom Lane2005-03-101-2/+1
| | | | | | | | | Formerly, if such a clause contained no aggregate functions we mistakenly treated it as equivalent to WHERE. Per spec it must cause the query to be treated as a grouped query of a single group, the same as appearance of aggregate functions would do. Also, the HAVING filter must execute after aggregate function computation even if it itself contains no aggregate functions.
* Tag appropriate files for rc3PostgreSQL Daemon2004-12-316-12/+12
| | | | | | | | Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
* Pgindent run for 8.0.Bruce Momjian2004-08-291-3/+3
|
* Update copyright to 2004.Bruce Momjian2004-08-296-12/+12
|
* Repair some issues with column aliases and RowExpr construction in theTom Lane2004-08-191-2/+2
| | | | | | | | | | | | presence of dropped columns. Document the already-presumed fact that eref aliases in relation RTEs are supposed to have entries for dropped columns; cause the user alias structs to have such entries too, so that there's always a one-to-one mapping to the underlying physical attnums. Adjust expandRTE() and related code to handle the case where a column that is part of a JOIN has been dropped. Generalize expandRTE()'s API so that it can be used in a couple of places that formerly rolled their own implementation of the same logic. Fix ruleutils.c to suppress display of aliases for columns that were dropped since the rule was made.
* Promote row expressions to full-fledged citizens of the expression syntax,Tom Lane2004-05-101-2/+3
| | | | | | | | | | rather than allowing them only in a few special cases as before. In particular you can now pass a ROW() construct to a function that accepts a rowtype parameter. Internal generation of RowExprs fixes a number of corner cases that used to not work very well, such as referencing the whole-row result of a JOIN or subquery. This represents a further step in the work I started a month or so back to make rowtype values into first-class citizens.
* make sure the $Id tags are converted to $PostgreSQL as well ...PostgreSQL Daemon2003-11-296-6/+6
|
* Update copyrights to 2003.Bruce Momjian2003-08-046-12/+12
|
* Rule rewriter was doing the wrong thing with conditional INSTEAD rulesTom Lane2002-10-201-2/+2
| | | | | | | | | whose conditions might yield NULL. The negated qual to attach to the original query is properly 'x IS NOT TRUE', not 'NOT x'. This fix produces correct behavior, but we may be taking a performance hit because the planner is much stupider about IS NOT TRUE than it is about NOT clauses. Future TODO: teach prepqual, other parts of planner how to cope with BooleanTest clauses more effectively.
* pgindent run.Bruce Momjian2002-09-042-4/+4
|
* The attached patch (against HEAD) implementsBruce Momjian2002-07-181-2/+2
| | | | | | | | | | | | | | | COPY x (a,d,c,b) from stdin; COPY x (a,c) to stdout; as well as the corresponding changes to pg_dump to use the new functionality. This functionality is not available when using the BINARY option. If a column is not specified in the COPY FROM statement, its default values will be used. In addition to this functionality, I tweaked a couple of the error messages emitted by the new COPY <options> checks. Brent Verner
* Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.Tom Lane2002-07-121-3/+7
| | | | | | | | | | | | pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY constraints all have real live entries in pg_constraint. pg_depend exists, and RESTRICT/CASCADE options work on most kinds of DROP; however, pg_depend is not yet very well populated with dependencies. (Most of the ones that are present at this point just replace formerly hardwired associations, such as the implicit drop of a relation's pg_type entry when the relation is dropped.) Need to add more logic to create dependency entries, improve pg_dump to dump constraints in place of indexes and triggers, and add some regression tests.
* Update copyright to 2002.Bruce Momjian2002-06-206-12/+12
|
* Change naming rule for ON SELECT rules of views: they're all justTom Lane2002-04-191-3/+4
| | | | _RETURN now, since there's no need to keep 'em unique anymore.
* Rule names are now unique per-relation, rather than unique globally.Tom Lane2002-04-183-6/+7
| | | | | | | | DROP RULE and COMMENT ON RULE syntax adds an 'ON tablename' clause, similar to TRIGGER syntaxes. To allow loading of existing pg_dump files containing COMMENT ON RULE, the COMMENT code will still accept the old syntax --- but only if the target rulename is unique across the whole database.
* pg_type has a typnamespace column; system now supports creating typesTom Lane2002-03-291-2/+2
| | | | | | in different namespaces. Also, cleanup work on relation namespace support: drop, alter, rename commands work for tables in non-default namespaces.
* Change the aclchk.c routines to uniformly use OIDs to identify theTom Lane2002-03-211-2/+1
| | | | | | objects to be privilege-checked. Some change in their APIs would be necessary no matter what in the schema environment, and simply getting rid of the name-based interface entirely seems like the best way.
* New pgindent run with fixes suggested by Tom. Patch manually reviewed,Bruce Momjian2001-11-056-12/+12
| | | | initdb/regression tests pass.
* Another pgindent run. Fixes enum indenting, and improves #endifBruce Momjian2001-10-286-6/+12
| | | | spacing. Also adds space for one-line comments.
* pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian2001-10-256-12/+6
| | | | tests pass.
* Make ALTER TABLE RENAME on a view rename the view's on-select rule too.Tom Lane2001-08-122-3/+7
| | | | Needed to keep pg_dump from getting confused.
* Remove some dead code, simplify calling convention.Tom Lane2001-06-132-20/+6
|
* pgindent run. Make it all clean.Bruce Momjian2001-03-222-6/+6
|
* Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.Bruce Momjian2001-01-246-12/+12
|
* Repair breakage of rules containing INSERT ... SELECT actions, per bugTom Lane2000-12-051-2/+3
| | | | | | | | | | | report from Joel Burton. Turns out that my simple idea of turning the SELECT into a subquery does not interact well *at all* with the way the rule rewriter works. Really what we need to make INSERT ... SELECT work cleanly is to decouple targetlists from rangetables: an INSERT ... SELECT wants to have two levels of targetlist but only one rangetable. No time for that for 7.1, however, so I've inserted some ugly hacks to make the rewriter know explicitly about the structure of INSERT ... SELECT queries. Ugh :-(
* Change SearchSysCache coding conventions so that a reference count isTom Lane2000-11-161-2/+2
| | | | | | | maintained for each cache entry. A cache entry will not be freed until the matching ReleaseSysCache call has been executed. This eliminates worries about cache entries getting dropped while still in use. See my posting to pg-hackers of even date for more info.
* Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.Tom Lane2000-09-293-32/+6
| | | | | | | | | (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!
* First cut at full support for OUTER JOINs. There are still a few looseTom Lane2000-09-122-7/+10
| | | | | ends to clean up (see my message of same date to pghackers), but mostly it works. INITDB REQUIRED!
* Use a private memory context to store rule information in each relcacheTom Lane2000-06-301-9/+2
| | | | | | | | | | | | | | entry that has rules. This allows us to release the rule parsetrees on relcache flush without needing a working freeObject() routine. Formerly, the rule trees were leaked permanently at relcache flush. Also, clean up handling of rule creation and deletion --- there was not sufficient locking of the relation being modified, and there was no reliable notification of other backends that a relcache reload was needed. Also, clean up relcache.c code so that scans of system tables needed to load a relcache entry are done in the caller's memory context, not in CacheMemoryContext. This prevents any un-pfreed memory from those scans from becoming a permanent memory leak.
* Ye-old pgindent run. Same 4-space tabs.Bruce Momjian2000-04-121-5/+5
|
* Fix some (more) problems with subselects in rules. Rewriter failed toTom Lane2000-03-161-1/+6
| | | | | | | mark query as having subselects if a subselect was added from a rule WHERE condition (as opposed to a rule action). Also, fix adjustment of varlevelsup so that it actually has some prospect of working when inserting an expression containing a subselect into a subquery.
* Add:Bruce Momjian2000-01-267-14/+21
| | | | | | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
* Clean up rewriter routines to use expression_tree_walker andTom Lane1999-10-011-13/+12
| | | | | | | | | | | | expression_tree_mutator rather than ad-hoc tree walking code. This shortens the code materially and fixes a fair number of sins of omission. Also, change modifyAggrefQual to *not* recurse into subselects, since its mission is satisfied if it removes aggregate functions from the top level of a WHERE clause. This cures problems with queries of the form SELECT ... WHERE x IN (SELECT ... HAVING something-using-an-aggregate), which would formerly get mucked up by modifyAggrefQual. The routine is still fundamentally broken, of course, but I don't think there's any way to get rid of it before we implement subselects in FROM ...
* Change #include's to use <> and "" as appropriate.Bruce Momjian1999-07-151-3/+3
|
* Clean up #include in /include directory. Add scripts for checking includes.Bruce Momjian1999-07-153-7/+3
|
* Make functions static or NOT_USED as appropriate.Bruce Momjian1999-05-262-8/+2
|
* pgindent run over code.Bruce Momjian1999-05-252-3/+5
|
* Replaced targetlist entry in GroupClause by reference numberJan Wieck1999-05-121-1/+2
| | | | | | | in Resdom and GroupClause so changing of resno's doesn't confuse the grouping any more. Jan
* Change my-function-name-- to my_function_name, and optimizer renames.Bruce Momjian1999-02-137-14/+14
|
* Hi!Bruce Momjian1999-01-182-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | INTERSECT and EXCEPT is available for postgresql-v6.4! The patch against v6.4 is included at the end of the current text (in uuencoded form!) I also included the text of my Master's Thesis. (a postscript version). I hope that you find something of it useful and would be happy if parts of it find their way into the PostgreSQL documentation project (If so, tell me, then I send the sources of the document!) The contents of the document are: -) The first chapter might be of less interest as it gives only an overview on SQL. -) The second chapter gives a description on much of PostgreSQL's features (like user defined types etc. and how to use these features) -) The third chapter starts with an overview of PostgreSQL's internal structure with focus on the stages a query has to pass (i.e. parser, planner/optimizer, executor). Then a detailed description of the implementation of the Having clause and the Intersect/Except logic is given. Originally I worked on v6.3.2 but never found time enough to prepare and post a patch. Now I applied the changes to v6.4 to get Intersect and Except working with the new version. Chapter 3 of my documentation deals with the changes against v6.3.2, so keep that in mind when comparing the parts of the code printed there with the patched sources of v6.4. Here are some remarks on the patch. There are some things that have still to be done but at the moment I don't have time to do them myself. (I'm doing my military service at the moment) Sorry for that :-( -) I used a rewrite technique for the implementation of the Except/Intersect logic which rewrites the query to a semantically equivalent query before it is handed to the rewrite system (for views, rules etc.), planner, executor etc. -) In v6.3.2 the types of the attributes of two select statements connected by the UNION keyword had to match 100%. In v6.4 the types only need to be familiar (i.e. int and float can be mixed). Since this feature did not exist when I worked on Intersect/Except it does not work correctly for Except/Intersect queries WHEN USED IN COMBINATION WITH UNIONS! (i.e. sometimes the wrong type is used for the resulting table. This is because until now the types of the attributes of the first select statement have been used for the resulting table. When Intersects and/or Excepts are used in combination with Unions it might happen, that the first select statement of the original query appears at another position in the query which will be executed. The reason for this is the technique used for the implementation of Except/Intersect which does a query rewrite!) NOTE: It is NOT broken for pure UNION queries and pure INTERSECT/EXCEPT queries!!! -) I had to add the field intersect_clause to some data structures but did not find time to implement printfuncs for the new field. This does NOT break the debug modes but when an Except/Intersect is used the query debug output will be the already rewritten query. -) Massive changes to the grammar rules for SELECT and INSERT statements have been necessary (see comments in gram.y and documentation for deatails) in order to be able to use mixed queries like (SELECT ... UNION (SELECT ... EXCEPT SELECT)) INTERSECT SELECT...; -) When using UNION/EXCEPT/INTERSECT you will get: NOTICE: equal: "Don't know if nodes of type xxx are equal". I did not have time to add comparsion support for all the needed nodes, but the default behaviour of the function equal met my requirements. I did not dare to supress this message! That's the reason why the regression test for union will fail: These messages are also included in the union.out file! -) Somebody of you changed the union_planner() function for v6.4 (I copied the targetlist to new_tlist and that was removed and replaced by a cleanup of the original targetlist). These chnages violated some having queries executed against views so I changed it back again. I did not have time to examine the differences between the two versions but now it works :-) If you want to find out, try the file queries/view_having.sql on both versions and compare the results . Two queries won't produce a correct result with your version. regards Stefan
* The patch does 2 things:Bruce Momjian1998-10-211-2/+2
| | | | | | | | | | | | Fixes a bug in the rule system that caused a crashing backend when a join-view with calculated column is used in subselect. Modifies EXPLAIN to explain rewritten queries instead of the plain SeqScan on a view. Rules can produce very deep MORE Jan.
* Make functions static or ifdef NOT_USED. Prevent pg_version creation.Bruce Momjian1998-10-081-4/+1
|
* Here's a combination of all the patches I'm currently waitingBruce Momjian1998-10-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for against a just updated CVS tree. It contains Partial new rewrite system that handles subselects, view aggregate columns, insert into select from view, updates with set col = view-value and select rules restriction to view definition. Updates for rule/view backparsing utility functions to handle subselects correct. New system views pg_tables and pg_indexes (where you can see the complete index definition in the latter one). Enabling array references on query parameters. Bugfix for functional index. Little changes to system views pg_rules and pg_views. The rule system isn't a release-stopper any longer. But another stopper is that I don't know if the latest changes to PL/pgSQL (not already in CVS) made it compile on AIX. Still wait for some response from Dave. Jan
* OK, folks, here is the pgindent output.Bruce Momjian1998-09-017-25/+20
|