summaryrefslogtreecommitdiff
path: root/src/backend/rewrite
Commit message (Collapse)AuthorAgeFilesLines
* Hello.Bruce Momjian1999-10-261-3/+18
| | | | | | | | | | | | | | | | | | | The following patch extends the COMMENT ON functionality to the rest of the database objects beyond just tables, columns, and views. The grammer of the COMMENT ON statement now looks like: COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] <objname> | COLUMN <relation>.<attribute> | AGGREGATE <aggname> <aggtype> | FUNCTION <funcname> (arg1, arg2, ...) | OPERATOR <op> (leftoperand_typ rightoperand_typ) | TRIGGER <triggername> ON relname> Mike Mascari (mascarim@yahoo.com)
* Bugfix for CREATE RULE invoked via SPI --- from Hiroshi,Tom Lane1999-10-211-2/+3
| | | | 23 Jul 99. Not sure why this didn't get applied before...
* Remove fixed-size buffers in rule storage routine.Tom Lane1999-10-211-35/+40
|
* Except_Intersect_Rewrite() forgot to move LIMIT info to newTom Lane1999-10-171-1/+8
| | | | topmost SELECT node after rearranging query tree.
* Fix planner and rewriter to follow SQL semantics for tables that areTom Lane1999-10-071-35/+56
| | | | | | | | | | | mentioned in FROM but not elsewhere in the query: such tables should be joined over anyway. Aside from being more standards-compliant, this allows removal of some very ugly hacks for COUNT(*) processing. Also, allow HAVING clause without aggregate functions, since SQL does. Clean up CREATE RULE statement-list syntax the same way Bruce just fixed the main stmtmulti production. CAUTION: addition of a field to RangeTblEntry nodes breaks stored rules; you will have to initdb if you have any rules.
* Stick finger into a couple more holes in the leaky dike ofTom Lane1999-10-021-1/+16
| | | | | | | modifyAggrefQual. This routine really, really needs to be retired, but until we have subselects in FROM there's no chance of doing the job right. In the meantime try to respond to unhandlable cases with elog rather than coredump.
* Clean up rewriter routines to use expression_tree_walker andTom Lane1999-10-013-2430/+953
| | | | | | | | | | | | 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 ...
* Remove incorrect 'Assert(targetList != NULL)'. AnTom Lane1999-09-191-9/+2
| | | | | INSERT ... DEFAULT VALUES statement does indeed have a null targetlist, at least during parse and rewrite stages.
* Mega-commit to make heap_open/heap_openr/heap_close take anTom Lane1999-09-185-54/+33
| | | | | | | | | | | | | | | | | additional argument specifying the kind of lock to acquire/release (or 'NoLock' to do no lock processing). Ensure that all relations are locked with some appropriate lock level before being examined --- this ensures that relevant shared-inval messages have been processed and should prevent problems caused by concurrent VACUUM. Fix several bugs having to do with mismatched increment/decrement of relation ref count and mismatched heap_open/close (which amounts to the same thing). A bogus ref count on a relation doesn't matter much *unless* a SI Inval message happens to arrive at the wrong time, which is probably why we got away with this sloppiness for so long. Repair missing grab of AccessExclusiveLock in DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi. Recommend 'make clean all' after pulling this update; I modified the Relation struct layout slightly. Will post further discussion to pghackers list shortly.
* Revise implementation of SubLinks so that there is a consistent,Tom Lane1999-08-252-101/+43
| | | | | | | | | documented intepretation of the lefthand and oper fields. Fix a number of obscure problems while at it --- for example, the old code failed if the parser decided to insert a type-coercion function just below the operator of a SubLink. CAUTION: this will break stored rules that contain subplans. You may need to initdb.
* Major revision of sort-node handling: push knowledge of queryTom Lane1999-08-211-14/+28
| | | | | | | | | | | | | sort order down into planner, instead of handling it only at the very top level of the planner. This fixes many things. An explicit sort is now avoided if there is a cheaper alternative (typically an indexscan) not only for ORDER BY, but also for the internal sort of GROUP BY. It works even when there is no other reason (such as a WHERE condition) to consider the indexscan. It works for indexes on functions. It works for indexes on functions, backwards. It's just so cool... CAUTION: I have changed the representation of SortClause nodes, therefore THIS UPDATE BREAKS STORED RULES. You will need to initdb.
* Install new alignment code to use MAXALIGN rather than DOUBLEALIGN whereBruce Momjian1999-07-191-3/+4
| | | | approproate.
* Move some system includes into c.h, and remove duplicates.Bruce Momjian1999-07-174-15/+4
|
* Final cleanup.Bruce Momjian1999-07-165-30/+30
|
* Update #include cleanupsBruce Momjian1999-07-166-18/+18
|
* Remove unused #includes in *.c files.Bruce Momjian1999-07-156-47/+6
|
* Clean up #include in /include directory. Add scripts for checking includes.Bruce Momjian1999-07-155-15/+10
|
* Remove S*I comments from Stephan.Bruce Momjian1999-07-132-17/+2
|
* RewritePreprocessQuery tried to match resjunk targets againstTom Lane1999-07-111-6/+9
| | | | result relation ... wrong ...
* Clean up maximum rewrite tuple length.Bruce Momjian1999-07-041-14/+8
|
* Replace rewriter's checkQueryHasAggs and checkQueryHasSubLinkTom Lane1999-06-211-226/+29
| | | | | | | | with expression_tree_walker-based code. The former failed to cope with expressions containing SubLinks, and the latter returned TRUE for both SubLinks and Aggrefs (cut-and-paste bug?). There is a lot more scope for using expression_tree_walker in this module, but I'll restrain myself until the 6.6 split occurs from touching not-demonstrably-broken code.
* Make functions static or NOT_USED as appropriate.Bruce Momjian1999-05-262-10/+17
|
* pgindent run over code.Bruce Momjian1999-05-254-1326/+1438
|
* Bugfix - Range table entries that are unused after rewriting shouldJan Wieck1999-05-251-2/+140
| | | | | | | | | | | not be marked inFromCl any longer. Otherwise the planner gets confused and joins over them where in fact it does not have to. Adjust hasSubLinks now with a recursive lookup - could be wrong in multi action rules because parse state isn't reset correctly and all actions in the rule are marked hasSubLinks if one of them has. Jan
* Skip junk nodes when comparing UNION target list lengths.Bruce Momjian1999-05-171-5/+14
|
* Change resjunk to a boolean.Bruce Momjian1999-05-171-2/+2
|
* Rip out QueryTreeList structure, root and branch. QuerytreeTom Lane1999-05-131-18/+18
| | | | | | | | | | lists are now plain old garden-variety Lists, allocated with palloc, rather than specialized expansible-array data allocated with malloc. This substantially simplifies their handling and eliminates several sources of memory leakage. Several basic types of erroneous queries (syntax error, attempt to insert a duplicate key into a unique index) now demonstrably leak zero bytes per query.
* Fixed wrong hasAggs when aggregate columns of view aren'tJan Wieck1999-05-122-4/+146
| | | | | | | | selected. Disabled ability of defining DISTINCT or ORDER BY on views. Jan
* Replaced targetlist entry in GroupClause by reference numberJan Wieck1999-05-122-126/+53
| | | | | | | in Resdom and GroupClause so changing of resno's doesn't confuse the grouping any more. Jan
* Change error messages to oids come out as %u and not %d. Change has noBruce Momjian1999-05-102-5/+5
| | | | real affect now.
* Rearrange top-level rewrite operations so that EXPLAIN worksTom Lane1999-05-091-9/+54
| | | | on queries involving UNION, EXCEPT, INTERSECT.
* Final optimizer cleanups.Bruce Momjian1999-02-221-3/+3
|
* From: Tatsuo Ishii <t-ishii@sra.co.jp>Marc G. Fournier1999-02-212-4/+4
| | | | | | Ok. I made patches replacing all of "#if FALSE" or "#if 0" to "#ifdef NOT_USED" for current. I have tested these patches in that the postgres binaries are identical.
* Change my-function-name-- to my_function_name, and optimizer renames.Bruce Momjian1999-02-136-12/+12
|
* Added LIMIT/OFFSET functionality including new regression test for it.Jan Wieck1999-02-081-1/+7
| | | | | | | Removed CURRENT keyword for rule queries and changed rules regression accordingly. CURRENT has beed announced to disappear in v6.5. Jan
* Revert some changes from the INTERSECT/EXPECT patch that brokeJan Wieck1999-02-081-10/+20
| | | | | | | | | | | | rule system semantics by having Var nodes referenced across multiple parsetrees when rules split them. Added more tests to the rules regression test. The code in question resulted from v6.3 based development and was a little careless applied to the v6.5 source tree. Jan
* Cleanup of source files where 'return' or 'var =' is alone on a line.Bruce Momjian1999-02-033-13/+8
|
* Add TEMP tables/indexes. Add COPY pfree(). Other cleanups.Bruce Momjian1999-02-021-3/+7
|
* Agg/Aggreg cleanup and datetime.sql patch.Bruce Momjian1999-01-253-31/+31
|
* SELECT FOR UPDATE is implemented...Vadim B. Mikheev1999-01-251-1/+3
|
* Rename Aggreg to Aggref.Bruce Momjian1999-01-243-128/+128
|
* FOR UPDATE is in parser & rules.Vadim B. Mikheev1999-01-211-2/+40
|
* Hi!Bruce Momjian1999-01-182-14/+477
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Initial MVCC code.Vadim B. Mikheev1998-12-152-5/+5
| | | | New code for locking buffer' context.
* Add support for the CASE statement in the rewrite handling.Thomas G. Lockhart1998-12-143-8/+170
| | | | | | Allows (at least some) rules and views. Still some trouble (crashes) with target CASE columns spanning tables, but lots now works.
* Implement CASE expression.Thomas G. Lockhart1998-12-041-13/+74
|
* New HeapTuple structure/interface.Vadim B. Mikheev1998-11-272-6/+6
|
* The patch does 2 things:Bruce Momjian1998-10-212-477/+390
| | | | | | | | | | | | 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.
* Fix for rules system from Jan.Bruce Momjian1998-10-202-7/+8
|
* Make functions static or ifdef NOT_USED. Prevent pg_version creation.Bruce Momjian1998-10-081-1/+6
|