CVS log for pgsql/src/backend/optimizer/util/clauses.c

[BACK] Up to [PostgreSQL CVS Repository] / pgsql / src / backend / optimizer / util

Request diff between arbitrary revisions - Display revisions graphically


Keyword substitution: kv
Default branch: MAIN


Revision 1.277.2.3: download - view: text, markup, annotated - select for diffs
Sat Aug 14 15:47:30 2010 UTC (15 years ago) by tgl
Branches: REL8_4_STABLE
Diff to: previous 1.277.2.2: preferred, colored; branchpoint 1.277: preferred, colored; next MAIN 1.278: preferred, colored
Changes since revision 1.277.2.2: +13 -1 lines
Fix planner to make a reasonable assumption about the amount of memory space
used by array_agg(), string_agg(), and similar aggregate functions that use
"internal" as their transition datatype.  The previous coding thought this
took *no* extra space, since "internal" is pass-by-value; but actually these
aggregates typically consume a great deal of space.  Per bug #5608 from
Itagaki Takahiro, and fix suggestion from Hitoshi Harada.

Back-patch to 8.4, where array_agg was introduced.

Revision 1.287.4.1: download - view: text, markup, annotated - select for diffs
Sat Aug 14 15:47:21 2010 UTC (15 years ago) by tgl
Branches: REL9_0_STABLE
CVS tags: REL9_0_RC1, REL9_0_0
Diff to: previous 1.287: preferred, colored; next MAIN 1.288: preferred, colored
Changes since revision 1.287: +13 -1 lines
Fix planner to make a reasonable assumption about the amount of memory space
used by array_agg(), string_agg(), and similar aggregate functions that use
"internal" as their transition datatype.  The previous coding thought this
took *no* extra space, since "internal" is pass-by-value; but actually these
aggregates typically consume a great deal of space.  Per bug #5608 from
Itagaki Takahiro, and fix suggestion from Hitoshi Harada.

Back-patch to 8.4, where array_agg was introduced.

Revision 1.288: download - view: text, markup, annotated - select for diffs
Sat Aug 14 15:47:13 2010 UTC (15 years ago) by tgl
Branches: MAIN
CVS tags: REL9_1_ALPHA1, HEAD
Diff to: previous 1.287: preferred, colored
Changes since revision 1.287: +13 -1 lines
Fix planner to make a reasonable assumption about the amount of memory space
used by array_agg(), string_agg(), and similar aggregate functions that use
"internal" as their transition datatype.  The previous coding thought this
took *no* extra space, since "internal" is pass-by-value; but actually these
aggregates typically consume a great deal of space.  Per bug #5608 from
Itagaki Takahiro, and fix suggestion from Hitoshi Harada.

Back-patch to 8.4, where array_agg was introduced.

Revision 1.277.2.2: download - view: text, markup, annotated - select for diffs
Fri Mar 19 22:54:49 2010 UTC (15 years, 5 months ago) by tgl
Branches: REL8_4_STABLE
CVS tags: REL8_4_4
Diff to: previous 1.277.2.1: preferred, colored; branchpoint 1.277: preferred, colored
Changes since revision 1.277.2.1: +54 -51 lines
Modify error context callback functions to not assume that they can fetch
catalog entries via SearchSysCache and related operations.  Although, at the
time that these callbacks are called by elog.c, we have not officially aborted
the current transaction, it still seems rather risky to initiate any new
catalog fetches.  In all these cases the needed information is readily
available in the caller and so it's just a matter of a bit of extra notation
to pass it to the callback.

Per crash report from Dennis Koegel.  I've concluded that the real fix for
his problem is to clear the error context stack at entry to proc_exit, but
it still seems like a good idea to make the callbacks a bit less fragile
for other cases.

Backpatch to 8.4.  We could go further back, but the patch doesn't apply
cleanly.  In the absence of proof that this fixes something and isn't just
paranoia, I'm not going to expend the effort.

Revision 1.287: download - view: text, markup, annotated - select for diffs
Fri Mar 19 22:54:41 2010 UTC (15 years, 5 months ago) by tgl
Branches: MAIN
CVS tags: REL9_0_BETA4, REL9_0_BETA3, REL9_0_BETA2, REL9_0_BETA1, REL9_0_ALPHA5_BRANCH, REL9_0_ALPHA5
Branch point for: REL9_0_STABLE
Diff to: previous 1.286: preferred, colored
Changes since revision 1.286: +54 -51 lines
Modify error context callback functions to not assume that they can fetch
catalog entries via SearchSysCache and related operations.  Although, at the
time that these callbacks are called by elog.c, we have not officially aborted
the current transaction, it still seems rather risky to initiate any new
catalog fetches.  In all these cases the needed information is readily
available in the caller and so it's just a matter of a bit of extra notation
to pass it to the callback.

Per crash report from Dennis Koegel.  I've concluded that the real fix for
his problem is to clear the error context stack at entry to proc_exit, but
it still seems like a good idea to make the callbacks a bit less fragile
for other cases.

Backpatch to 8.4.  We could go further back, but the patch doesn't apply
cleanly.  In the absence of proof that this fixes something and isn't just
paranoia, I'm not going to expend the effort.

Revision 1.286: download - view: text, markup, annotated - select for diffs
Fri Feb 26 02:00:46 2010 UTC (15 years, 6 months ago) by momjian
Branches: MAIN
Diff to: previous 1.285: preferred, colored
Changes since revision 1.285: +32 -32 lines
pgindent run for 9.0

Revision 1.285: download - view: text, markup, annotated - select for diffs
Sun Feb 14 18:42:15 2010 UTC (15 years, 6 months ago) by rhaas
Branches: MAIN
CVS tags: REL9_0_ALPHA4_BRANCH, REL9_0_ALPHA4
Diff to: previous 1.284: preferred, colored
Changes since revision 1.284: +5 -10 lines
Wrap calls to SearchSysCache and related functions using macros.

The purpose of this change is to eliminate the need for every caller
of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists,
GetSysCacheOid, and SearchSysCacheList to know the maximum number
of allowable keys for a syscache entry (currently 4).  This will
make it far easier to increase the maximum number of keys in a
future release should we choose to do so, and it makes the code
shorter, too.

Design and review by Tom Lane.

