Commit Graph

10063 Commits

Author SHA1 Message Date
Teodor Sigaev 26e6c896c9 Fix compiler warning "res may be used uninitialized in this function".
Actually, it can't but some compilers are not smart enough.
Per Peter Eisentraut gripe.
2008-11-19 10:23:21 +00:00
Tom Lane 31ec957a15 Fix define_custom_variable so that SUSET custom variables behave
somewhat reasonably.  It's not perfect, but it beats the kluge
proposed in the auto-explain patch ...
2008-11-19 02:07:07 +00:00
Tom Lane cd35e9d746 Some infrastructure changes for the upcoming auto-explain contrib module:
* Refactor explain.c slightly to export a convenient-to-use subroutine
for printing EXPLAIN results.

* Provide hooks for plugins to get control at ExecutorStart and ExecutorEnd
as well as ExecutorRun.

* Add some minimal support for tracking the total runtime of ExecutorRun.
This code won't actually do anything unless a plugin prods it to.

* Change the API of the DefineCustomXXXVariable functions to allow nonzero
"flags" to be specified for a custom GUC variable.  While at it, also make
the "bootstrap" default value for custom GUCs be explicitly specified as a
parameter to these functions.  This is to eliminate confusion over where the
default comes from, as has been expressed in the past by some users of the
custom-variable facility.

* Refactor GUC code a bit to ensure that a custom variable gets initialized to
something valid (like its default value) even if the placeholder value was
invalid.
2008-11-19 01:10:24 +00:00
Peter Eisentraut f426fbf746 Ident authentication over Unix-domain sockets on Solaris, using
getpeerucred() function.

Author: Garick Hamlin <ghamlin@isc.upenn.edu>
2008-11-18 13:10:20 +00:00
Teodor Sigaev 25ca5a9a54 Replace plain-memory ordered array by binary tree in ts_stat() function.
Performance is increased from 50% up to 10^3 times depending on data.
2008-11-17 12:17:09 +00:00
Tom Lane 18004101ac Modify UPDATE/DELETE WHERE CURRENT OF to use the FOR UPDATE infrastructure to
locate the target row, if the cursor was declared with FOR UPDATE or FOR
SHARE.  This approach is more flexible and reliable than digging through the
plan tree; for instance it can cope with join cursors.  But we still provide
the old code for use with non-FOR-UPDATE cursors.  Per gripe from Robert Haas.
2008-11-16 17:34:28 +00:00
Peter Eisentraut 8aad333f8f Fix crash of xmlconcat(NULL)
also backpatched to 8.3
2008-11-15 20:52:35 +00:00
Tom Lane 0656ed3daa Make SELECT FOR UPDATE/SHARE work on inheritance trees, by having the plan
return the tableoid as well as the ctid for any FOR UPDATE targets that
have child tables.  All child tables are listed in the ExecRowMark list,
but the executor just skips the ones that didn't produce the current row.

Curiously, this longstanding restriction doesn't seem to have been documented
anywhere; so no doc changes.
2008-11-15 19:43:47 +00:00
Tom Lane 9e0247aba5 In CREATE AGGREGATE, allow the transition datatype to be "internal", but only
if the user is superuser.  This makes available to extension modules the same
sort of trick being practiced by array_agg().  The reason for the superuser
restriction is that you could crash the system by connecting up an
incompatible pair of internal-using functions as an aggregate.  It shouldn't
interfere with any legitimate use, since you'd have to be superuser to create
the internal-using transition and final functions anyway.
2008-11-14 19:47:50 +00:00
Tom Lane 4f38b9a80a Make CREATE CONVERSION verify that a putative encoding conversion function
returns VOID.  This is the last of the easy fixes I recommended in
11870.1218838360@sss.pgh.pa.us --- the others got done awhile ago but
I forgot about this one.
2008-11-14 17:40:56 +00:00
Heikki Linnakangas f06b7604ca Fix oversight in previous error-reporting patch; mustn't pfree path string
before passing it to elog.
2008-11-14 11:09:50 +00:00
Tom Lane 81e11f2d05 Actually, instead of whining about how type internal might not safely store
a pointer, why don't we just fix that.  Every known use of "internal" really
means a pointer anyway.
2008-11-14 02:09:52 +00:00
Alvaro Herrera 03e5248d0f Replace the usage of heap_addheader to create pg_attribute tuples with regular
heap_form_tuple.  Since this removes the last remaining caller of
heap_addheader, remove it.

