Commit Graph

15227 Commits

Author SHA1 Message Date
Tom Lane 1daac8e165 Document return-value conventions used by this implementation, per
suggestion from Bruce.
2005-12-05 21:57:00 +00:00
Tom Lane 8cb4e4f6bd Add regression test to see if the min/max values of int8 convert correctly. 2005-12-05 04:13:38 +00:00
Tom Lane 3311c7669a Fix a rather sizable number of problems in our homegrown snprintf, such as
incorrect implementation of argument reordering, arbitrary limit of output
size for sprintf and fprintf, willingness to access more bytes than "%.Ns"
specification allows, wrong formatting of LONGLONG_MIN, various field-padding
bugs and omissions.  I believe it now accurately implements a subset of
the Single Unix Spec requirements (remaining unimplemented features are
documented, too).  Bruce Momjian and Tom Lane.
2005-12-05 02:39:38 +00:00
Tom Lane e4a9229d55 Treat procedural languages as owned by the bootstrap superuser, rather
than owned by nobody.  This results in cleaner display of language ACLs,
since the backend's aclchk.c uses the same convention.  AFAICS there is
no practical difference but it's nice to avoid emitting SET SESSION
AUTHORIZATION; also this will make it easier to transition pg_dump to
some future version in which we may include an explicit ownership column
in pg_language.  Per gripe from David Begley.
2005-12-03 21:06:18 +00:00
Tom Lane 6d4bcda38c Fix out-of-order inclusion of -L switches from LDFLAGS on AIX and HPUX.
Per example from Dirk Pirschel.
2005-12-03 20:16:31 +00:00
Bruce Momjian d20901a39b Allow to_char(interval) and to_char(time) to use AM/PM specifications.
Map them to a single day, so '30 hours' is 'AM'.

Have to_char(interval) and to_char(time) use "HH", "HH12" as 12-hour
intervals, rather than bypass and print the full interval hours.  This
is neeeded because to_char(time) is mapped to interval in this function.
Intervals should use "HH24", and document suggestion.

Allow "D" format specifiers for interval/time.
2005-12-03 16:45:06 +00:00
Tom Lane a98871b7ac Tweak indexscan machinery to avoid taking an AccessShareLock on an index
if we already have a stronger lock due to the index's table being the
update target table of the query.  Same optimization I applied earlier
at the table level.  There doesn't seem to be much interest in the more
radical idea of not locking indexes at all, so do what we can ...
2005-12-03 05:51:03 +00:00
Tom Lane 6f5efe3d16 Fix obsolete comment. 2005-12-02 22:06:07 +00:00
Tom Lane d780f07ac1 Adjust scan plan nodes to avoid getting an extra AccessShareLock on a
relation if it's already been locked by execMain.c as either a result
relation or a FOR UPDATE/SHARE relation.  This avoids an extra trip to
the shared lock manager state.  Per my suggestion yesterday.
2005-12-02 20:03:42 +00:00
Michael Meskes 5106aff99a Added special handling of CONNECTION variable that is used by ECPG instead of given to the backend. 2005-12-02 15:03:57 +00:00
Bruce Momjian cf17131767 Remove comment on errno=0 lines, but add mention to port/strtol.c function. 2005-12-02 02:49:11 +00:00
Tom Lane de1dfc1209 Rearrange code in ExecInitBitmapHeapScan so that we don't initialize the
child plan nodes until we have acquired lock on the relation to scan.
The relative order of initialization of plan nodes isn't real important in
other cases, but it's critical here because one is supposed to lock a
relation before its indexes, not vice versa.  The original coding was at
least vulnerable to deadlock against DROP INDEX, and perhaps worse things.
2005-12-02 01:29:55 +00:00
Bruce Momjian 8c8c0108e8 Add comment to pg_atoi. 2005-12-01 21:16:13 +00:00
Bruce Momjian 0e6b1528b7 Comment "errno = 0" in a more generic way. 2005-12-01 21:11:58 +00:00
Tom Lane ace17c1d82 Retry in FileRead and FileWrite if Windows returns ERROR_NO_SYSTEM_RESOURCES.
Also add a retry for Unixen returning EINTR, which hasn't been reported
as an issue but at least theoretically could be.  Patch by Qingqing Zhou,
some minor adjustments by me.
2005-12-01 20:24:18 +00:00
Bruce Momjian 277b2ea328 Add comments about why errno is set to zero. 2005-12-01 20:06:37 +00:00
Tom Lane 814acfcc3a Check for overflow in strtol() while parsing datetime inputs.
Michael Fuhr.
2005-12-01 17:56:34 +00:00
Alvaro Herrera 7415e083e4 Refactor some bits in aclchk.c in order to reduce code duplication. 2005-12-01 02:03:01 +00:00
Tom Lane 164442fe7f Rearrange code in pg_atoi() to avoid assuming that isspace() cannot
change errno.  No reported bugs here, but why take a chance?
2005-11-30 23:10:08 +00:00
Tom Lane bae3fefd4a Tweak choose_bitmap_and() heuristics in the light of example provided in bug
#2075: consider an index redundant if any of its index conditions were already
used, rather than if all of them were.  Also, make the selectivity comparison
a bit fuzzy, so that very small differences in estimated selectivities don't
skew the results.
2005-11-30 17:10:19 +00:00
Michael Meskes 150131d9d9 - Made several variables "const char *" instead of "char *" as proposed by Qingqing Zhou <zhouqq@cs.toronto.edu>.
- Replaced all strdup() calls by ECPGstrdup().
- Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1.
2005-11-30 12:49:49 +00:00
Tom Lane 9a39423436 Fix EXPLAIN and EXECUTE commands to pass portal parameters through to
the executor.  This allows, for example, JDBC clients to use '?' bound
parameters in these commands.  Per gripe from Virag Saksena.
2005-11-29 01:25:50 +00:00
Tom Lane 4ab76b1c20 Tweak hash join code to use an additional heuristic for deciding whether
it's worth probing the outer relation for emptiness before building the
hash table.  To wit, if we're rescanning a join previously performed,
remember whether we found it nonempty the previous time, and don't bother
with the probe if it was nonempty.  This buys back the performance lost
in examples like Mario Weilguni's.
2005-11-28 23:46:03 +00:00
Tom Lane 200545039c Come to think of it, the backend doesn't use -lz either. 2005-11-28 22:43:30 +00:00
Tom Lane a2c43740d5 Don't link readline and supporting libraries into the backend.
After a proposal by Martijn van Oosterhout (not exactly his patch though).
2005-11-28 22:06:39 +00:00
Alvaro Herrera f1713078c5 Install a more future-proof fix for the snapshot-unset bug just found.
Per suggestion from Tom Lane.
2005-11-28 17:23:11 +00:00
Tom Lane b79cb1eea1 Recent changes to allow hash join to exit early given empty input from
one child or the other had a problem: they did not leave the node in a
state that ExecReScanHashJoin would understand.  In particular it would
tend to fail to reset the child plans when needed.  Per report from
Mario Weilguni.
2005-11-28 17:14:23 +00:00
Alvaro Herrera d4fc4ac4c7 Set a snapshot before running analyze on a single table, to avoid a
crash when analyzing tables with expressional indexes.

