Commit Graph

18838 Commits

Author SHA1 Message Date
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 312d51798f Suppress leap-second-aware timezones in the output of pg_tzenumerate_next,
and thereby in the pg_timezone_names view.  Although we allow such zones
to be used in certain limited contexts like AT TIME ZONE, we don't allow
them in SET TIME ZONE, and bug #4528 shows that they're more likely to
confuse users than do anything useful.  So hide 'em.  (Note that we don't
even generate these zones when installing our own timezone database.
But they are likely to be present when using a system-provided database.)
2008-11-13 20:49:38 +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
Tom Lane 69a0e2f76d PGDLLIMPORT-ize the global variables referenced in pg_crc.h.
I think this will fix current mingw buildfarm failures for pg_trgm.
2008-11-13 14:42:28 +00:00
Michael Meskes 53f93cbb20 Updated parser file to the one generated by the latest version of parse.[awk|pl] from the latest version of gram.y
Some small corrections to test suite.
2008-11-13 11:54:39 +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
Magnus Hagander c89404edf3 Fix libpq certificate validation for SSL connections.
Add config parameter "sslverify" to control the verification. Default
is to do full verification.

Clean up some old SSL code that never really worked.
2008-11-13 09:45:25 +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
Alvaro Herrera 249b224bf5 Update URL to Ross Williams' CRC paper.
Per note from Devrim Gunduz
2008-11-12 21:53:46 +00:00
Michael Meskes 9e6976057c Do not use ICONST/SCONST in rules other than Iconst/Sconst. 2008-11-12 15:50:20 +00:00
Tom Lane e4ffd143a3 If we're going to use a SQL function for this, at least make it schema-proof. 2008-11-12 13:38:04 +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
Magnus Hagander ccc9073f26 Make psql report "SSL connection (unknown cipher)" when libpq has set
up a SSL connection, but psql is compiled without support for it.

Not a really realistic use-case, but the patch also cuts down on
the number of places with #ifdef's...
2008-11-11 15:01:53 +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
Michael Meskes c7f5c7c128 Replaced manually synced preproc.y by the one created by the new script.
Adapted regression test files accordingly.
2008-11-11 11:41:24 +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
Alvaro Herrera 6462e7b81c Add a --locale switch to createdb, to ease the creation of databases with
different locales.  This is just syntactical sweetener over --lc-collate and
--lc-ctype.  Per discussion.

While at it, properly document --lc-ctype and --lc-collate in SGML docs,
which apparently were forgotten (or purposefully ommited?) when they were
created.
2008-11-10 16:25:41 +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
Tom Lane cdc197cf31 Improve psql's \dC command to take a pattern parameter. Casts are shown
if their source or target types match the pattern (using the same definition
of "match" as \dT does).  Per recent discussion.
2008-11-06 15:18:36 +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 e2a277bd08 A few additional test cases for array functionality 2008-11-05 12:27:09 +00:00
Tom Lane e0dc7d026f Rename several aliases for PLpgSQL_datum.dno to also be called dno.
Hopefully this will forestall future confusion about their roles.

Jonah Harris
2008-11-05 00:07:54 +00:00
Alvaro Herrera b6cb3d0c06 Revert unwanted patch, per Tom. 2008-11-04 21:00:15 +00:00
Alvaro Herrera 45fffcf778 Remove unused rfno from PLpgSQL_recfield
Jonah Harris
2008-11-04 20:58:46 +00:00
Tom Lane 70b6e99e40 Fix bug introduced in recent patch to make plpython cope with OUT arguments:
the proc->argnames array has to be initialized to zero immediately on creation,
since the error recovery path will try to free its elements.
2008-11-04 15:16:48 +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