summaryrefslogtreecommitdiff
path: root/src/backend/rewrite
Commit message (Collapse)AuthorAgeFilesLines
* O.K. -Bruce Momjian2000-09-121-3/+6
| | | | | | | | | | | | | | | | | | | Here's the multibyte aware version of my patch to fix the truncation of the rulename autogenerated during a CREATE VIEW. I've modified all the places in the backend that want to construct the rulename to use the MakeRetrieveViewRuleName(), where I put the #ifdef MULTIBYTE, so that's the only place that knows how to construct a view rulename. Except pg_dump, where I replicated the code, since it's a standalone binary. The only effect the enduser will see is that views with names len(name) > NAMEDATALEN-4 will fail to be created, if the derived rulename clases with an existing rule: i.e. the user is trying to create two views with long names whose first difference is past NAMEDATALEN-4 (but before NAMEDATALEN: that'll error out after the viewname truncation.) In no case will the user get left with a table without a view rule, as the current code does. Ross Reedstrom
* Code cleanup of user name and user id handling in the backend. The currentPeter Eisentraut2000-09-062-5/+5
| | | | | | | | | | | user is now defined in terms of the user id, the user name is only computed upon request (for display purposes). This is kind of the opposite of the previous state, which would maintain the user name and compute the user id for permission checks. Besides perhaps saving a few cycles (integer vs string), this now creates a single point of attack for changing the user id during a connection, for purposes of "setuid" functions, etc.
* Fix relative path references so that make knowns which dependencies referPeter Eisentraut2000-08-311-4/+4
| | | | | to one another. Sort out builddir vs srcdir variable namings. Remove some now obsoleted make variables.
* Remove 'func_tlist' from Func expression nodes, likewise 'param_tlist'Tom Lane2000-08-081-4/+2
| | | | | | | | from Param nodes, per discussion a few days ago on pghackers. Add new expression node type FieldSelect that implements the functionality where it's actually needed. Clean up some other unused fields in Func nodes as well. NOTE: initdb forced due to change in stored expression trees for rules.
* Type lztext is toast.Tom Lane2000-07-301-3/+3
| | | | | | | (Sorry, couldn't help it...) Removed type filename as well, since it's unused and probably useless. INITDB FORCED, because pg_rewrite columns are now plain text again.
* Make view/rule permission checking behave properly withTom Lane2000-07-091-56/+126
| | | | subqueries in the rule.
* Use a private memory context to store rule information in each relcacheTom Lane2000-06-304-303/+101
| | | | | | | | | | | | | | 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.
* First phase of memory management rewrite (see backend/utils/mmgr/READMETom Lane2000-06-282-60/+63
| | | | | | | | | | | | | for details). It doesn't really do that much yet, since there are no short-term memory contexts in the executor, but the infrastructure is in place and long-term contexts are handled reasonably. A few long- standing bugs have been fixed, such as 'VACUUM; anything' in a single query string crashing. Also, out-of-memory is now considered a recoverable ERROR, not FATAL. Eliminate a large amount of crufty, now-dead code in and around memory management. Fix problem with holding off SIGTRAP, SIGSEGV, etc in postmaster and backend startup.
* Final #include cleanup.Bruce Momjian2000-06-151-2/+1
|
* Clean up #include's.Bruce Momjian2000-06-151-1/+2
|
* Rename rule CURRENT to OLD in source tree. Add mapping for backwardBruce Momjian2000-06-121-8/+8
| | | | compatiblity with old rules.
* Remove unused include files. Do not touch /port or includes used by defines.Bruce Momjian2000-05-304-9/+4
|
* Generated header files parse.h and fmgroids.h are now copied intoTom Lane2000-05-291-3/+1
| | | | | the src/include tree, so that -I backend is no longer necessary anywhere. Also, clean up some bit rot in contrib tree.
* First round of changes for new fmgr interface. fmgr itself and theTom Lane2000-05-281-1/+2
| | | | | | | key call sites are changed, but most called functions are still oldstyle. An exception is that the PL managers are updated (so, for example, NULL handling now behaves as expected in plperl and plpgsql functions). NOTE initdb is forced due to added column in pg_proc.
* Except_Intersect_Rewrite() failed to ignore resjunk targetlist entries,Tom Lane2000-04-271-33/+50
| | | | | thus causing failure if one sub-select had resjunk entries that the other did not (cf. bug report from Espinosa 4/27/00).
* Correct error in rewriter that caused SELECT count(*) FROM viewTom Lane2000-04-201-19/+19
| | | | | | | to give wrong results: it should be looking at inJoinSet not inFromCl. Also, make 'modified' flag be local to ApplyRetrieveRule: we should append a rule's quals to the query iff that particular rule applies, not if we have fired any previously-considered rule for the query!
* Ye-old pgindent run. Same 4-space tabs.Bruce Momjian2000-04-125-129/+174
|
* When rewriting an aggregate introduced into WHERE, allow agg argument toTom Lane2000-04-041-11/+14
| | | | | | | be an expression not just a simple Var, so long as only one table is referenced (so that code isn't really any more difficult than before). This whole thing is still fundamentally bogus, but at least we can accept a few more cases than before.
* Fix some (more) problems with subselects in rules. Rewriter failed toTom Lane2000-03-162-165/+182
| | | | | | | 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.
* Fix performance problem in fireRIRonSubselect: with nested subqueries,Tom Lane2000-03-121-12/+6
| | | | | fireRIRonSubselect was invoked twice at each subselect, leading to an exponential amount of wasted effort.
* Undo a couple of mistaken applications of NameStr() to StringInfos.Tom Lane2000-02-261-3/+3
| | | | | It worked, because they both have fields named 'data', but it's surely trouble waiting to happen. I wonder whether there are more ...
* Redesign DISTINCT ON as discussed in pgsql-sql 1/25/00: syntax is nowTom Lane2000-01-273-28/+17
| | | | | | | | | | | | | SELECT DISTINCT ON (expr [, expr ...]) targetlist ... and there is a check to make sure that the user didn't specify an ORDER BY that's incompatible with the DISTINCT operation. Reimplement nodeUnique and nodeGroup to use the proper datatype-specific equality function for each column being compared --- they used to do bitwise comparisons or convert the data to text strings and strcmp(). (To add insult to injury, they'd look up the conversion functions once for each tuple...) Parse/plan representation of DISTINCT is now a list of SortClause nodes. initdb forced by querytree change...
* Add:Bruce Momjian2000-01-266-12/+18
| | | | | | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
* Removed MBFLAGS from makefiles since it's now done in include/config.h.Peter Eisentraut2000-01-191-4/+1
|
* Pass atttypmod to CoerceTargetExpr, so that it can pass it on toTom Lane2000-01-171-2/+2
| | | | | coerce_type, so that the right things happen when coercing a previously- unknown constant to a destination data type.
* Fix it's and its to be correct.Bruce Momjian2000-01-051-2/+2
|
* Some changes to prepare for LONG attributes.Jan Wieck1999-12-162-5/+5
| | | | Jan
* New LDOUT makefile variable for QNX os.Bruce Momjian1999-12-131-2/+2
|
* Make LD -r as macros that can be changed for QNX.Bruce Momjian1999-12-091-2/+2
|
* Add pg_statistic index, add missing Hiroshi file.Bruce Momjian1999-11-241-2/+2
|
* Rename heap_replace to heap_update.Bruce Momjian1999-11-241-2/+2
|
* Add system indexes to match all caches.Bruce Momjian1999-11-223-8/+8
| | | | | | | Make all system indexes unique. Make all cache loads use system indexes. Rename *rel to *relid in inheritance tables. Rename cache names to be clearer.
* Changed pg_rewrite attributes ev_qual and ev_action to the newJan Wieck1999-11-182-3/+4
| | | | | | compressed lztext data type. Jan
* Implement subselects in target lists. Also, relax requirement thatTom Lane1999-11-151-76/+78
| | | | | | | | | | | | | subselects can only appear on the righthand side of a binary operator. That's still true for quantified predicates like x = ANY (SELECT ...), but a subselect that delivers a single result can now appear anywhere in an expression. This is implemented by changing EXPR_SUBLINK sublinks to represent just the (SELECT ...) expression, without any 'left hand side' or combining operator --- so they're now more like EXISTS_SUBLINK. To handle the case of '(x, y, z) = (SELECT ...)', I added a new sublink type MULTIEXPR_SUBLINK, which acts just like EXPR_SUBLINK used to. But the grammar will only generate one for a multiple-left-hand-side row expression.
* New NameStr macro to convert Name to Str. No need for var.data anymore.Bruce Momjian1999-11-074-12/+13
| | | | | | Fewer calls to nameout. Better use of RelationGetRelationName.
* Eliminate RewritePreprocessQuery, which was taking anTom Lane1999-11-011-72/+22
| | | | | | unreasonable amount of time to clean up after a vanished parser problem. Don't call fireRIRonSubselect when we know there are no subselects, either.
* 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
|