Per report from Frank van Vugt.
2005-11-28 13:35:09 +00:00
Alvaro Herrera ec9f81b4ae Install pg_regress where PGXS' "make installcheck" can find it. 2005-11-28 12:03:56 +00:00
Tom Lane 3d376fce8d Change the parser to translate "foo [NOT] IN (expression-list)" to
ScalarArrayOpExpr when possible, that is, whenever there is an array type
for the values of the expression list.  This completes the project I've
been working on to improve the speed of index searches with long IN lists,
as per discussion back in mid-October.

I did not force initdb, but until you do one you will see failures in the
"rules" regression test, because some of the standard system views use IN
and their compiled formats have changed.
2005-11-28 04:35:32 +00:00
Tom Lane 8a9acd3c41 Teach predtest.c how to reason about ScalarArrayOpExpr clauses as though
they were broken-out AND or OR lists.  The least grotty way to do this
seemed to be to set up a general mechanism for handling nodes as though
they were ANDs or ORs.  There's no other immediate use for it, but perhaps
we might want to use the mechanism someday for things like BETWEEN
SYMMETRIC.
2005-11-27 22:15:42 +00:00
Tom Lane 1b68a88f22 Add missing semicolon. Recent versions of bison seem to choke on this,
per buildfarm report from platypus, even though older versions let it pass.
2005-11-27 01:22:23 +00:00
Tom Lane da27c0a1ef Teach tid-scan code to make use of "ctid = ANY (array)" clauses, so that
"ctid IN (list)" will still work after we convert IN to ScalarArrayOpExpr.
Make some minor efficiency improvements while at it, such as ensuring that
multiple TIDs are fetched in physical heap order.  And fix EXPLAIN so that
it shows what's really going on for a TID scan.
2005-11-26 22:14:57 +00:00
Tom Lane a66e2c8885 Teach push_nots() how to negate a ScalarArrayOpExpr. In passing, save
a palloc or two in the OpExpr case.
2005-11-26 18:07:40 +00:00
Tom Lane 4c4eb57154 Some marginal additional hacking to shave a few more cycles off
heapgettup.
2005-11-26 05:03:06 +00:00
Tom Lane 70f1482de3 Change seqscan logic so that we check visibility of all tuples on a page
when we first read the page, rather than checking them one at a time.
This allows us to take and release the buffer content lock just once
per page, instead of once per tuple.  Since it's a shared lock the
contention penalty for holding the lock longer shouldn't be too bad.
We can safely do this only when using an MVCC snapshot; else the
assumption that visibility won't change over time is uncool.  Therefore
there are now two code paths depending on the snapshot type.  I also
made the same change in nodeBitmapHeapscan.c, where it can be done always
because we only support MVCC snapshots for bitmap scans anyway.
Also make some incidental cleanups in the APIs of these functions.
Per a suggestion from Qingqing Zhou.
2005-11-26 03:03:07 +00:00
Tom Lane 290166f934 Teach planner and executor to handle ScalarArrayOpExpr as an indexable
qualification when the underlying operator is indexable and useOr is true.
That is, indexkey op ANY (ARRAY[...]) is effectively translated into an
OR combination of one indexscan for each array element.  This only works
for bitmap index scans, of course, since regular indexscans no longer
support OR'ing of scans.  There are still some loose ends to clean up
before changing 'x IN (list)' to translate as a ScalarArrayOpExpr;
for instance predtest.c ought to be taught about it.  But this gets the
basic functionality in place.
2005-11-25 19:47:50 +00:00
Tom Lane dab52ab13d Improve ExecStoreTuple to be smarter about replacing the contents of
a TupleTableSlot: instead of calling ExecClearTuple, inline the needed
operations, so that we can avoid redundant steps.  In particular, when
the old and new tuples are both on the same disk page, avoid releasing
and re-acquiring the buffer pin --- this saves work in both the bufmgr
and ResourceOwner modules.  To make this improvement actually useful,
partially revert a change I made on 2004-04-21 that caused SeqNext
et al to call ExecClearTuple before ExecStoreTuple.  The motivation
for that, to avoid grabbing the BufMgrLock separately for releasing
the old buffer and grabbing the new one, no longer applies.  My
profiling says that this saves about 5% of the CPU time for an
all-in-memory seqscan.
2005-11-25 04:24:48 +00:00
Tom Lane 4dd2048a47 Get rid of ExecAssignResultTypeFromOuterPlan() and make all plan node types
generate their output tuple descriptors from their target lists (ie, using
ExecAssignResultTypeFromTL()).  We long ago fixed things so that all node
types have minimally valid tlists, so there's no longer any good reason to
have two different ways of doing it.  This change is needed to fix bug
reported by Hayden James: the fix of 2005-11-03 to emit the correct column
names after optimizing away a SubqueryScan node didn't work if the new
top-level plan node used ExecAssignResultTypeFromOuterPlan to generate its
tupdesc, since the next plan node down won't have the correct column labels.
2005-11-23 20:27:58 +00:00
Tom Lane 19ff959bff Fix problems with rewriter failing to set Query.hasSubLinks when inserting
a SubLink expression into a rule query.  Pre-8.1 we essentially did this
unconditionally; 8.1 tries to do it only when needed, but was missing a
couple of cases.  Per report from Kyle Bateman.  Add some regression test
cases covering this area.
2005-11-23 17:21:04 +00:00
Bruce Momjian aac96b8994 Fix pgindent of libpq-fe.h by hacking pgindent script.
Remove pgbench comment that was causing problems.
2005-11-23 04:23:30 +00:00
Tom Lane e96925fba7 Fix up comment munged by pg_indent. (Not pg_indent's fault; should have
protected comment with dashes the first time round.)
2005-11-22 22:30:33 +00:00
Bruce Momjian 436a2956d8 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.
2005-11-22 18:17:34 +00:00
Andrew Dunstan 5b352d8e12 DROP DATABASE IF EXISTS variant 2005-11-22 15:24:18 +00:00
Alvaro Herrera cec3b0a9e6 Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the
process of dropping roles by dropping objects owned by them and privileges
granted to them, or giving the owned objects to someone else, through the
use of the data stored in the new pg_shdepend catalog.

