Tom Lane [Sun, 18 Jan 2004 00:50:03 +0000 (00:50 +0000)]
When testing whether a sub-plan can do projection, use a general-purpose
check instead of hardwiring assumptions that only certain plan node types
can appear at the places where we are testing. This was always a pretty
fragile assumption, and it turns out to be broken in 7.4 for certain cases
involving IN-subselect tests that need type coercion.
Also, modify code that builds finished Plan tree so that node types that
don't do projection always copy their input node's targetlist, rather than
having the tlist passed in from the caller. The old method makes it too
easy to write broken code that thinks it can modify the tlist when it
cannot.
Tom Lane [Sat, 17 Jan 2004 20:09:35 +0000 (20:09 +0000)]
Repair misestimation of indexscan CPU costs. When an indexqual contains
a run-time key (that is, a nonconstant expression compared to the index
variable), the key is evaluated just once per scan, but we were charging
costs as though it were evaluated once per visited index entry.
Tom Lane [Fri, 16 Jan 2004 20:51:30 +0000 (20:51 +0000)]
Tighten short-circuit tests for deciding whether we need to invoke
tuptoaster.c --- fields that are compressed in-line are not a reason
to invoke the toaster. Along the way, add a couple more htup.h macros
to eliminate confusing negated tests, and get rid of the already
vestigial TUPLE_TOASTER_ACTIVE symbol.
Tom Lane [Wed, 14 Jan 2004 23:01:55 +0000 (23:01 +0000)]
Fix permission-checking bug reported by Tim Burgess 10-Feb-03 (this time
for sure...). Rather than relying on the query context of a rangetable
entry to identify what permissions it wants checked, store a full AclMode
mask in each RTE, and check exactly those bits. This allows an RTE
specifying, say, INSERT privilege on a view to be copied into a derived
UPDATE query without changing meaning. Per recent discussion thread.
initdb forced due to change of stored rule representation.
Tom Lane [Wed, 14 Jan 2004 03:39:22 +0000 (03:39 +0000)]
Revert ill-starred change of 13-Feb-02: it appeared to fix a problem of
incorrect permissions checking, but in fact disabled most all permissions
checks for view updates. This corrects problems reported by Sergey
Yatskevich among others, at the cost of re-introducing the problem
previously reported by Tim Burgess. However, since we'd lived with that
problem for quite awhile without knowing it, we can live with it awhile
longer until a proper fix can be made in 7.5.
Tom Lane [Mon, 12 Jan 2004 20:48:15 +0000 (20:48 +0000)]
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.
Neil Conway [Sat, 10 Jan 2004 23:28:45 +0000 (23:28 +0000)]
Implement "WITH / WITHOID OIDS" clause for CREATE TABLE AS. This is
intended to allow application authors to insulate themselves from
changes to the default value of 'default_with_oids' in future releases
of PostgreSQL.
This patch also fixes a bug in the earlier implementation of the
'default_with_oids' GUC variable: code in gram.y should not examine
the value of GUC variables directly due to synchronization issues.
Tom Lane [Sat, 10 Jan 2004 18:13:53 +0000 (18:13 +0000)]
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.
Tom Lane [Sat, 10 Jan 2004 00:30:21 +0000 (00:30 +0000)]
Fix subquery pullup logic to not be fooled when a view that appears
'simple' references another view that is not simple. Must recheck
conditions after performing recursive pullup. Per example from
Laurent Perez, 9-Jan-04.
Bruce Momjian [Fri, 9 Jan 2004 02:02:43 +0000 (02:02 +0000)]
Allow libpq to do thread-safe SIGPIPE handling. This allows it to
ignore SIGPIPE from send() in libpq, but terminate on any other SIGPIPE,
unless the user installs their own signal handler.
This is a minor fix because the only time you get SIGPIPE from libpq's
send() is when the backend dies.
Tom Lane [Thu, 8 Jan 2004 23:40:27 +0000 (23:40 +0000)]
Remove broken (and unnecessary) definition of operator <> for _int4
datatype; the generic array comparators added in 7.4 supersede this.
Per report and patch from Korea PostgreSQL Users' Group.
Tom Lane [Wed, 7 Jan 2004 22:02:48 +0000 (22:02 +0000)]
Make some improvements in the intelligence of the partial-index
predicate tester. It can now deal with commuted clauses (for
instance, 4 < x implies x > 3), subclauses more complicated than
a simple Var (for example, upper(x) = 't' implies upper(x) > 'a'),
and <> operators (for example, x < 3 implies x <> 4). Still
only understands operators associated with btree opclasses, though.
Inspired by example from Martin Hampl.
Neil Conway [Wed, 7 Jan 2004 18:56:30 +0000 (18:56 +0000)]
More janitorial work: remove the explicit casting of NULL literals to a
pointer type when it is not necessary to do so.
For future reference, casting NULL to a pointer type is only necessary
when (a) invoking a function AND either (b) the function has no prototype
OR (c) the function is a varargs function.
Tom Lane [Wed, 7 Jan 2004 06:20:02 +0000 (06:20 +0000)]
Support function parameter names in plpgsql. This is the last of
Dennis Bjorklund's original patch for function parameter names, but
there's still plenty left to do (documentation for instance...)
Tom Lane [Tue, 6 Jan 2004 23:55:19 +0000 (23:55 +0000)]
Apply the core parts of Dennis Bjorklund's patch to allow function
parameters to be declared with names. pg_proc has a column to store
names, and CREATE FUNCTION can insert data into it, but that's all as
yet. I need to do more work on the pg_dump and plpgsql portions of the
patch before committing those, but I thought I'd get the bulky changes
in before the tree drifts under me.
initdb forced due to pg_proc change.
Bruce Momjian [Tue, 6 Jan 2004 23:15:22 +0000 (23:15 +0000)]
Final rearrangement of main postgresql child process (ie.
BackendFork/SSDataBase/pgstat) startup, to allow fork/exec calls to
closely mimic (the soon to be provided) Win32 CreateProcess equivalent
calls.
Neil Conway [Tue, 6 Jan 2004 18:07:32 +0000 (18:07 +0000)]
Code cleanup, mostly in the smgr:
- Update comment in IsReservedName() to the present day
- Improve some variable & function names in commands/vacuum.c. I
was planning to rewrite this to avoid lappend(), but since I
still intend to do the list rewrite, there's no need for that.
- Update some smgr comments which seemed to imply that we still
forced all dirty pages to disk at commit-time.
- Replace some #ifdef DIAGNOSTIC code with assertions.
- Make the distinction between OS-level file descriptors and
virtual file descriptors a little clearer in a few comments
- Other minor comment improvements in the smgr code
Tom Lane [Tue, 6 Jan 2004 04:31:01 +0000 (04:31 +0000)]
Instead of rechecking lossy index operators by putting them into the
regular qpqual ('filter condition'), add special-purpose code to
nodeIndexscan.c to recheck them. This ends being almost no net addition
of code, because the removal of planner code balances out the extra
executor code, but it is significantly more efficient when a lossy
operator is involved in an OR indexscan. The old implementation had
to recheck the entire indexqual in such cases.
Tom Lane [Mon, 5 Jan 2004 23:39:54 +0000 (23:39 +0000)]
Adjust indexscan planning logic to keep RestrictInfo nodes associated
with index qual clauses in the Path representation. This saves a little
work during createplan and (probably more importantly) allows reuse of
cached selectivity estimates during indexscan planning. Also fix latent
bug: wrong plan would have been generated for a 'special operator' used
in a nestloop-inner-indexscan join qual, because the special operator
would not have gotten into the list of quals to recheck. This bug is
only latent because at present the special-operator code could never
trigger on a join qual, but sooner or later someone will want to do it.
Tom Lane [Mon, 5 Jan 2004 18:04:39 +0000 (18:04 +0000)]
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.
Tom Lane [Mon, 5 Jan 2004 05:07:36 +0000 (05:07 +0000)]
Add the ability to extract OR indexscan conditions from OR-of-AND
join conditions in which each OR subclause includes a constraint on
the same relation. This implements the other useful side-effect of
conversion to CNF format, without its unpleasant side-effects. As
per pghackers discussion of a few weeks ago.
Tom Lane [Sun, 4 Jan 2004 05:57:21 +0000 (05:57 +0000)]
There's no longer any good reason for genbki.sh and Gen_fmgrtab.sh to
run the data through cpp, and we know of at least one platform where
unusual cpp behavior breaks the process. So remove the cpp step,
and make consequent simplifications.
Tom Lane [Sun, 4 Jan 2004 03:51:52 +0000 (03:51 +0000)]
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.
Tom Lane [Sun, 4 Jan 2004 00:07:32 +0000 (00:07 +0000)]
Rewrite OR indexscan processing to be more flexible. We can now for the
first time generate an OR indexscan for a two-column index when the WHERE
condition is like 'col1 = foo AND (col2 = bar OR col2 = baz)' --- before,
the OR had to be on the first column of the index or we'd not notice the
possibility of using it. Some progress towards extracting OR indexscans
from subclauses of an OR that references multiple relations, too, although
this code is #ifdef'd out because it needs more work.
Tom Lane [Thu, 1 Jan 2004 19:27:15 +0000 (19:27 +0000)]
Do an explicit fflush after writing a progress message with puts.
This ensures stdout is kept in sync with messages on stderr.
Per report from Olaf Ferger.
Tom Lane [Tue, 30 Dec 2003 23:53:15 +0000 (23:53 +0000)]
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.