summaryrefslogtreecommitdiff
path: root/src/backend/rewrite
Commit message (Collapse)AuthorAgeFilesLines
* To suppress memory leakage in long-lived Lists, lremove() should pfreeTom Lane2002-12-171-2/+4
| | | | | the cons cell it's deleting from the list. Do this, and fix a few callers that were bogusly assuming it wouldn't free the cons cell.
* Phase 2 of read-only-plans project: restructure expression-tree nodesTom Lane2002-12-122-8/+8
| | | | | | | | | so that all executable expression nodes inherit from a common supertype Expr. This is somewhat of an exercise in code purity rather than any real functional advance, but getting rid of the extra Oper or Func node formerly used in each operator or function call should provide at least a little space and speed improvement. initdb forced by changes in stored-rules representation.
* More cleanup of userid to be AclId rather than Oid.Bruce Momjian2002-12-051-3/+3
|
* Rule rewriter was doing the wrong thing with conditional INSTEAD rulesTom Lane2002-10-202-33/+27
| | | | | | | | | 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.
* Fix rewrite code so that rules are in fact executed in order by name,Tom Lane2002-10-191-122/+82
| | | | | | | | | | rather than being reordered according to INSTEAD attribute for implementation convenience. Also, increase compiled-in recursion depth limit from 10 to 100 rewrite cycles. 10 seems pretty marginal for situations where multiple rules exist for the same query. There was a complaint about this recently, so I'm going to bump it up. (Perhaps we should make the limit a GUC parameter, but that's too close to being a new feature to do in beta.)
* Adjust handling of command status strings in the presence of rules,Tom Lane2002-10-141-3/+19
| | | | | as per recent pghackers discussions. initdb forced due to change in fields of stored Query nodes.
* Extend pg_cast castimplicit column to a three-way value; this allows usTom Lane2002-09-181-23/+14
| | | | | | | | | | | | | | | | | | | | | | | | to be flexible about assignment casts without introducing ambiguity in operator/function resolution. Introduce a well-defined promotion hierarchy for numeric datatypes (int2->int4->int8->numeric->float4->float8). Change make_const to initially label numeric literals as int4, int8, or numeric (never float8 anymore). Explicitly mark Func and RelabelType nodes to indicate whether they came from a function call, explicit cast, or implicit cast; use this to do reverse-listing more accurately and without so many heuristics. Explicit casts to char, varchar, bit, varbit will truncate or pad without raising an error (the pre-7.2 behavior), while assigning to a column without any explicit cast will still raise an error for wrong-length data like 7.3. This more nearly follows the SQL spec than 7.2 behavior (we should be reporting a 'completion condition' in the explicit-cast cases, but we have no mechanism for that, so just do silent truncation). Fix some problems with enforcement of typmod for array elements; it didn't work at all in 'UPDATE ... SET array[n] = foo', for example. Provide a generalized array_length_coerce() function to replace the specialized per-array-type functions that used to be needed (and were missing for NUMERIC as well as all the datetime types). Add missing conversions int8<->float4, text<->numeric, oid<->int8. initdb forced.
* Tweak querytree-dependency-extraction code so that columns of tablesTom Lane2002-09-113-22/+24
| | | | | | | | | that are explicitly JOINed are not considered dependencies unless they are actually used in the query: mere presence in the joinaliasvars list of a JOIN RTE doesn't count as being used. The patch touches a number of files because I needed to generalize the API of query_tree_walker to support an additional flag bit, but the changes are otherwise quite small.
* pgindent run.Bruce Momjian2002-09-044-62/+61
|
* CREATE OR REPLACE VIEW, CREATE OR REPLACE RULE.Tom Lane2002-09-021-18/+59
| | | | | Gavin Sherry, Neil Conway, and Tom Lane all got their hands dirty on this one ...
* Rephrase 'Cannot insert into a view' and related messages, perTom Lane2002-08-291-4/+7
| | | | pghackers discussion around 31-Jul-02.
* Modify array operations to include array's element type OID in theTom Lane2002-08-261-3/+3
| | | | | | | | | | array header, and to compute sizing and alignment of array elements the same way normal tuple access operations do --- viz, using the tupmacs.h macros att_addlength and att_align. This makes the world safe for arrays of cstrings or intervals, and should make it much easier to write array-type-polymorphic functions; as examples see the cleanups of array_out and contrib/array_iterator. By Joe Conway and Tom Lane.
* Restructure system-catalog index updating logic. Instead of havingTom Lane2002-08-052-28/+7
| | | | | | | | | hardwired lists of index names for each catalog, use the relcache's mechanism for caching lists of OIDs of indexes of any table. This reduces the common case of updating system catalog indexes to a single line, makes it much easier to add a new system index (in fact, you can now do so on-the-fly if you want to), and as a nice side benefit improves performance a little. Per recent pghackers discussion.
* ALTER TABLE DROP COLUMN works. Patch by Christopher Kings-Lynne,Tom Lane2002-08-022-2/+16
| | | | | | | | | | code review by Tom Lane. Remaining issues: functions that take or return tuple types are likely to break if one drops (or adds!) a column in the table defining the type. Need to think about what to do here. Along the way: some code review for recent COPY changes; mark system columns attnotnull = true where appropriate, per discussion a month ago.
* oid is needed, it is added at the end of the struct (after the nullBruce Momjian2002-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitmap, if present). Per Tom Lane's suggestion the information whether a tuple has an oid or not is carried in the tuple descriptor. For debugging reasons tdhasoid is of type char, not bool. There are predefined values for WITHOID, WITHOUTOID and UNDEFOID. This patch has been generated against a cvs snapshot from last week and I don't expect it to apply cleanly to current sources. While I post it here for public review, I'm working on a new version against a current snapshot. (There's been heavy activity recently; hope to catch up some day ...) This is a long patch; if it is too hard to swallow, I can provide it in smaller pieces: Part 1: Accessor macros Part 2: tdhasoid in TupDesc Part 3: Regression test Part 4: Parameter withoid to heap_addheader Part 5: Eliminate t_oid from HeapTupleHeader Part 2 is the most hairy part because of changes in the executor and even in the parser; the other parts are straightforward. Up to part 4 the patched postmaster stays binary compatible to databases created with an unpatched version. Part 5 is small (100 lines) and finally breaks compatibility. Manfred Koizar
* The attached patch (against HEAD) implementsBruce Momjian2002-07-181-3/+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
* Add code to extract dependencies from an expression tree, and use itTom Lane2002-07-161-10/+22
| | | | | | | to build dependencies for rules, constraint expressions, and default expressions. Repair some problems in the original design of recursiveDeletion() exposed by more complex dependency sets. Fix regression tests that were deleting things in illegal sequences.
* Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.Tom Lane2002-07-123-98/+109
| | | | | | | | | | | | 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-205-10/+10
|
* Remove global variable scanCommandId in favor of storing a command IDTom Lane2002-05-211-4/+2
| | | | | | | | | | | in snapshots, per my proposal of a few days ago. Also, tweak heapam.c routines (heap_insert, heap_update, heap_delete, heap_mark4update) to be passed the command ID to use, instead of doing GetCurrentCommandID. For catalog updates they'll still get passed current command ID, but for updates generated from the main executor they'll get passed the command ID saved in the snapshot the query is using. This should fix some corner cases associated with functions and triggers that advance current command ID while an outer query is still in progress.
* Restructure indexscan API (index_beginscan, index_getnext) perTom Lane2002-05-201-10/+3
| | | | | | | yesterday's proposal to pghackers. Also remove unnecessary parameters to heap_beginscan, heap_rescan. I modified pg_proc.h to reflect the new numbers of parameters for the AM interface routines, but did not force an initdb because nothing actually looks at those fields.
* First pass at set-returning-functions in FROM, by Joe Conway withTom Lane2002-05-121-2/+2
| | | | | | some kibitzing from Tom Lane. Not everything works yet, and there's no documentation or regression test, but let's commit this so Joe doesn't need to cope with tracking changes in so many files ...
* Restructure aclcheck error reporting to make permission-failureTom Lane2002-04-272-15/+10
| | | | | | | messages more uniform and internationalizable: the global array aclcheck_error_strings[] is gone in favor of a subroutine aclcheck_error(). Partial implementation of namespace-related permission checks --- not all done yet.
* Change naming rule for ON SELECT rules of views: they're all justTom Lane2002-04-192-45/+20
| | | | _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-46/+47
| | | | | | | | 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.
* Restructure representation of aggregate functions so that they have pg_procTom Lane2002-04-111-2/+2
| | | | | | | | | | entries, per pghackers discussion. This fixes aggregates to live in namespaces, and also simplifies/speeds up lookup in parse_func.c. Also, add a 'proimplicit' flag to pg_proc that controls whether a type coercion function may be invoked implicitly, or only explicitly. The current settings of these flags are more permissive than I would like, but we will need to debate and refine the behavior; for now, I avoided breaking regression tests as much as I could.
* Undo not-so-hot decision to postpone insertion of default values intoTom Lane2002-04-051-2/+299
| | | | | | | | INSERT statements to the planner. Taking it out of the parser was right (so that defaults don't get into stored rules), but it has to happen before rewrite rule expansion, else references to NEW.field behave incorrectly. Accordingly, add a step to the rewriter to insert defaults just before rewrite-rule expansion.
* pg_type has a typnamespace column; system now supports creating typesTom Lane2002-03-291-3/+11
| | | | | | in different namespaces. Also, cleanup work on relation namespace support: drop, alter, rename commands work for tables in non-default namespaces.
* pg_class has a relnamespace column. You can create and access tablesTom Lane2002-03-261-2/+2
| | | | | | in schemas other than the system namespace; however, there's no search path yet, and not all operations work yet on tables outside the system namespace.
* A little further progress on schemas: push down RangeVars intoTom Lane2002-03-221-24/+3
| | | | | | | addRangeTableEntry calls. Remove relname field from RTEs, since it will no longer be a useful unique identifier of relations; we want to encourage people to rely on the relation OID instead. Further work on dumping qual expressions in EXPLAIN, too.
* Change the aclchk.c routines to uniformly use OIDs to identify theTom Lane2002-03-212-38/+26
| | | | | | 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.
* First phase of SCHEMA changes, concentrating on fixing the grammar andTom Lane2002-03-212-86/+10
| | | | | | | | the parsetree representation. As yet we don't *do* anything with schema names, just drop 'em on the floor; but you can enter schema-compatible command syntax, and there's even a primitive CREATE SCHEMA command. No doc updates yet, except to note that you can now extract a field from a function-returning-row's result with (foo(...)).fieldname.
* Restructure representation of join alias variables. An explicit JOINTom Lane2002-03-122-13/+47
| | | | | | | | | | | | | | | now has an RTE of its own, and references to its outputs now are Vars referencing the JOIN RTE, rather than CASE-expressions. This allows reverse-listing in ruleutils.c to use the correct alias easily, rather than painfully reverse-engineering the alias namespace as it used to do. Also, nested FULL JOINs work correctly, because the result of the inner joins are simple Vars that the planner can cope with. This fixes a bug reported a couple times now, notably by Tatsuo on 18-Nov-01. The alias Vars are expanded into COALESCE expressions where needed at the very end of planning, rather than during parsing. Also, beginnings of support for showing plan qualifier expressions in EXPLAIN. There are probably still cases that need work. initdb forced due to change of stored-rule representation.
* New pgindent run with fixes suggested by Tom. Patch manually reviewed,Bruce Momjian2001-11-051-3/+3
| | | | initdb/regression tests pass.
* Another pgindent run. Fixes enum indenting, and improves #endifBruce Momjian2001-10-281-1/+2
| | | | spacing. Also adds space for one-line comments.
* pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian2001-10-252-43/+40
| | | | tests pass.
* Revert treatment of NOTIFY in rules to its pre-7.1 behavior: notify willTom Lane2001-09-071-11/+15
| | | | | | occur unconditionally, even if the rule should otherwise execute conditionally. This is more useful than giving an error, even though it's not truly the correct behavior. Per today's pghackers discussion.
* Make ALTER TABLE RENAME on a view rename the view's on-select rule too.Tom Lane2001-08-122-3/+89
| | | | Needed to keep pg_dump from getting confused.
* Make OIDs optional, per discussions in pghackers. WITH OIDS is still theTom Lane2001-08-101-6/+4
| | | | | | | | | | | | default, but OIDS are removed from many system catalogs that don't need them. Some interesting side effects: TOAST pointers are 20 bytes not 32 now; pg_description has a three-column key instead of one. Bugs fixed in passing: BINARY cursors work again; pg_class.relhaspkey has some usefulness; pg_dump dumps comments on indexes, rules, and triggers in a valid order. initdb forced.
* Fix rule rewriter so that new ordering of ON INSERT actions appliesTom Lane2001-07-091-18/+34
| | | | | | in cases of qualified rules as well as unqualified ones. Tweak rules test to avoid cluttering output with dummy SELECT results. Update documentation to match code.
* Fire rule actions ON INSERT after original statement (if not INSTEAD).Jan Wieck2001-07-061-2/+5
| | | | Jan
* Remove some dead code, simplify calling convention.Tom Lane2001-06-131-62/+44
|
* Repair problem with multi-action rules in combination with any nontrivialTom Lane2001-06-121-20/+19
| | | | | | manipulation of rtable/jointree by planner. Rewriter was generating actions that shared rtable/jointree substructure, which caused havoc when planner got to the later actions that it'd already mucked up.
* Permission checking wasn't quite right for insert/update/delete rules,Tom Lane2001-05-031-13/+12
| | | | either :-(.
* Permissions were not checked correctly when one view invokes another.Tom Lane2001-05-031-1/+3
| | | | Per bug report from Lieven Van Acker, 5/2/01.
* Make the world safe for passing whole rows of views to functions. ThisTom Lane2001-04-181-3/+8
| | | | already worked fine for whole rows of tables, but not so well for views...
* Add some defenses to guard against case where a rule refers to a tableTom Lane2001-04-171-5/+27
| | | | | | | or view that's been dropped and then recreated with the same name (but, perhaps, different columns). Eventually we'd like to support this but for now all we can do is fail cleanly, rather than possibly coredumping if we proceed using the obsolete rule.
* Fix comments that were mis-wrapped, for Tom Lane.Bruce Momjian2001-03-231-4/+8
|
* Remove dashes in comments that don't need them, rewrap with pgindent.Bruce Momjian2001-03-222-41/+32
|
* pgindent run. Make it all clean.Bruce Momjian2001-03-225-145/+153
|