Extracted from the column privileges patch from Stephen Frost, with further
code cleanups by me.
2008-11-14 01:57:42 +00:00
Tom Lane c889ebce0a Implement the basic form of UNNEST, ie unnest(anyarray) returns setof
anyelement.  This lacks the WITH ORDINALITY option, as well as the multiple
input arrays option added in the most recent SQL specs.  But it's still a
pretty useful subset of the spec's functionality, and it is enough to
allow obsoleting contrib/intagg.
2008-11-14 00:51:47 +00:00
Tom Lane 5b9453bcd3 Minor code clarity improvements in array_agg functions, and add a comment
about how this is playing fast and loose with the type system.
2008-11-14 00:12:08 +00:00
Tom Lane 10e3acb8e7 Prevent synchronous scan during GIN index build, because GIN is optimized
for inserting tuples in increasing TID order.  It's not clear whether this
fully explains Ivan Sergio Borgonovo's complaint, but simple testing
confirms that a scan that doesn't start at block 0 can slow GIN build by
a factor of three or four.

Backpatch to 8.3.  Sync scan didn't exist before that.
2008-11-13 17:42:10 +00:00
Peter Eisentraut 3379fae6de array_agg aggregate function, as per SQL:2008, but without ORDER BY clause
Rearrange the documentation a bit now that array_agg and xmlagg have similar
semantics and issues.

best of Robert Haas, Jeff Davis, Peter Eisentraut
2008-11-13 15:59:51 +00:00
Michael Meskes cd583703ea Removed two non-terminals:
- FloatOnly: only used by NumericOnly, instead put the FloatOnly production into NumericOnly
- IntegerOnly: only used by NumericOnly and one ALTER TABLE rule, replacement SignedIconst is already used in several other places
2008-11-13 11:10:06 +00:00
Tom Lane e7d8bfb934 Arrange to cache the results of looking up a btree predicate proof comparison
operator.  The result depends only on the two input operators and the proof
direction (imply or refute), so it's easy to cache.  This provides a very
large savings in cases such as Sergey Konoplev's long NOT-IN-list example,
where predtest spends all its time repeatedly figuring out that the same pair
of operators cannot be used to prove anything.  (But of course the O(N^2)
behavior still catches up with you eventually.)  I'm not convinced it buys
a whole lot when constraint_exclusion isn't turned on, but it's not a lot
of added code so we might as well cache all the time.
2008-11-13 00:20:45 +00:00
Tom Lane fdf8d0624a In predtest.c, install a limit on the number of branches we will process in
AND, OR, or equivalent clauses: if there are too many (more than 100) just
exit without proving anything.  This ensures that we don't spend O(N^2) time
trying (and most likely failing) to prove anything about very long IN lists
and similar cases.

Also, install a couple of CHECK_FOR_INTERRUPTS calls to ensure that a long
proof attempt can be interrupted.

Per gripe from Sergey Konoplev.

Back-patch the whole patch to 8.2 and just the CHECK_FOR_INTERRUPTS addition
to 8.1.  (The rest of the patch doesn't apply cleanly, and since 8.1 doesn't
show the complained-of behavior anyway, it doesn't seem necessary to work
hard on it.)
2008-11-12 23:08:37 +00:00
Michael Meskes 9e6976057c Do not use ICONST/SCONST in rules other than Iconst/Sconst. 2008-11-12 15:50:20 +00:00
Peter Eisentraut f98f6ee064 array_length() function, and for SQL compatibility also cardinality()
function as a special case.

