postgresql/src/backend/parser
Tom Lane 13cc7eb3e2 Clean up two rather nasty bugs in operator selection code.
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-16 03:16:58 +00:00
..
.cvsignore Add .cvsignore file so cvs doesn't complain if you have lex/yacc 1999-03-21 02:43:58 +00:00
analyze.c Arrange for ORDER BY an expression on a UNION/INTERSECT/EXCEPT result, 2001-02-15 01:10:28 +00:00
gram.y plpgsql's private copy of xlateSqlType was out of sync. Again. This 2001-02-09 03:26:28 +00:00
keywords.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Makefile Only look for bison as YACC; other yaccs need to be selected explicitly. 2001-02-10 22:31:42 +00:00
parse_agg.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
parse_clause.c Clean up two rather nasty bugs in operator selection code. 2001-02-16 03:16:58 +00:00
parse_coerce.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
parse_expr.c Clean up two rather nasty bugs in operator selection code. 2001-02-16 03:16:58 +00:00
parse_func.c Change scoping of table and join refnames to conform to SQL92: a JOIN 2001-02-14 21:35:07 +00:00
parse_node.c Change scoping of table and join refnames to conform to SQL92: a JOIN 2001-02-14 21:35:07 +00:00
parse_oper.c Clean up two rather nasty bugs in operator selection code. 2001-02-16 03:16:58 +00:00
parse_relation.c Change scoping of table and join refnames to conform to SQL92: a JOIN 2001-02-14 21:35:07 +00:00
parse_target.c Change scoping of table and join refnames to conform to SQL92: a JOIN 2001-02-14 21:35:07 +00:00
parse_type.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
parser.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
README cleanup 1998-08-23 14:43:46 +00:00
scan.l Use elog() instead of exit() for fatal scanner errors. 2001-02-03 20:13:05 +00:00
scansup.c Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00

This directory does more than tokenize and parse SQL queries.  It also
creates Query structures for the various complex queries that is passed
to the optimizer and then executor.

parser.c	things start here
scan.l		break query into tokens
scansup.c	handle escapes in input
keywords.c	turn keywords into specific tokens
gram.y		parse the tokens and fill query-type-specific structures
analyze.c	handle post-parse processing for each query type
parse_clause.c	handle clauses like WHERE, ORDER BY, GROUP BY, ...
parse_coerce.c	used for coercing expressions of different types
parse_expr.c	handle expressions like col, col + 3, x = 3 or x = 4
parse_oper.c	handle operations in expressions
parse_agg.c	handle aggregates, like SUM(col1),  AVG(col2), ...
parse_func.c	handle functions, table.column and column identifiers
parse_node.c	create nodes for various structures
parse_target.c	handle the result list of the query
parse_relation.c support routines for tables and column handling
parse_type.c	support routines for type handling