Tom Lane [Thu, 5 Dec 2002 21:46:37 +0000 (21:46 +0000)]
Avoid pulling up sublinks from a subselect's targetlist. Works around
problems that occur if sublink is referenced via a join alias variable.
Perhaps this can be improved later, but a simple and safe fix is needed
for 7.3.1.
Tom Lane [Thu, 5 Dec 2002 15:50:39 +0000 (15:50 +0000)]
Phase 1 of read-only-plans project: cause executor state nodes to point
to plan nodes, not vice-versa. All executor state nodes now inherit from
struct PlanState. Copying of plan trees has been simplified by not
storing a list of SubPlans in Plan nodes (eliminating duplicate links).
The executor still needs such a list, but it can build it during
ExecutorStart since it has to scan the plan tree anyway.
No initdb forced since no stored-on-disk structures changed, but you
will need a full recompile because of node-numbering changes.
Tom Lane [Wed, 4 Dec 2002 20:00:37 +0000 (20:00 +0000)]
Repair oversight in recent change of dependency extraction code: when
recursing to handle a join alias var, the context had better be set to
be appropriate to the join var's query level. Per report from Hristo Neshev.
Tom Lane [Sun, 1 Dec 2002 21:05:14 +0000 (21:05 +0000)]
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.
Tom Lane [Sun, 1 Dec 2002 20:27:32 +0000 (20:27 +0000)]
Fix ExecMakeTableFunctionResult() to work with generic expressions as
well as function calls. This is needed for cases where the planner has
constant-folded or inlined the original function call. Possibly we should
back-patch this change into 7.3 branch as well.
Tom Lane [Sun, 1 Dec 2002 18:14:22 +0000 (18:14 +0000)]
Run COPY OUT in a temporary memory context that's reset once per row,
and eliminate its manual pfree() calls. This solves the encoding-conversion
bug recently reported, and should be faster and more robust than the
original coding anyway. For example, we are no longer at risk if
datatype output routines leak memory or choose to return a constant string.
Tom Lane [Sat, 30 Nov 2002 21:25:08 +0000 (21:25 +0000)]
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.
Tom Lane [Sat, 30 Nov 2002 00:08:22 +0000 (00:08 +0000)]
Upgrade planner and executor to allow multiple hash keys for a hash join,
instead of only one. This should speed up planning (only one hash path
to consider for a given pair of relations) as well as allow more effective
hashing, when there are multiple hashable joinclauses.
Tom Lane [Fri, 29 Nov 2002 21:39:12 +0000 (21:39 +0000)]
Tighten selection of equality and ordering operators for grouping
operations: make sure we use operators that are compatible, as determined
by a mergejoin link in pg_operator. Also, add code to planner to ensure
we don't try to use hashed grouping when the grouping operators aren't
marked hashable.
Tom Lane [Tue, 26 Nov 2002 03:01:59 +0000 (03:01 +0000)]
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.
Tom Lane [Mon, 25 Nov 2002 18:12:12 +0000 (18:12 +0000)]
Restructure outfuncs and readfuncs to use macros in the same style as
just done for copyfuncs/equalfuncs. Read functions in particular get
a lot shorter than before, and it's much easier to compare an out function
with the corresponding read function to make sure they agree.
initdb forced due to small changes in nodestring format (regularizing
a few cases that were formerly idiosyncratic).
Tom Lane [Mon, 25 Nov 2002 03:33:27 +0000 (03:33 +0000)]
Restructure the code in copyfuncs and equalfuncs to put much heavier
reliance on macros, in hopes of eliminating silly typos (like copying
to the wrong field) and just generally making it easier to see the forest
instead of the trees. As an example, here is the new code for A_Indices:
I'm sending you a small patch to pgdb.py module. This
raises pgdb.DatabaseError when any of the fetch*
methods was invoked but previous call to execute* did
not produce any result set or no call was issued yet.
Also, raises pgdb.NotSupportedError when .nextset() is
invoked, instead of NameError.
Change the pkey method so that the caller can optionally set the dictionary
used for the primary key lookup. This will prevent a database lookup
for each connection object that gets created. This could be a significant
optimization on a busy system.
Similarly, the get_attnames method allows for the attributes dictionary
to be installed directly.
Change the debug variable to allow better control by the caller over how
debug output is managed. The user can continue to use the current method
of passing a formatting string to have a replacement done and output will
be sent to the standard output exactly as it did before. In addition they
can set it to a file object, sys.stderr for example, and the query string
will be printed to it. Thay can also set it to a method (function) and the
query string will be passed to that method giving them the maximum flexibility
to do whatever they want with the query string.
I will be working with the PyGreSQL documentation shortly and at that time
will properly document this feature.
Tom Lane [Sun, 24 Nov 2002 21:52:15 +0000 (21:52 +0000)]
Restructure planning of nestloop inner indexscans so that the set of usable
joinclauses is determined accurately for each join. Formerly, the code only
considered joinclauses that used all of the rels from the outer side of the
join; thus for example
FROM (a CROSS JOIN b) JOIN c ON (c.f1 = a.x AND c.f2 = b.y)
could not exploit a two-column index on c(f1,f2), since neither of the
qual clauses would be in the joininfo list it looked in. The new code does
this correctly, and also is able to eliminate redundant clauses, thus fixing
the problem noted 24-Oct-02 by Hans-Jürgen Schönig.
Bruce Momjian [Sun, 24 Nov 2002 03:15:55 +0000 (03:15 +0000)]
7.4devel now supports SQL:1999's "enhanced trigger capability" (which
is just FOR EACH STATEMENT triggers, AFAICS); this patch updates the
SQL conformance docs to note that.
Bruce Momjian [Sat, 23 Nov 2002 04:06:32 +0000 (04:06 +0000)]
Heres a patch which will create the sql_help.h file on Win32 if it
doesn't already exist using an installed copy of perl. I've tested it
using perl v5.6.1 from ActiveState and all appears to work.
Bruce Momjian [Sat, 23 Nov 2002 03:59:09 +0000 (03:59 +0000)]
This patch implements FOR EACH STATEMENT triggers, per my email to
-hackers a couple days ago.
Notes/caveats:
- added regression tests for the new functionality, all
regression tests pass on my machine
- added pg_dump support
- updated PL/PgSQL to support per-statement triggers; didn't
look at the other procedural languages.
- there's (even) more code duplication in trigger.c than there
was previously. Any suggestions on how to refactor the
ExecXXXTriggers() functions to reuse more code would be
welcome -- I took a brief look at it, but couldn't see an
easy way to do it (there are several subtly-different
versions of the code in question)
- updated the documentation. I also took the liberty of
removing a big chunk of duplicated syntax documentation in
the Programmer's Guide on triggers, and moving that
information to the CREATE TRIGGER reference page.
- I also included some spelling fixes and similar small
cleanups I noticed while making the changes. If you'd like
me to split those into a separate patch, let me know.
Bruce Momjian [Sat, 23 Nov 2002 03:50:50 +0000 (03:50 +0000)]
When I made the cube(text) function for 7.3, I neglected to add a
matching create cast command. The attached diff adds a create cast as
assignment to cube.sql.in .
Tom Lane [Fri, 22 Nov 2002 22:10:01 +0000 (22:10 +0000)]
Redesign internal logic of nodeLimit so that it does not need to fetch
one more row from the subplan than the COUNT would appear to require.
This costs a little more logic but a number of people have complained
about the old implementation.
Tom Lane [Fri, 22 Nov 2002 16:25:32 +0000 (16:25 +0000)]
Fix a dozen or so places that were passing unpredictable data strings
as elog format strings. Hai-Chen Tu pointed out the problem in
contrib/dbmirror, but it wasn't the only such error.
Tom Lane [Thu, 21 Nov 2002 23:31:20 +0000 (23:31 +0000)]
Fix breakage in new-in-7.3 timetz_zone() function: was giving random
results due to doing arithmetic on uninitialized values. Add some
documentation about the AT TIME ZONE construct. Update some other
date/time documentation that seemed out of date for 7.3.
Tom Lane [Thu, 21 Nov 2002 06:36:08 +0000 (06:36 +0000)]
Code review for superuser_reserved_connections patch. Don't try to do
database access outside a transaction; revert bogus performance improvement
in SIBackendInit(); improve comments; add documentation (this part courtesy
Neil Conway).
Tom Lane [Thu, 21 Nov 2002 04:40:26 +0000 (04:40 +0000)]
NetBSD versions 1.6 and (we hope) later can use the standard geometry
comparison file, instead of geometry-positive-zeros. Per report from
Patrick Welche.
Tom Lane [Thu, 21 Nov 2002 00:42:20 +0000 (00:42 +0000)]
Finish implementation of hashed aggregation. Add enable_hashagg GUC
parameter to allow it to be forced off for comparison purposes.
Add ORDER BY clauses to a bunch of regression test queries that will
otherwise produce randomly-ordered output in the new regime.
Barry Lind [Wed, 20 Nov 2002 07:34:32 +0000 (07:34 +0000)]
Fixed bug reported by Marko Strukelj and Keith Wannamaker. Using executeBatch
on a preparedStatement would reset the prepared statment causing subsequent
uses of the preparedStatement to fail (i.e. the following series of calls
would fail: addBatch() executeBatch() addBatch() executBatch()). This is
a regression from 7.2 where this worked correctly. The regression test has
also been modified to explicitly test for this case.
Tom Lane [Tue, 19 Nov 2002 23:22:00 +0000 (23:22 +0000)]
Add an at-least-marginally-plausible method of estimating the number
of groups produced by GROUP BY. This improves the accuracy of planning
estimates for grouped subselects, and is needed to check whether a
hashed aggregation plan risks memory overflow.