Commit Graph

6307 Commits

Author SHA1 Message Date
Tom Lane 864412fd0a Recognize that IN subqueries return already-unique results if they use
UNION/INTERSECT/EXCEPT (without ALL).  This adds on to the previous
optimization for subqueries using DISTINCT.
2004-01-19 03:49:41 +00:00
Tom Lane 5c625a9326 Add a hash table to cache lookups of 'C'-language functions (that is,
dynamically loaded C functions).  Some limited testing suggests that
this puts the lookup speed for external functions just about on par
with built-in functions.  Per discussion with Eric Ridge.
2004-01-19 02:06:42 +00:00
Tom Lane be4b8a867f Don't use %s-with-precision format spec to truncate data being displayed
in a COPY error message.  It seems that glibc gets indigestion if it is
asked to truncate strings that contain invalid UTF-8 encoding sequences.
vsnprintf will return -1 in such cases, leading to looping and eventual
memory overflow in elog.c.  Instead use our own, more robust pg_mbcliplen
routine.  I believe this problem accounts for several recent reports of
unexpected 'out of memory' errors during COPY IN.
2004-01-18 02:15:29 +00:00
Tom Lane 6bdfde9a77 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.
2004-01-18 00:50:03 +00:00
Tom Lane de816a03c4 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.
2004-01-17 20:09:35 +00:00
Tom Lane 0966516b75 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.
2004-01-16 20:51:30 +00:00
Jan Wieck dfdd59e918 Adjusted calculation of shared memory requirements to new
ARC buffer replacement strategy.

Jan
2004-01-15 16:14:26 +00:00
Tom Lane cfd7fb7ed4 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.
2004-01-14 23:01:55 +00:00
Tom Lane d505f30281 pg_settings should have UPDATE privilege allowed to public. 2004-01-14 03:46:28 +00:00
Tom Lane 7562103f6e The no-updates-to-system-catalogs-unless-usecatupd restriction should
not apply to system views.  It never mattered before 7.4, but it does now.
2004-01-14 03:44:53 +00:00
Tom Lane 303a257b5f 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.
2004-01-14 03:39:22 +00:00
Tom Lane 67af5bace5 Fix another place that wasn't maintaining AND/OR flatness of an
already-canonicalized qual expression.
2004-01-12 22:20:28 +00:00
Tom Lane 5590be0a9e 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.
2004-01-12 20:48:15 +00:00
Dennis Bjorklund 1c15812c3c Translation updates 2004-01-11 19:42:44 +00:00
Neil Conway e97b8f2da9 Add CREATE TRIGGER, CREATE INDEX, and CREATE SEQUENCE to the list of
expressions supported by CREATE SCHEMA.

Also added the beginning of some regression tests for CREATE SCHEMA;
plenty more work is needed here.
2004-01-11 04:58:17 +00:00
Bruce Momjian 4cdf51e646 Drops in the CreateProcess calls for Win32 (essentially wrapping up the
fork/exec portion of the port), and fixes a handful of whitespace issues

Claudio Natoli
2004-01-11 03:49:31 +00:00
Neil Conway 98dcf085e3 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.
2004-01-10 23:28:45 +00:00
Tom Lane a43f4307f7 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.
2004-01-10 18:13:53 +00:00
Dennis Bjorklund 47f8f33409 Translation updates 2004-01-10 15:02:50 +00:00
Dennis Bjorklund bbefabfd55 Translation updates 2004-01-10 10:39:26 +00:00
Bruce Momjian a620a760ed Allow BEGIN WORK to specify transaction isolation level, like START
TRANSACTION.
2004-01-10 02:21:08 +00:00
Tom Lane e439fef6fc 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.
2004-01-10 00:30:21 +00:00
Bruce Momjian 2afa36be9d Remove ereport() from failed connection; already done, per Tom. 2004-01-09 23:27:20 +00:00
Bruce Momjian 9640cc7dfa Fix for cancel key restarting postmaster, from Claudio 2004-01-09 23:11:39 +00:00
Bruce Momjian 38081fd000 Change PG_DELAY from msec to usec and use it consistenly rather than
select().   Add Win32 Sleep() for delay.
2004-01-09 21:08:50 +00:00
Bruce Momjian ee7fbb1eaa Add WIN32 pipe implementation that uses sockets.
Claudio Natoli
2004-01-09 04:58:09 +00:00
Bruce Momjian 0d2148a71e Remove duplicate include of value.h. I think it got in because Tom and I both added it. 2004-01-09 03:07:32 +00:00
Bruce Momjian 0150dbdce5 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.
2004-01-09 02:02:43 +00:00
Tom Lane 92ff092d40 [Forced commit to add log message that I fat-fingered last time]
Give a more reasonable error message when lock file exists but has
zero length; prior code confused this with could-not-read-file case.
2004-01-08 06:01:21 +00:00
Tom Lane 4f913efe73 make 2004-01-07 23:03:06 +00:00
Tom Lane cad5f4a8c4 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.
2004-01-07 22:02:48 +00:00
Tom Lane 2bc0c8b2b7 Add missing inclusion of nodes/value.h. 2004-01-07 21:12:56 +00:00
Neil Conway 192ad63bd7 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.
2004-01-07 18:56:30 +00:00
Neil Conway afca5d50dc Cleanup: move the 'Value' node into a separate file, rather than putting
it in the same file as the 'List' node.
2004-01-07 18:43:36 +00:00
Tom Lane a77e32d7c5 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.
2004-01-06 23:55:19 +00:00
Bruce Momjian 488f2785d0 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.

Claudio Natoli
2004-01-06 23:15:22 +00:00
Tom Lane 06288d4e22 Suppress compiler warning (xlog_outrec is unused if not WAL_DEBUG). 2004-01-06 22:22:37 +00:00
Neil Conway dfc7e7b71d 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
2004-01-06 18:07:32 +00:00
Neil Conway 030f8e7313 Remove unused 'noversion' command-line option processing from the
backend.
2004-01-06 17:36:31 +00:00
Neil Conway bc028beb16 Make the 'wal_debug' GUC variable a boolean (rather than an integer), and
hide it behind #ifdef WAL_DEBUG blocks.
2004-01-06 17:26:23 +00:00
Tom Lane b0c4a50bbb 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.
2004-01-06 04:31:01 +00:00
Tom Lane fa559a86ee 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.
2004-01-05 23:39:54 +00:00
Neil Conway 5d472f6464 Trivial refactoring: move analysis of ViewStmt into its own function for
readability and for the sake of consistency with the rest of analyze.c
2004-01-05 20:58:58 +00:00
Neil Conway 548523533f Fix three trivial typos in comments. 2004-01-05 20:36:04 +00:00
Tom Lane 5c74ce23db 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.
2004-01-05 18:04:39 +00:00
Tom Lane cce442da6d Dept. of second thoughts: clause_selectivity shouldn't try to cache its
result for jointypes associated with IN processing.
2004-01-05 16:44:40 +00:00
Tom Lane 9091e8d1b2 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.
2004-01-05 05:07:36 +00:00
Tom Lane 187b190adb 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.
2004-01-04 05:57:21 +00:00
Tom Lane 558ed5aee1 Fix discrepancy in prototypes for HPUX pg_dlerror. 2004-01-04 04:06:37 +00:00
Tom Lane 82b4dd394f 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.
2004-01-04 03:51:52 +00:00