This version still has the suspicious behavior of returning null for an
empty array (rather than zero), but this may need a wholesale revision of
empty array behavior, currently under discussion.

Jim Nasby, Robert Haas, Peter Eisentraut
2008-11-12 13:09:28 +00:00
Heikki Linnakangas 4c22564471 Fix off-by-one error in autovacuum shmem struct sizing. This could lead to
autovacuum worker sending SIGUSR1 signal to wrong process, per Zou Yong's
report.

Backpatch to 8.3.
2008-11-12 10:10:32 +00:00
Tom Lane d1ab3eb712 Clean up the ancient decision to show only two fractional-seconds digits
in "postgres_verbose" intervalstyle, and the equally arbitrary decision to
show at least two fractional-seconds digits in most other datetime display
styles.  This results in some minor changes in the expected regression test
outputs.

Also, coalesce a lot of repetitive code in datetime.c into subroutines,
for clarity and ease of maintenance.  In particular this roughly halves
the number of #ifdef HAVE_INT64_TIMESTAMP segments.

Ron Mayer, with some additional kibitzing from Tom Lane
2008-11-12 01:36:20 +00:00
Tom Lane 0d7099d2f0 Ensure that the phrels sets of PlaceHolderVars appearing in an AppendRelInfo's
translated_vars list get updated when pulling up an appendrel member.  It's
not clear that this really matters at present, since relatively little gets
done with the outputs of an appendrel child relation; but it probably will
come back to bite us sometime if we leave them with the wrong values.
2008-11-11 19:05:21 +00:00
Tom Lane 0436679969 Get rid of adjust_appendrel_attr_needed(), which has been broken ever since
we extended the appendrel mechanism to support UNION ALL optimization.  The
reason nobody noticed was that we are not actually using attr_needed data for
appendrel children; hence it seems more reasonable to rip it out than fix it.
Back-patch to 8.2 because an Assert failure is possible in corner cases.
Per examination of an example from Jim Nasby.

In HEAD, also get rid of AppendRelInfo.col_mappings, which is quite inadequate
to represent UNION ALL situations; depend entirely on translated_vars instead.
2008-11-11 18:13:32 +00:00
Tom Lane cad3a26a95 Fix sloppy omission of now-required #include's. 2008-11-11 14:17:02 +00:00
Heikki Linnakangas 7e8b0b9ab1 Change error messages to print the physical path, like
"base/11517/3767_fsm", instead of symbolic names like "1663/11517/3767/1",
per Alvaro's suggestion. I didn't change the messages in the higher-level
index, heap and FSM routines, though, where the fork is implicit.
2008-11-11 13:19:16 +00:00
Tom Lane 3be2448525 Add an explicit caution about how to use pg_do_encoding_conversion with
non-null-terminated input.  Per discussion with ITAGAKI Takahiro.
2008-11-11 03:01:20 +00:00
Tom Lane a4917bef0e Add support for input and output of interval values formatted per ISO 8601;
specifically, we can input either the "format with designators" or the
"alternative format", and we can output the former when IntervalStyle is set
to iso_8601.

Ron Mayer
2008-11-11 02:42:33 +00:00
Alvaro Herrera a44564b4f8 Fix a case of string building. 2008-11-10 21:49:16 +00:00
Tom Lane 5e11e73d37 Fix bugs in sqlchar_to_unicode and unicode_to_sqlchar: both were measuring
the length of a UTF8 character with pg_mblen (wrong if DB encoding isn't
UTF8), and the latter was blithely assuming that a static buffer would somehow
revert to all zeroes for each use.
2008-11-10 18:02:20 +00:00
Heikki Linnakangas 45d146a6db Fix 'Q' format char parsing in the new to_timestamp() code. Used to crash. 2008-11-10 17:36:53 +00:00
Tom Lane 2b74d45c1b pg_do_encoding_conversion cannot return NULL (at least not unless the input
is NULL), so remove some useless tests for the case.
2008-11-10 15:18:40 +00:00
Tom Lane c5451c22e3 Make relhasrules and relhastriggers work like relhasindex, namely we let
VACUUM reset them to false rather than trying to clean 'em up during DROP.
2008-11-10 00:49:37 +00:00
Tom Lane e4718f2c9e Replace pg_class.reltriggers with relhastriggers, which is just a boolean hint
("there might be triggers") rather than an exact count.  This is necessary
catalog infrastructure for the upcoming patch to reduce the strength of
locking needed for trigger addition/removal.  Split out and committed
separately for ease of reviewing/testing.

