summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
AgeCommit message (Collapse)Author
2002-09-19Tweak heap.c to refuse attempts to create table columns of standaloneTom Lane
composite types. Add a couple more lsyscache.c routines to support this, and make use of them in some other places that were doing lookups the hard way.
2002-09-19Department of second thoughts: suppressing implicit casts everywhere inTom Lane
ruleutils display is not such a great idea. For arguments of functions and operators I think we'd better keep the historical behavior of showing such casts explicitly, to ensure that the function/operator is reparsed the same way when the rule is reloaded. This also makes the output of EXPLAIN less obscurantist about exactly what's happening.
2002-09-18Extend pg_cast castimplicit column to a three-way value; this allows usTom Lane
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.
2002-09-04pgindent run.Bruce Momjian
2002-08-31Code review for domain-constraints patch. Use a new ConstraintTest nodeTom Lane
type for runtime constraint checks, instead of misusing the parse-time Constraint node for the purpose. Fix some damage introduced into type coercion logic; in particular ensure that a coerced expression tree will read out the correct result type when inspected (patch had broken some RelabelType cases). Enforce domain NOT NULL constraints against columns that are omitted from an INSERT.
2002-08-29Fix ruleutils to dump column definition lists for anonymous record typesTom Lane
defined in the FROM clause. From Joe Conway, with some tweaks.
2002-08-26Modify array operations to include array's element type OID in theTom Lane
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.
2002-08-18Make pg_dump output more portable and more pleasing to look at.Peter Eisentraut
The -n and -N options were removed. Quoting is now smart enough to supply quotes if and only if necessary. Numerical types are now printed without quotes, except in cases of special values such as NaN. Boolean values printed as true and false. Most string literals now do not escape whitespace characters (newlines, etc.) for portability. SET SESSION AUTHORIZATION argument is a string literal, to follow SQL. Made commands output by pg_dump use consistent spacing and indentation.
2002-08-16Modify pg_dump to dump foreign-key constraints as constraints, not asTom Lane
sets of triggers. Also modify psql \d command to show foreign key constraints as such and hide the triggers. pg_get_constraintdef() function added to backend to support these. From Rod Taylor, code review and some editorialization by Tom Lane.
2002-08-16Make domain types indexable. Rod Taylor & Tom Lane.Tom Lane
2002-08-08Cause view/rule display to work as expected after rename of an underlyingTom Lane
table or column, or of an output column of the view itself.
2002-08-08Cause schema-qualified FROM items and schema-qualified variable referencesTom Lane
to behave according to SQL92 (or according to my current understanding of same, anyway). Per pghackers discussion way back in March 2002: thread 'Do FROM items of different schemas conflict?'
2002-07-18pg_cast table, and standards-compliant CREATE/DROP CAST commands, plusPeter Eisentraut
extension to create binary compatible casts. Includes dependency tracking as well. pg_proc.proimplicit is now defunct, but will be removed in a separate commit. pg_dump provides a migration path from the previous scheme to declare casts. Dumping binary compatible casts is currently impossible, though.
2002-07-18Back out BETWEEN node patch, was causing initdb failure.Bruce Momjian
2002-07-18Finished the Between patch Christopher started.Bruce Momjian
Implements between (symmetric / asymmetric) as a node. Executes the left or right expression once, makes a Const out of the resulting Datum and executes the >=, <= portions out of the Const sets. Of course, the parser does a fair amount of preparatory work for this to happen. Rod Taylor
2002-07-04Implement the IS DISTINCT FROM operator per SQL99.Thomas G. Lockhart
Reused the Expr node to hold DISTINCT which strongly resembles the existing OP info. Define DISTINCT_EXPR which strongly resembles the existing OPER_EXPR opType, but with handling for NULLs required by SQL99. We have explicit support for single-element DISTINCT comparisons all the way through to the executor. But, multi-element DISTINCTs are handled by expanding into a comparison tree in gram.y as is done for other row comparisons. Per discussions, it might be desirable to move this into one or more purpose-built nodes to be handled in the backend. Define the optional ROW keyword and token per SQL99. This allows single-element row constructs, which were formerly disallowed due to shift/reduce conflicts with parenthesized a_expr clauses. Define the SQL99 TREAT() function. Currently, use as a synonym for CAST().
2002-06-13Further tweaks to support display of sort keys in EXPLAIN --- initialTom Lane
implementation didn't work for Sort nodes associated with Append plans.
2002-05-28Queries used by ruleutils were not schema-proof.Tom Lane
2002-05-18Add display of sort keys to the default EXPLAIN output.Tom Lane
2002-05-17Merge the last few variable.c configuration variables into the genericTom Lane
GUC support. It's now possible to set datestyle, timezone, and client_encoding from postgresql.conf and per-database or per-user settings. Also, implement rollback of SET commands that occur in a transaction that later fails. Create a SET LOCAL var = value syntax that sets the variable only for the duration of the current transaction. All per previous discussions in pghackers.
2002-05-12Get rid of long-since-vestigial Iter node type, in favor of adding aTom Lane
returns-set boolean field in Func and Oper nodes. This allows cleaner, more reliable tests for expressions returning sets in the planner and parser. For example, a WHERE clause returning a set is now detected and complained of in the parser, not only at runtime.
2002-05-12First pass at set-returning-functions in FROM, by Joe Conway withTom Lane
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 ...
2002-05-03Make ruleutils.c schema-aware. Displayed names are schema-qualifiedTom Lane
only if they would not be found without qualification given the current search path, as per idea from Peter Eisentraut.
2002-05-02Tweak scanner/grammar interface so that the keyword-as-identifier rulesTom Lane
in gram.y can make use of the keywords.c string table, instead of having their own copies of the keyword strings. This saves a few kilobytes and more importantly eliminates an opportunity for cut-and-paste errors.
2002-04-28Make ruleutils.c use format_type for printing typenames. Minor tweaksTom Lane
in quoting rules and recognition of implicit type coercions.
2002-04-25Implement types regprocedure, regoper, regoperator, regclass, regtypeTom Lane
per pghackers discussion. Add some more typsanity tests, and clean up some problems exposed thereby (broken or missing array types for some built-in types). Also, clean up loose ends from unknownin/out patch.
2002-04-19Change naming rule for ON SELECT rules of views: they're all justTom Lane
_RETURN now, since there's no need to keep 'em unique anymore.
2002-04-18Rule names are now unique per-relation, rather than unique globally.Tom Lane
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.
2002-04-11Restructure representation of aggregate functions so that they have pg_procTom Lane
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.
2002-03-22A little further progress on schemas: push down RangeVars intoTom Lane
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.
2002-03-21First phase of SCHEMA changes, concentrating on fixing the grammar andTom Lane
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.
2002-03-12Restructure representation of join alias variables. An explicit JOINTom Lane
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.
2002-03-06Modify ALTER TABLE OWNER to change index ownership; code cleanup.Bruce Momjian
Neil Conway
2002-03-06Change made to elog:Bruce Momjian
o Change all current CVS messages of NOTICE to WARNING. We were going to do this just before 7.3 beta but it has to be done now, as you will see below. o Change current INFO messages that should be controlled by client_min_messages to NOTICE. o Force remaining INFO messages, like from EXPLAIN, VACUUM VERBOSE, etc. to always go to the client. o Remove INFO from the client_min_messages options and add NOTICE. Seems we do need three non-ERROR elog levels to handle the various behaviors we need for these messages. Regression passed.
2002-02-19A bunch of changes aimed at reducing backend startup time...Tom Lane
Improve 'pg_internal.init' relcache entry preload mechanism so that it is safe to use for all system catalogs, and arrange to preload a realistic set of system-catalog entries instead of only the three nailed-in-cache indexes that were formerly loaded this way. Fix mechanism for deleting out-of-date pg_internal.init files: this must be synchronized with transaction commit, not just done at random times within transactions. Drive it off relcache invalidation mechanism so that no special-case tests are needed. Cache additional information in relcache entries for indexes (their pg_index tuples and index-operator OIDs) to eliminate repeated lookups. Also cache index opclass info at the per-opclass level to avoid repeated lookups during relcache load. Generalize 'systable scan' utilities originally developed by Hiroshi, move them into genam.c, use in a number of places where there was formerly ugly code for choosing either heap or index scan. In particular this allows simplification of the logic that prevents infinite recursion between syscache and relcache during startup: we can easily switch to heapscans in relcache.c when and where needed to avoid recursion, so IndexScanOK becomes simpler and does not need any expensive initialization. Eliminate useless opening of a heapscan data structure while doing an indexscan (this saves an mdnblocks call and thus at least one kernel call).
2001-11-26Change display of FieldSelect nodes from arg.field to field(arg),Tom Lane
per bug report from Stefan Hadjistoytchev. There are some cases where the dot notation works, but there are more where it doesn't. Eventually ought to consider fixing the parser to allow cases like func().field, but for now this is the simplest patch.
2001-11-26Repair problem with listing rules that have a WHERE condition andTom Lane
have an INSERT...SELECT as the first or only action. Per bug report from Sergio Pili.
2001-11-19Tweak format_type so that we get good behavior for both column typeTom Lane
display (with a typemod) and function arg/result type display (without a typemod).
2001-10-25pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian
tests pass.
2001-10-08Fix ruleutils to depend on format_type, rather than having a privateTom Lane
copy of code that knows about displaying types with typmod info. Needed so that it does the right thing with timestamp datatypes now.
2001-10-04Ooops, I was a little too enthusiastic about suppressing defaultTom Lane
index opclasses; they might be default for some other datatype, in which case we mustn't suppress 'em.
2001-10-01Extend pg_get_indexdef() to know about index predicates. Also, tweakTom Lane
it to suppress index opclass output for opclasses that are the default for their datatype; only non-default opclasses are shown explicitly. This is expected to improve portability of the CREATE INDEX command across future versions of Postgres --- we've changed index opclasses too often in the past to think we won't do so again.
2001-08-12Make ALTER TABLE RENAME on a view rename the view's on-select rule too.Tom Lane
Needed to keep pg_dump from getting confused.
2001-07-31Fix optimizer to not try to push WHERE clauses down into a sub-SELECT thatTom Lane
has a DISTINCT ON clause, per bug report from Anthony Wood. While at it, improve the DISTINCT-ON-clause recognizer routine to not be fooled by out- of-order DISTINCT lists.
2001-07-16Partial indexes work again, courtesy of Martijn van Oosterhout.Tom Lane
Note: I didn't force an initdb, figuring that one today was enough. However, there is a new function in pg_proc.h, and pg_dump won't be able to dump partial indexes until you add that function.
2001-07-10Remove unnecessarily enthusiastic parenthesizing in reverse-listing ofTom Lane
IS NULL, IS TRUE, and friends (my fault...)
2001-06-19Add IS UNKNOWN, IS NOT UNKNOWN boolean tests, fix the existing booleanTom Lane
tests to return the correct results per SQL9x when given NULL inputs. Reimplement these tests as well as IS [NOT] NULL to have their own expression node types, instead of depending on special functions. From Joe Conway, with a little help from Tom Lane.
2001-04-18Make rule lister do the right thing with Vars representing whole tuples.Tom Lane
2001-04-15Constant expressions that appear in ORDER BY, GROUP BY, DISTINCT ONTom Lane
lists should be reverse-compiled into targetlist index numbers, because that's the only interpretation the parser allows for a constant in these clauses. (Ergo, the only way they could have gotten into the list in the first place is to have come from the targetlist; so this should always work.) Per problem report from Peter E.
2001-03-22Remove dashes in comments that don't need them, rewrap with pgindent.Bruce Momjian