summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
AgeCommit message (Collapse)Author
2002-12-06Re-addd Rod's ALTER DOMAIN patch.Bruce Momjian
2002-12-06Back out ALTER DOMAIN patch until missing file appears.Bruce Momjian
2002-12-06ALTER DOMAIN .. SET / DROP NOT NULLBruce Momjian
ALTER DOMAIN .. SET / DROP DEFAULT ALTER DOMAIN .. ADD / DROP CONSTRAINT New files: - doc/src/sgml/ref/alter_domain.sgml Rod Taylor
2002-11-30Code review for IS DISTINCT FROM patch. Fix incorrect constant-foldingTom Lane
logic, dissuade planner from thinking that 'x IS DISTINCT FROM 42' may be optimized into 'x = 42' (!!), cause dependency on = operator to be recorded correctly, minor other improvements.
2002-11-26Use Params, rather than run-time-modified Const nodes, to handleTom Lane
sublink results and COPY's domain constraint checking. A Const that isn't really constant is just a Bad Idea(tm). Remove hacks in parse_coerce and other places that were needed because of the former klugery.
2002-11-15Add DOMAIN check constraints.Bruce Momjian
Rod Taylor
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-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-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-08-04Implement IS OF type predicate. Can now do queries of the form:Thomas G. Lockhart
select value IS OF (integer, float8);
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-06I've fixed up the way domain constraints (not null and type length)Bruce Momjian
are managed as per request. Moved from merging with table attributes to applying themselves during coerce_type() and coerce_type_typmod. Regression tests altered to test the cast() scenarios. 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-20Update copyright to 2002.Bruce Momjian
2002-05-17Get rid of the last few uses of typeidTypeName() rather thanTom Lane
format_type_be() in error messages.
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-04-28Make ruleutils.c use format_type for printing typenames. Minor tweaksTom Lane
in quoting rules and recognition of implicit type coercions.
2002-04-16Operators live in namespaces. CREATE/DROP/COMMENT ON OPERATOR takeTom Lane
qualified operator names directly, for example CREATE OPERATOR myschema.+ ( ... ). To qualify an operator name in an expression you need to write OPERATOR(myschema.+) (thanks to Peter for suggesting an escape hatch). I also took advantage of having to reformat pg_operator to fix something that'd been bugging me for a while: mergejoinable operators should have explicit links to the associated cross-data-type comparison operators, rather than hardwiring an assumption that they are named < and >.
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-04-09Functions live in namespaces. Qualified function names work, egTom Lane
SELECT schema1.func2(...). Aggregate names can be qualified at the syntactic level, but the qualification is ignored for the moment.
2002-03-29pg_type has a typnamespace column; system now supports creating typesTom Lane
in different namespaces. Also, cleanup work on relation namespace support: drop, alter, rename commands work for tables in non-default namespaces.
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-20Code review for DOMAIN patch.Tom Lane
2002-03-19Add DOMAIN support. Includes manual pages and regression tests, fromBruce Momjian
Rod Taylor.
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-07Back out domain patch until it works properly.Bruce Momjian
2002-03-06Ok. Updated patch attached.Bruce Momjian
- domain.patch -> source patch against pgsql in cvs - drop_domain.sgml and create_domain.sgml -> New doc/src/sgml/ref docs - dominfo.txt -> basic domain related queries I used for testing [ ADDED TO /doc] Enables domains of array elements -> CREATE DOMAIN dom int4[3][2]; Uses a typbasetype column to describe the origin of the domain. Copies data to attnotnull rather than processing in execMain(). Some documentation differences from earlier. If this is approved, I'll start working on pg_dump, and a \dD <domain> option in psql, and regression tests. I don't really feel like doing those until the system table structure settles for pg_type. CHECKS when added, will also be copied to to the table attributes. FK Constraints (if I ever figure out how) will be done similarly. Both will lbe handled by MergeDomainAttributes() which is called shortly before MergeAttributes(). Rod Taylor
2001-11-12If the alternatives for a CASE construct all have the same typmod,Tom Lane
use that typmod not -1 as the typmod of the CASE result. Part of response to bug#513.
2001-10-25pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian
tests pass.
2001-10-08Fix transformExpr() to not scribble on its input datastructure whileTom Lane
transforming CASE expressions. This was definitely confusing FigureColname, and might lead to bad things elsewhere as well.
2001-09-28Measure the current transaction time to milliseconds.Thomas G. Lockhart
Define a new function, GetCurrentTransactionStartTimeUsec() to get the time to this precision. Allow now() and timestamp 'now' to use this higher precision result so we now have fractional seconds in this "constant". Add timestamp without time zone type. Move previous timestamp type to timestamp with time zone. Accept another ISO variant for date/time values: yyyy-mm-ddThh:mm:ss (note the "T" separating the day from hours information). Remove 'current' from date/time types; convert to 'now' in input. Separate time and timetz regression tests. Separate timestamp and timestamptz regression test.
2001-09-20Suppress gcc warning.Tom Lane
2001-09-20Provide tunable knob for x = NULL -> x IS NULL transformation, default to off.Peter Eisentraut
2001-08-09Use format_type sibling in backend error messages, so the user seesPeter Eisentraut
consistent type naming.
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-06-04This patch adds support for %TYPE in CREATE FUNCTION argument and returnBruce Momjian
types. This version has an elog() to remind the user the type resolution is not dynamic. Ian Lance Taylor
2001-05-21Print error on SELECT tab FROM tab:Bruce Momjian
You can't use relation names alone in the target list, try relation.*
2001-05-19New comment. This func/column things has always confused me.Bruce Momjian
/* * parse function * This code is confusing because the database can accept * relation.column, column.function, or relation.column.function. * In these cases, funcname is the last parameter, and fargs are * the rest. * * It can also be called as func(col) or func(col,col). * In this case, Funcname is the part before parens, and fargs * are the part in parens. * */ Node * ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, bool agg_star, bool agg_distinct, int precedence)
2001-05-18Rename ParseFuncOrColumn() to ParseColumnOrFunc().Bruce Momjian
2001-05-18Small code cleanups,formatting.Bruce Momjian
2001-03-22pgindent run. Make it all clean.Bruce Momjian
2001-02-16Clean up two rather nasty bugs in operator selection code.Tom Lane
1. If there is exactly one pg_operator entry of the right name and oprkind, oper() and related routines would return that entry whether its input type had anything to do with the request or not. This is just premature optimization: we shouldn't return the single candidate until after we verify that it really is a valid candidate, ie, is at least coercion-compatible with the given types. 2. oper() and related routines only promise a coercion-compatible result. Unfortunately, there were quite a few callers that assumed the returned operator is binary-compatible with the given datatype; they would proceed to call it without making any datatype coercions. These callers include sorting, grouping, aggregation, and VACUUM ANALYZE. In general I think it is appropriate for these callers to require an exact or binary-compatible match, so I've added a new routine compatible_oper() that only succeeds if it can find an operator that doesn't require any run-time conversions. Callers now call oper() or compatible_oper() depending on whether they are prepared to deal with type conversion or not. The upshot of these bugs is revealed by the following silliness in PL/Tcl's selftest: it creates an operator @< on int4, and then tries to use it to sort a char(N) column. The system would let it do that :-( (and evidently has done so since 6.3 :-( :-(). The result in this case was just a silly sort order, but the reverse combination would've provoked coredump from trying to dereference integers. With this fix you get more reasonable behavior: pltcl_test=# select * from T_pkey1 order by key1, key2 using @<; ERROR: Unable to identify an operator '@<' for types 'bpchar' and 'bpchar' You will have to retype this query using an explicit cast
2001-02-14Change scoping of table and join refnames to conform to SQL92: a JOINTom Lane
clause with an alias is a <subquery> and therefore hides table references appearing within it, according to the spec. This is the same as the preliminary patch I posted to pgsql-patches yesterday, plus some really grotty code in ruleutils.c to reverse-list a query tree with the correct alias name depending on context. I'd rather not have done that, but unless we want to force another initdb for 7.1, there's no other way for now.
2001-01-24Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.Bruce Momjian
2000-11-16Change SearchSysCache coding conventions so that a reference count isTom Lane
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.
2000-11-16Add support for casting bit string constants.Peter Eisentraut
2000-10-07Arrange that no database accesses are attempted during parser() --- thisTom Lane
took some rejiggering of typename and ACL parsing, as well as moving parse_analyze call out of parser(). Restructure postgres.c processing so that parse analysis and rewrite are skipped when in abort-transaction state. Only COMMIT and ABORT statements will be processed beyond the raw parser() phase. This addresses problem of parser failing with database access errors while in aborted state (see pghackers discussions around 7/28/00). Also fix some bugs with COMMIT/ABORT statements appearing in the middle of a single query input string. Function, operator, and aggregate arguments/results can now use full TypeName production, in particular foo[] for array types. DROP OPERATOR and COMMENT ON OPERATOR were broken for unary operators. Allow CREATE AGGREGATE to accept unquoted numeric constants for initcond.