In passing, also get rid of the unused pg_class columns relukeys, relfkeys,
and relrefs, which haven't been maintained in many years and now have no
chance of ever being maintained (because of wishing to avoid locking).

Simon Riggs
2008-11-09 21:24:33 +00:00
Tom Lane 1d577f5e49 Add a startup check that pg_xlog and pg_xlog/archive_status exist.
If the latter doesn't exist, automatically recreate it.  (We don't do
this for pg_xlog, though, per discussion.)

Jonah Harris
2008-11-09 17:51:15 +00:00
Tom Lane df7641e25a Add a new GUC variable called "IntervalStyle" that decouples interval output
from DateStyle, and create a new interval style that produces output matching
the SQL standard (at least for interval values that fall within the standard's
restrictions).  IntervalStyle is also used to resolve the conflict between the
standard and traditional Postgres rules for interpreting negative interval
input.

Ron Mayer
2008-11-09 00:28:35 +00:00
Tom Lane eec501c4f7 Fix recently added code for SQL years-months interval syntax so that
it behaves correctly for a leading minus sign, zero year value, and
nonzero month value.  Per discussion with Ron Mayer.
2008-11-08 20:51:49 +00:00
Tom Lane 6517f377d6 Implement ALTER DATABASE SET TABLESPACE to move a whole database (or at least
as much of it as lives in its default tablespace) to a new tablespace.

Guillaume Lelarge, with some help from Bernd Helmle and Tom Lane
2008-11-07 18:25:07 +00:00
Tom Lane 85e2cedf98 Improve bulk-insert performance by keeping the current target buffer pinned
(but not locked, as that would risk deadlocks).  Also, make it work in a small
ring of buffers to avoid having bulk inserts trash the whole buffer arena.

Robert Haas, after an idea of Simon Riggs'.
2008-11-06 20:51:15 +00:00
Heikki Linnakangas 5ae29525d1 The logic in systable_beginscan to translate heap attribute numbers to
index column numbers needs to handle the case where you have more than
one scankey on the same index column. toast_fetch_datum_slice() needs it.
2008-11-06 13:07:08 +00:00
Tom Lane 53b4e469ca This maneuver really requires a comment ... 2008-11-05 20:17:18 +00:00
Andrew Dunstan 0db527c05b change fix for suppress_redundant_updates_trigger() where relation has Oids, to only apply if present Oid is invalid, per second thought from TGL 2008-11-05 19:15:15 +00:00
Andrew Dunstan b65ebc7e8b fix suppress_redundant_updates_trigger() where relation has Oids, per gripe from KaiGai Kohei 2008-11-05 18:49:28 +00:00
Peter Eisentraut 254aecb704 ADD array_ndims function
Author: Robert Haas <robertmhaas@gmail.com>
2008-11-04 14:49:12 +00:00
Peter Eisentraut 9beb9e761b Fix compiler warning about uninitialized variable 2008-11-04 11:04:06 +00:00
Tom Lane 31b15fe8dc Disallow LOCK TABLE outside a transaction block (or function), since this case
almost certainly represents user error.  Per a gripe from Sebastian Böhm
and subsequent discussion.
2008-11-04 00:57:19 +00:00
Tom Lane 99e0996284 Fix compiler warnings (including a seriously bogus elog call); minor
code beautification.
2008-11-04 00:29:39 +00:00
Tom Lane 1a2b41f498 Use bool for a boolean flag. 2008-11-03 23:49:07 +00:00