aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
Commit message (Collapse)AuthorAge
...
* pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian2001-10-25
| | | | tests pass.
* Fix transformExpr() to not scribble on its input datastructure whileTom Lane2001-10-08
| | | | | transforming CASE expressions. This was definitely confusing FigureColname, and might lead to bad things elsewhere as well.
* Measure the current transaction time to milliseconds.Thomas G. Lockhart2001-09-28
| | | | | | | | | | | | | | 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.
* Suppress gcc warning.Tom Lane2001-09-20
|
* Provide tunable knob for x = NULL -> x IS NULL transformation, default to off.Peter Eisentraut2001-09-20
|
* Use format_type sibling in backend error messages, so the user seesPeter Eisentraut2001-08-09
| | | | consistent type naming.
* Add IS UNKNOWN, IS NOT UNKNOWN boolean tests, fix the existing booleanTom Lane2001-06-19
| | | | | | | 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.
* This patch adds support for %TYPE in CREATE FUNCTION argument and returnBruce Momjian2001-06-04
| | | | | | | types. This version has an elog() to remind the user the type resolution is not dynamic. Ian Lance Taylor
* Print error on SELECT tab FROM tab:Bruce Momjian2001-05-21
| | | | You can't use relation names alone in the target list, try relation.*
* New comment. This func/column things has always confused me.Bruce Momjian2001-05-19
| | | | | | | | | | | | | | | | | | | /* * 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)
* Rename ParseFuncOrColumn() to ParseColumnOrFunc().Bruce Momjian2001-05-18
|
* Small code cleanups,formatting.Bruce Momjian2001-05-18
|
* pgindent run. Make it all clean.Bruce Momjian2001-03-22
|
* Clean up two rather nasty bugs in operator selection code.Tom Lane2001-02-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change scoping of table and join refnames to conform to SQL92: a JOINTom Lane2001-02-14
| | | | | | | | | 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.
* Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.Bruce Momjian2001-01-24
|
* Change SearchSysCache coding conventions so that a reference count isTom Lane2000-11-16
| | | | | | | 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.
* Add support for casting bit string constants.Peter Eisentraut2000-11-16
|
* Arrange that no database accesses are attempted during parser() --- thisTom Lane2000-10-07
| | | | | | | | | | | | | | | 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.
* Reimplementation of UNION/INTERSECT/EXCEPT. INTERSECT/EXCEPT now meet theTom Lane2000-10-05
| | | | | | | | | | | SQL92 semantics, including support for ALL option. All three can be used in subqueries and views. DISTINCT and ORDER BY work now in views, too. This rewrite fixes many problems with cross-datatype UNIONs and INSERT/SELECT where the SELECT yields different datatypes than the INSERT needs. I did that by making UNION subqueries and SELECT in INSERT be treated like subselects-in-FROM, thereby allowing an extra level of targetlist where the datatype conversions can be inserted safely. INITDB NEEDED!
* Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.Tom Lane2000-09-29
| | | | | | | | | (Don't forget that an alias is required.) Views reimplemented as expanding to subselect-in-FROM. Grouping, aggregates, DISTINCT in views actually work now (he says optimistically). No UNION support in subselects/views yet, but I have some ideas about that. Rule-related permissions checking moved out of rewriter and into executor. INITDB REQUIRED!
* First cut at full support for OUTER JOINs. There are still a few looseTom Lane2000-09-12
| | | | | ends to clean up (see my message of same date to pghackers), but mostly it works. INITDB REQUIRED!
* Remove 'func_tlist' from Func expression nodes, likewise 'param_tlist'Tom Lane2000-08-08
| | | | | | | | 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.
* Clean up #include's.Bruce Momjian2000-06-15
|
* Latest round of fmgr updates. All functions with bool,char, or int2Tom Lane2000-06-05
| | | | | | | inputs have been converted to newstyle. This should go a long way towards fixing our portability problems with platforms where char and short parameters are passed differently from int-width parameters. Still more to do for the Alpha port however.
* Remove unused include files. Do not touch /port or includes used by defines.Bruce Momjian2000-05-30
|
* Generated header files parse.h and fmgroids.h are now copied intoTom Lane2000-05-29
| | | | | the src/include tree, so that -I backend is no longer necessary anywhere. Also, clean up some bit rot in contrib tree.
* Modify raw parsetree representation returned by gram.y for SubLinks:Tom Lane2000-05-25
| | | | | | | | the oper field should be a valid Node structure so it can be dumped by outfuncs.c without risk of coredump. (We had been using a raw pointer to character string, which surely is NOT a valid Node.) This doesn't cause any backwards compatibility problems for stored rules, since raw unanalyzed parsetrees are never stored.
* Ye-old pgindent run. Same 4-space tabs.Bruce Momjian2000-04-12
|
* transformExpr() did the Wrong Thing if applied to a SubLink node thatTom Lane2000-03-19
| | | | | | | | | had already been transformed. This led to failure in examples like UPDATE table SET fld = (SELECT ...). Repair this, and revise the comments to explain that transformExpr has to be robust against this condition. Someday we might want to fix the callers so that transformExpr is never invoked on its own output, but that someday is not today.
* Add safety check on expression nesting depth. Default value is set byTom Lane2000-03-17
| | | | a config.h #define, and the runtime value can be controlled via SET.
* Implement column aliases on views "CREATE VIEW name (collist)".Thomas G. Lockhart2000-03-14
| | | | | | | | | | | | | | | | | | Implement TIME WITH TIME ZONE type (timetz internal type). Remap length() for character strings to CHAR_LENGTH() for SQL92 and to remove the ambiguity with geometric length() functions. Keep length() for character strings for backward compatibility. Shrink stored views by removing internal column name list from visible rte. Implement min(), max() for time and timetz data types. Implement conversion of TIME to INTERVAL. Implement abs(), mod(), fac() for the int8 data type. Rename some math functions to generic names: round(), sqrt(), cbrt(), pow(), etc. Rename NUMERIC power() function to pow(). Fix int2 factorial to calculate result in int4. Enhance the Oracle compatibility function translate() to work with string arguments (from Edwin Ramirez). Modify pg_proc system table to remove OID holes.
* Someone (probably me) forgot about handling of typecasts applied toTom Lane2000-03-07
| | | | parameters.
* Fix exprTypmod to recognize length-coercion function expressions,Tom Lane2000-02-26
| | | | | | | | | | | such as bpchar(char_expression, N), and pull out the attrtypmod that the function is coercing to. This allows correct deduction of the column type in examples such as CREATE VIEW v AS SELECT f1::char(8) FROM tbl; Formerly we labeled v's column as char-of-unknown-length not char(8). Also, this change causes the parser not to insert a redundant length coercion function if the user has explicitly casted an INSERT or UPDATE expression to the right length.
* Change parse-time representation of float literals (which include oversizeTom Lane2000-02-21
| | | | | | | | integers) to be strings instead of 'double'. We convert from string form to internal representation only after type resolution has determined the correct type for the constant. This eliminates loss-of-precision worries and gets rid of the change in behavior seen at 17 digits with the previous kluge.
* Create a new expression node type RelabelType, which exists solely toTom Lane2000-02-20
| | | | | | | | | | represent the result of a binary-compatible type coercion. At runtime it just evaluates its argument --- but during type resolution, exprType will pick up the output type of the RelabelType node instead of the type of the argument. This solves some longstanding problems with dropped type coercions, an example being 'select now()::abstime::int4' which used to produce date-formatted output, not an integer, because the coercion to int4 was dropped on the floor.
* Carry column aliases from the parser frontend. Enables queries likeThomas G. Lockhart2000-02-15
| | | | | | | SELECT a FROM t1 tx (a); Allow join syntax, including queries like SELECT * FROM t1 NATURAL JOIN t2; Update RTE structure to hold column aliases in an Attr structure.
* Add:Bruce Momjian2000-01-26
| | | | | | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
* Pass atttypmod to CoerceTargetExpr, so that it can pass it on toTom Lane2000-01-17
| | | | | coerce_type, so that the right things happen when coercing a previously- unknown constant to a destination data type.
* Create a new parsetree node type, TypeCast, so that transformation ofTom Lane2000-01-17
| | | | | | SQL cast constructs can be performed during expression transformation instead of during parsing. This allows constructs like x::numeric(9,2) and x::int2::float8 to behave as one would expect.
* Fix passing of atttypmod that Tom found.Bruce Momjian2000-01-16
|
* Clean up handling of explicit NULL constants. Cases likeTom Lane1999-12-24
| | | | | | | | | | | | | SELECT null::text; SELECT int4fac(null); work as expected now. In some cases a NULL must be surrounded by parentheses: SELECT 2 + null; fails SELECT 2 + (null); OK This is a grammatical ambiguity that seems difficult to avoid. Other than that, NULLs seem to behave about like you'd expect. The internal implementation is that NULL constants are typed as UNKNOWN (like untyped string constants) until the parser can deduce the right type.
* Reverse out nextval patch.Bruce Momjian1999-12-17
|
* >Turning nextval and currval into keywords is not an acceptable way toBruce Momjian1999-12-16
| | | | | | | | | | | | | | | | | | >go about this. That will risk breaking existing applications that use >those names as column names. > >It should actually almost work to write sq.nextval as things stand, >because Postgres has for a long time considered table.function and >function(table) to be interchangeable notations for certain kinds of >functions. nextval doesn't seem to be one of that kind of function, >at the moment. I'd suggest leaving the grammar as it was, and taking a >look at ParseFuncOrColumn in parse_func.c to see if you can't persuade >it to accept the sequence functions in that style. OK, good point. I tried to implement it somewhere else and ended up extending transformAttr. Attached you'll find the patch. Jeroen van Vianen
* Teach grammar and parser about aggregate(DISTINCT ...). No implementationTom Lane1999-12-10
| | | | | | | yet, but at least we can give a better error message: regression=> select count(distinct f1) from int4_tbl; ERROR: aggregate(DISTINCT ...) is not implemented yet instead of 'parser: parse error at or near distinct'.
* Implement subselects in target lists. Also, relax requirement thatTom Lane1999-11-15
| | | | | | | | | | | | | 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.
* Allow CASE statement to contain *only* untyped result clauses or nulls.Thomas G. Lockhart1999-09-13
| | | | | | | Almost worked before, but forgot one place to check. Reported by Tatsuo Ishii. Still does not do the right thing if inserting into a non-string target column. Should look for a type coersion later, but doesn't.
* Revise implementation of SubLinks so that there is a consistent,Tom Lane1999-08-25
| | | | | | | | | 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.
* Revise parse_coerce() to handle coercion of int and floatTom Lane1999-08-05
| | | | | constants, not only string constants, at parse time. Get rid of parser_typecast2(), which is bogus and redundant...
* Rewrite parser's handling of INSERT ... SELECT so that processingTom Lane1999-07-19
| | | | | | | | | of the SELECT part of the statement is just like a plain SELECT. All INSERT-specific processing happens after the SELECT parsing is done. This eliminates many problems, e.g. INSERT ... SELECT ... GROUP BY using the wrong column labels. Ensure that DEFAULT clauses are coerced to the target column type, whether or not stored clause produces the right type. Substantial cleanup of parser's array support.