Revision 1.284: download - view: text, markup, annotated - select for diffs
Tue Jan 19 16:33:33 2010 UTC (15 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.283: preferred, colored
Changes since revision 1.283: +8 -6 lines
Fix thinko in my recent change to put an explicit argisrow field in NullTest:
when the planner splits apart a ROW(...) IS NULL test, the argisrow values
of the component tests have to be determined from the component field types,
not copied from the original NullTest (in which argisrow is surely true).

Revision 1.283: download - view: text, markup, annotated - select for diffs
Sat Jan 2 16:57:48 2010 UTC (15 years, 8 months ago) by momjian
Branches: MAIN
Diff to: previous 1.282: preferred, colored
Changes since revision 1.282: +2 -2 lines
Update copyright for the year 2010.

Revision 1.282: download - view: text, markup, annotated - select for diffs
Fri Jan 1 23:03:10 2010 UTC (15 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.281: preferred, colored
Changes since revision 1.281: +7 -5 lines
Add an "argisrow" field to NullTest nodes, following a plan made way back in
8.2beta but never carried out.  This avoids repetitive tests of whether the
argument is of scalar or composite type.  Also, be a bit more paranoid about
composite arguments in some places where we previously weren't checking.

Revision 1.281: download - view: text, markup, annotated - select for diffs
Tue Dec 15 17:57:47 2009 UTC (15 years, 8 months ago) by tgl
Branches: MAIN
CVS tags: REL8_5_ALPHA3_BRANCH, REL8_5_ALPHA3
Diff to: previous 1.280: preferred, colored
Changes since revision 1.280: +10 -9 lines
Support ORDER BY within aggregate function calls, at long last providing a
non-kluge method for controlling the order in which values are fed to an
aggregate function.  At the same time eliminate the old implementation
restriction that DISTINCT was only supported for single-argument aggregates.

Possibly release-notable behavioral change: formerly, agg(DISTINCT x)
dropped null values of x unconditionally.  Now, it does so only if the
agg transition function is strict; otherwise nulls are treated as DISTINCT
normally would, ie, you get one copy.

Andrew Gierth, reviewed by Hitoshi Harada

Revision 1.277.2.1: download - view: text, markup, annotated - select for diffs
Mon Dec 14 02:16:03 2009 UTC (15 years, 8 months ago) by tgl
Branches: REL8_4_STABLE
CVS tags: REL8_4_3
Diff to: previous 1.277: preferred, colored
Changes since revision 1.277: +17 -5 lines
Fix a bug introduced when set-returning SQL functions were made inline-able:
we have to cope with the possibility that the declared result rowtype contains
dropped columns.  This fails in 8.4, as per bug #5240.

While at it, be more paranoid about inserting binary coercions when inlining.
The pre-8.4 code did not really need to worry about that because it could not
inline at all in any case where an added coercion could change the behavior
of the function's statement.  However, when inlining a SRF we allow sorting,
grouping, and set-ops such as UNION.  In these cases, modifying one of the
targetlist entries that the sort/group/setop depends on could conceivably
change the behavior of the function's statement --- so don't inline when
such a case applies.

Revision 1.280: download - view: text, markup, annotated - select for diffs
Mon Dec 14 02:15:52 2009 UTC (15 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.279: preferred, colored
Changes since revision 1.279: +17 -5 lines
Fix a bug introduced when set-returning SQL functions were made inline-able:
we have to cope with the possibility that the declared result rowtype contains
dropped columns.  This fails in 8.4, as per bug #5240.

While at it, be more paranoid about inserting binary coercions when inlining.
The pre-8.4 code did not really need to worry about that because it could not
inline at all in any case where an added coercion could change the behavior
of the function's statement.  However, when inlining a SRF we allow sorting,
grouping, and set-ops such as UNION.  In these cases, modifying one of the
targetlist entries that the sort/group/setop depends on could conceivably
change the behavior of the function's statement --- so don't inline when
such a case applies.

Revision 1.279: download - view: text, markup, annotated - select for diffs
Thu Oct 8 02:39:21 2009 UTC (15 years, 11 months ago) by tgl
Branches: MAIN
CVS tags: REL8_5_ALPHA2_BRANCH, REL8_5_ALPHA2
Diff to: previous 1.278: preferred, colored
Changes since revision 1.278: +255 -71 lines
Support use of function argument names to identify which actual arguments
match which function parameters.  The syntax uses AS, for example
	funcname(value AS arg1, anothervalue AS arg2)

Pavel Stehule

Revision 1.278: download - view: text, markup, annotated - select for diffs
Mon Jul 20 00:24:30 2009 UTC (16 years, 1 month ago) by tgl
Branches: MAIN
CVS tags: REL8_5_ALPHA1_BRANCH, REL8_5_ALPHA1
Diff to: previous 1.277: preferred, colored
Changes since revision 1.277: +40 -16 lines
Teach simplify_boolean_equality to simplify the forms foo <> true and
foo <> false, along with its previous duties of simplifying foo = true
and foo = false.  (All of these are equivalent to just foo or NOT foo
as the case may be.)  It's not clear how often this is really useful;
but it costs almost nothing to do, and it seems some people think we
should be smart about such cases.  Per recent bug report.

Revision 1.277: download - view: text, markup, annotated - select for diffs
Thu Jun 11 14:48:59 2009 UTC (16 years, 3 months ago) by momjian
Branches: MAIN
CVS tags: REL8_4_RC2, REL8_4_RC1, REL8_4_2, REL8_4_1, REL8_4_0
Branch point for: REL8_4_STABLE
Diff to: previous 1.276: preferred, colored
Changes since revision 1.276: +48 -47 lines
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.

Revision 1.276: download - view: text, markup, annotated - select for diffs
Wed Feb 25 03:30:37 2009 UTC (16 years, 6 months ago) by tgl
Branches: MAIN
CVS tags: REL8_4_BETA2, REL8_4_BETA1
Diff to: previous 1.275: preferred, colored
Changes since revision 1.275: +1 -37 lines
Get rid of the rather fuzzily defined FlattenedSubLink node type in favor of
making pull_up_sublinks() construct a full-blown JoinExpr tree representation
of IN/EXISTS SubLinks that it is able to convert to semi or anti joins.
This makes pull_up_sublinks() a shade more complex, but the gain in semantic
clarity is worth it.  I still have more to do in this area to address the
previously-discussed problems, but this commit in itself fixes at least one
bug in HEAD, as shown by added regression test case.

Revision 1.275: download - view: text, markup, annotated - select for diffs
Fri Jan 9 15:46:10 2009 UTC (16 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.274: preferred, colored
Changes since revision 1.274: +10 -3 lines
Arrange for function default arguments to be processed properly in expressions
that are set up for execution with ExecPrepareExpr rather than going through
the full planner process.  By introducing an explicit notion of "expression
planning", this patch also lays a bit of groundwork for maybe someday
allowing sub-selects in standalone expressions.

Revision 1.274: download - view: text, markup, annotated - select for diffs
Tue Jan 6 01:23:21 2009 UTC (16 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.273: preferred, colored
Changes since revision 1.273: +24 -7 lines
Fix an oversight in the function-default-arguments patch: after adding some
default expressions to a function call, eval_const_expressions must recurse on
those expressions.  Else they don't get simplified, and in particular we fail
to insert additional default arguments if any functions needing defaults are
in there.  Per report from Rushabh Lathia.

Revision 1.273: download - view: text, markup, annotated - select for diffs
Thu Jan 1 17:23:44 2009 UTC (16 years, 8 months ago) by momjian
Branches: MAIN
Diff to: previous 1.272: preferred, colored
Changes since revision 1.272: +2 -2 lines
Update copyright for 2009.

Revision 1.272: download - view: text, markup, annotated - select for diffs
Sun Dec 28 18:53:57 2008 UTC (16 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.271: preferred, colored
Changes since revision 1.271: +122 -2 lines
Support window functions a la SQL:2008.

Hitoshi Harada, with some kibitzing from Heikki and Tom.

Revision 1.271: download - view: text, markup, annotated - select for diffs
Thu Dec 18 18:20:34 2008 UTC (16 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.270: preferred, colored
Changes since revision 1.270: +96 -12 lines
Code review for function default parameters patch.  Fix numerous problems as
per recent discussions.  In passing this also fixes a couple of bugs in
the previous variadic-parameters patch.

Revision 1.270: download - view: text, markup, annotated - select for diffs
Tue Oct 21 20:42:53 2008 UTC (16 years, 10 months ago) by tgl
Branches: MAIN
Diff to: previous 1.269: preferred, colored
Changes since revision 1.269: +28 -1 lines
Add a concept of "placeholder" variables to the planner.  These are variables
that represent some expression that we desire to compute below the top level
of the plan, and then let that value "bubble up" as though it were a plain
Var (ie, a column value).

The immediate application is to allow sub-selects to be flattened even when
they are below an outer join and have non-nullable output expressions.
Formerly we couldn't flatten because such an expression wouldn't properly
go to NULL when evaluated above the outer join.  Now, we wrap it in a
PlaceHolderVar and arrange for the actual evaluation to occur below the outer
join.  When the resulting Var bubbles up through the join, it will be set to
NULL if necessary, yielding the correct results.  This fixes a planner
limitation that's existed since 7.1.

In future we might want to use this mechanism to re-introduce some form of
Hellerstein's "expensive functions" optimization, ie place the evaluation of
an expensive function at the most suitable point in the plan tree.

Revision 1.269: download - view: text, markup, annotated - select for diffs
Thu Oct 9 19:27:40 2008 UTC (16 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.268: preferred, colored
Changes since revision 1.268: +65 -13 lines
Improve the recently-added code for inlining set-returning functions so that
it can handle functions returning setof record.  The case was left undone
originally, but it turns out to be simple to fix.

Revision 1.268: download - view: text, markup, annotated - select for diffs
Sat Oct 4 21:56:53 2008 UTC (16 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.267: preferred, colored
Changes since revision 1.267: +2 -1 lines
Implement SQL-standard WITH clauses, including WITH RECURSIVE.

There are some unimplemented aspects: recursive queries must use UNION ALL
(should allow UNION too), and we don't have SEARCH or CYCLE clauses.
These might or might not get done for 8.4, but even without them it's a
pretty useful feature.

There are also a couple of small loose ends and definitional quibbles,
which I'll send a memo about to pgsql-hackers shortly.  But let's land
the patch now so we can get on with other development.

Yoshiyuki Asaba, with lots of help from Tatsuo Ishii and Tom Lane

Revision 1.267: download - view: text, markup, annotated - select for diffs
Tue Sep 9 18:58:08 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.266: preferred, colored
Changes since revision 1.266: +23 -1 lines
Improve the plan cache invalidation mechanism to make it invalidate plans
when user-defined functions used in a plan are modified.  Also invalidate
plans when schemas, operators, or operator classes are modified; but for these
cases we just invalidate everything rather than tracking exact dependencies,
since these types of objects seldom change in a production database.

Tom Lane; loosely based on a patch by Martin Pihlak.

Revision 1.266: download - view: text, markup, annotated - select for diffs
Thu Aug 28 23:09:46 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.265: preferred, colored
Changes since revision 1.265: +16 -1 lines
Extend the parser location infrastructure to include a location field in
most node types used in expression trees (both before and after parse
analysis).  This allows us to place an error cursor in many situations
where we formerly could not, because the information wasn't available
beyond the very first level of parse analysis.  There's a fair amount
of work still to be done to persuade individual ereport() calls to actually
include an error location, but this gets the initdb-forcing part of the
work out of the way; and the situation is already markedly better than
before for complaints about unimplementable implicit casts, such as
CASE and UNION constructs with incompatible alternative data types.
Per my proposal of a few days ago.

Revision 1.254.2.3: download - view: text, markup, annotated - select for diffs
Tue Aug 26 02:16:39 2008 UTC (17 years ago) by tgl
Branches: REL8_3_STABLE
CVS tags: REL8_3_9, REL8_3_8, REL8_3_7, REL8_3_6, REL8_3_5, REL8_3_4, REL8_3_11, REL8_3_10
Diff to: previous 1.254.2.2: preferred, colored; branchpoint 1.254: preferred, colored; next MAIN 1.255: preferred, colored
Changes since revision 1.254.2.2: +36 -1 lines
Teach eval_const_expressions() to simplify an ArrayCoerceExpr to a constant
when its input is constant and the element coercion function is immutable
(or nonexistent, ie, binary-coercible case).  This is an oversight in the
8.3 implementation of ArrayCoerceExpr, and its result is that certain cases
involving IN or NOT IN with constants don't get optimized as they should be.
Per experimentation with an example from Ow Mun Heng.

Revision 1.265: download - view: text, markup, annotated - select for diffs
Tue Aug 26 02:16:31 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.264: preferred, colored
Changes since revision 1.264: +36 -1 lines
Teach eval_const_expressions() to simplify an ArrayCoerceExpr to a constant
when its input is constant and the element coercion function is immutable
(or nonexistent, ie, binary-coercible case).  This is an oversight in the
8.3 implementation of ArrayCoerceExpr, and its result is that certain cases
involving IN or NOT IN with constants don't get optimized as they should be.
Per experimentation with an example from Ow Mun Heng.

Revision 1.264: download - view: text, markup, annotated - select for diffs
Mon Aug 25 22:42:33 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.263: preferred, colored
Changes since revision 1.263: +4 -1228 lines
Move exprType(), exprTypmod(), expression_tree_walker(), and related routines
into nodes/nodeFuncs, so as to reduce wanton cross-subsystem #includes inside
the backend.  There's probably more that should be done along this line,
but this is a start anyway.

Revision 1.263: download - view: text, markup, annotated - select for diffs
Fri Aug 22 00:16:04 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.262: preferred, colored
Changes since revision 1.262: +23 -3 lines
Arrange to convert EXISTS subqueries that are equivalent to hashable IN
subqueries into the same thing you'd have gotten from IN (except always with
unknownEqFalse = true, so as to get the proper semantics for an EXISTS).
I believe this fixes the last case within CVS HEAD in which an EXISTS could
give worse performance than an equivalent IN subquery.

The tricky part of this is that if the upper query probes the EXISTS for only
a few rows, the hashing implementation can actually be worse than the default,
and therefore we need to make a cost-based decision about which way to use.
But at the time when the planner generates plans for subqueries, it doesn't
really know how many times the subquery will be executed.  The least invasive
solution seems to be to generate both plans and postpone the choice until
execution.  Therefore, in a query that has been optimized this way, EXPLAIN
will show two subplans for the EXISTS, of which only one will actually get
executed.

There is a lot more that could be done based on this infrastructure: in
particular it's interesting to consider switching to the hash plan if we start
out using the non-hashed plan but find a lot more upper rows going by than we
expected.  I have therefore left some minor inefficiencies in place, such as
initializing both subplans even though we will currently only use one.

Revision 1.262: download - view: text, markup, annotated - select for diffs
Thu Aug 14 18:47:59 2008 UTC (17 years ago) by tgl
Branches: MAIN
Diff to: previous 1.261: preferred, colored
Changes since revision 1.261: +358 -12 lines
Implement SEMI and ANTI joins in the planner and executor.  (Semijoins replace
the old JOIN_IN code, but antijoins are new functionality.)  Teach the planner
to convert appropriate EXISTS and NOT EXISTS subqueries into semi and anti
joins respectively.  Also, LEFT JOINs with suitable upper-level IS NULL
filters are recognized as being anti joins.  Unify the InClauseInfo and
OuterJoinInfo infrastructure into "SpecialJoinInfo".  With that change,
it becomes possible to associate a SpecialJoinInfo with every join attempt,
which permits some cleanup of join selectivity estimation.  That needs to be
taken much further than this patch does, but the next step is to change the
API for oprjoin selectivity functions, which seems like material for a
separate patch.  So for the moment the output size estimates for semi and
especially anti joins are quite bogus.

Revision 1.261: download - view: text, markup, annotated - select for diffs
Thu Aug 7 01:11:50 2008 UTC (17 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.260: preferred, colored
Changes since revision 1.260: +4 -1 lines
Teach the system how to use hashing for UNION.  (INTERSECT/EXCEPT will follow,
but seem like a separate patch since most of the remaining work is on the
executor side.)  I took the opportunity to push selection of the grouping
operators for set operations into the parser where it belongs.  Otherwise this
is just a small exercise in making prepunion.c consider both alternatives.

As with the recent DISTINCT patch, this means we can UNION on datatypes that
can hash but not sort, and it means that UNION without ORDER BY is no longer
certain to produce sorted output.

Revision 1.260: download - view: text, markup, annotated - select for diffs
Sat Aug 2 21:32:00 2008 UTC (17 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.259: preferred, colored
Changes since revision 1.259: +1 -80 lines
Rearrange the querytree representation of ORDER BY/GROUP BY/DISTINCT items
as per my recent proposal:

1. Fold SortClause and GroupClause into a single node type SortGroupClause.
We were already relying on them to be struct-equivalent, so using two node
tags wasn't accomplishing much except to get in the way of comparing items
with equal().

2. Add an "eqop" field to SortGroupClause to carry the associated equality
operator.  This is cheap for the parser to get at the same time it's looking
up the sort operator, and storing it eliminates the need for repeated
not-so-cheap lookups during planning.  In future this will also let us
represent GROUP/DISTINCT operations on datatypes that have hash opclasses
but no btree opclasses (ie, they have equality but no natural sort order).
The previous representation simply didn't work for that, since its only
indicator of comparison semantics was a sort operator.

3. Add a hasDistinctOn boolean to struct Query to explicitly record whether
the distinctClause came from DISTINCT or DISTINCT ON.  This allows removing
some complicated and not 100% bulletproof code that attempted to figure
that out from the distinctClause alone.

This patch doesn't in itself create any new capability, but it's necessary
infrastructure for future attempts to use hash-based grouping for DISTINCT
and UNION/INTERSECT/EXCEPT.

Revision 1.254.2.2: download - view: text, markup, annotated - select for diffs
Thu May 15 17:37:57 2008 UTC (17 years, 3 months ago) by tgl
Branches: REL8_3_STABLE
CVS tags: REL8_3_3, REL8_3_2
Diff to: previous 1.254.2.1: preferred, colored; branchpoint 1.254: preferred, colored
Changes since revision 1.254.2.1: +66 -1 lines
Add code to eval_const_expressions() to support const-simplification of
CoerceViaIO nodes.  This improves the ability of the planner to deal with
cases where the node input is a constant.  Per bug #4170.

Revision 1.259: download - view: text, markup, annotated - select for diffs
Thu May 15 17:37:49 2008 UTC (17 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.258: preferred, colored
Changes since revision 1.258: +66 -1 lines
Add code to eval_const_expressions() to support const-simplification of
CoerceViaIO nodes.  This improves the ability of the planner to deal with
cases where the node input is a constant.  Per bug #4170.

Revision 1.258: download - view: text, markup, annotated - select for diffs
Mon May 12 00:00:49 2008 UTC (17 years, 4 months ago) by alvherre
Branches: MAIN
Diff to: previous 1.257: preferred, colored
Changes since revision 1.257: +1 -2 lines
Restructure some header files a bit, in particular heapam.h, by removing some
unnecessary #include lines in it.  Also, move some tuple routine prototypes and
macros to htup.h, which allows removal of heapam.h inclusion from some .c
files.

For this to work, a new header file access/sysattr.h needed to be created,
initially containing attribute numbers of system columns, for pg_dump usage.

While at it, make contrib ltree, intarray and hstore header files more
consistent with our header style.

Revision 1.254.2.1: download - view: text, markup, annotated - select for diffs
Tue Apr 1 00:48:44 2008 UTC (17 years, 5 months ago) by tgl
Branches: REL8_3_STABLE
Diff to: previous 1.254: preferred, colored
Changes since revision 1.254: +9 -3 lines
Fix an oversight I made in a cleanup patch over a year ago:
eval_const_expressions needs to be passed the PlannerInfo ("root") structure,
because in some cases we want it to substitute values for Param nodes.
(So "constant" is not so constant as all that ...)  This mistake partially
disabled optimization of unnamed extended-Query statements in 8.3: in
particular the LIKE-to-indexscan optimization would never be applied if the
LIKE pattern was passed as a parameter, and constraint exclusion depending
on a parameter value didn't work either.

Revision 1.257: download - view: text, markup, annotated - select for diffs
Tue Apr 1 00:48:33 2008 UTC (17 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.256: preferred, colored
Changes since revision 1.256: +9 -3 lines
Fix an oversight I made in a cleanup patch over a year ago:
eval_const_expressions needs to be passed the PlannerInfo ("root") structure,
because in some cases we want it to substitute values for Param nodes.
(So "constant" is not so constant as all that ...)  This mistake partially
disabled optimization of unnamed extended-Query statements in 8.3: in
particular the LIKE-to-indexscan optimization would never be applied if the
LIKE pattern was passed as a parameter, and constraint exclusion depending
on a parameter value didn't work either.

Revision 1.256: download - view: text, markup, annotated - select for diffs
Tue Mar 25 22:42:43 2008 UTC (17 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.255: preferred, colored
Changes since revision 1.255: +4 -4 lines
Simplify and standardize conversions between TEXT datums and ordinary C
strings.  This patch introduces four support functions cstring_to_text,
cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
two macros CStringGetTextDatum and TextDatumGetCString.  A number of
existing macros that provided variants on these themes were removed.

Most of the places that need to make such conversions now require just one
function or macro call, in place of the multiple notational layers that used
to be needed.  There are no longer any direct calls of textout or textin,
and we got most of the places that were using handmade conversions via
memcpy (there may be a few still lurking, though).

This commit doesn't make any serious effort to eliminate transient memory
leaks caused by detoasting toasted text objects before they reach
text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
places where it was easy, but much more could be done.

Brendan Jurd and Tom Lane

Revision 1.255: download - view: text, markup, annotated - select for diffs
Tue Mar 18 22:04:14 2008 UTC (17 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.254: preferred, colored
Changes since revision 1.254: +306 -22 lines
Arrange to "inline" SQL functions that appear in a query's FROM clause,
are declared to return set, and consist of just a single SELECT.  We
can replace the FROM-item with a sub-SELECT and then optimize much as
if we were dealing with a view.  Patch from Richard Rowell, cleaned up
by me.

Revision 1.254: download - view: text, markup, annotated - select for diffs
Fri Jan 11 18:39:40 2008 UTC (17 years, 8 months ago) by tgl
Branches: MAIN
CVS tags: REL8_3_RC2, REL8_3_1, REL8_3_0
Branch point for: REL8_3_STABLE
Diff to: previous 1.253: preferred, colored
Changes since revision 1.253: +3 -2 lines
The original implementation of polymorphic aggregates didn't really get the
checking of argument compatibility right; although the problem is only exposed
with multiple-input aggregates in which some arguments are polymorphic and
some are not.  Per bug #3852 from Sokolov Yura.

Revision 1.253: download - view: text, markup, annotated - select for diffs
Tue Jan 1 19:45:50 2008 UTC (17 years, 8 months ago) by momjian
Branches: MAIN
CVS tags: REL8_3_RC1
Diff to: previous 1.252: preferred, colored
Changes since revision 1.252: +2 -2 lines
Update copyrights in source tree to 2008.

Revision 1.252: download - view: text, markup, annotated - select for diffs
Thu Nov 22 19:09:23 2007 UTC (17 years, 9 months ago) by tgl
Branches: MAIN
CVS tags: REL8_3_BETA4
Diff to: previous 1.251: preferred, colored
Changes since revision 1.251: +23 -12 lines
Save one syscache lookup when examining volatility or strictness of
OpExpr and related nodes.  We're going to have to set the opfuncid of
such nodes eventually (if we haven't already), so we might as well
exploit the opportunity to cache the function OID.  Buys back some
of the extra planner overhead noted by Guillaume Smet, though I still
need to fool with equivclass.c to really respond to that.

Revision 1.251: download - view: text, markup, annotated - select for diffs
Thu Nov 15 21:14:36 2007 UTC (17 years, 9 months ago) by momjian
Branches: MAIN
CVS tags: REL8_3_BETA3
Diff to: previous 1.250: preferred, colored
Changes since revision 1.250: +40 -37 lines
pgindent run for 8.3.

Revision 1.109.2.2: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:28:39 2007 UTC (17 years, 11 months ago) by tgl
Branches: REL7_3_STABLE
CVS tags: REL7_3_21
Diff to: previous 1.109.2.1: preferred, colored; branchpoint 1.109: preferred, colored; next MAIN 1.110: preferred, colored
Changes since revision 1.109.2.1: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.154.2.8: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:28:30 2007 UTC (17 years, 11 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_29, REL7_4_28, REL7_4_27, REL7_4_26, REL7_4_25, REL7_4_24, REL7_4_23, REL7_4_22, REL7_4_21, REL7_4_20, REL7_4_19
Diff to: previous 1.154.2.7: preferred, colored; branchpoint 1.154: preferred, colored; next MAIN 1.155: preferred, colored
Changes since revision 1.154.2.7: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.186.4.8: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:28:20 2007 UTC (17 years, 11 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_25, REL8_0_24, REL8_0_23, REL8_0_22, REL8_0_21, REL8_0_20, REL8_0_19, REL8_0_18, REL8_0_17, REL8_0_16, REL8_0_15
Diff to: previous 1.186.4.7: preferred, colored; branchpoint 1.186: preferred, colored; next MAIN 1.187: preferred, colored
Changes since revision 1.186.4.7: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.201.2.5: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:28:12 2007 UTC (17 years, 11 months ago) by tgl
Branches: REL8_1_STABLE
CVS tags: REL8_1_21, REL8_1_20, REL8_1_19, REL8_1_18, REL8_1_17, REL8_1_16, REL8_1_15, REL8_1_14, REL8_1_13, REL8_1_12, REL8_1_11
Diff to: previous 1.201.2.4: preferred, colored; branchpoint 1.201: preferred, colored; next MAIN 1.202: preferred, colored
Changes since revision 1.201.2.4: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.223.2.4: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:28:05 2007 UTC (17 years, 11 months ago) by tgl
Branches: REL8_2_STABLE
CVS tags: REL8_2_9, REL8_2_8, REL8_2_7, REL8_2_6, REL8_2_17, REL8_2_16, REL8_2_15, REL8_2_14, REL8_2_13, REL8_2_12, REL8_2_11, REL8_2_10
Diff to: previous 1.223.2.3: preferred, colored; branchpoint 1.223: preferred, colored; next MAIN 1.224: preferred, colored
Changes since revision 1.223.2.3: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.250: download - view: text, markup, annotated - select for diffs
Thu Oct 11 21:27:49 2007 UTC (17 years, 11 months ago) by tgl
Branches: MAIN
CVS tags: REL8_3_BETA2
Diff to: previous 1.249: preferred, colored
Changes since revision 1.249: +14 -3 lines
Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.

Revision 1.249: download - view: text, markup, annotated - select for diffs
Thu Sep 6 17:31:58 2007 UTC (18 years ago) by tgl
Branches: MAIN
CVS tags: REL8_3_BETA1
Diff to: previous 1.248: preferred, colored
Changes since revision 1.248: +3 -3 lines
Make eval_const_expressions() preserve typmod when simplifying something like
null::char(3) to a simple Const node.  (It already worked for non-null values,
but not when we skipped evaluation of a strict coercion function.)  This
prevents loss of typmod knowledge in situations such as exhibited in bug
#3598.  Unfortunately there seems no good way to fix that bug in 8.1 and 8.2,
because they simply don't carry a typmod for a plain Const node.

In passing I made all the other callers of makeNullConst supply "real" typmod
values too, though I think it probably doesn't matter anywhere else.

Revision 1.248: download - view: text, markup, annotated - select for diffs
Mon Sep 3 00:39:15 2007 UTC (18 years ago) by tgl
Branches: MAIN
Diff to: previous 1.247: preferred, colored
Changes since revision 1.247: +3 -1 lines
Implement function-local GUC parameter settings, as per recent discussion.
There are still some loose ends: I didn't do anything about the SET FROM
CURRENT idea yet, and it's not real clear whether we are happy with the
interaction of SET LOCAL with function-local settings.  The documentation
is a bit spartan, too.

Revision 1.247: download - view: text, markup, annotated - select for diffs
Sat Jun 23 22:12:50 2007 UTC (18 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.246: preferred, colored
Changes since revision 1.246: +4 -10 lines
Separate parse-analysis for utility commands out of parser/analyze.c
(which now deals only in optimizable statements), and put that code
into a new file parser/parse_utilcmd.c.  This helps clarify and enforce
the design rule that utility statements shouldn't be processed during
the regular parse analysis phase; all interpretation of their meaning
should happen after they are given to ProcessUtility to execute.
(We need this because we don't retain any locks for a utility statement
that's in a plan cache, nor have any way to detect that it's stale.)

We are also able to simplify the API for parse_analyze() and related
routines, because they will now always return exactly one Query structure.

In passing, fix bug #3403 concerning trying to add a serial column to
an existing temp table (this is largely Heikki's work, but we needed
all that restructuring to make it safe).

Revision 1.246: download - view: text, markup, annotated - select for diffs
Mon Jun 11 01:16:23 2007 UTC (18 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.245: preferred, colored
Changes since revision 1.245: +3 -1 lines
Support UPDATE/DELETE WHERE CURRENT OF cursor_name, per SQL standard.

Along the way, allow FOR UPDATE in non-WITH-HOLD cursors; there may once
have been a reason to disallow that, but it seems to work now, and it's
really rather necessary if you want to select a row via a cursor and then
update it in a concurrent-safe fashion.

Original patch by Arul Shaji, rather heavily editorialized by Tom Lane.

Revision 1.245: download - view: text, markup, annotated - select for diffs
Tue Jun 5 21:31:05 2007 UTC (18 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.244: preferred, colored
Changes since revision 1.244: +67 -1 lines
Downgrade implicit casts to text to be assignment-only, except for the ones
from the other string-category types; this eliminates a lot of surprising
interpretations that the parser could formerly make when there was no directly
applicable operator.

Create a general mechanism that supports casts to and from the standard string
types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's
I/O functions.  These new casts are assignment-only in the to-string direction,
explicit-only in the other, and therefore should create no surprising behavior.
Remove a bunch of thereby-obsoleted datatype-specific casting functions.

The "general mechanism" is a new expression node type CoerceViaIO that can
actually convert between *any* two datatypes if their external text
representations are compatible.  This is more general than needed for the
immediate feature, but might be useful in plpgsql or other places in future.

This commit does nothing about the issue that applying the concatenation
operator || to non-text types will now fail, often with strange error messages
due to misinterpreting the operator as array concatenation.  Since it often
(not always) worked before, we should either make it succeed or at least give
a more user-friendly error; but details are still under debate.

Peter Eisentraut and Tom Lane

Revision 1.154.2.7: download - view: text, markup, annotated - select for diffs
Tue May 1 18:54:24 2007 UTC (18 years, 4 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_18
Diff to: previous 1.154.2.6: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.6: +4 -4 lines
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

Revision 1.186.4.7: download - view: text, markup, annotated - select for diffs
Tue May 1 18:54:16 2007 UTC (18 years, 4 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_14
Diff to: previous 1.186.4.6: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.6: +4 -4 lines
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

Revision 1.201.2.4: download - view: text, markup, annotated - select for diffs
Tue May 1 18:54:09 2007 UTC (18 years, 4 months ago) by tgl
Branches: REL8_1_STABLE
CVS tags: REL8_1_10
Diff to: previous 1.201.2.3: preferred, colored; branchpoint 1.201: preferred, colored
Changes since revision 1.201.2.3: +4 -4 lines
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

Revision 1.223.2.3: download - view: text, markup, annotated - select for diffs
Tue May 1 18:54:01 2007 UTC (18 years, 4 months ago) by tgl
Branches: REL8_2_STABLE
CVS tags: REL8_2_5
Diff to: previous 1.223.2.2: preferred, colored; branchpoint 1.223: preferred, colored
Changes since revision 1.223.2.2: +4 -4 lines
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

Revision 1.244: download - view: text, markup, annotated - select for diffs
Tue May 1 18:53:51 2007 UTC (18 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.243: preferred, colored
Changes since revision 1.243: +4 -4 lines
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

Revision 1.243: download - view: text, markup, annotated - select for diffs
Mon Apr 30 00:14:54 2007 UTC (18 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.242: preferred, colored
Changes since revision 1.242: +25 -4 lines
Marginal performance hack: avoid unnecessary work in expression_tree_mutator.
We can just palloc, instead of using makeNode, when we are going to
overwrite the whole node anyway in the FLATCOPY macro.  Also, use
FLATCOPY instead of copyObject for common node types Var and Const.

Revision 1.242: download - view: text, markup, annotated - select for diffs
Fri Apr 27 22:05:48 2007 UTC (18 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.241: preferred, colored
Changes since revision 1.241: +3 -2 lines
Modify processing of DECLARE CURSOR and EXPLAIN so that they can resolve the
types of unspecified parameters when submitted via extended query protocol.
This worked in 8.2 but I had broken it during plancache changes.  DECLARE
CURSOR is now treated almost exactly like a plain SELECT through parse
analysis, rewrite, and planning; only just before sending to the executor
do we divert it away to ProcessUtility.  This requires a special-case check
in a number of places, but practically all of them were already special-casing
SELECT INTO, so it's not too ugly.  (Maybe it would be a good idea to merge
the two by treating IntoClause as a form of utility statement?  Not going to
worry about that now, though.)  That approach doesn't work for EXPLAIN,
however, so for that I punted and used a klugy solution of running parse
analysis an extra time if under extended query protocol.

Revision 1.241: download - view: text, markup, annotated - select for diffs
Mon Apr 2 03:49:38 2007 UTC (18 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.240: preferred, colored
Changes since revision 1.240: +3 -4 lines
Support enum data types.  Along the way, use macros for the values of
pg_type.typtype whereever practical.  Tom Dunstan, with some kibitzing
from Tom Lane.

Revision 1.240: download - view: text, markup, annotated - select for diffs
Tue Mar 27 23:21:09 2007 UTC (18 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.239: preferred, colored
Changes since revision 1.239: +58 -11 lines
Fix array coercion expressions to ensure that the correct volatility is
seen by code inspecting the expression.  The best way to do this seems
to be to drop the original representation as a function invocation, and
instead make a special expression node type that represents applying
the element-type coercion function to each array element.  In this way
the element function is exposed and will be checked for volatility.
Per report from Guillaume Smet.

Revision 1.239: download - view: text, markup, annotated - select for diffs
Sat Mar 17 00:11:04 2007 UTC (18 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.238: preferred, colored
Changes since revision 1.238: +31 -25 lines
Fix up the remaining places where the expression node structure would lose
available information about the typmod of an expression; namely, Const,
ArrayRef, ArrayExpr, and EXPR and ARRAY SubLinks.  In the ArrayExpr and
SubLink cases it wasn't really the data structure's fault, but exprTypmod()
being lazy.  This seems like a good idea in view of the expected increase in
typmod usage from Teodor's work to allow user-defined types to have typmods.
In particular this responds to the concerns we had about eliminating the
special-purpose hack that exprTypmod() used to have for BPCHAR Consts.
We can now tell whether or not such a Const has been cast to a specific
length, and report or display properly if so.

initdb forced due to changes in stored rules.

Revision 1.238: download - view: text, markup, annotated - select for diffs
Tue Mar 13 00:33:41 2007 UTC (18 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.237: preferred, colored
Changes since revision 1.237: +1 -33 lines
First phase of plan-invalidation project: create a plan cache management
module and teach PREPARE and protocol-level prepared statements to use it.
In service of this, rearrange utility-statement processing so that parse
analysis does not assume table schemas can't change before execution for
utility statements (necessary because we don't attempt to re-acquire locks
for utility statements when reusing a stored plan).  This requires some
refactoring of the ProcessUtility API, but it ends up cleaner anyway,
for instance we can get rid of the QueryContext global.

Still to do: fix up SPI and related code to use the plan cache; I'm tempted to
try to make SQL functions use it too.  Also, there are at least some aspects
of system state that we want to ensure remain the same during a replan as in
the original processing; search_path certainly ought to behave that way for
instance, and perhaps there are others.

Revision 1.154.2.6: download - view: text, markup, annotated - select for diffs
Tue Mar 6 22:45:41 2007 UTC (18 years, 6 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_17
Diff to: previous 1.154.2.5: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.5: +18 -1 lines
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

Revision 1.186.4.6: download - view: text, markup, annotated - select for diffs
Tue Mar 6 22:45:35 2007 UTC (18 years, 6 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_13
Diff to: previous 1.186.4.5: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.5: +20 -3 lines
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

Revision 1.201.2.3: download - view: text, markup, annotated - select for diffs
Tue Mar 6 22:45:29 2007 UTC (18 years, 6 months ago) by tgl
Branches: REL8_1_STABLE
CVS tags: REL8_1_9
Diff to: previous 1.201.2.2: preferred, colored; branchpoint 1.201: preferred, colored
Changes since revision 1.201.2.2: +19 -2 lines
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

Revision 1.223.2.2: download - view: text, markup, annotated - select for diffs
Tue Mar 6 22:45:23 2007 UTC (18 years, 6 months ago) by tgl
Branches: REL8_2_STABLE
CVS tags: REL8_2_4
Diff to: previous 1.223.2.1: preferred, colored; branchpoint 1.223: preferred, colored
Changes since revision 1.223.2.1: +19 -2 lines
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

Revision 1.237: download - view: text, markup, annotated - select for diffs
Tue Mar 6 22:45:16 2007 UTC (18 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.236: preferred, colored
Changes since revision 1.236: +19 -2 lines
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

Revision 1.236: download - view: text, markup, annotated - select for diffs
Thu Feb 22 22:00:24 2007 UTC (18 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.235: preferred, colored
Changes since revision 1.235: +2 -2 lines
Turn the rangetable used by the executor into a flat list, and avoid storing
useless substructure for its RangeTblEntry nodes.  (I chose to keep using the
same struct node type and just zero out the link fields for unneeded info,
rather than making a separate ExecRangeTblEntry type --- it seemed too
fragile to have two different rangetable representations.)

Along the way, put subplans into a list in the toplevel PlannedStmt node,
and have SubPlan nodes refer to them by list index instead of direct pointers.
Vadim wanted to do that years ago, but I never understood what he was on about
until now.  It makes things a *whole* lot more robust, because we can stop
worrying about duplicate processing of subplans during expression tree
traversals.  That's been a constant source of bugs, and it's finally gone.

There are some consequent simplifications yet to be made, like not using
a separate EState for subplans in the executor, but I'll tackle that later.

Revision 1.235: download - view: text, markup, annotated - select for diffs
Mon Feb 19 07:03:30 2007 UTC (18 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.234: preferred, colored
Changes since revision 1.234: +8 -5 lines
Get rid of some old and crufty global variables in the planner.  When
this code was last gone over, there wasn't really any alternative to
globals because we didn't have the PlannerInfo struct being passed all
through the planner code.  Now that we do, we can restructure things
to avoid non-reentrancy.  I'm fooling with this because otherwise I'd
have had to add another global variable for the planned compact
range table list.

Revision 1.234: download - view: text, markup, annotated - select for diffs
Fri Feb 16 23:32:08 2007 UTC (18 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.233: preferred, colored
Changes since revision 1.233: +71 -19 lines
Teach find_nonnullable_rels to handle OR cases: if every arm of an OR
forces a particular relation nonnullable, then we can say that the OR does.
This is worth a little extra trouble since it may allow reduction of
outer joins to plain joins.

Revision 1.154.2.5: download - view: text, markup, annotated - select for diffs
Fri Feb 2 00:04:02 2007 UTC (18 years, 7 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_16
Diff to: previous 1.154.2.4: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.4: +11 -17 lines
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

Revision 1.186.4.5: download - view: text, markup, annotated - select for diffs
Fri Feb 2 00:03:44 2007 UTC (18 years, 7 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_12, REL8_0_11
Diff to: previous 1.186.4.4: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.4: +9 -17 lines
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

Revision 1.201.2.2: download - view: text, markup, annotated - select for diffs
Fri Feb 2 00:03:30 2007 UTC (18 years, 7 months ago) by tgl
Branches: REL8_1_STABLE
CVS tags: REL8_1_8, REL8_1_7
Diff to: previous 1.201.2.1: preferred, colored; branchpoint 1.201: preferred, colored
Changes since revision 1.201.2.1: +4 -12 lines
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

Revision 1.223.2.1: download - view: text, markup, annotated - select for diffs
Fri Feb 2 00:03:17 2007 UTC (18 years, 7 months ago) by tgl
Branches: REL8_2_STABLE
CVS tags: REL8_2_3, REL8_2_2
Diff to: previous 1.223: preferred, colored
Changes since revision 1.223: +4 -12 lines
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

Revision 1.233: download - view: text, markup, annotated - select for diffs
Fri Feb 2 00:02:55 2007 UTC (18 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.232: preferred, colored
Changes since revision 1.232: +4 -12 lines
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

Revision 1.232: download - view: text, markup, annotated - select for diffs
Thu Feb 1 19:10:26 2007 UTC (18 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.231: preferred, colored
Changes since revision 1.231: +2 -2 lines
Wording cleanup for error messages.  Also change can't -> cannot.

Standard English uses "may", "can", and "might" in different ways:

        may - permission, "You may borrow my rake."

        can - ability, "I can lift that log."

        might - possibility, "It might rain today."

Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice.  Similarly, "It may crash" is better stated, "It might crash".

Revision 1.231: download - view: text, markup, annotated - select for diffs
Mon Jan 22 01:35:20 2007 UTC (18 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.230: preferred, colored
Changes since revision 1.230: +74 -1 lines
Add COST and ROWS options to CREATE/ALTER FUNCTION, plus underlying pg_proc
columns procost and prorows, to allow simple user adjustment of the estimated
cost of a function call, as well as control of the estimated number of rows
returned by a set-returning function.  We might eventually wish to extend this
to allow function-specific estimation routines, but there seems to be
consensus that we should try a simple constant estimate first.  In particular
this provides a relatively simple way to control the order in which different
WHERE clauses are applied in a plan node, which is a Good Thing in view of the
fact that the recent EquivalenceClass planner rewrite made that much less
predictable than before.

Revision 1.230: download - view: text, markup, annotated - select for diffs
Wed Jan 17 17:25:52 2007 UTC (18 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.229: preferred, colored
Changes since revision 1.229: +7 -1 lines
Add a note pointing out that is_pseudo_constant_clause() doesn't check
for aggregates.  This is OK for current uses but could burn somebody
someday...

Revision 1.229: download - view: text, markup, annotated - select for diffs
Wed Jan 10 18:06:04 2007 UTC (18 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.228: preferred, colored
Changes since revision 1.228: +2 -1 lines
Change the planner-to-executor API so that the planner tells the executor
which comparison operators to use for plan nodes involving tuple comparison
(Agg, Group, Unique, SetOp).  Formerly the executor looked up the default
equality operator for the datatype, which was really pretty shaky, since it's
possible that the data being fed to the node is sorted according to some
nondefault operator class that could have an incompatible idea of equality.
The planner knows what it has sorted by and therefore can provide the right
equality operator to use.  Also, this change moves a couple of catalog lookups
out of the executor and into the planner, which should help startup time for
pre-planned queries by some small amount.  Modify the planner to remove some
other cavalier assumptions about always being able to use the default
operators.  Also add "nulls first/last" info to the Plan node for a mergejoin
--- neither the executor nor the planner can cope yet, but at least the API is
in place.

Revision 1.228: download - view: text, markup, annotated - select for diffs
Tue Jan 9 02:14:13 2007 UTC (18 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.227: preferred, colored
Changes since revision 1.227: +3 -3 lines
Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST
per-column options for btree indexes.  The planner's support for this is still
pretty rudimentary; it does not yet know how to plan mergejoins with
nondefault ordering options.  The documentation is pretty rudimentary, too.
I'll work on improving that stuff later.

Note incompatible change from prior behavior: ORDER BY ... USING will now be
rejected if the operator is not a less-than or greater-than member of some
btree opclass.  This prevents less-than-sane behavior if an operator that
doesn't actually define a proper sort ordering is selected.

Revision 1.227: download - view: text, markup, annotated - select for diffs
Fri Jan 5 22:19:32 2007 UTC (18 years, 8 months ago) by momjian
Branches: MAIN
Diff to: previous 1.226: preferred, colored
Changes since revision 1.226: +2 -2 lines
Update CVS HEAD for 2007 copyright.  Back branches are typically not
back-stamped for this.

Revision 1.226: download - view: text, markup, annotated - select for diffs
Sun Dec 24 00:29:18 2006 UTC (18 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.225: preferred, colored
Changes since revision 1.225: +13 -11 lines
Code review for XML patch.  Instill a bit of sanity in the location of
the XmlExpr code in various lists, use a representation that has some hope
of reverse-listing correctly (though it's still a de-escaping function
shy of correctness), generally try to make it look more like Postgres
coding conventions.

Revision 1.225: download - view: text, markup, annotated - select for diffs
Sat Dec 23 00:43:10 2006 UTC (18 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.224: preferred, colored
Changes since revision 1.224: +3 -7 lines
Restructure operator classes to allow improved handling of cross-data-type
cases.  Operator classes now exist within "operator families".  While most
families are equivalent to a single class, related classes can be grouped
into one family to represent the fact that they are semantically compatible.
Cross-type operators are now naturally adjunct parts of a family, without
having to wedge them into a particular opclass as we had done originally.

This commit restructures the catalogs and cleans up enough of the fallout so
that everything still works at least as well as before, but most of the work
needed to actually improve the planner's behavior will come later.  Also,
there are not yet CREATE/DROP/ALTER OPERATOR FAMILY commands; the only way
to create a new family right now is to allow CREATE OPERATOR CLASS to make
one by default.  I owe some more documentation work, too.  But that can all
be done in smaller pieces once this infrastructure is in place.

Revision 1.224: download - view: text, markup, annotated - select for diffs
Thu Dec 21 16:05:13 2006 UTC (18 years, 8 months ago) by petere
Branches: MAIN
Diff to: previous 1.223: preferred, colored
Changes since revision 1.223: +26 -1 lines
Initial SQL/XML support: xml data type and initial set of functions.

Revision 1.223: download - view: text, markup, annotated - select for diffs
Wed Oct 25 22:11:32 2006 UTC (18 years, 10 months ago) by tgl
Branches: MAIN
CVS tags: REL8_2_RC1, REL8_2_BETA3, REL8_2_1, REL8_2_0
Branch point for: REL8_2_STABLE
Diff to: previous 1.222: preferred, colored
Changes since revision 1.222: +4 -5 lines
expression_tree_walker failed to let walker function see the immediate child
node of a SubLink or SubPlan testexpr field.  Bug resulted from replacing
the old lefthand/exprs list fields with a simple expression field, and not
remembering that expression_tree_walker is coded to save a few cycles by
recursing directly to self on list fields (on the assumption the walker
isn't interested in List nodes per se).  On non-list fields it must of
course call the walker.  Possibly that hack isn't worth the risk of more
such bugs, but I'll leave it be for now.  Per bug report from James Robinson.

Revision 1.222: download - view: text, markup, annotated - select for diffs
Wed Oct 4 00:29:55 2006 UTC (18 years, 11 months ago) by momjian
Branches: MAIN
CVS tags: REL8_2_BETA2
Diff to: previous 1.221: preferred, colored
Changes since revision 1.221: +28 -27 lines
pgindent run for 8.2.

Revision 1.221: download - view: text, markup, annotated - select for diffs
Thu Sep 28 20:51:41 2006 UTC (18 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.220: preferred, colored
Changes since revision 1.220: +80 -1 lines
Fix IS NULL and IS NOT NULL tests on row-valued expressions to conform to
the SQL spec, viz IS NULL is true if all the row's fields are null, IS NOT
NULL is true if all the row's fields are not null.  The former coding got
this right for a limited number of cases with IS NULL (ie, those where it
could disassemble a ROW constructor at parse time), but was entirely wrong
for IS NOT NULL.  Per report from Teodor.

I desisted from changing the behavior for arrays, since on closer inspection
it's not clear that there's any support for that in the SQL spec.  This
probably needs more consideration.

Revision 1.220: download - view: text, markup, annotated - select for diffs
Wed Sep 6 20:40:47 2006 UTC (19 years ago) by tgl
Branches: MAIN
CVS tags: REL8_2_BETA1
Diff to: previous 1.219: preferred, colored
Changes since revision 1.219: +59 -21 lines
Change processing of extended-Query mode so that an unnamed statement
that has parameters is always planned afresh for each Bind command,
treating the parameter values as constants in the planner.  This removes
the performance penalty formerly often paid for using out-of-line
parameters --- with this definition, the planner can do constant folding,
LIKE optimization, etc.  After a suggestion by Andrew@supernews.

Revision 1.219: download - view: text, markup, annotated - select for diffs
Sat Aug 12 20:05:55 2006 UTC (19 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.218: preferred, colored
Changes since revision 1.218: +1 -2 lines
Tweak SPI_cursor_open to allow INSERT/UPDATE/DELETE RETURNING; this was
merely a matter of fixing the error check, since the underlying Portal
infrastructure already handles it.  This in turn allows these statements
to be used in some existing plpgsql and plperl contexts, such as a
plpgsql FOR loop.  Also, do some marginal code cleanup in places that
were being sloppy about distinguishing SELECT from SELECT INTO.

Revision 1.218: download - view: text, markup, annotated - select for diffs
Sat Aug 12 02:52:05 2006 UTC (19 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.217: preferred, colored
Changes since revision 1.217: +4 -1 lines
Add INSERT/UPDATE/DELETE RETURNING, with basic docs and regression tests.
plpgsql support to come later.  Along the way, convert execMain's
SELECT INTO support into a DestReceiver, in order to eliminate some ugly
special cases.

Jonah Harris and Tom Lane

Revision 1.217: download - view: text, markup, annotated - select for diffs
Fri Aug 4 14:09:51 2006 UTC (19 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.216: preferred, colored
Changes since revision 1.216: +53 -1 lines
Teach eval_const_expressions to simplify BooleanTest nodes that have
constant input.  Seems worth doing because rule rewriter inserts
IS NOT TRUE tests into WHERE clauses.

Revision 1.216: download - view: text, markup, annotated - select for diffs
Wed Aug 2 01:59:46 2006 UTC (19 years, 1 month ago) by joe
Branches: MAIN
Diff to: previous 1.215: preferred, colored
Changes since revision 1.215: +8 -1 lines
Add support for multi-row VALUES clauses as part of INSERT statements
(e.g. "INSERT ... VALUES (...), (...), ...") and elsewhere as allowed
by the spec. (e.g. similar to a FROM clause subselect). initdb required.
Joe Conway and Tom Lane.

Revision 1.215: download - view: text, markup, annotated - select for diffs
Thu Jul 27 19:52:05 2006 UTC (19 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.214: preferred, colored
Changes since revision 1.214: +38 -20 lines
Aggregate functions now support multiple input arguments.  I also took
the opportunity to treat COUNT(*) as a zero-argument aggregate instead
of the old hack that equated it to COUNT(1); this is materially cleaner
(no more weird ANYOID cases) and ought to be at least a tiny bit faster.
Original patch by Sergey Koposov; review, documentation, simple regression
tests, pg_dump and psql support by moi.

Revision 1.214: download - view: text, markup, annotated - select for diffs
Fri Jul 14 14:52:21 2006 UTC (19 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.213: preferred, colored
Changes since revision 1.213: +1 -2 lines
Remove 576 references of include files that were not needed.

Revision 1.213: download - view: text, markup, annotated - select for diffs
Sat Jul 1 18:38:33 2006 UTC (19 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.212: preferred, colored
Changes since revision 1.212: +7 -36 lines
Revise the planner's handling of "pseudoconstant" WHERE clauses, that is
clauses containing no variables and no volatile functions.  Such a clause
can be used as a one-time qual in a gating Result plan node, to suppress
plan execution entirely when it is false.  Even when the clause is true,
putting it in a gating node wins by avoiding repeated evaluation of the
clause.  In previous PG releases, query_planner() would do this for
pseudoconstant clauses appearing at the top level of the jointree, but
there was no ability to generate a gating Result deeper in the plan tree.
To fix it, get rid of the special case in query_planner(), and instead
process pseudoconstant clauses through the normal RestrictInfo qual
distribution mechanism.  When a pseudoconstant clause is found attached to
a path node in create_plan(), pull it out and generate a gating Result at
that point.  This requires special-casing pseudoconstants in selectivity
estimation and cost_qual_eval, but on the whole it's pretty clean.
It probably even makes the planner a bit faster than before for the normal
case of no pseudoconstants, since removing pull_constant_clauses saves one
useless traversal of the qual tree.  Per gripe from Phil Frost.

Revision 1.212: download - view: text, markup, annotated - select for diffs
Fri Jun 16 18:42:22 2006 UTC (19 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.211: preferred, colored
Changes since revision 1.211: +8 -1 lines
Fix problems with cached tuple descriptors disappearing while still in use
by creating a reference-count mechanism, similar to what we did a long time
ago for catcache entries.  The back branches have an ugly solution involving
lots of extra copies, but this way is more efficient.  Reference counting is
only applied to tupdescs that are actually in caches --- there seems no need
to use it for tupdescs that are generated in the executor, since they'll go
away during plan shutdown by virtue of being in the per-query memory context.
Neil Conway and Tom Lane

Revision 1.211: download - view: text, markup, annotated - select for diffs
Sat Apr 22 01:25:59 2006 UTC (19 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.210: preferred, colored
Changes since revision 1.210: +28 -29 lines
Simplify ParamListInfo data structure to support only numbered parameters,
not named ones, and replace linear searches of the list with array indexing.
The named-parameter support has been dead code for many years anyway,
and recent profiling suggests that the searching was costing a noticeable
amount of performance for complex queries.

Revision 1.210: download - view: text, markup, annotated - select for diffs
Tue Mar 14 22:48:19 2006 UTC (19 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.209: preferred, colored
Changes since revision 1.209: +2 -2 lines
Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages.
This is per my earlier proposal.  This commit includes all the basic
infrastructure, but locations are only tracked and reported for errors
involving column references, function calls, and operators.  More could
be done later but this seems like a good set to start with.  I've also
moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
which should make it available to more people --- even within psql this
is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.

Revision 1.209: download - view: text, markup, annotated - select for diffs
Sun Mar 5 15:58:31 2006 UTC (19 years, 6 months ago) by momjian
Branches: MAIN
Diff to: previous 1.208: preferred, colored
Changes since revision 1.208: +2 -2 lines
Update copyright for 2006.  Update scripts.

Revision 1.208: download - view: text, markup, annotated - select for diffs
Mon Feb 6 22:21:12 2006 UTC (19 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.207: preferred, colored
Changes since revision 1.207: +59 -5 lines
Improve the tests to see if ScalarArrayOpExpr is strict.  Original coding
would basically punt in all cases for 'foo <> ALL (array)', which resulted
in a performance regression for NOT IN compared to what we were doing in
8.1 and before.  Per report from Pavel Stehule.

Revision 1.207: download - view: text, markup, annotated - select for diffs
Tue Jan 31 21:39:24 2006 UTC (19 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.206: preferred, colored
Changes since revision 1.206: +20 -1 lines
Restructure planner's handling of inheritance.  Rather than processing
inheritance trees on-the-fly, which pretty well constrained us to considering
only one way of planning inheritance, expand inheritance sets during the
planner prep phase, and build a side data structure that can be consulted
later to find which RTEs are members of which inheritance sets.  As proof of
concept, use the data structure to plan joins against inheritance sets more
efficiently: we can now use indexes on the set members in inner-indexscan
joins.  (The generated plans could be improved further, but it'll take some
executor changes.)  This data structure will also support handling UNION ALL
subqueries in the same way as inheritance sets, but that aspect of it isn't
finished yet.

Revision 1.206: download - view: text, markup, annotated - select for diffs
Wed Jan 25 20:29:23 2006 UTC (19 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.205: preferred, colored
Changes since revision 1.205: +70 -3 lines
Allow row comparisons to be used as indexscan qualifications.
This completes the project to upgrade our handling of row comparisons.

Revision 1.205: download - view: text, markup, annotated - select for diffs
Wed Dec 28 01:30:00 2005 UTC (19 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.204: preferred, colored
Changes since revision 1.204: +45 -19 lines
Implement SQL-compliant treatment of row comparisons for < <= > >= cases
(previously we only did = and <> correctly).  Also, allow row comparisons
with any operators that are in btree opclasses, not only those with these
specific names.  This gets rid of a whole lot of indefensible assumptions
about the behavior of particular operators based on their names ... though
it's still true that IN and NOT IN expand to "= ANY".  The patch adds a
RowCompareExpr expression node type, and makes some changes in the
representation of ANY/ALL/ROWCOMPARE SubLinks so that they can share code
with RowCompareExpr.

I have not yet done anything about making RowCompareExpr an indexable
operator, but will look at that soon.

initdb forced due to changes in stored rules.

Revision 1.204: download - view: text, markup, annotated - select for diffs
Tue Dec 20 02:30:36 2005 UTC (19 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.203: preferred, colored
Changes since revision 1.203: +131 -3 lines
Teach planner how to rearrange join order for some classes of OUTER JOIN.
Per my recent proposal.  I ended up basing the implementation on the
existing mechanism for enforcing valid join orders of IN joins --- the
rules for valid outer-join orders are somewhat similar.

Revision 1.201.2.1: download - view: text, markup, annotated - select for diffs
Tue Nov 22 18:23:12 2005 UTC (19 years, 9 months ago) by momjian
Branches: REL8_1_STABLE
CVS tags: REL8_1_6, REL8_1_5, REL8_1_4, REL8_1_3, REL8_1_2, REL8_1_1
Diff to: previous 1.201: preferred, colored
Changes since revision 1.201: +10 -10 lines
Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.

Revision 1.203: download - view: text, markup, annotated - select for diffs
Tue Nov 22 18:17:14 2005 UTC (19 years, 9 months ago) by momjian
Branches: MAIN
Diff to: previous 1.202: preferred, colored
Changes since revision 1.202: +10 -10 lines
Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.

Revision 1.202: download - view: text, markup, annotated - select for diffs
Thu Nov 17 22:14:52 2005 UTC (19 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.201: preferred, colored
Changes since revision 1.201: +4 -3 lines
Make SQL arrays support null elements.  This commit fixes the core array
functionality, but I still need to make another pass looking at places
that incidentally use arrays (such as ACL manipulation) to make sure they
are null-safe.  Contrib needs work too.
I have not changed the behaviors that are still under discussion about
array comparison and what to do with lower bounds.

Revision 1.201: download - view: text, markup, annotated - select for diffs
Sat Oct 15 02:49:21 2005 UTC (19 years, 10 months ago) by momjian
Branches: MAIN
CVS tags: REL8_1_0RC1, REL8_1_0BETA4, REL8_1_0
Branch point for: REL8_1_STABLE
Diff to: previous 1.200: preferred, colored
Changes since revision 1.200: +179 -188 lines
Standard pgindent run for 8.1.

Revision 1.200: download - view: text, markup, annotated - select for diffs
Sun Jul 3 21:14:17 2005 UTC (20 years, 2 months ago) by tgl
Branches: MAIN
CVS tags: REL8_1_0BETA3, REL8_1_0BETA2, REL8_1_0BETA1
Diff to: previous 1.199: preferred, colored
Changes since revision 1.199: +12 -8 lines
Don't try to constant-fold functions returning RECORD.  We were never
able to do this before, but I had tried to make an exception for functions
with OUT parameters.  Michael Fuhr found one problem with it already, and
I found another, which was it didn't work for strict functions with a
NULL input.  While both of these could be worked around, the probability
that there are more gotchas seems high; I think prudence dictates just
reverting to the former behavior for now.  Accordingly, remove the kluge
added to get_expr_result_type() for Michael's case.

Revision 1.199: download - view: text, markup, annotated - select for diffs
Sun Jun 26 22:05:38 2005 UTC (20 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.198: preferred, colored
Changes since revision 1.198: +18 -2 lines
Add Oracle-compatible GREATEST and LEAST functions.  Pavel Stehule

Revision 1.198: download - view: text, markup, annotated - select for diffs
Sun Jun 5 22:32:56 2005 UTC (20 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.197: preferred, colored
Changes since revision 1.197: +1 -4 lines
Remove planner's private fields from Query struct, and put them into
a new PlannerInfo struct, which is passed around instead of the bare
Query in all the planning code.  This commit is essentially just a
code-beautification exercise, but it does open the door to making
larger changes to the planner data structures without having to muck
with the widely-known Query struct.

Revision 1.197: download - view: text, markup, annotated - select for diffs
Sun May 22 22:30:20 2005 UTC (20 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.196: preferred, colored
Changes since revision 1.196: +41 -11 lines
Teach the planner to remove SubqueryScan nodes from the plan if they
aren't doing anything useful (ie, neither selection nor projection).
Also, extend to SubqueryScan the hacks already in place to avoid
unnecessary ExecProject calls when the result would just be the same
tuple the subquery already delivered.  This saves some overhead in
UNION and other set operations, as well as avoiding overhead for
unflatten-able subqueries.  Per example from Sokolov Yura.

Revision 1.196: download - view: text, markup, annotated - select for diffs
Sat Apr 23 04:42:53 2005 UTC (20 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.195: preferred, colored
Changes since revision 1.195: +156 -65 lines
Turns out that my recent elimination of the 'redundant' flatten_andors()
code in prepqual.c had a small drawback: the flatten_andors code was
able to cope with deeply nested AND/OR structures (like 10000 ORs in
a row), whereas eval_const_expressions tends to recurse until it
overruns the stack.  Revise eval_const_expressions so that it doesn't
choke on deeply nested ANDs or ORs.

Revision 1.109.2.1: download - view: text, markup, annotated - select for diffs
Thu Apr 14 21:44:46 2005 UTC (20 years, 5 months ago) by tgl
Branches: REL7_3_STABLE
CVS tags: REL7_3_20, REL7_3_19, REL7_3_18, REL7_3_17, REL7_3_16, REL7_3_15, REL7_3_14, REL7_3_13, REL7_3_12, REL7_3_11, REL7_3_10
Diff to: previous 1.109: preferred, colored
Changes since revision 1.109: +8 -1 lines
Don't try to constant-fold functions returning RECORD, since the optimizer
isn't presently set up to pass them an expected tuple descriptor.  Bug has
been there since 7.3 but was just recently reported by Thomas Hallgren.

Revision 1.154.2.4: download - view: text, markup, annotated - select for diffs
Thu Apr 14 21:44:35 2005 UTC (20 years, 5 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_9, REL7_4_8, REL7_4_15, REL7_4_14, REL7_4_13, REL7_4_12, REL7_4_11, REL7_4_10
Diff to: previous 1.154.2.3: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.3: +8 -1 lines
Don't try to constant-fold functions returning RECORD, since the optimizer
isn't presently set up to pass them an expected tuple descriptor.  Bug has
been there since 7.3 but was just recently reported by Thomas Hallgren.

Revision 1.186.4.4: download - view: text, markup, annotated - select for diffs
Thu Apr 14 21:44:22 2005 UTC (20 years, 5 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_9, REL8_0_8, REL8_0_7, REL8_0_6, REL8_0_5, REL8_0_4, REL8_0_3, REL8_0_10
Diff to: previous 1.186.4.3: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.3: +8 -1 lines
Don't try to constant-fold functions returning RECORD, since the optimizer
isn't presently set up to pass them an expected tuple descriptor.  Bug has
been there since 7.3 but was just recently reported by Thomas Hallgren.

Revision 1.195: download - view: text, markup, annotated - select for diffs
Thu Apr 14 21:44:09 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.194: preferred, colored
Changes since revision 1.194: +12 -1 lines
Don't try to constant-fold functions returning RECORD, since the optimizer
isn't presently set up to pass them an expected tuple descriptor.  Bug has
been there since 7.3 but was just recently reported by Thomas Hallgren.

Revision 1.154.2.3: download - view: text, markup, annotated - select for diffs
Sun Apr 10 20:58:03 2005 UTC (20 years, 5 months ago) by tgl
Branches: REL7_4_STABLE
Diff to: previous 1.154.2.2: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.2: +5 -1 lines
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs.  Fixes crash
reported by Michael Williamson.

Revision 1.186.4.3: download - view: text, markup, annotated - select for diffs
Sun Apr 10 20:57:45 2005 UTC (20 years, 5 months ago) by tgl
Branches: REL8_0_STABLE
Diff to: previous 1.186.4.2: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.2: +5 -1 lines
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs.  Fixes crash
reported by Michael Williamson.

Revision 1.194: download - view: text, markup, annotated - select for diffs
Sun Apr 10 20:57:32 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.193: preferred, colored
Changes since revision 1.193: +5 -1 lines
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs.  Fixes crash
reported by Michael Williamson.

Revision 1.193: download - view: text, markup, annotated - select for diffs
Wed Apr 6 16:34:06 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.192: preferred, colored
Changes since revision 1.192: +5 -9 lines
Merge Resdom nodes into TargetEntry nodes to simplify code and save a
few palloc's.  I also chose to eliminate the restype and restypmod fields
entirely, since they are redundant with information stored in the node's
contained expression; re-examining the expression at need seems simpler
and more reliable than trying to keep restype/restypmod up to date.

initdb forced due to change in contents of stored rules.

Revision 1.192: download - view: text, markup, annotated - select for diffs
Thu Mar 31 22:46:09 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.191: preferred, colored
Changes since revision 1.191: +2 -3 lines
First phase of OUT-parameters project.  We can now define and use SQL
functions with OUT parameters.  The various PLs still need work, as does
pg_dump.  Rudimentary docs and regression tests included.

Revision 1.191: download - view: text, markup, annotated - select for diffs
Tue Mar 29 00:17:02 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.190: preferred, colored
Changes since revision 1.190: +23 -20 lines
Convert oidvector and int2vector into variable-length arrays.  This
change saves a great deal of space in pg_proc and its primary index,
and it eliminates the former requirement that INDEX_MAX_KEYS and
FUNC_MAX_ARGS have the same value.  INDEX_MAX_KEYS is still embedded
in the on-disk representation (because it affects index tuple header
size), but FUNC_MAX_ARGS is not.  I believe it would now be possible
to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet.
There are still a lot of vestigial references to FUNC_MAX_ARGS, which
I will clean up in a separate pass.  However, getting rid of it
altogether would require changing the FunctionCallInfoData struct,
and I'm not sure I want to buy into that.

Revision 1.190: download - view: text, markup, annotated - select for diffs
Mon Mar 28 00:58:24 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.189: preferred, colored
Changes since revision 1.189: +6 -3 lines
Rethink the order of expression preprocessing: eval_const_expressions
really ought to run before canonicalize_qual, because it can now produce
forms that canonicalize_qual knows how to improve (eg, NOT clauses).
Also, because eval_const_expressions already knows about flattening
nested ANDs and ORs into N-argument form, the initial flatten_andors
pass in canonicalize_qual is now completely redundant and can be
removed.  This doesn't save a whole lot of code, but the time and
palloc traffic eliminated is a useful gain on large expression trees.

Revision 1.189: download - view: text, markup, annotated - select for diffs
Sun Mar 27 19:18:02 2005 UTC (20 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.188: preferred, colored
Changes since revision 1.188: +57 -1 lines
Teach const-expression simplification to simplify boolean equality cases,
that is 'x = true' becomes 'x' and 'x = false' becomes 'NOT x'.  This isn't
all that amazingly useful in itself, but it ensures that we will recognize
the different forms as being logically equivalent when checking partial
index predicates.  Per example from Patrick Clery.

Revision 1.186.4.2: download - view: text, markup, annotated - select for diffs
Wed Feb 2 21:49:43 2005 UTC (20 years, 7 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_2
Diff to: previous 1.186.4.1: preferred, colored; branchpoint 1.186: preferred, colored
Changes since revision 1.186.4.1: +82 -40 lines
Adjust constant-folding of CASE expressions so that the simple comparison
form of CASE (eg, CASE 0 WHEN 1 THEN ...) can be constant-folded as it
was in 7.4.  Also, avoid constant-folding result expressions that are
certainly unreachable --- the former coding was a bit cavalier about this
and could generate unexpected results for all-constant CASE expressions.
Add regression test cases.  Per report from Vlad Marchenko.

Revision 1.188: download - view: text, markup, annotated - select for diffs
Wed Feb 2 21:49:07 2005 UTC (20 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.187: preferred, colored
Changes since revision 1.187: +82 -40 lines
Adjust constant-folding of CASE expressions so that the simple comparison
form of CASE (eg, CASE 0 WHEN 1 THEN ...) can be constant-folded as it
was in 7.4.  Also, avoid constant-folding result expressions that are
certainly unreachable --- the former coding was a bit cavalier about this
and could generate unexpected results for all-constant CASE expressions.
Add regression test cases.  Per report from Vlad Marchenko.

Revision 1.186.4.1: download - view: text, markup, annotated - select for diffs
Fri Jan 28 19:36:14 2005 UTC (20 years, 7 months ago) by tgl
Branches: REL8_0_STABLE
CVS tags: REL8_0_1
Diff to: previous 1.186: preferred, colored
Changes since revision 1.186: +85 -47 lines
Improve planner's estimation of the space needed for HashAgg plans:
look at the actual aggregate transition datatypes and the actual overhead
needed by nodeAgg.c, instead of using pessimistic round numbers.
Per a discussion with Michael Tiemann.

Revision 1.187: download - view: text, markup, annotated - select for diffs
Fri Jan 28 19:34:07 2005 UTC (20 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.186: preferred, colored
Changes since revision 1.186: +85 -47 lines
Improve planner's estimation of the space needed for HashAgg plans:
look at the actual aggregate transition datatypes and the actual overhead
needed by nodeAgg.c, instead of using pessimistic round numbers.
Per a discussion with Michael Tiemann.

Revision 1.186: download - view: text, markup, annotated - select for diffs
Fri Dec 31 22:00:23 2004 UTC (20 years, 8 months ago) by pgsql
Branches: MAIN
CVS tags: REL8_0_0RC5, REL8_0_0RC4, REL8_0_0RC3, REL8_0_0
Branch point for: REL8_0_STABLE
Diff to: previous 1.185: preferred, colored
Changes since revision 1.185: +2 -2 lines

Tag appropriate files for rc3

Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...

Revision 1.185: download - view: text, markup, annotated - select for diffs
Sat Dec 11 23:26:39 2004 UTC (20 years, 9 months ago) by tgl
Branches: MAIN
CVS tags: REL8_0_0RC2
Diff to: previous 1.184: preferred, colored
Changes since revision 1.184: +25 -4 lines
Instead of supposing (wrongly, in the general case) that the rowtype
of an inheritance child table is binary-compatible with the rowtype of
its parent, invent an expression node type that does the conversion
correctly.  Fixes the new bug exhibited by Kris Shannon as well as a
lot of old bugs that would only show up when using multiple inheritance
or after altering the parent table.

Revision 1.184: download - view: text, markup, annotated - select for diffs
Tue Nov 9 21:42:53 2004 UTC (20 years, 10 months ago) by tgl
Branches: MAIN
CVS tags: REL8_0_0RC1, REL8_0_0BETA5
Diff to: previous 1.183: preferred, colored
Changes since revision 1.183: +33 -16 lines
Allow planner to fold "stable" functions to constants when forming
selectivity estimates, per recent discussion.

Revision 1.183: download - view: text, markup, annotated - select for diffs
Fri Oct 22 17:20:05 2004 UTC (20 years, 10 months ago) by tgl
Branches: MAIN
CVS tags: REL8_0_0BETA4
Diff to: previous 1.182: preferred, colored
Changes since revision 1.182: +36 -1 lines
In ALTER COLUMN TYPE, strip any implicit coercion operations appearing
at the top level of the column's old default expression before adding
an implicit coercion to the new column type.  This seems to satisfy the
principle of least surprise, as per discussion of bug #1290.

Revision 1.182: download - view: text, markup, annotated - select for diffs
Thu Oct 7 18:38:49 2004 UTC (20 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.181: preferred, colored
Changes since revision 1.181: +3 -2 lines
Fix problems with SQL functions returning rowtypes that have dropped
columns.  The returned tuple needs to have appropriate NULL columns
inserted so that it actually matches the declared rowtype.  It seemed
convenient to use a JunkFilter for this, so I made some cleanups and
simplifications in the JunkFilter code to allow it to support this
additional functionality.  (That in turn exposed a latent bug in
nodeAppend.c, which is that it was returning a tuple slot whose
descriptor didn't match its data.)  Also, move check_sql_fn_retval
out of pg_proc.c and into functions.c, where it seems to more naturally
belong.

Revision 1.181: download - view: text, markup, annotated - select for diffs
Sat Oct 2 22:39:48 2004 UTC (20 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.180: preferred, colored
Changes since revision 1.180: +11 -1 lines
Clean up handling of inherited-table update queries, per bug report
from Sebastian Böck.  The fix involves being more consistent about
when rangetable entries are copied or modified.  Someday we really
need to fix this stuff to not scribble on its input data structures
in the first place...

Revision 1.180: download - view: text, markup, annotated - select for diffs
Sun Aug 29 05:06:44 2004 UTC (21 years ago) by momjian
Branches: MAIN
CVS tags: REL8_0_0BETA3, REL8_0_0BETA2
Diff to: previous 1.179: preferred, colored
Changes since revision 1.179: +37 -41 lines
Pgindent run for 8.0.

Revision 1.179: download - view: text, markup, annotated - select for diffs
Sun Aug 29 04:12:34 2004 UTC (21 years ago) by momjian
Branches: MAIN
Diff to: previous 1.178: preferred, colored
Changes since revision 1.178: +2 -2 lines
Update copyright to 2004.

Revision 1.178: download - view: text, markup, annotated - select for diffs
Tue Aug 17 18:47:08 2004 UTC (21 years ago) by tgl
Branches: MAIN
Diff to: previous 1.177: preferred, colored
Changes since revision 1.177: +54 -7 lines
Standardize on the assumption that the arguments of a RowExpr correspond
to the physical layout of the rowtype, ie, there are dummy arguments
corresponding to any dropped columns in the rowtype.  We formerly had a
couple of places that did it this way and several others that did not.
Fixes Gaetano Mendola's "cache lookup failed for type 0" bug of 5-Aug.

Revision 1.177: download - view: text, markup, annotated - select for diffs
Mon Aug 2 01:30:43 2004 UTC (21 years, 1 month ago) by tgl
Branches: MAIN
CVS tags: REL8_0_0BETA1
Diff to: previous 1.176: preferred, colored
Changes since revision 1.176: +12 -30 lines
Allow DECLARE CURSOR to take parameters from the portal in which it is
executed.  Previously, the DECLARE would succeed but subsequent FETCHes
would fail since the parameter values supplied to DECLARE were not
propagated to the portal created for the cursor.
In support of this, add type Oids to ParamListInfo entries, which seems
like a good idea anyway since code that extracts a value can double-check
that it got the type of value it was expecting.
Oliver Jowett, with minor editorialization by Tom Lane.

Revision 1.176: download - view: text, markup, annotated - select for diffs
Fri Jun 11 01:08:54 2004 UTC (21 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.175: preferred, colored
Changes since revision 1.175: +128 -32 lines
When using extended-query protocol, postpone planning of unnamed statements
until Bind is received, so that actual parameter values are visible to the
planner.  Make use of the parameter values for estimation purposes (but
don't fold them into the actual plan).  This buys back most of the
potential loss of plan quality that ensues from using out-of-line
parameters instead of putting literal values right into the query text.

This patch creates a notion of constant-folding expressions 'for
estimation purposes only', in which case we can be more aggressive than
the normal eval_const_expressions() logic can be.  Right now the only
difference in behavior is inserting bound values for Params, but it will
be interesting to look at other possibilities.  One that we've seen
come up repeatedly is reducing now() and related functions to current
values, so that queries like ... WHERE timestampcol > now() - '1 day'
have some chance of being planned effectively.

Oliver Jowett, with some kibitzing from Tom Lane.

Revision 1.175: download - view: text, markup, annotated - select for diffs
Wed Jun 9 19:08:16 2004 UTC (21 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.174: preferred, colored
Changes since revision 1.174: +32 -1 lines
Support assignment to subfields of composite columns in UPDATE and INSERT.
As a side effect, cause subscripts in INSERT targetlists to do something
more or less sensible; previously we evaluated such subscripts and then
effectively ignored them.  Another side effect is that UPDATE-ing an
element or slice of an array value that is NULL now produces a non-null
result, namely an array containing just the assigned-to positions.

Revision 1.174: download - view: text, markup, annotated - select for diffs
Sat Jun 5 19:48:08 2004 UTC (21 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.173: preferred, colored
Changes since revision 1.173: +2 -2 lines
Tweak palloc/repalloc to allow zero bytes to be requested, as per recent
proposal.  Eliminate several dozen now-unnecessary hacks to avoid palloc(0).
(It's likely there are more that I didn't find.)

Revision 1.173: download - view: text, markup, annotated - select for diffs
Tue Jun 1 04:47:45 2004 UTC (21 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.172: preferred, colored
Changes since revision 1.172: +33 -35 lines
Just about there on de-FastList-ification.

Revision 1.172: download - view: text, markup, annotated - select for diffs
Sun May 30 23:40:30 2004 UTC (21 years, 3 months ago) by neilc
Branches: MAIN
Diff to: previous 1.171: preferred, colored
Changes since revision 1.171: +30 -30 lines
Use the new List API function names throughout the backend, and disable the
list compatibility API by default. While doing this, I decided to keep
the llast() macro around and introduce llast_int() and llast_oid() variants.

Revision 1.171: download - view: text, markup, annotated - select for diffs
Wed May 26 04:41:27 2004 UTC (21 years, 3 months ago) by neilc
Branches: MAIN
Diff to: previous 1.170: preferred, colored
Changes since revision 1.170: +39 -39 lines
Reimplement the linked list data structure used throughout the backend.

In the past, we used a 'Lispy' linked list implementation: a "list" was
merely a pointer to the head node of the list. The problem with that
design is that it makes lappend() and length() linear time. This patch
fixes that problem (and others) by maintaining a count of the list
length and a pointer to the tail node along with each head node pointer.
A "list" is now a pointer to a structure containing some meta-data
about the list; the head and tail pointers in that structure refer
to ListCell structures that maintain the actual linked list of nodes.

The function names of the list API have also been changed to, I hope,
be more logically consistent. By default, the old function names are
still available; they will be disabled-by-default once the rest of
the tree has been updated to use the new API names.

Revision 1.170: download - view: text, markup, annotated - select for diffs
Mon May 10 22:44:45 2004 UTC (21 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.169: preferred, colored
Changes since revision 1.169: +58 -51 lines
Promote row expressions to full-fledged citizens of the expression syntax,
rather than allowing them only in a few special cases as before.  In
particular you can now pass a ROW() construct to a function that accepts
a rowtype parameter.  Internal generation of RowExprs fixes a number of
corner cases that used to not work very well, such as referencing the
whole-row result of a JOIN or subquery.  This represents a further step in
the work I started a month or so back to make rowtype values into
first-class citizens.

Revision 1.169: download - view: text, markup, annotated - select for diffs
Fri Apr 2 23:14:08 2004 UTC (21 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.168: preferred, colored
Changes since revision 1.168: +3 -3 lines
check_sql_fn_retval has always thought that we supported doing
'SELECT foo()' in a SQL function returning a rowtype, to simply pass
back the results of another function returning the same rowtype.
However, that hasn't actually worked in many years.  Now it works again.

Revision 1.168: download - view: text, markup, annotated - select for diffs
Fri Apr 2 19:06:57 2004 UTC (21 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.167: preferred, colored
Changes since revision 1.167: +1 -21 lines
Get rid of crocky use of RangeVar nodes in parser to represent partially
transformed whole-row variables.  Cleaner to use regular whole-row Vars.

Revision 1.167: download - view: text, markup, annotated - select for diffs
Wed Mar 24 22:40:28 2004 UTC (21 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.166: preferred, colored
Changes since revision 1.166: +9 -1 lines
Replace max_expr_depth parameter with a max_stack_depth parameter that
is measured in kilobytes and checked against actual physical execution
stack depth, as per my proposal of 30-Dec.  This gives us a fairly
bulletproof defense against crashing due to runaway recursive functions.

Revision 1.166: download - view: text, markup, annotated - select for diffs
Sun Mar 21 22:29:11 2004 UTC (21 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.165: preferred, colored
Changes since revision 1.165: +23 -3 lines
Revise syntax-error reporting behavior to give pleasant results for
errors in internally-generated queries, such as those submitted by
plpgsql functions.  Per recent discussions with Fabien Coelho.

Revision 1.165: download - view: text, markup, annotated - select for diffs
Wed Mar 17 20:48:42 2004 UTC (21 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.164: preferred, colored
Changes since revision 1.164: +21 -7 lines
Reimplement CASE val WHEN compval1 THEN ... WHEN compval2 THEN ... END
so that the 'val' is computed only once, per recent discussion.  The
speedup is not much when 'val' is just a simple variable, but could be
significant for larger expressions.  More importantly this avoids issues
with multiple evaluations of a volatile 'val', and it allows the CASE
expression to be reverse-listed in its original form by ruleutils.c.

Revision 1.164: download - view: text, markup, annotated - select for diffs
Sun Mar 14 23:41:27 2004 UTC (21 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.163: preferred, colored
Changes since revision 1.163: +36 -2 lines
Tweak planner so that index expressions and predicates are matched to
queries without regard to whether coercions are stated explicitly or
implicitly.  Per suggestion from Stephan Szabo.

Revision 1.154.2.2: download - view: text, markup, annotated - select for diffs
Wed Jan 28 00:05:25 2004 UTC (21 years, 7 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_7, REL7_4_6, REL7_4_5, REL7_4_4, REL7_4_3, REL7_4_2
Diff to: previous 1.154.2.1: preferred, colored; branchpoint 1.154: preferred, colored
Changes since revision 1.154.2.1: +11 -1 lines
simplify_function() mustn't try to evaluate functions that return
composite types, because TupleTableSlots aren't Datums and can't be
stored in Const nodes.  We can remove this restriction if we ever
adopt a cleaner runtime representation for whole-tuple results, but
at the moment it's broken.  Per example from Thomas Hallgren.

Revision 1.163: download - view: text, markup, annotated - select for diffs
Wed Jan 28 00:05:04 2004 UTC (21 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.162: preferred, colored
Changes since revision 1.162: +11 -1 lines
simplify_function() mustn't try to evaluate functions that return
composite types, because TupleTableSlots aren't Datums and can't be
stored in Const nodes.  We can remove this restriction if we ever
adopt a cleaner runtime representation for whole-tuple results, but
at the moment it's broken.  Per example from Thomas Hallgren.

Revision 1.162: download - view: text, markup, annotated - select for diffs
Mon Jan 12 20:48:15 2004 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.161: preferred, colored
Changes since revision 1.161: +154 -84 lines
Preserve AND/OR flatness during eval_const_expressions().  This seems a
useful improvement in any case, and it keeps the new logic for restrictinfo
structures happy.  Per report from Kris Jurka.

Revision 1.161: download - view: text, markup, annotated - select for diffs
Sat Jan 10 18:13:53 2004 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.160: preferred, colored
Changes since revision 1.160: +21 -19 lines
Improve has_nullable_targetlist() to allow strict functions of simple
variables, not just simple variables.  This was foreseen in the original
coding of this routine, but not implemented until now.  Responds to
performance gripe from Laurent Perez.

Revision 1.160: download - view: text, markup, annotated - select for diffs
Mon Jan 5 18:04:39 2004 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.159: preferred, colored
Changes since revision 1.159: +16 -1 lines
Improve UniquePath logic to detect the case where the input is already
known unique (eg, it is a SELECT DISTINCT ... subquery), and not do a
redundant unique-ification step.

Revision 1.159: download - view: text, markup, annotated - select for diffs
Sun Jan 4 03:51:52 2004 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.158: preferred, colored
Changes since revision 1.158: +1 -46 lines
Merge restrictlist_selectivity into clauselist_selectivity by
teaching the latter to accept either RestrictInfo nodes or bare
clause expressions; and cache the selectivity result in the RestrictInfo
node when possible.  This extends the caching behavior of approx_selectivity
to many more contexts, and should reduce duplicate selectivity
calculations.

Revision 1.158: download - view: text, markup, annotated - select for diffs
Tue Dec 30 23:53:15 2003 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.157: preferred, colored
Changes since revision 1.157: +15 -1 lines
Adjust the definition of RestrictInfo's left_relids and right_relids
fields: now they are valid whenever the clause is a binary opclause,
not only when it is a potential join clause (there is a new boolean
field canjoin to signal the latter condition).  This lets us avoid
recomputing the relid sets over and over while examining indexes.
Still more work to do to make this as useful as it could be, because
there are places that could use the info but don't have access to the
RestrictInfo node.

Revision 1.157: download - view: text, markup, annotated - select for diffs
Sun Dec 28 21:57:37 2003 UTC (21 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.156: preferred, colored
Changes since revision 1.156: +3 -3 lines
Clean up the usage of canonicalize_qual(): in particular, be consistent
about whether it is applied before or after eval_const_expressions().
I believe there were some corner cases where the system would fail to
recognize that a partial index is applicable because of the previous
inconsistency.  Store normal rather than 'implicit AND' representations
of constraints and index predicates in the catalogs.
initdb forced due to representation change of constraints/predicates.

Revision 1.154.2.1: download - view: text, markup, annotated - select for diffs
Tue Dec 9 01:56:41 2003 UTC (21 years, 9 months ago) by tgl
Branches: REL7_4_STABLE
CVS tags: REL7_4_1
Diff to: previous 1.154: preferred, colored
Changes since revision 1.154: +4 -9 lines
query_tree_mutator should copy RangeTblEntry nodes even when it's not
planning to modify them itself.  Otherwise we end up with shared RTE
substructure, which breaks inheritance_planner because the rte->inh
flag needs to be independent in each copied subquery.  Per bug report
from Chris Piker.

Revision 1.156: download - view: text, markup, annotated - select for diffs
Tue Dec 9 01:56:20 2003 UTC (21 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.155: preferred, colored
Changes since revision 1.155: +4 -9 lines
query_tree_mutator should copy RangeTblEntry nodes even when it's not
planning to modify them itself.  Otherwise we end up with shared RTE
substructure, which breaks inheritance_planner because the rte->inh
flag needs to be independent in each copied subquery.  Per bug report
from Chris Piker.

Revision 1.155: download - view: text, markup, annotated - select for diffs
Sat Nov 29 19:51:51 2003 UTC (21 years, 9 months ago) by pgsql
Branches: MAIN
Diff to: previous 1.154: preferred, colored
Changes since revision 1.154: +1 -1 lines

$Header: -> $PostgreSQL Changes ...

Revision 1.154: download - view: text, markup, annotated - select for diffs
Wed Oct 29 18:10:15 2003 UTC (21 years, 10 months ago) by tgl
Branches: MAIN
CVS tags: REL7_4_RC2, REL7_4_RC1, REL7_4
Branch point for: REL7_4_STABLE
Diff to: previous 1.153: preferred, colored
Changes since revision 1.153: +21 -1 lines
Give a useful error message if a RangeVar is encountered in an expression.
Per example from Ian Barwick, 28-Oct-03.

Revision 1.152.2.1: download - view: text, markup, annotated - select for diffs
Sun Sep 7 04:36:49 2003 UTC (22 years ago) by momjian
Branches: WIN32_DEV
Diff to: previous 1.152: preferred, colored; next MAIN 1.153: preferred, colored
Changes since revision 1.152: +2 -2 lines
Update this branch to match CVS head, includes WIN32 improvements.

Revision 1.153: download - view: text, markup, annotated - select for diffs
Sun Aug 17 23:43:26 2003 UTC (22 years ago) by tgl
Branches: MAIN
CVS tags: REL7_4_BETA5, REL7_4_BETA4, REL7_4_BETA3, REL7_4_BETA2
Diff to: previous 1.152: preferred, colored
Changes since revision 1.152: +2 -2 lines
Fix ARRAY[] construct so that in multidimensional case, elements can
be anything yielding an array of the proper kind, not only sub-ARRAY[]
constructs; do subscript checking at runtime not parse time.  Also,
adjust array_cat to make array || array comply with the SQL99 spec.

Joe Conway

Revision 1.152: download - view: text, markup, annotated - select for diffs
Fri Aug 8 21:41:55 2003 UTC (22 years, 1 month ago) by momjian
Branches: MAIN
Branch point for: WIN32_DEV
Diff to: previous 1.151: preferred, colored
Changes since revision 1.151: +5 -5 lines
Another pgindent run with updated typedefs.

Revision 1.151: download - view: text, markup, annotated - select for diffs
Mon Aug 4 02:40:01 2003 UTC (22 years, 1 month ago) by momjian
Branches: MAIN
CVS tags: REL7_4_BETA1
Diff to: previous 1.150: preferred, colored
Changes since revision 1.150: +2 -2 lines
Update copyrights to 2003.

Revision 1.150: download - view: text, markup, annotated - select for diffs
Mon Aug 4 00:43:20 2003 UTC (22 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.149: preferred, colored
Changes since revision 1.149: +125 -111 lines
pgindent run.

Revision 1.149: download - view: text, markup, annotated - select for diffs
Sun Aug 3 23:46:37 2003 UTC (22 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.148: preferred, colored
Changes since revision 1.148: +28 -6 lines
Tighten inline_function's test for overly complex parameters.  This
should catch most situations where repeated inlining blows up the
expression complexity unreasonably, as in Joe Conway's recent example.

Revision 1.148: download - view: text, markup, annotated - select for diffs
Mon Jul 28 18:33:18 2003 UTC (22 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.147: preferred, colored
Changes since revision 1.147: +27 -1 lines
Add error stack traceback support for SQL-language functions.

Revision 1.147: download - view: text, markup, annotated - select for diffs
Fri Jul 25 00:01:08 2003 UTC (22 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.146: preferred, colored
Changes since revision 1.146: +17 -15 lines
Error message editing in backend/optimizer, backend/rewrite.

Revision 1.146: download - view: text, markup, annotated - select for diffs
Thu Jul 3 19:07:25 2003 UTC (22 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.145: preferred, colored
Changes since revision 1.145: +7 -1 lines
Do honest transformation and preprocessing of LIMIT/OFFSET clauses,
instead of the former kluge whereby gram.y emitted already-transformed
expressions.  This is needed so that Params appearing in these clauses
actually work correctly.  I suppose some might claim that the side effect
of 'SELECT ... LIMIT 2+2' working is a new feature, but I say this is
a bug fix.

Revision 1.145: download - view: text, markup, annotated - select for diffs
Thu Jul 3 16:33:07 2003 UTC (22 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.144: preferred, colored
Changes since revision 1.144: +3 -1 lines
Code review for UPDATE tab SET col = DEFAULT patch ... whack it around
so it has some chance of working in rules ...

Revision 1.144: download - view: text, markup, annotated - select for diffs
Tue Jul 1 19:07:02 2003 UTC (22 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.143: preferred, colored
Changes since revision 1.143: +34 -11 lines
Dept. of second thoughts: supporting inlining of polymorphic SQL functions
takes only a few more lines of code than preventing it, so might as well
support it.

Revision 1.143: download - view: text, markup, annotated - select for diffs
Tue Jul 1 00:04:37 2003 UTC (22 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.142: preferred, colored
Changes since revision 1.142: +11 -2 lines
SQL functions can have arguments and results declared ANYARRAY or
ANYELEMENT.  The effect is to postpone typechecking of the function
body until runtime.  Documentation is still lacking.

Original patch by Joe Conway, modified to postpone type checking
by Tom Lane.

Revision 1.142: download - view: text, markup, annotated - select for diffs
Sun Jun 29 00:33:43 2003 UTC (22 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.141: preferred, colored
Changes since revision 1.141: +44 -2 lines
Support expressions of the form 'scalar op ANY (array)' and
'scalar op ALL (array)', where the operator is applied between the
lefthand scalar and each element of the array.  The operator must
yield boolean; the result of the construct is the OR or AND of the
per-element results, respectively.

Original coding by Joe Conway, after an idea of Peter's.  Rewritten
by Tom to keep the implementation strictly separate from subqueries.

Revision 1.141: download - view: text, markup, annotated - select for diffs
Wed Jun 25 21:30:30 2003 UTC (22 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.140: preferred, colored
Changes since revision 1.140: +0 -22 lines
Back out array mega-patch.

Joe Conway

Revision 1.140: download - view: text, markup, annotated - select for diffs
Tue Jun 24 23:14:43 2003 UTC (22 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.139: preferred, colored
Changes since revision 1.139: +23 -1 lines
Array mega-patch.

Joe Conway

Revision 1.139: download - view: text, markup, annotated - select for diffs
Fri Jun 6 15:04:02 2003 UTC (22 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.138: preferred, colored
Changes since revision 1.138: +24 -1 lines
Implement outer-level aggregates to conform to the SQL spec, with
extensions to support our historical behavior.  An aggregate belongs
to the closest query level of any of the variables in its argument,
or the current query level if there are no variables (e.g., COUNT(*)).
The implementation involves adding an agglevelsup field to Aggref,
and treating outer aggregates like outer variables at planning time.

Revision 1.138: download - view: text, markup, annotated - select for diffs
Wed May 28 22:32:49 2003 UTC (22 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.137: preferred, colored
Changes since revision 1.137: +51 -42 lines
Fix some planner performance problems with large WHERE clauses, by
introducing new 'FastList' list-construction subroutines to use in
hot spots.  This avoids the O(N^2) behavior of repeated lappend's
by keeping a tail pointer, while not changing behavior by reversing
list order as the lcons() method would do.

Revision 1.137: download - view: text, markup, annotated - select for diffs
Wed May 28 16:03:56 2003 UTC (22 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.136: preferred, colored
Changes since revision 1.136: +1 -23 lines
Replace functional-index facility with expressional indexes.  Any column
of an index can now be a computed expression instead of a simple variable.
Restrictions on expressions are the same as for predicates (only immutable
functions, no sub-selects).  This fixes problems recently introduced with
inlining SQL functions, because the inlining transformation is applied to
both expression trees so the planner can still match them up.  Along the
way, improve efficiency of handling index predicates (both predicates and
index expressions are now cached by the relcache) and fix 7.3 oversight
that didn't record dependencies of predicate expressions.

Revision 1.136: download - view: text, markup, annotated - select for diffs
Tue Apr 29 22:13:09 2003 UTC (22 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.135: preferred, colored
Changes since revision 1.135: +7 -7 lines
Infrastructure for deducing Param types from context, in the same way
that the types of untyped string-literal constants are deduced (ie,
when coerce_type is applied to 'em, that's what the type must be).
Remove the ancient hack of storing the input Param-types array as a
global variable, and put the info into ParseState instead.  This touches
a lot of files because of adjustment of routine parameter lists, but
it's really not a large patch.  Note: PREPARE statement still insists on
exact specification of parameter types, but that could easily be relaxed
now, if we wanted to do so.

Revision 1.135: download - view: text, markup, annotated - select for diffs
Sun Apr 27 20:09:44 2003 UTC (22 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.134: preferred, colored
Changes since revision 1.134: +2 -6 lines
Put back encoding-conversion step in processing of incoming queries;
I had inadvertently omitted it while rearranging things to support
length-counted incoming messages.  Also, change the parser's API back
to accepting a 'char *' query string instead of 'StringInfo', as the
latter wasn't buying us anything except overhead.  (I think when I put
it in I had some notion of making the parser API 8-bit-clean, but
seeing that flex depends on null-terminated input, that's not really
ever gonna happen.)

Revision 1.134: download - view: text, markup, annotated - select for diffs
Tue Apr 8 23:20:01 2003 UTC (22 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.133: preferred, colored
Changes since revision 1.133: +140 -77 lines
First phase of work on array improvements.  ARRAY[x,y,z] constructor
expressions, ARRAY(sub-SELECT) expressions, some array functions.
Polymorphic functions using ANYARRAY/ANYELEMENT argument and return
types.  Some regression tests in place, documentation is lacking.
Joe Conway, with some kibitzing from Tom Lane.

Revision 1.133: download - view: text, markup, annotated - select for diffs
Sat Mar 22 01:49:38 2003 UTC (22 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.132: preferred, colored
Changes since revision 1.132: +5 -27 lines
Adjust subquery qual pushdown rules to be more forgiving: if a qual
refers to a non-DISTINCT output column of a DISTINCT ON subquery, or
if it refers to a function-returning-set, we cannot push it down.
But the old implementation refused to push down *any* quals if the
subquery had any such 'dangerous' outputs.  Now we just look at the
output columns actually referenced by each qual expression.  More code
than before, but probably no slower since we don't make unnecessary checks.

Revision 1.132: download - view: text, markup, annotated - select for diffs
Fri Mar 14 00:55:17 2003 UTC (22 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.131: preferred, colored
Changes since revision 1.131: +23 -1 lines
Make eval_const_expressions simplify FieldSelect from a whole-row Var
into an ordinary one-field Var.  Per example from Chris Mungall.

Revision 1.131: download - view: text, markup, annotated - select for diffs
Mon Mar 10 03:53:50 2003 UTC (22 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.130: preferred, colored
Changes since revision 1.130: +1 -2 lines
Restructure parsetree representation of DECLARE CURSOR: now it's a
utility statement (DeclareCursorStmt) with a SELECT query dangling from
it, rather than a SELECT query with a few unusual fields in it.  Add
code to determine whether a planned query can safely be run backwards.
If DECLARE CURSOR specifies SCROLL, ensure that the plan can be run
backwards by adding a Materialize plan node if it can't.  Without SCROLL,
you get an error if you try to fetch backwards from a cursor that can't
handle it.  (There is still some discussion about what the exact
behavior should be, but this is necessary infrastructure in any case.)
Along the way, make EXPLAIN DECLARE CURSOR work.

Revision 1.130: download - view: text, markup, annotated - select for diffs
Sun Feb 16 02:30:38 2003 UTC (22 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.129: preferred, colored
Changes since revision 1.129: +86 -11 lines
COALESCE() and NULLIF() are now first-class expressions, not macros
that turn into CASE expressions.  They evaluate their arguments at most
once.  Patch by Kris Jurka, review and (very light) editorializing by me.

Revision 1.129: download - view: text, markup, annotated - select for diffs
Sun Feb 9 06:56:27 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.128: preferred, colored
Changes since revision 1.128: +6 -6 lines
Create a distinction between Lists of integers and Lists of OIDs, to get
rid of the assumption that sizeof(Oid)==sizeof(int).  This is one small
step towards someday supporting 8-byte OIDs.  For the moment, it doesn't
do much except get rid of a lot of unsightly casts.

Revision 1.128: download - view: text, markup, annotated - select for diffs
Sat Feb 8 20:20:55 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.127: preferred, colored
Changes since revision 1.127: +8 -9 lines
Replace planner's representation of relation sets, per pghackers discussion.
Instead of Lists of integers, we now store variable-length bitmap sets.
This should be faster as well as less error-prone.

Revision 1.127: download - view: text, markup, annotated - select for diffs
Tue Feb 4 00:50:00 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.126: preferred, colored
Changes since revision 1.126: +12 -46 lines
Minor code cleanup: remove no-longer-useful pull_subplans() function,
and convert pull_agg_clause() into count_agg_clause(), which is a more
efficient way of doing what it's really being used for.

Revision 1.126: download - view: text, markup, annotated - select for diffs
Mon Feb 3 21:15:44 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.125: preferred, colored
Changes since revision 1.125: +9 -12 lines
Determine the set of constraints applied to a domain at executor
startup, not in the parser; this allows ALTER DOMAIN to work correctly
with domain constraint operations stored in rules.  Rod Taylor;
code review by Tom Lane.

Revision 1.125: download - view: text, markup, annotated - select for diffs
Mon Jan 20 18:54:54 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.124: preferred, colored
Changes since revision 1.124: +23 -1 lines
IN clauses appearing at top level of WHERE can now be handled as joins.
There are two implementation techniques: the executor understands a new
JOIN_IN jointype, which emits at most one matching row per left-hand row,
or the result of the IN's sub-select can be fed through a DISTINCT filter
and then joined as an ordinary relation.
Along the way, some minor code cleanup in the optimizer; notably, break
out most of the jointree-rearrangement preprocessing in planner.c and
put it in a new file prep/prepjointree.c.

Revision 1.124: download - view: text, markup, annotated - select for diffs
Fri Jan 17 03:25:03 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.123: preferred, colored
Changes since revision 1.123: +1 -163 lines
Fix parse_agg.c to detect ungrouped Vars in sub-SELECTs; remove code
that used to do it in planner.  That was an ancient kluge that was
never satisfactory; errors should be detected at parse time when possible.
But at the time we didn't have the support mechanism (expression_tree_walker
et al) to make it convenient to do in the parser.

Revision 1.123: download - view: text, markup, annotated - select for diffs
Fri Jan 17 02:01:16 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.122: preferred, colored
Changes since revision 1.122: +83 -18 lines
Adjust API of expression_tree_mutator and query_tree_mutator to
simplify callers.  It turns out the common case is that the caller
does want to recurse into sub-queries, so push support for that into
these subroutines.

Revision 1.122: download - view: text, markup, annotated - select for diffs
Wed Jan 15 19:35:44 2003 UTC (22 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.121: preferred, colored
Changes since revision 1.121: +5 -9 lines
Allow merge and hash joins to occur on arbitrary expressions (anything not
containing a volatile function), rather than only on 'Var = Var' clauses
as before.  This makes it practical to do flatten_join_alias_vars at the
start of planning, which in turn eliminates a bunch of klugery inside the
planner to deal with alias vars.  As a free side effect, we now detect
implied equality of non-Var expressions; for example in
	SELECT ... WHERE a.x = b.y and b.y = 42
we will deduce a.x = 42 and use that as a restriction qual on a.  Also,
we can remove the restriction introduced 12/5/02 to prevent pullup of
subqueries whose targetlists contain sublinks.
Still TODO: make statistical estimation routines in selfuncs.c and costsize.c
smarter about expressions that are more complex than plain Vars.  The need
for this is considerably greater now that we have to be able to estimate
the suitability of merge and hash join techniques on such expressions.

Revision 1.121: download - view: text, markup, annotated - select for diffs
Fri Jan 10 21:08:13 2003 UTC (22 years, 8 months ago) by tgl
Branches: MAIN
Diff to: previous 1.120: preferred, colored
Changes since revision 1.120: +48 -18 lines
Further tweaking of parsetree & plantree representation of SubLinks.
Simplify SubLink by storing just a List of operator OIDs, instead of
a list of incomplete OpExprs --- that was a bizarre and bulky choice,
with no redeeming social value since we have to build new OpExprs
anyway when forming the plan tree.

Revision 1.120: download - view: text, markup, annotated - select for diffs
Sun Dec 15 16:17:50 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.119: preferred, colored
Changes since revision 1.119: +27 -11 lines
Revise executor APIs so that all per-query state structure is built in
a per-query memory context created by CreateExecutorState --- and destroyed
by FreeExecutorState.  This provides a final solution to the longstanding
problem of memory leaked by various ExecEndNode calls.

Revision 1.119: download - view: text, markup, annotated - select for diffs
Sat Dec 14 00:17:59 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.118: preferred, colored
Changes since revision 1.118: +55 -68 lines
Clean up plantree representation of SubPlan-s --- SubLink does not appear
in the planned representation of a subplan at all any more, only SubPlan.
This means subselect.c doesn't scribble on its input anymore, which seems
like a good thing; and there are no longer three different possible
interpretations of a SubLink.  Simplify node naming and improve comments
in primnodes.h.  No change to stored rules, though.

Revision 1.118: download - view: text, markup, annotated - select for diffs
Fri Dec 13 19:45:56 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.117: preferred, colored
Changes since revision 1.117: +17 -4 lines
Phase 3 of read-only-plans project: ExecInitExpr now builds expression
execution state trees, and ExecEvalExpr takes an expression state tree
not an expression plan tree.  The plan tree is now read-only as far as
the executor is concerned.  Next step is to begin actually exploiting
this property.

Revision 1.117: download - view: text, markup, annotated - select for diffs
Thu Dec 12 20:35:12 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.116: preferred, colored
Changes since revision 1.116: +3 -12 lines
Preliminary code review for domain CHECK constraints patch: add documentation,
make VALUE a non-reserved word again, use less invasive method of passing
ConstraintTestValue into transformExpr, fix problems with nested constraint
testing, do correct thing with NULL result from a constraint expression,
remove memory leak.  Domain checks still need much more work if we are going
to allow ALTER DOMAIN, however.

Revision 1.116: download - view: text, markup, annotated - select for diffs
Thu Dec 12 15:49:32 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.115: preferred, colored
Changes since revision 1.115: +587 -529 lines
Phase 2 of read-only-plans project: restructure expression-tree nodes
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.

Revision 1.115: download - view: text, markup, annotated - select for diffs
Sun Dec 1 21:05:14 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.114: preferred, colored
Changes since revision 1.114: +435 -102 lines
Teach planner to expand sufficiently simple SQL-language functions
('SELECT expression') inline, like macros, during the constant-folding
phase of planning.  The actual expansion is not difficult, but checking
that we're not changing the semantics of the call turns out to be more
subtle than one might think; in particular must pay attention to
permissions issues, strictness, and volatility.

Revision 1.114: download - view: text, markup, annotated - select for diffs
Sat Nov 30 21:25:04 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.113: preferred, colored
Changes since revision 1.113: +34 -94 lines
Code review for IS DISTINCT FROM patch.  Fix incorrect constant-folding
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.

Revision 1.113: download - view: text, markup, annotated - select for diffs
Tue Nov 26 03:01:58 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.112: preferred, colored
Changes since revision 1.112: +5 -12 lines
Use Params, rather than run-time-modified Const nodes, to handle
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.

Revision 1.112: download - view: text, markup, annotated - select for diffs
Mon Nov 25 21:29:40 2002 UTC (22 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.111: preferred, colored
Changes since revision 1.111: +7 -7 lines
Remove unused constisset and constiscast fields of Const nodes.  Clean
up code and documentation associated with Param nodes.

Revision 1.111: download - view: text, markup, annotated - select for diffs
Fri Nov 15 02:50:07 2002 UTC (22 years, 10 months ago) by momjian
Branches: MAIN
Diff to: previous 1.110: preferred, colored
Changes since revision 1.110: +12 -1 lines
Add DOMAIN check constraints.

Rod Taylor

Revision 1.110: download - view: text, markup, annotated - select for diffs
Wed Nov 6 22:31:24 2002 UTC (22 years, 10 months ago) by tgl
Branches: MAIN
Diff to: previous 1.109: preferred, colored
Changes since revision 1.109: +28 -1 lines
Phase 2 of hashed-aggregation project.  nodeAgg.c now knows how to do
hashed aggregation, but there's not yet planner support for it.

Revision 1.109: download - view: text, markup, annotated - select for diffs
Wed Sep 11 14:48:54 2002 UTC (23 years ago) by tgl
Branches: MAIN
CVS tags: REL7_3_9, REL7_3_8, REL7_3_7, REL7_3_6, REL7_3_5, REL7_3_4, REL7_3_2
Branch point for: REL7_3_STABLE
Diff to: previous 1.108: preferred, colored
Changes since revision 1.108: +25 -19 lines
Tweak querytree-dependency-extraction code so that columns of tables
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.

Revision 1.108: download - view: text, markup, annotated - select for diffs
Wed Sep 4 20:31:22 2002 UTC (23 years ago) by momjian
Branches: MAIN
Diff to: previous 1.107: preferred, colored
Changes since revision 1.107: +41 -31 lines
pgindent run.

Revision 1.107: download - view: text, markup, annotated - select for diffs
Sat Aug 31 22:10:43 2002 UTC (23 years ago) by tgl
Branches: MAIN
Diff to: previous 1.106: preferred, colored
Changes since revision 1.106: +16 -17 lines
Code review for domain-constraints patch.  Use a new ConstraintTest node
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.

Revision 1.106: download - view: text, markup, annotated - select for diffs
Sat Jul 20 05:16:58 2002 UTC (23 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.105: preferred, colored
Changes since revision 1.105: +2 -2 lines
oid is needed, it is added at the end of the struct (after the null
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

Revision 1.105: download - view: text, markup, annotated - select for diffs
Thu Jul 18 17:14:19 2002 UTC (23 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.104: preferred, colored
Changes since revision 1.104: +5 -25 lines
Back out BETWEEN node patch, was causing initdb failure.

Revision 1.104: download - view: text, markup, annotated - select for diffs
Thu Jul 18 04:41:45 2002 UTC (23 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.103: preferred, colored
Changes since revision 1.103: +25 -5 lines
Finished the Between patch Christopher started.

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

Revision 1.103: download - view: text, markup, annotated - select for diffs
Sat Jul 6 20:16:35 2002 UTC (23 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.102: preferred, colored
Changes since revision 1.102: +17 -1 lines
I've fixed up the way domain constraints (not null and type length)
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

Revision 1.102: download - view: text, markup, annotated - select for diffs
Thu Jul 4 15:23:58 2002 UTC (23 years, 2 months ago) by thomas
Branches: MAIN
Diff to: previous 1.101: preferred, colored
Changes since revision 1.101: +100 -4 lines
Implement the IS DISTINCT FROM operator per SQL99.
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().

Revision 1.101: download - view: text, markup, annotated - select for diffs
Thu Jun 20 20:29:31 2002 UTC (23 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.100: preferred, colored
Changes since revision 1.100: +2 -2 lines
Update copyright to 2002.

Revision 1.100: download - view: text, markup, annotated - select for diffs
Sat May 18 18:49:41 2002 UTC (23 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.99: preferred, colored
Changes since revision 1.99: +10 -3 lines
Teach query_tree_walker, query_tree_mutator, and SS_finalize_plan to
process function RTE expressions, which they were previously missing.
This allows outer-Var references and subselects to work correctly in
the arguments of a function RTE.  Install check to prevent function RTEs
from cross-referencing Vars of sibling FROM-items, which doesn't make
any sense (if you want to join, write a JOIN or WHERE clause).

Revision 1.99: download - view: text, markup, annotated - select for diffs
Sun May 12 23:43:03 2002 UTC (23 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.98: preferred, colored
Changes since revision 1.98: +53 -70 lines
Get rid of long-since-vestigial Iter node type, in favor of adding a
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.

Revision 1.98: download - view: text, markup, annotated - select for diffs
Sun May 12 20:10:03 2002 UTC (23 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.97: preferred, colored
Changes since revision 1.97: +3 -1 lines
First pass at set-returning-functions in FROM, by Joe Conway with
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 ...

Revision 1.97: download - view: text, markup, annotated - select for diffs
Sun Apr 28 19:54:28 2002 UTC (23 years, 4 months ago) by tgl
Branches: MAIN
Diff to: previous 1.96: preferred, colored
Changes since revision 1.96: +43 -23 lines
Second try at fixing join alias variables.  Instead of attaching miscellaneous
lists to join RTEs, attach a list of Vars and COALESCE expressions that will
replace the join's alias variables during planning.  This simplifies
flatten_join_alias_vars while still making it easy to fix up varno references
when transforming the query tree.  Add regression test cases for interactions
of subqueries with outer joins.

Revision 1.96: download - view: text, markup, annotated - select for diffs
Fri Apr 5 00:31:27 2002 UTC (23 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.95: preferred, colored
Changes since revision 1.95: +79 -27 lines
Divide functions into three volatility classes (immutable, stable, and
volatile), rather than the old cachable/noncachable distinction.  This
allows indexscan optimizations in many places where we formerly didn't.
Also, add a pronamespace column to pg_proc (it doesn't do anything yet,
however).

Revision 1.95: download - view: text, markup, annotated - select for diffs
Thu Mar 21 16:00:44 2002 UTC (23 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.94: preferred, colored
Changes since revision 1.94: +2 -4 lines
First phase of SCHEMA changes, concentrating on fixing the grammar and
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.

Revision 1.94: download - view: text, markup, annotated - select for diffs
Tue Mar 12 00:51:50 2002 UTC (23 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.93: preferred, colored
Changes since revision 1.93: +3 -8 lines
Restructure representation of join alias variables.  An explicit JOIN
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.

Revision 1.93: download - view: text, markup, annotated - select for diffs
Thu Jan 3 18:01:59 2002 UTC (23 years, 8 months ago) by tgl
Branches: MAIN
CVS tags: REL7_2_STABLE, REL7_2_RC2, REL7_2_RC1, REL7_2_BETA5, REL7_2_8, REL7_2_7, REL7_2_6, REL7_2_5, REL7_2_4, REL7_2_3, REL7_2
Diff to: previous 1.92: preferred, colored
Changes since revision 1.92: +3 -2 lines
Shouldn't try to copy null datums with datumCopy.

Revision 1.92: download - view: text, markup, annotated - select for diffs
Mon Dec 10 22:54:12 2001 UTC (23 years, 9 months ago) by tgl
Branches: MAIN
CVS tags: REL7_2_BETA4
Diff to: previous 1.91: preferred, colored
Changes since revision 1.91: +35 -1 lines
Suppress subquery pullup and pushdown when the subquery has any
set-returning functions in its target list.  This ensures that we
won't rewrite the query in a way that places set-returning functions
into quals (WHERE clauses).  Cf. bug reports from Joe Conway.

Revision 1.91: download - view: text, markup, annotated - select for diffs
Mon Nov 5 17:46:26 2001 UTC (23 years, 10 months ago) by momjian
Branches: MAIN
CVS tags: REL7_2_BETA3, REL7_2_BETA2
Diff to: previous 1.90: preferred, colored
Changes since revision 1.90: +14 -13 lines
New pgindent run with fixes suggested by Tom.  Patch manually reviewed,
initdb/regression tests pass.

Revision 1.90: download - view: text, markup, annotated - select for diffs
Tue Oct 30 19:58:58 2001 UTC (23 years, 10 months ago) by tgl
Branches: MAIN
Diff to: previous 1.89: preferred, colored
Changes since revision 1.89: +67 -22 lines
Fix problems with subselects used in GROUP BY expressions, per gripe
from Philip Warner.  Side effect of change is that GROUP BY expressions
will not be re-evaluated at multiple plan levels anymore, whereas this
sometimes happened with old code.

Revision 1.89: download - view: text, markup, annotated - select for diffs
Thu Oct 25 05:49:34 2001 UTC (23 years, 10 months ago) by momjian
Branches: MAIN
CVS tags: REL7_2_BETA1
Diff to: previous 1.88: preferred, colored
Changes since revision 1.88: +12 -23 lines
pgindent run on all C files.  Java run to follow.  initdb/regression
tests pass.

Revision 1.88: download - view: text, markup, annotated - select for diffs
Tue Jul 31 20:16:33 2001 UTC (24 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.87: preferred, colored
Changes since revision 1.87: +52 -17 lines
Further thought shows that has_distinct_on_clause() needs to take much
more care with resjunk tlist entries than it was doing.  The original
coding ignored resjunk entries entirely, but a resjunk entry that is
in either the distinctClause or sortClause lists indicates that DISTINCT
ON was used.  It's important for ruleutils.c to get this right, else we
may dump views using DISTINCT ON incorrectly.

Revision 1.84.2.1: download - view: text, markup, annotated - select for diffs
Tue Jul 31 18:39:12 2001 UTC (24 years, 1 month ago) by tgl
Branches: REL7_1_STABLE
Diff to: previous 1.84: preferred, colored; next MAIN 1.85: preferred, colored
Changes since revision 1.84: +54 -2 lines
Fix optimizer to not try to push WHERE clauses down into a sub-SELECT that
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.
Also, back-patch earlier fix to not push down into sub-SELECT with LIMIT.

Revision 1.87: download - view: text, markup, annotated - select for diffs
Tue Jul 31 17:56:31 2001 UTC (24 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.86: preferred, colored
Changes since revision 1.86: +54 -2 lines
Fix optimizer to not try to push WHERE clauses down into a sub-SELECT that
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.

Revision 1.86: download - view: text, markup, annotated - select for diffs
Tue Jun 19 22:39:11 2001 UTC (24 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.85: preferred, colored
Changes since revision 1.85: +25 -1 lines
Add IS UNKNOWN, IS NOT UNKNOWN boolean tests, fix the existing boolean
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.

Revision 1.85: download - view: text, markup, annotated - select for diffs
Sun May 20 20:28:19 2001 UTC (24 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.84: preferred, colored
Changes since revision 1.84: +1 -198 lines
Modify optimizer data structures so that IndexOptInfo lists built for
create_index_paths are not immediately discarded, but are available for
subsequent planner work.  This allows avoiding redundant syscache lookups
in several places.  Change interface to operator selectivity estimation
procedures to allow faster and more flexible estimation.
Initdb forced due to change of pg_proc entries for selectivity functions!

Revision 1.84: download - view: text, markup, annotated - select for diffs
Tue Mar 27 17:12:34 2001 UTC (24 years, 5 months ago) by tgl
Branches: MAIN
CVS tags: REL7_1_2, REL7_1
Branch point for: REL7_1_STABLE
Diff to: previous 1.83: preferred, colored
Changes since revision 1.83: +10 -9 lines
Repair pgindent damage to comments.

Revision 1.83: download - view: text, markup, annotated - select for diffs
Thu Mar 22 03:59:39 2001 UTC (24 years, 5 months ago) by momjian
Branches: MAIN
Diff to: previous 1.82: preferred, colored
Changes since revision 1.82: +46 -39 lines
pgindent run.  Make it all clean.

Revision 1.82: download - view: text, markup, annotated - select for diffs
Thu Mar 8 01:49:01 2001 UTC (24 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.81: preferred, colored
Changes since revision 1.81: +9 -1 lines
A subplan invoked within an aggregate function's argument should
be allowed to receive ungrouped variables of the current query level.
Curious that no one reported this bug before...

Revision 1.81: download - view: text, markup, annotated - select for diffs
Mon Feb 12 18:46:40 2001 UTC (24 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.80: preferred, colored
Changes since revision 1.80: +6 -6 lines
Cleanup

Revision 1.80: download - view: text, markup, annotated - select for diffs
Mon Feb 12 18:30:52 2001 UTC (24 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.79: preferred, colored
Changes since revision 1.79: +6 -6 lines
Add // -> /* */ mapping to pgindent.

Revision 1.79: download - view: text, markup, annotated - select for diffs
Wed Jan 24 19:42:59 2001 UTC (24 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.78: preferred, colored
Changes since revision 1.78: +2 -2 lines
Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.

Revision 1.78: download - view: text, markup, annotated - select for diffs
Thu Nov 16 22:30:26 2000 UTC (24 years, 9 months ago) by tgl
Branches: MAIN
CVS tags: REL7_1_BETA3, REL7_1_BETA2, REL7_1_BETA
Diff to: previous 1.77: preferred, colored
Changes since revision 1.77: +30 -26 lines
Change SearchSysCache coding conventions so that a reference count is
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.

Revision 1.77: download - view: text, markup, annotated - select for diffs
Thu Oct 5 19:11:32 2000 UTC (24 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.76: preferred, colored
Changes since revision 1.76: +103 -8 lines
Reimplementation of UNION/INTERSECT/EXCEPT.  INTERSECT/EXCEPT now meet the
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!

Revision 1.76: download - view: text, markup, annotated - select for diffs
Fri Sep 29 18:21:23 2000 UTC (24 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.75: preferred, colored
Changes since revision 1.75: +59 -41 lines
Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.
(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!

Revision 1.75: download - view: text, markup, annotated - select for diffs
Mon Sep 25 18:14:55 2000 UTC (24 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.74: preferred, colored
Changes since revision 1.74: +3 -6 lines
Use variable aliases, if supplied, rather than real column names in
complaints about ungrouped variables.  This is for consistency with
behavior elsewhere, notably the fact that the relname is reported as
an alias in these same complaints.  Also, it'll work with subselect-
in-FROM where old code didn't.

Revision 1.74: download - view: text, markup, annotated - select for diffs
Tue Sep 12 21:06:58 2000 UTC (25 years ago) by tgl
Branches: MAIN
Diff to: previous 1.73: preferred, colored
Changes since revision 1.73: +121 -22 lines
First cut at full support for OUTER JOINs.  There are still a few loose
ends to clean up (see my message of same date to pghackers), but mostly
it works.  INITDB REQUIRED!

Revision 1.73: download - view: text, markup, annotated - select for diffs
Thu Aug 24 03:29:05 2000 UTC (25 years ago) by tgl
Branches: MAIN
Diff to: previous 1.72: preferred, colored
Changes since revision 1.72: +2 -4 lines
SQL-language functions are now callable in ordinary fmgr contexts ...
for example, an SQL function can be used in a functional index.  (I make
no promises about speed, but it'll work ;-).)  Clean up and simplify
handling of functions returning sets.

Revision 1.72: download - view: text, markup, annotated - select for diffs
Mon Aug 21 17:22:34 2000 UTC (25 years ago) by tgl
Branches: MAIN
Diff to: previous 1.71: preferred, colored
Changes since revision 1.71: +23 -17 lines
fmgr interface mopup work.  Use new DatumGetBool and BoolGetDatum
macros where appropriate (the code used to have several different ways
of doing that, including Int32, Int8, UInt8, ...).  Remove last few
references to float32 and float64 typedefs --- it's all float4/float8
now.  The typedefs themselves should probably stay in c.h for a release
or two, though, to avoid breaking user-written C functions.

Revision 1.71: download - view: text, markup, annotated - select for diffs
Sun Aug 13 02:50:10 2000 UTC (25 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.70: preferred, colored
Changes since revision 1.70: +137 -17 lines
Clean up handling of variable-free qual clauses.  System now does the
right thing with variable-free clauses that contain noncachable functions,
such as 'WHERE random() < 0.5' --- these are evaluated once per
potential output tuple.  Expressions that contain only Params are
now candidates to be indexscan quals --- for example, 'var = ($1 + 1)'
can now be indexed.  Cope with RelabelType nodes atop potential indexscan
variables --- this oversight prevents 7.0.* from recognizing some
potentially indexscanable situations.

Revision 1.70: download - view: text, markup, annotated - select for diffs
Tue Aug 8 15:41:53 2000 UTC (25 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.69: preferred, colored
Changes since revision 1.69: +14 -4 lines
Remove 'func_tlist' from Func expression nodes, likewise 'param_tlist'
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.

Revision 1.69: download - view: text, markup, annotated - select for diffs
Wed Jul 12 02:37:11 2000 UTC (25 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.68: preferred, colored
Changes since revision 1.68: +22 -8 lines
First stage of reclaiming memory in executor by resetting short-term
memory contexts.  Currently, only leaks in expressions executed as
quals or projections are handled.  Clean up some old dead cruft in
executor while at it --- unused fields in state nodes, that sort of thing.

Revision 1.68: download - view: text, markup, annotated - select for diffs
Tue May 30 00:49:49 2000 UTC (25 years, 3 months ago) by momjian
Branches: MAIN
Diff to: previous 1.67: preferred, colored
Changes since revision 1.67: +1 -3 lines
Remove unused include files.  Do not touch /port or includes used by defines.

Revision 1.67: download - view: text, markup, annotated - select for diffs
Sun May 28 20:33:28 2000 UTC (25 years, 3 months ago) by tgl
Branches: MAIN
Diff to: previous 1.66: preferred, colored
Changes since revision 1.66: +47 -13 lines
Constant-expression simplifier now knows how to simplify strict functions
that have at least one constant-NULL input, even if other inputs are
not constants.

Revision 1.66: download - view: text, markup, annotated - select for diffs
Sun Apr 16 01:55:45 2000 UTC (25 years, 5 months ago) by tgl
Branches: MAIN
CVS tags: REL7_0_PATCHES, REL7_0
Diff to: previous 1.65: preferred, colored
Changes since revision 1.65: +3 -2 lines
get_relattval() should treat a NULL constant as a non-constant expression,
since it has no way to indicate to its caller that the constant is
actually NULL.  This prevents coredump in cases like
  WHERE textfield < null::text;

Revision 1.65: download - view: text, markup, annotated - select for diffs
Wed Apr 12 17:15:24 2000 UTC (25 years, 5 months ago) by momjian
Branches: MAIN
Diff to: previous 1.64: preferred, colored
Changes since revision 1.64: +290 -231 lines
Ye-old pgindent run.  Same 4-space tabs.

Revision 1.64: download - view: text, markup, annotated - select for diffs
Tue Apr 4 01:21:46 2000 UTC (25 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.63: preferred, colored
Changes since revision 1.63: +103 -33 lines
Fix extremely nasty little bug observed when a sub-SELECT appears in
WHERE in a place where it can be part of a nestloop inner indexqual.
As the code stood, it put the same physical sub-Plan node into both
indxqual and indxqualorig of the IndexScan plan node.  That confused
later processing in the optimizer (which expected that tracing the
subPlan list would visit each subplan node exactly once), and would
probably have blown up in the executor if the planner hadn't choked first.
Fix by making the 'fixed' indexqual be a complete deep copy of the
original indexqual, rather than trying to share nodes below the topmost
operator node.  This had further ramifications though, because we were
making the aforesaid list of sub-Plan nodes during SS_process_sublinks
which is run before construction of the 'fixed' indexqual, meaning that
the copy of the sub-Plan didn't show up in that list.  Fix by rearranging
logic so that the sub-Plan list is built by the final set_plan_references
pass, not in SS_process_sublinks.  This may sound like a mess, but it's
actually a good deal cleaner now than it was before, because we are no
longer dependent on the assumption that planning will never make a copy
of a sub-Plan node.

Revision 1.63: download - view: text, markup, annotated - select for diffs
Tue Mar 21 05:12:12 2000 UTC (25 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.62: preferred, colored
Changes since revision 1.62: +13 -24 lines
Restructure planning code so that preprocessing of targetlist and quals
to simplify constant expressions and expand SubLink nodes into SubPlans
is done in a separate routine subquery_planner() that calls union_planner().
We formerly did most of this work in query_planner(), but that's the
wrong place because it may never see the real targetlist.  Splitting
union_planner into two routines also allows us to avoid redundant work
when union_planner is invoked recursively for UNION and inheritance
cases.  Upshot is that it is now possible to do something like
select float8(count(*)) / (select count(*) from int4_tbl)  from int4_tbl
group by f1;
which has never worked before.

Revision 1.62: download - view: text, markup, annotated - select for diffs
Sun Mar 19 18:20:38 2000 UTC (25 years, 5 months ago) by tgl
Branches: MAIN
Diff to: previous 1.61: preferred, colored
Changes since revision 1.61: +129 -105 lines
Minor code rearrangement & doc improvement in eval_const_expressions().

Revision 1.61: download - view: text, markup, annotated - select for diffs
Sun Mar 12 19:32:06 2000 UTC (25 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.60: preferred, colored
Changes since revision 1.60: +13 -5 lines
Fix performance bug in constant-expression simplifier.  After finding
that the inputs to a given operator can be recursively simplified to
constants, it was evaluating the operator using the op's *original*
(unsimplified) arg list, so that any subexpressions had to be evaluated
again.  A constant subexpression at depth N got evaluated N times.
Probably not very important in practical situations, but it made us look
real slow in MySQL's 'crashme' test...

Revision 1.60: download - view: text, markup, annotated - select for diffs
Sun Feb 20 21:32:06 2000 UTC (25 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.59: preferred, colored
Changes since revision 1.59: +44 -1 lines
Create a new expression node type RelabelType, which exists solely to
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.

Revision 1.59: download - view: text, markup, annotated - select for diffs
Tue Feb 15 03:37:36 2000 UTC (25 years, 7 months ago) by thomas
Branches: MAIN
Diff to: previous 1.58: preferred, colored
Changes since revision 1.58: +2 -2 lines
Carry column aliases from the parser frontend. Enables queries like
  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.

Revision 1.58: download - view: text, markup, annotated - select for diffs
Wed Jan 26 05:56:40 2000 UTC (25 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.57: preferred, colored
Changes since revision 1.57: +3 -2 lines
Add:

  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc

to all files copyright Regents of Berkeley.  Man, that's a lot of files.

Revision 1.57: download - view: text, markup, annotated - select for diffs
Mon Dec 13 01:26:55 1999 UTC (25 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.56: preferred, colored
Changes since revision 1.56: +35 -3 lines
aggregate(DISTINCT ...) works, per SQL spec.
Note this forces initdb because of change of Aggref node in stored rules.

Revision 1.56: download - view: text, markup, annotated - select for diffs
Thu Dec 9 05:58:53 1999 UTC (25 years, 9 months ago) by tgl
Branches: MAIN
Diff to: previous 1.55: preferred, colored
Changes since revision 1.55: +47 -13 lines
Replace generic 'Illegal use of aggregates' error message with one that
shows the specific ungrouped variable being complained of.  Perhaps this
will reduce user confusion...

Revision 1.55: download - view: text, markup, annotated - select for diffs
Mon Nov 22 17:56:17 1999 UTC (25 years, 9 months ago) by momjian
Branches: MAIN
Diff to: previous 1.54: preferred, colored
Changes since revision 1.54: +2 -2 lines
Add system indexes to match all caches.
Make all system indexes unique.
Make all cache loads use system indexes.
Rename *rel to *relid in inheritance tables.
Rename cache names to be clearer.

Revision 1.54: download - view: text, markup, annotated - select for diffs
Thu Oct 7 04:23:08 1999 UTC (25 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.53: preferred, colored
Changes since revision 1.53: +26 -13 lines
Fix planner and rewriter to follow SQL semantics for tables that are
mentioned in FROM but not elsewhere in the query: such tables should be
joined over anyway.  Aside from being more standards-compliant, this allows
removal of some very ugly hacks for COUNT(*) processing.  Also, allow
HAVING clause without aggregate functions, since SQL does.  Clean up
CREATE RULE statement-list syntax the same way Bruce just fixed the
main stmtmulti production.
CAUTION: addition of a field to RangeTblEntry nodes breaks stored rules;
you will have to initdb if you have any rules.

Revision 1.53: download - view: text, markup, annotated - select for diffs
Sat Oct 2 04:37:52 1999 UTC (25 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.52: preferred, colored
Changes since revision 1.52: +22 -20 lines
Fix make_clause and make_opclause to record valid type info
in the Expr nodes they produce.  This fixes a few cases of errors like
'typeidTypeRelid: Invalid type - oid = 0' caused by calling parser-related
routines on expression trees that have already been processed by planner-
related routines.

Revision 1.52: download - view: text, markup, annotated - select for diffs
Sun Sep 26 02:28:33 1999 UTC (25 years, 11 months ago) by tgl
Branches: MAIN
Diff to: previous 1.51: preferred, colored
Changes since revision 1.51: +417 -4 lines
Implement constant-expression simplification per Bernard
Frankpitt, plus some improvements from yours truly.  The simplifier depends
on the proiscachable field of pg_proc to tell it whether a function is
safe to pre-evaluate --- things like nextval() are not, for example.
Update pg_proc.h to contain reasonable cacheability information; as of
6.5.* hardly any functions were marked cacheable.  I may have erred too
far in the other direction; see recent mail to pghackers for more info.
This update does not force an initdb, exactly, but you won't see much
benefit from the simplifier until you do one.

Revision 1.51: download - view: text, markup, annotated - select for diffs
Thu Sep 9 02:35:53 1999 UTC (26 years ago) by tgl
Branches: MAIN
Diff to: previous 1.50: preferred, colored
Changes since revision 1.50: +17 -11 lines
Repair error noticed by Roberto Cornacchia: selectivity code
was rejecting negative attnums as bogus, which of course they are not.
Add code to get_attdisbursion to produce a useful value for OID attribute,
since VACUUM does not store stats for system attributes.
Also, repair bug that's been in eqjoinsel for a long time: it was taking
the max of the two columns' disbursions, whereas it should use the min.

Revision 1.50: download - view: text, markup, annotated - select for diffs
Thu Aug 26 05:09:05 1999 UTC (26 years ago) by tgl
Branches: MAIN
Diff to: previous 1.49: preferred, colored
Changes since revision 1.49: +6 -4 lines
Clean up some mistakes in handling of uplevel Vars in planner.
Most parts of the planner should ignore, or indeed never even see, uplevel
Vars because they will be or have been replaced by Params.  There were a
couple of places that got it wrong though, probably my fault from recent
changes...

Revision 1.49: download - view: text, markup, annotated - select for diffs
Wed Aug 25 23:21:41 1999 UTC (26 years ago) by tgl
Branches: MAIN
Diff to: previous 1.48: preferred, colored
Changes since revision 1.48: +27 -26 lines
Revise implementation of SubLinks so that there is a consistent,
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.

Revision 1.48: download - view: text, markup, annotated - select for diffs
Sun Aug 22 20:14:53 1999 UTC (26 years ago) by tgl
Branches: MAIN
Diff to: previous 1.47: preferred, colored
Changes since revision 1.47: +117 -28 lines
Further planner/optimizer cleanups.  Move all set_tlist_references
and fix_opids processing to a single recursive pass over the plan tree
executed at the very tail end of planning, rather than haphazardly here
and there at different places.  Now that tlist Vars do not get modified
until the very end, it's possible to get rid of the klugy var_equal and
match_varid partial-matching routines, and just use plain equal()
throughout the optimizer.  This is a step towards allowing merge and
hash joins to be done on expressions instead of only Vars ...

Revision 1.47: download - view: text, markup, annotated - select for diffs
Mon Aug 16 02:17:56 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.46: preferred, colored
Changes since revision 1.46: +2 -39 lines
Major planner/optimizer revision: get rid of PathOrder node type,
store all ordering information in pathkeys lists (which are now lists of
lists of PathKeyItem nodes, not just lists of lists of vars).  This was
a big win --- the code is smaller and IMHO more understandable than it
was, even though it handles more cases.  I believe the node changes will
not force an initdb for anyone; planner nodes don't show up in stored
rules.

Revision 1.46: download - view: text, markup, annotated - select for diffs
Thu Aug 12 04:32:54 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.45: preferred, colored
Changes since revision 1.45: +15 -14 lines
Clean up optimizer's handling of indexscan quals that need to be
commuted (ie, the index var appears on the right).  These are now handled
the same way as merge and hash join quals that need to be commuted: the
actual reversing of the clause only happens if we actually choose the path
and generate a plan from it.  Furthermore, the clause is only reversed in
the 'indexqual' field of the plan, not in the 'indxqualorig' field.  This
allows the clause to still be recognized and removed from qpquals of upper
level join plans.  Also, simplify and generalize match_clause_to_indexkey;
now it recognizes binary-compatible indexes for join as well as restriction
clauses.

Revision 1.45: download - view: text, markup, annotated - select for diffs
Tue Aug 10 03:00:15 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.44: preferred, colored
Changes since revision 1.44: +30 -95 lines
Minor cleanups and code beautification; eliminate some
routines that are now dead code.

Revision 1.44: download - view: text, markup, annotated - select for diffs
Mon Aug 9 00:51:24 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.43: preferred, colored
Changes since revision 1.43: +274 -38 lines
Create a standardized expression_tree_mutator support routine
to go along with expression_tree_walker.  (_walker is not suitable for
routines that need to alter the tree structure significantly.)  Other minor
cleanups in clauses.c.

Revision 1.37.2.1: download - view: text, markup, annotated - select for diffs
Mon Aug 2 06:27:07 1999 UTC (26 years, 1 month ago) by scrappy
Branches: REL6_5_PATCHES
Diff to: previous 1.37: preferred, colored; next MAIN 1.38: preferred, colored
Changes since revision 1.37: +4 -13 lines

Final round before bed...more tomorrow...

Revision 1.43: download - view: text, markup, annotated - select for diffs
Tue Jul 27 03:51:04 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.42: preferred, colored
Changes since revision 1.42: +15 -3 lines
First cut at doing LIKE/regex indexing optimization in
optimizer rather than parser.  This has many advantages, such as not
getting fooled by chance uses of operator names ~ and ~~ (the operators
are identified by OID now), and not creating useless comparison operations
in contexts where the comparisons will not actually be used as indexquals.
The new code also recognizes exact-match LIKE and regex patterns, and
produces an = indexqual instead of >= and <=.

This change does NOT fix the problem with non-ASCII locales: the code
still doesn't know how to generate an upper bound indexqual for non-ASCII
collation order.  But it's no worse than before, just the same deficiency
in a different place...

Also, dike out loc_restrictinfo fields in Plan nodes.  These were doing
nothing useful in the absence of 'expensive functions' optimization,
and they took a considerable amount of processing to fill in.

Revision 1.42: download - view: text, markup, annotated - select for diffs
Sun Jul 25 23:07:25 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.41: preferred, colored
Changes since revision 1.41: +106 -90 lines
Further work on planning of indexscans.  Cleaned up interfaces
to index_selectivity so that it can be handed an indexqual clause list
rather than a bunch of assorted derivative data.

Revision 1.41: download - view: text, markup, annotated - select for diffs
Sat Jul 24 23:21:13 1999 UTC (26 years, 1 month ago) by tgl
Branches: MAIN
Diff to: previous 1.40: preferred, colored
Changes since revision 1.40: +16 -33 lines
Clean up messy clause-selectivity code in clausesel.c; repair bug
identified by Hiroshi (incorrect cost attributed to OR clauses
after multiple passes through set_rest_selec()).  I think the code
was trying to allow selectivities of OR subclauses to be passed in
from outside, but noplace was actually passing any useful data, and
set_rest_selec() was passing wrong data.

Restructure representation of "indexqual" in IndexPath nodes so that
it is the same as for indxqual in completed IndexScan nodes: namely,
a toplevel list with an entry for each pass of the index scan, having
sublists that are implicitly-ANDed index qual conditions for that pass.
You don't want to know what the old representation was :-(

Improve documentation of OR-clause indexscan functions.

Remove useless 'notclause' field from RestrictInfo nodes.  (This might
force an initdb for anyone who has stored rules containing RestrictInfos,
but I do not think that RestrictInfo ever appears in completed plans.)

Revision 1.40: download - view: text, markup, annotated - select for diffs
Fri Jul 16 04:59:23 1999 UTC (26 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.39: preferred, colored
Changes since revision 1.39: +3 -6 lines
Final cleanup.

Revision 1.39: download - view: text, markup, annotated - select for diffs
Thu Jul 15 23:03:17 1999 UTC (26 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.38: preferred, colored
Changes since revision 1.38: +2 -2 lines
Change #include's to use <> and "" as appropriate.

Revision 1.38: download - view: text, markup, annotated - select for diffs
Thu Jul 15 22:39:29 1999 UTC (26 years, 2 months ago) by momjian
Branches: MAIN
Diff to: previous 1.37: preferred, colored
Changes since revision 1.37: +1 -6 lines
Remove unused #includes in *.c files.

Revision 1.37: download - view: text, markup, annotated - select for diffs
Mon Jun 21 01:18:02 1999 UTC (26 years, 2 months ago) by tgl
Branches: MAIN
CVS tags: REL6_5
Branch point for: REL6_5_PATCHES
Diff to: previous 1.36: preferred, colored
Changes since revision 1.36: +13 -5 lines
On second thought, expression_tree_walker should handle bare
SubLink nodes after all ...

Revision 1.36: download - view: text, markup, annotated - select for diffs
Sat Jun 19 03:41:45 1999 UTC (26 years, 2 months ago) by tgl
Branches: MAIN
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +210 -76 lines
Create a generic expression-tree-walker subroutine, which
will gradually replace all of the boilerplate tree-walk-recursion code that
currently exists in O(N) slightly different forms in N subroutines.
I've had it with adding missing cases to these subroutines...

Revision 1.35: download - view: text, markup, annotated - select for diffs
Tue May 25 22:41:46 1999 UTC (26 years, 3 months ago) by momjian
Branches: MAIN
Diff to: previous 1.34: preferred, colored
Changes since revision 1.34: +2 -2 lines
Another pgindent run.  Sorry folks.

Revision 1.34: download - view: text, markup, annotated - select for diffs
Tue May 25 16:09:50 1999 UTC (26 years, 3 months ago) by momjian
Branches: MAIN
Diff to: previous 1.33: preferred, colored
Changes since revision 1.33: +17 -17 lines
pgindent run over code.

Revision 1.33: download - view: text, markup, annotated - select for diffs
Mon May 10 00:45:24 1999 UTC (26 years, 4 months ago) by momjian
Branches: MAIN
Diff to: previous 1.32: preferred, colored
Changes since revision 1.32: +2 -2 lines
Change error messages to oids come out as %u and not %d.  Change has no
real affect now.

Revision 1.32: download - view: text, markup, annotated - select for diffs
Mon Mar 1 00:10:35 1999 UTC (26 years, 6 months ago) by tgl
Branches: MAIN
Diff to: previous 1.31: preferred, colored
Changes since revision 1.31: +6 -5 lines
Executor no longer cares about mergejoinop, mergerightorder, mergeleftorder,
so remove them from MergeJoin node.  Hack together a partial
solution for commuted mergejoin operators --- yesterday
a mergejoin int4 = int8 would crash if the planner decided to
commute it, today it works.  The planner's representation of
mergejoins really needs a rewrite though.
Also, further testing of mergejoin ops in opr_sanity regress test.

Revision 1.31: download - view: text, markup, annotated - select for diffs
Thu Feb 18 00:49:37 1999 UTC (26 years, 6 months ago) by momjian
Branches: MAIN
Diff to: previous 1.30: preferred, colored
Changes since revision 1.30: +2 -2 lines
Fix bushy plans.  Cleanup.

Revision 1.30: download - view: text, markup, annotated - select for diffs
Sun Feb 14 22:24:25 1999 UTC (26 years, 7 months ago) by tgl
Branches: MAIN
Diff to: previous 1.29: preferred, colored
Changes since revision 1.29: +88 -98 lines
Fix optimizer coredump with unary-operator WHERE clauses.
A test case is:
create table linetab (x line);
select * from linetab where ?| x;
which coredumps in 6.4.2 and current sources.

Revision 1.29: download - view: text, markup, annotated - select for diffs
Sat Feb 13 23:16:42 1999 UTC (26 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.28: preferred, colored
Changes since revision 1.28: +26 -26 lines
Change my-function-name-- to my_function_name, and optimizer renames.

Revision 1.28: download - view: text, markup, annotated - select for diffs
Wed Feb 3 21:16:51 1999 UTC (26 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.27: preferred, colored
Changes since revision 1.27: +7 -13 lines
Cleanup of source files where 'return' or 'var =' is alone on a line.

Revision 1.27: download - view: text, markup, annotated - select for diffs
Sun Jan 24 00:28:21 1999 UTC (26 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.26: preferred, colored
Changes since revision 1.26: +3 -3 lines
Rename Aggreg to Aggref.

Revision 1.26: download - view: text, markup, annotated - select for diffs
Fri Dec 4 15:34:14 1998 UTC (26 years, 9 months ago) by thomas
Branches: MAIN
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +37 -4 lines
Implement CASE expression.

Revision 1.25: download - view: text, markup, annotated - select for diffs
Fri Nov 27 19:52:07 1998 UTC (26 years, 9 months ago) by vadim
Branches: MAIN
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +2 -2 lines
New HeapTuple structure/interface.

Revision 1.24: download - view: text, markup, annotated - select for diffs
Tue Sep 1 04:30:02 1998 UTC (27 years ago) by momjian
Branches: MAIN
CVS tags: REL6_4
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +4 -4 lines
OK, folks, here is the pgindent output.

Revision 1.23: download - view: text, markup, annotated - select for diffs
Tue Sep 1 03:23:49 1998 UTC (27 years ago) by momjian
Branches: MAIN
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +18 -18 lines
Renaming cleanup, no pgindent yet.

Revision 1.22: download - view: text, markup, annotated - select for diffs
Mon Aug 31 07:55:47 1998 UTC (27 years ago) by momjian
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +3 -2 lines
Fix for regproc

Revision 1.21: download - view: text, markup, annotated - select for diffs
Mon Aug 31 07:19:56 1998 UTC (27 years ago) by momjian
Branches: MAIN
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +3 -4 lines
OR clause index fix

Revision 1.20: download - view: text, markup, annotated - select for diffs
Mon Aug 10 02:26:29 1998 UTC (27 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +4 -4 lines
Cleanup optimizer function names and clarify code.

Revision 1.19: download - view: text, markup, annotated - select for diffs
Sun Aug 9 04:59:06 1998 UTC (27 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +2 -2 lines
New pgindent.

Revision 1.18: download - view: text, markup, annotated - select for diffs
Fri Aug 7 05:02:22 1998 UTC (27 years, 1 month ago) by momjian
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +1 -3 lines
OPTIMIZER_DEBUG additions.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Mon Jun 15 19:28:47 1998 UTC (27 years, 3 months ago) by momjian
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +1 -23 lines
Remove un-needed braces around single statements.

Revision 1.16: download - view: text, markup, annotated - select for diffs
Thu Feb 26 04:33:11 1998 UTC (27 years, 6 months ago) by momjian
Branches: MAIN
CVS tags: release-6-3
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +28 -28 lines
pgindent run before 6.3 release, with Thomas' requested changes.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Feb 13 03:40:19 1998 UTC (27 years, 7 months ago) by vadim
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +20 -12 lines
Support for subselects.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Tue Jan 20 22:11:39 1998 UTC (27 years, 7 months ago) by momjian
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +3 -2 lines
Add Var.varlevelup to code.  More parser cleanup.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Dec 22 05:42:14 1997 UTC (27 years, 8 months ago) by momjian
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +3 -3 lines
Fix for select 1=1 or 2=2, select 1=1 and 2=2, and select sum(2+2).

Revision 1.12: download - view: text, markup, annotated - select for diffs
Thu Sep 25 12:48:15 1997 UTC (27 years, 11 months ago) by vadim
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +7 -17 lines
Fix handling of functions with non-attribute first argument in WHERE
clauses.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Mon Sep 8 21:45:47 1997 UTC (28 years ago) by momjian
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +42 -42 lines
Used modified version of indent that understands over 100 typedefs.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Mon Sep 8 20:56:19 1997 UTC (28 years ago) by momjian
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +4 -4 lines
Add typdefs to pgindent run.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Mon Sep 8 02:24:52 1997 UTC (28 years ago) by momjian
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +53 -53 lines
Another PGINDENT run that changes variable indenting and case label indenting.  Also static variable indenting.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Sun Sep 7 04:44:20 1997 UTC (28 years ago) by momjian
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +539 -491 lines
Massive commit to run PGINDENT on all *.c and *.h files.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Tue Aug 19 21:31:54 1997 UTC (28 years ago) by momjian
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +4 -2 lines
Make functions static where possible, enclose unused functions in #ifdef NOT_USED.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Wed Jan 22 06:30:57 1997 UTC (28 years, 7 months ago) by vadim
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +9 -1 lines
INDEXSCAN_PATCH changes: should work for (Param OP VAR) too
(but I didn't test FUNC OP PARAM and PARAM OP FUNC - no time)

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sat Nov 30 17:48:52 1996 UTC (28 years, 9 months ago) by momjian
Branches: MAIN
CVS tags: REL2_0B, REL2_0
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +4 -1 lines
As someone asked for this feature - patch for 1.09 follows.
Now You can do queries like

select sum(some_func(x)) from ...
select min(table1.x + table2.y) from table1, table2 where ...

and so on.

Vadim

Revision 1.4: download - view: text, markup, annotated - select for diffs
Wed Nov 6 09:29:22 1996 UTC (28 years, 10 months ago) by scrappy
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +2 -3 lines
More files cleaned out

Revision 1.3: download - view: text, markup, annotated - select for diffs
Tue Sep 10 06:48:41 1996 UTC (29 years ago) by scrappy
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +9 -1 lines
Fixes:

The problem is that the function arguments are not considered as possible key
candidates for index scan and so only a sequential scan is possible inside
the body of a function.  I have therefore made some patches to the optimizer
so that indices are now used also by functions.  I have also moved the plan
debug message from pg_eval to pg_plan so that it is printed also for plans
genereated for function execution.  I had also to add an index rescan to the
executor because it ignored the parameters set in the execution state, they
were flagged as runtime variables in ExecInitIndexScan but then never used
by the executor so that the scan were always done with any key=1. Very odd.
This means that an index rescan is now done twice for each function execution
which uses an index, the first time when the index scan is initialized and
the second when the actual function arguments are finally available for the
execution.  I don't know what is the cost of an double index scan but I
suppose it is anyway less than the cost of a full sequential scan, at leat
for large tables. This is my patch, you must also add -DINDEXSCAN_PATCH in
Makefile.global to enable the changes.

Submitted by: Massimo Dal Zotto <dz@cs.unitn.it>

Revision 1.2: download - view: text, markup, annotated - select for diffs
Thu Jul 25 20:36:46 1996 UTC (29 years, 1 month ago) by scrappy
Branches: MAIN
CVS tags: Release_2_0_0, Release_2_0, Release_1_0_3, Release_1_0_2
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +12 -2 lines
Fix applied for NESTLOOP bug

submitted by: vadim@sable.krasnoyarsk.su (Vadim B. Mikheev)

Revision 1.1.1.1 (vendor branch): download - view: text, markup, annotated - select for diffs
Tue Jul 9 06:21:38 1996 UTC (29 years, 2 months ago) by scrappy
Branches: PG95_DIST
CVS tags: PG95-1_01
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +0 -0 lines
Postgres95 1.01 Distribution - Virgin Sources

Revision 1.1: download - view: text, markup, annotated - select for diffs
Tue Jul 9 06:21:38 1996 UTC (29 years, 2 months ago) by scrappy
Branches: MAIN
Initial revision

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

PostgreSQL CVSweb <webmaster@postgresql.org>