Some refactoring of the GRANT/REVOKE code was needed, as well as ALTER OWNER
code.  Further cleanup of code duplication in the GRANT code seems necessary.

Implemented by me after an idea from Tom Lane, who also provided various kind
of implementation advice.

Regression tests pass.  Some tests for the new functionality are also added,
as well as rudimentary documentation.
2005-11-21 12:49:33 +00:00
Tom Lane b91e6ed93e Clean up after DROP IF EXISTS patch. 2005-11-20 23:24:12 +00:00
Tom Lane dd218ae7b0 Remove the t_datamcxt field of HeapTupleData. This was introduced for
the convenience of tuptoaster.c and is no longer needed, so may as well
get rid of some small amount of overhead.
2005-11-20 19:49:08 +00:00
Tom Lane 40314f2dac Modify tuptoaster's API so that it does not try to modify the passed
tuple in-place, but instead passes back an all-new tuple structure if
any changes are needed.  This is a much cleaner and more robust solution
for the bug discovered by Alexey Beschiokov; accordingly, revert the
quick hack I installed yesterday.
With this change, HeapTupleData.t_datamcxt is no longer needed; will
remove it in a separate commit in HEAD only.
2005-11-20 18:38:20 +00:00
Tom Lane 33a9af738d Stopgap solution for problem reported by Alexey Beschiokov: after
doing heap_insert or heap_update, wipe out any extracted fields in
the TupleTableSlot containing the tuple, because they might not be valid
anymore if tuptoaster.c changed the tuple.  Safe because slot must be
in the materialized state, but mighty ugly --- find a better answer!
2005-11-19 20:57:44 +00:00
Tom Lane 659f681638 Change array comparison rules to consider dimensionality information,
not only the array contents, before claiming two arrays are equal.
Per recent discussion.
2005-11-19 19:44:55 +00:00