Commit Graph

2103 Commits

Author SHA1 Message Date
Tom Lane 8436489c81 Add KNNGIST support to contrib/btree_gist.
This extends GiST's support for nearest-neighbor searches to many of the
standard data types.

Teodor Sigaev
2011-03-02 14:44:33 -05:00
Tom Lane a874fe7b4c Refactor the executor's API to support data-modifying CTEs better.
The originally committed patch for modifying CTEs didn't interact well
with EXPLAIN, as noted by myself, and also had corner-case problems with
triggers, as noted by Dean Rasheed.  Those problems show it is really not
practical for ExecutorEnd to call any user-defined code; so split the
cleanup duties out into a new function ExecutorFinish, which must be called
between the last ExecutorRun call and ExecutorEnd.  Some Asserts have been
added to these functions to help verify correct usage.

It is no longer necessary for callers of the executor to call
AfterTriggerBeginQuery/AfterTriggerEndQuery for themselves, as this is now
done by ExecutorStart/ExecutorFinish respectively.  If you really need to
suppress that and do it for yourself, pass EXEC_FLAG_SKIP_TRIGGERS to
ExecutorStart.

Also, refactor portal commit processing to allow for the possibility that
PortalDrop will invoke user-defined code.  I think this is not actually
necessary just yet, since the portal-execution-strategy logic forces any
non-pure-SELECT query to be run to completion before we will consider
committing.  But it seems like good future-proofing.
2011-02-27 13:44:12 -05:00
Alvaro Herrera 0056066d06 Update pageinspect--1.0.sql to match the upgrade script
Per comment from Tom
2011-02-25 19:39:02 -03:00
Alvaro Herrera a338d65461 Fix pageinspect's heap_page_item to return infomasks as 32 bit values
HeapTupleHeader's t_infomask and t_infomask2 are defined as 16-bit
unsigned integers, so when the 16th bit was set, heap_page_item was
returning them as negative values, which was ugly.

The change to pageinspect--unpackaged--1.0.sql allows a module upgraded
from 9.0 to be cleanly updated from the previous definition.
2011-02-25 19:04:25 -03:00
Itagaki Takahiro 3cba8240a1 Add ENCODING option to COPY TO/FROM and file_fdw.
File encodings can be specified separately from client encoding.
If not specified, client encoding is used for backward compatibility.

Cases when the encoding doesn't match client encoding are slower
than matched cases because we don't have conversion procs for other
encodings. Performance improvement would be be a future work.

Original patch by Hitoshi Harada, and modified by me.
2011-02-21 14:32:40 +09:00
Tom Lane 087bd179e6 Minor logic fix for new levenshtein implementation.
Alexander Korotkov
2011-02-20 14:55:07 -05:00
Tom Lane 7c5d0ae707 Add contrib/file_fdw foreign-data wrapper for reading files via COPY.
This is both very useful in its own right, and an important test case
for the core FDW support.

This commit includes a small refactoring of copy.c to expose its option
checking code as a separately callable function.  The original patch
submission duplicated hundreds of lines of that code, which seemed pretty
unmaintainable.

Shigeru Hanada, reviewed by Itagaki Takahiro and Tom Lane
2011-02-20 14:06:59 -05:00
Tom Lane 472f608e43 One more hack to make contrib upgrades from 9.0 match fresh 9.1 installs.
intarray and tsearch2 both reference core support functions in their GIN
opclasses, and the signatures of those functions changed for 9.1.  We added
backwards-compatible pg_proc entries for the functions in order to allow
9.0 dump files to be restored at all, but that hack leaves the opclasses
pointing at pg_proc entries different from what they'd point to if the
contrib modules were installed fresh in 9.1.  To forestall any possibility
of future problems, fix the opclasses to match fresh installs via the
expedient of direct UPDATEs on pg_amproc in the update-from-unpackaged
scripts.  (Yech ... but the alternatives are worse, or require far more
effort than seems justified right now.)

Note: updating pg_amproc is sufficient because there will be no pg_depend
entries corresponding to these dependencies, since the referenced functions
are all pinned.
2011-02-18 11:55:57 -05:00
Tom Lane de623f3335 Fix upgrade of contrib/xml2 from 9.0.
Update script was being sloppy about two functions that have been changed
since 9.0.
2011-02-17 18:11:28 -05:00
Tom Lane 0024e34898 Fix upgrade of contrib/intarray and contrib/unaccent from 9.0.
Take care of a couple of discrepancies between what you get from a fresh
install and what the first-draft update-from-unpackaged scripts produced.
2011-02-17 17:45:09 -05:00
Tom Lane ec65a79db2 Fix upgrade of contrib/btree_gist from 9.0.
The initial version of the update-from-unpackaged script neglected to
include the <> operators that were added to the opclasses during 9.1.
To make this script produce the same final state as the regular install
script, use the same ALTER OPERATOR FAMILY trick as in pg_trgm.
2011-02-17 16:38:04 -05:00
Tom Lane 4eb49db7ae Fix contrib/pg_trgm to have smoother updates from 9.0.
Take care of some loose ends in the update-from-unpackaged script, and
apply some ugly hacks to ensure that it produces the same catalog state
as the fresh-install script.  Per discussion, this seems like a safer
plan than having two different catalog states that both call themselves
"pg_trgm 1.0", even if it's not immediately clear that the subtle
differences would ever matter.

Also, fix the stub function gin_extract_trgm() so that it works instead
of just bleating.  Needed because this function will get called during a
regular dump and reload, if there are any indexes using its opclass.
The user won't have an opportunity to update the extension till later,
so telling him to do so is unhelpful.
2011-02-17 15:04:33 -05:00
Robert Haas 24bc6b3db3 Remove rule to build sepgsql-regtest.pp.
Instead, document how to build it manually.

Per discussion.  KaiGai Kohei, with some wordsmithing by me.
2011-02-17 06:40:32 -05:00
Tom Lane 6595dd04d1 Add backwards-compatible declarations of some core GIN support functions.
These are needed to support reloading dumps of 9.0 installations containing
contrib/intarray or contrib/tsearch2.  Since not only regular dump/reload
but binary upgrade would fail, it seems worth the trouble to carry these
stubs for awhile.  Note that the contrib opclasses referencing these
functions will still work fine, since GIN doesn't actually pay any
attention to the declared signature of a support function.
2011-02-16 17:24:46 -05:00
Bruce Momjian 497e65f822 In pg_upgrade, no need to initialize global struct values; they are
always zeros.  Also no need to free memory before we exit.
2011-02-16 15:17:28 -05:00
Alvaro Herrera b4a7e5980b Cleanup ClusterInfo initialization in pg_upgrade 2011-02-16 14:06:17 -03:00
Bruce Momjian 1cc19cc358 Fix bug in 9.1 pg_upgrade processing of old/new relations; adjust debug
output.
2011-02-15 19:01:33 -05:00
Alvaro Herrera 8b2557553c Make pg_upgrade compile again 2011-02-15 19:52:32 -03:00
Bruce Momjian fe8f15d5d2 Adjust pg_upgrade error message, array freeing, and add error check. 2011-02-15 15:00:47 -05:00
Tom Lane f5fc1de501 Bring hstore's comment into line with style of other contrib comments.
All the other ones that are primarily a new datatype say "data type for
<purpose>", so make this one similar.
2011-02-15 14:21:45 -05:00
Tom Lane 74883d3373 Rethink naming of contrib/intagg extension.
Initially it was called int_aggregate after the old SQL file, but since
the documentation just says "intagg" and that's also the directory name,
let's conform to that instead.
2011-02-14 21:00:24 -05:00
Tom Lane de06cfe834 More fixups for "unpackaged" conversion scripts. 2011-02-13 23:33:18 -05:00
Tom Lane 3b61e57f3c Assorted fixups for "unpackaged" conversion scripts.
From first pass of testing.  Notably, there seems to be no need for
adminpack--unpackaged--1.0.sql because none of the objects that the
old module creates would ever be dumped by pg_dump anyway (they are
all in pg_catalog).
2011-02-13 22:54:53 -05:00
Tom Lane 029fac2264 Avoid use of CREATE OR REPLACE FUNCTION in extension installation files.
It was never terribly consistent to use OR REPLACE (because of the lack of
comparable functionality for data types, operators, etc), and
experimentation shows that it's now positively pernicious in the extension
world.  We really want a failure to occur if there are any conflicts, else
it's unclear what the extension-ownership state of the conflicted object
ought to be.  Most of the time, CREATE EXTENSION will fail anyway because
of conflicts on other object types, but an extension defining only
functions can succeed, with bad results.
2011-02-13 22:54:52 -05:00
Tom Lane 629b3af27d Convert contrib modules to use the extension facility.
This isn't fully tested as yet, in particular I'm not sure that the
"foo--unpackaged--1.0.sql" scripts are OK.  But it's time to get some
buildfarm cycles on it.

sepgsql is not converted to an extension, mainly because it seems to
require a very nonstandard installation process.

Dimitri Fontaine and Tom Lane
2011-02-13 22:54:49 -05:00
Bruce Momjian 0de0cc150a Properly handle Win32 paths of 'E:abc', which can be either absolute or
relative, by creating a function path_is_relative_and_below_cwd() to
check for specific requirements.  It is unclear if this fixes a security
problem or not but the new code is more robust.
2011-02-12 09:47:51 -05:00
Tom Lane 1214749901 Add support for multiple versions of an extension and ALTER EXTENSION UPDATE.
This follows recent discussions, so it's quite a bit different from
Dimitri's original.  There will probably be more changes once we get a bit
of experience with it, but let's get it in and start playing with it.

This is still just core code.  I'll start converting contrib modules
shortly.

Dimitri Fontaine and Tom Lane
2011-02-11 21:25:57 -05:00
Tom Lane caddcb8f4b Fix pg_upgrade to handle extensions.
This follows my proposal of yesterday, namely that we try to recreate the
previous state of the extension exactly, instead of allowing CREATE
EXTENSION to run a SQL script that might create some entirely-incompatible
on-disk state.  In --binary-upgrade mode, pg_dump won't issue CREATE
EXTENSION at all, but instead uses a kluge function provided by
pg_upgrade_support to recreate the pg_extension row (and extension-level
pg_depend entries) without creating any member objects.  The member objects
are then restored in the same way as if they weren't members, in particular
using pg_upgrade's normal hacks to preserve OIDs that need to be preserved.
Then, for each member object, ALTER EXTENSION ADD is issued to recreate the
pg_depend entry that marks it as an extension member.

In passing, fix breakage in pg_upgrade's enum-type support: somebody didn't
fix it when the noise word VALUE got added to ALTER TYPE ADD.  Also,
rationalize parsetree representation of COMMENT ON DOMAIN and fix
get_object_address() to allow OBJECT_DOMAIN.
2011-02-09 19:18:08 -05:00
Peter Eisentraut 414c5a2ea6 Per-column collation support
This adds collation support for columns and domains, a COLLATE clause
to override it per expression, and B-tree index support.

Peter Eisentraut
reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
2011-02-08 23:04:18 +02:00
Robert Haas 87d967f70f Minor sepgsql regression test fixes. 2011-02-02 23:46:51 -05:00
Robert Haas c7689ee733 Various sepgsql corrections.
KaiGai Kohei
2011-02-02 23:39:43 -05:00
Tom Lane cd7d748d51 Repair multiple breakage in Windows-specific code for appending '.exe'. 2011-02-02 20:26:43 -05:00
Bruce Momjian 2b6e2dee78 Fix wrong verb in pg_upgrade text message, per Haas. 2011-02-02 16:53:12 -05:00
Bruce Momjian 9d220fc17e Simplify pg_upgrade checking of executable permissions. 2011-02-02 15:40:52 -05:00
Bruce Momjian 2bb87a61a8 Add pg_upgrade comment for why we can't use template1 inheritance for
the support functions.
2011-02-01 12:23:08 -05:00
Tom Lane 6e2f3ae884 Support LIKE and ILIKE index searches via contrib/pg_trgm indexes.
Unlike Btree-based LIKE optimization, this works for non-left-anchored
search patterns.  The effectiveness of the search depends on how many
trigrams can be extracted from the pattern.  (The worst case, with no
trigrams, degrades to a full-table scan, so this isn't a panacea.  But
it can be very useful.)

Alexander Korotkov, reviewed by Jan Urbanski
2011-01-31 21:34:49 -05:00
Bruce Momjian 6238473adb Fix pg_upgrade to create pg_authid restore functions in the 'postgres'
database, not in the os-user database, per report from Magnus.
2011-01-31 20:16:15 -05:00
Tom Lane 7ccb6dc2d3 Prevent buffer overrun while parsing an integer in a "query_int" value.
contrib/intarray's gettoken() uses a fixed-size buffer to collect an
integer's digits, and did not guard against overrunning the buffer.
This is at least a backend crash risk, and in principle might allow
arbitrary code execution.  The code didn't check for overflow of the
integer value either, which while not presenting a crash risk was still
bad.

Thanks to Apple Inc's security team for reporting this issue and supplying
the fix.

Security: CVE-2010-4015
2011-01-27 17:42:39 -05:00
Bruce Momjian 4fec63f94e Per Peter E, use 'kB' for kilobyte, not 'K'. 2011-01-26 16:21:19 -05:00
Bruce Momjian 00869024cb In pg_test_fsync, use K(1024) rather than k(1000) for write size units. 2011-01-26 11:02:52 -05:00
Bruce Momjian 64bc872761 Adjust pg_test_fsync to always do XLOG_BLCKSZ-sized writes, rather than
always 8k writes, per suggestion from Tom.  Also adjust open_sync output
layout.
2011-01-25 22:18:24 -05:00
Bruce Momjian d7a714828f Use consistent spacing for PGAPPICON Makefile option. 2011-01-24 20:46:30 -05:00
Bruce Momjian 9dd7933937 Use XLOG_BLCKSZ in pg_test_fsync, rather than our own define, but verify
it is 8k as expected.
2011-01-24 20:07:05 -05:00
Bruce Momjian 9fc0192283 In test_open_sync(), writes kilobytes as intended, not by bytes. 2011-01-24 19:42:32 -05:00
Robert Haas 41611f16e9 PGXS support for contrib/hstore
Joey Adams
2011-01-23 23:07:55 -05:00
Robert Haas 194c8f713a First round of cleanup of sepgsql code and documentation.
Robert Haas, with a few suggestions from Thom Brown
2011-01-23 22:48:22 -05:00
Robert Haas 968bc6fac9 sepgsql, an SE-Linux integration for PostgreSQL
This is still pretty rough - among other things, the documentation
needs work, and the messages need a visit from the style police -
but this gets the basic framework in place.

KaiGai Kohei
2011-01-23 20:48:27 -05:00
Tom Lane 37eb2cd4ad More pg_test_fsync fixups.
Reduce #includes to minimum actually needed; in particular include
postgres_fe.h not postgres.h, so as to stop build failures on some
platforms.

Use get_progname() instead of hardwired program name; improve error
checking for command line syntax; bring error messages into line with
style guidelines; include strerror result in die() cases.
2011-01-22 15:01:26 -05:00
Tom Lane 3ae28ce8c4 Suppress unused-variables warning when OPEN_SYNC_FLAG isn't defined.
Per buildfarm.
2011-01-22 12:26:44 -05:00
Tom Lane cb38ab6d3b More pg_test_fsync cleanup.
Un-break Windows build (I hope) by making the HAVE_FSYNC_WRITETHROUGH
code match the backend.  Fix incorrect program help message.  static-ize
all functions.
2011-01-21 19:44:53 -05:00
Tom Lane bc616703e8 Clean up pg_test_fsync commit.
Actually rename the program, rather than just claiming we did.  Hook it
into the build system.  Get rid of useless dependency on libpq.  Clean up
#include list and messy whitespace.
2011-01-21 19:27:25 -05:00
Bruce Momjian b35bfcae93 Update C banner on new pg_test_fsync file. 2011-01-21 12:49:04 -05:00
Bruce Momjian 606a3d54fc Move test_fsync to /contrib. 2011-01-21 12:47:54 -05:00
Bruce Momjian 0a5f119931 A toast relid field are no longer needed in pg_upgrade's rel arrays, so
remove them.  Also other renaming.
2011-01-10 11:46:02 -05:00
Tom Lane be0c3ea2d3 Update contrib/pg_trgm for new GIN extractQuery API.
No actual change in functionality ... just get rid of uselessly complex
code to pass the number of keys via extra_data.
2011-01-09 18:04:20 -05:00
Tom Lane ba398969cd Update contrib/hstore for new GIN extractQuery API.
In particular, make hstore @> '' succeed for all hstores, likewise
hstore ?& '{}'.  Previously the results were inconsistent and could
depend on whether you were using a GiST index, GIN index, or seqscan.
2011-01-09 16:43:56 -05:00
Tom Lane 327b257682 Improve comment. 2011-01-09 15:25:17 -05:00
Tom Lane 304845075c Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays.
This applies the fix for bug #5784 to remaining places where we wish
to reject nulls in user-supplied arrays.  In all these places, there's
no reason not to allow a null bitmap to be present, so long as none of
the current elements are actually null.

I did not change some other places where we are looking at system catalog
entries or aggregate transition values, as the presence of a null bitmap
in such an array would be suspicious.
2011-01-09 13:09:07 -05:00
Tom Lane fdf2dbda3f Fix assorted corner-case bugs in contrib/intarray.
The array containment operators now behave per mathematical expectation
for empty arrays (ie, an empty array is contained in anything).
Both these operators and the query_int operators now work as expected in
GiST and GIN index searches, rather than having corner cases where the
index searches gave different answers.

Also, fix unexpected failures where the operators would claim that an array
contained nulls, when in fact there was no longer any null present (similar
to bug #5784).  The restriction to not have nulls is still there, as
removing it would take a lot of added code complexity and probably slow
things down significantly.

Also, remove the arbitrary restriction to 1-D arrays; unlike the other
restriction, this was buying us nothing performance-wise.

Assorted cosmetic improvements and marginal performance improvements, too.
2011-01-09 00:39:21 -05:00
Bruce Momjian 002c105a07 In pg_upgrade, remove functions that did sequential array scans looking
up relations, but rather order old/new relations and use the same array
index value for both.  This should speed up pg_upgrade for databases
with many relations.
2011-01-08 13:44:44 -05:00
Bruce Momjian ebaf648ad2 In pg_upgrade, clarify use of install_db_support_functions(). 2011-01-08 09:11:48 -05:00
Bruce Momjian a60b32b3dc In pg_upgrade, remove unnecessary separate handling of toast tables now
that we restore by oid;  they can be handled like regular tables when
creating the file mapping structure.
2011-01-08 08:01:52 -05:00
Tom Lane 69c26c57cf Update GIN support function definitions for contrib/intarray.
The underlying C code still needs work, but this at least gets its
current regression test passing again.
2011-01-07 23:35:48 -05:00
Bruce Momjian 133641a48e Document why pg_upgrade preserves pg_auth.oid (because they are stored
in pg_largeobject_metadata).
2011-01-07 23:02:03 -05:00
Bruce Momjian 2f657e4d72 More pg_upgrade relfilenode C comments added. 2011-01-07 22:57:30 -05:00
Bruce Momjian 3095643d37 Simplify pg_upgrade C comment about what is preserved. 2011-01-07 22:46:41 -05:00
Bruce Momjian f75383e6e8 In pg_upgrade, track only one copy of namespace/relname in FileNameMap
because the old and new values are identical.
2011-01-07 22:36:51 -05:00
Bruce Momjian 519c008a96 Fix C indenting in pg_upgrade function. 2011-01-07 22:01:44 -05:00
Bruce Momjian d8d3d2a4f3 Fix pg_upgrade of large object permissions by preserving pg_auth.oid,
which is stored in pg_largeobject_metadata.

No backpatch to 9.0 because you can't migrate from 9.0 to 9.0 with the
same catversion (because of tablespace conflict), and a pre-9.0
migration to 9.0 has not large object permissions to migrate.
2011-01-07 21:59:29 -05:00
Bruce Momjian 2896c87ce4 Force pg_upgrade's to preserve pg_class.oid, not pg_class.relfilenode.
Toast tables have identical pg_class.oid and pg_class.relfilenode, but
for clarity it is good to preserve the pg_class.oid.

Update comments regarding what is preserved, and do some
variable/function renaming for clarity.
2011-01-07 21:26:13 -05:00
Tom Lane 541fc3d4df Ooops, forgot to fix contrib/tsearch2's references to GIN support funcs. 2011-01-07 21:10:48 -05:00
Tom Lane 73912e7fbd Fix GIN to support null keys, empty and null items, and full index scans.
Per my recent proposal(s).  Null key datums can now be returned by
extractValue and extractQuery functions, and will be stored in the index.
Also, placeholder entries are made for indexable items that are NULL or
contain no keys according to extractValue.  This means that the index is
now always complete, having at least one entry for every indexed heap TID,
and so we can get rid of the prohibition on full-index scans.  A full-index
scan is implemented much the same way as partial-match scans were already:
we build a bitmap representing all the TIDs found in the index, and then
drive the results off that.

Also, introduce a concept of a "search mode" that can be requested by
extractQuery when the operator requires matching to empty items (this is
just as cheap as matching to a single key) or requires a full index scan
(which is not so cheap, but it sure beats failing or giving wrong answers).
The behavior remains backward compatible for opclasses that don't return
any null keys or request a non-default search mode.

Using these features, we can now make the GIN index opclass for anyarray
behave in a way that matches the actual anyarray operators for &&, <@, @>,
and = ... which it failed to do before in assorted corner cases.

This commit fixes the core GIN code and ginarrayprocs.c, updates the
documentation, and adds some simple regression test cases for the new
behaviors using the array operators.  The tsearch and contrib GIN opclass
support functions still need to be looked over and probably fixed.

Another thing I intend to fix separately is that this is pretty inefficient
for cases where more than one scan condition needs a full-index search:
we'll run duplicate GinScanEntrys, each one of which builds a large bitmap.
There is some existing logic to merge duplicate GinScanEntrys but it needs
refactoring to make it work for entries belonging to different scan keys.

Note that most of gin.h has been split out into a new file gin_private.h,
so that gin.h doesn't export anything that's not supposed to be used by GIN
opclasses or the rest of the backend.  I did quite a bit of other code
beautification work as well, mostly fixing comments and choosing more
appropriate names for things.
2011-01-07 19:16:24 -05:00
Bruce Momjian 46d28820b6 Improve C comments about backend variables set by pg_upgrade_support
functions.
2011-01-06 22:45:36 -05:00
Bruce Momjian 56a9adcb96 Rename pg_upgrade variables, for clarity. 2011-01-05 20:14:59 -05:00
Bruce Momjian e66e43988a Update pg_upgrade C comments. 2011-01-05 14:09:01 -05:00
Bruce Momjian a45beaac64 Fix for recent pg_upgrade commit to fix large objects relfilenode
handling.  (metadata user ids still an open issue).
2011-01-05 13:52:44 -05:00
Bruce Momjian b1f2a94fa2 In pg_upgrade, adjust transfer_relfile()'s parameters to be more logical. 2011-01-05 12:07:45 -05:00
Bruce Momjian 5cff5b5779 Clarify pg_upgrade's creation of the map file structure. Also clean
up pg_dump's calling of pg_upgrade_support functions.
2011-01-05 11:37:08 -05:00
Bruce Momjian 3302334b48 In pg_upgrade, copy pg_largeobject_metadata and its index for 9.0+
servers because, like pg_largeobject, it is a system table whose
contents are not dumped by pg_dump --schema-only.
2011-01-04 23:35:49 -05:00
Bruce Momjian 0857a84498 In pg_upgrade, fix backward logging display of link operations. 2011-01-04 21:33:36 -05:00
Bruce Momjian 25cc7424e3 Simplify functions and parameters used by pg_upgrade. 2011-01-04 19:11:37 -05:00
Robert Haas 0d692a0dc9 Basic foreign table support.
Foreign tables are a core component of SQL/MED.  This commit does
not provide a working SQL/MED infrastructure, because foreign tables
cannot yet be queried.  Support for foreign table scans will need to
be added in a future patch.  However, this patch creates the necessary
system catalog structure, syntax support, and support for ancillary
operations such as COMMENT and SECURITY LABEL.

Shigeru Hanada, heavily revised by Robert Haas
2011-01-01 23:48:11 -05:00
Bruce Momjian 5d950e3b0c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Bruce Momjian 67c9e4442f Furter pg_upgrade optimizations to reduce function call argument count. 2011-01-01 12:28:48 -05:00
Bruce Momjian 6e6bee987f In pg_upgrade, remove use of whichCluster, and just pass old/new cluster
pointers, which simplifies the code.  This was not possible in 9.0 because
everything was in a single nested struct, but is possible now.

Per suggestion from Tom.
2011-01-01 12:06:36 -05:00
Bruce Momjian f82b3e58f8 In pg_upgrade, rename "CLUSTERNAME" to "CLUSTER_NAME". 2010-12-31 20:42:29 -05:00
Tom Lane 88c803457a Improve pg_upgrade's checks for required executables.
Don't insist on pg_dumpall and psql being present in the old cluster,
since they are not needed.  Do insist on pg_resetxlog being present
(in both old and new), since we need it.  Also check for pg_config,
but only in the new cluster.  Remove the useless attempt to call
pg_config in the old cluster; we don't need to know the old value of
--pkglibdir.  (In the case of a stripped-down migration installation
there might be nothing there to look at anyway, so any future change
that might reintroduce that need would have to be considered carefully.)

Per my attempts to build a minimal previous-version installation to support
pg_upgrade.
2010-12-29 13:43:53 -05:00
Bruce Momjian c0577c92a8 Mark unaccent functions as STABLE, rather than defaulting to VOLATILE. 2010-12-27 15:34:42 -05:00
Robert Haas 32ba2b5160 Use memcmp() rather than strncmp() when shorter string length is known.
It appears that this will be faster for all but the shortest strings;
at least one some platforms, memcmp() can use word-at-a-time comparisons.

Noah Misch, somewhat pared down.
2010-12-21 22:11:40 -05:00
Tom Lane abc1026269 Fix erroneous parsing of tsquery input "... & !(subexpression) | ..."
After parsing a parenthesized subexpression, we must pop all pending
ANDs and NOTs off the stack, just like the case for a simple operand.
Per bug #5793.

Also fix clones of this routine in contrib/intarray and contrib/ltree,
where input of types query_int and ltxtquery had the same problem.

Back-patch to all supported versions.
2010-12-19 12:48:34 -05:00
Tom Lane 2a6ebe70fb Fix contrib/seg's GiST picksplit method.
This patch replaces Guttman's generalized split method with a simple
sort-by-center-points algorithm.  Since the data is only one-dimensional
we don't really need the slow and none-too-stable Guttman method.

This is in part a bug fix, since seg has the same size_alpha versus
size_beta typo that was recently fixed in contrib/cube.  It seems
prudent to apply this rather aggressive fix only in HEAD, though.
Back branches will just get the typo fix.

Alexander Korotkov, reviewed by Yeb Havinga
2010-12-15 21:24:47 -05:00
Bruce Momjian 16b5e08dec Use "upgrade" in preference over "migrate" in pg_upgrade messages and
documentation.  (Many were left over from the old pg_migrator naming.)
2010-12-15 07:11:31 -05:00
Tom Lane 3864afa1d1 Clean up some copied-and-pasted code in pg_upgrade.
1. Don't reimplement S_ISDIR() and S_ISREG() badly.
2. Don't reimplement access() badly.

This code appears to have been copied from ancient versions of the
corresponding backend routines, and not patched to incorporate subsequent
fixes (see my commits of 2008-03-31 and 2010-01-14 respectively).
It might be a good idea to change it to just *call* those routines,
but for now I'll just transpose these fixes over.
2010-12-11 14:17:46 -05:00
Tom Lane b525bf771e Add KNNGIST support to contrib/pg_trgm.
Teodor Sigaev, with some revision by Tom
2010-12-04 00:16:21 -05:00
Robert Haas fab7fdb988 Fix typo.
Fujii Masao
2010-11-28 20:46:11 -05:00
Robert Haas fe7a32fc87 New contrib module, auth_delay.
KaiGai Kohei, with a few changes by me.
2010-11-27 07:22:25 -05:00
Tom Lane 4a2516a7f9 Fix significant memory leak in contrib/xml2 functions.
Most of the functions that execute XPath queries leaked the data structures
created by libxml2.  This memory would not be recovered until end of
session, so it mounts up pretty quickly in any serious use of the feature.
Per report from Pavel Stehule, though this isn't his patch.

Back-patch to all supported branches.
2010-11-26 15:21:53 -05:00
Itagaki Takahiro d3c1265443 Don't raise "identifier will be truncated" messages in dblink
except creating new connections.
2010-11-25 19:40:58 +09:00
Peter Eisentraut fc946c39ae Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
Robert Haas 4343c0e546 Expose quote_literal_cstr() from core.
This eliminates the need for inefficient implementions of this
functionality in both contrib/dblink and contrib/tablefunc, so remove
them.  The upcoming patch implementing an in-core format() function
will also require this functionality.

In passing, add some regression tests.
2010-11-20 10:04:48 -05:00
Robert Haas 4fa0a23c70 Fix bug in cube picksplit algorithm.
Alexander Korotkov
2010-11-14 21:27:34 -05:00
Robert Haas 5aa446c961 Cleanup various comparisons with the constant "true".
Itagaki Takahiro, with slight modifications.
2010-11-14 21:03:48 -05:00
Robert Haas 11e482c350 Move copydir() prototype into its own header file.
Having this in src/include/port.h makes no sense, now that copydir.c lives
in src/backend/strorage rather than src/port.  Along the way, remove an
obsolete comment from contrib/pg_upgrade that makes reference to the old
location.
2010-11-12 16:39:53 -05:00
Peter Eisentraut 19e231bbda Improved parallel make support
Replace for loops in makefiles with proper dependencies.  Parallel
make can now span across directories.  Also, make -k and make -q work
properly.

GNU make 3.80 or newer is now required.
2010-11-12 22:15:16 +02:00
Tom Lane 5e8b7b0b73 Allow moddatetime's target column to be of type timestamptz.
Dirk Heinrichs
2010-11-04 16:34:47 -04:00
Tom Lane 71baff1786 Fix buffer overrun in pg_upgrade.
Problem reported, and cause identified, by Hernan Gonzalez.
2010-11-02 17:31:41 -04:00
Peter Eisentraut a87d212636 Add missing newlines at end of files 2010-10-26 20:11:43 +03:00
Itagaki Takahiro 07ca728f69 Add .gitignore for contrib/uuid-ossp. 2010-10-26 12:25:34 +09:00
Tom Lane 84c123be1d Allow new values to be added to an existing enum type.
After much expenditure of effort, we've got this to the point where the
performance penalty is pretty minimal in typical cases.

Andrew Dunstan, reviewed by Brendan Jurd, Dean Rasheed, and Tom Lane
2010-10-24 23:05:41 -04:00
Robert Haas dd1587089c Correct a mistake in levenshtein_less_equal() multibyte character handling.
Spotted by Alexander Korotkov.

Along the way, remove a misleading comment line.
2010-10-22 15:27:39 -04:00
Bruce Momjian a52aa6c6db Clean up pg_upgrade cache lookup code; remove useless NULL pointer tests. 2010-10-20 20:02:37 +00:00
Heikki Linnakangas 18e752f226 If pk is NULL, the backend would segfault when accessing ->algo and the
following NULL check was never reached.

This problem was found by Coccinelle (null_ref.cocci from coccicheck).

Marti Raudsepp
2010-10-20 22:24:04 +03:00
Robert Haas 6d1af7b218 Updates to contrib/isn ISBN tables.
Jan Otto, reviewed by Peter Geoghegan
2010-10-19 22:48:19 -04:00
Bruce Momjian 691a67b922 Rename pg_upgrade 'log' to 'log_opts', to avoid platform naming conflict. 2010-10-20 02:31:17 +00:00
Bruce Momjian 3325c9bddb Further speed up pg_upgrade lookups. 2010-10-20 02:06:06 +00:00
Bruce Momjian 1c72614be7 Fix for new pg_upgrade cache code. 2010-10-20 01:24:31 +00:00
Bruce Momjian 333b4a45f1 Cache most recent relfilenode lookups, for speed, after report of
pg_upgrade slowness for 150k tables.
2010-10-20 00:55:16 +00:00
Bruce Momjian ad06db2610 In pg_upgrade, use cached copy of directory listing, rather than calling
scandir() with a pattern for every table.

Optimization after report of pg_upgrade slowness with 150k tables.
2010-10-20 00:33:19 +00:00
Bruce Momjian 07456b45e6 Pgindent run on pg_upgrade source after restructuring. 2010-10-19 22:37:04 +00:00
Bruce Momjian e13f7e9a71 Restructure the pg_upgrade code to use several global structures rather
than packing everything into 'ctx' and passing that to every function.
2010-10-19 21:38:34 +00:00
Bruce Momjian 722d5beeb2 In pg_upgrade, rename SHELL_EXT to SCRIPT_EXT, for clarity. 2010-10-19 15:57:55 +00:00
Bruce Momjian 51eeccd6cc Add removal of PG_VERSION to optional old cluster deletion script.
Backpatch to 9.0.X.
2010-10-19 15:52:43 +00:00
Robert Haas 604ab08145 Add levenshtein_less_equal, optimized version for small distances.
Alexander Korotkov, heavily revised by me.
2010-10-19 09:51:06 -04:00
Bruce Momjian 9df96f9bb1 In pg_upgrade, rename macro EXEC_EXT to SHELL_EXT for clarity.
Backpatch to 9.0.X.
2010-10-19 02:56:16 +00:00
Tom Lane caaf2e8469 Fix sloppy usage of TRIGGER_FIRED_BEFORE/TRIGGER_FIRED_AFTER.
Various places were testing TRIGGER_FIRED_BEFORE() where what they really
meant was !TRIGGER_FIRED_AFTER(), or vice versa.  This needs to be cleaned
up because there are about to be more than two possible states.

We might want to note this in the 9.1 release notes as something for
trigger authors to double-check.

For consistency's sake I also changed some places that assumed that
TRIGGER_FIRED_FOR_ROW and TRIGGER_FIRED_FOR_STATEMENT are necessarily
mutually exclusive; that's not in immediate danger of breaking, but
it's still sloppier than it should be.

Extracted from Dean Rasheed's patch for triggers on views.  I'm committing
this separately since it's an identifiable separate issue, and is the
only reason for the patch to touch most of these particular files.
2010-10-08 13:27:31 -04:00
Bruce Momjian fe61db6f0c Have pg_upgrade use strtoul(), not strtol(). 2010-09-29 02:40:25 +00:00
Bruce Momjian 807005c024 Use macro atooid() for conversion of strings to oids, per suggestion
from Tom.
2010-09-28 22:11:39 +00:00
Bruce Momjian 9340fb80b1 In pg_upgrade, properly handle oids > 2^31 by using strtoul() internally
rather than atol().

Per report from Brian Hirt
2010-09-28 21:41:03 +00:00
Bruce Momjian a1bb570de9 Fix leak patch that was using fclose() instead of close(). 2010-09-28 21:27:32 +00:00
Bruce Momjian f175884520 Properly close files after read file failure to prevent potential
resource leak.  Of course, any such failure aborts pg_upgrade, but might
as well be clean about it.

Per patch from Grzegorz Ja?kiewicz.
2010-09-28 19:28:34 +00:00
Robert Haas 4d355a8336 Add a SECURITY LABEL command.
This is intended as infrastructure to support integration with label-based
mandatory access control systems such as SE-Linux. Further changes (mostly
hooks) will be needed, but this is a big chunk of it.

KaiGai Kohei and Robert Haas
2010-09-27 20:55:27 -04:00
Robert Haas 12679b8bc9 In levenshtein_internal(), describe algorithm a bit more clearly. 2010-09-24 14:36:39 -04:00
Robert Haas 0a8ed2cdb4 Add contrib/xml2/pgxml.sql to .gitignore
Kevin Grittner
2010-09-23 22:08:22 -04:00
Tom Lane cc2c8152e6 Some more gitignore cleanups: cover contrib and PL regression test outputs.
Also do some further work in the back branches, where quite a bit wasn't
covered by Magnus' original back-patch.
2010-09-22 17:22:40 -04:00
Magnus Hagander fe9b36fd59 Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Tom Lane cd55aa2e00 Fix two new-in-9.0 bugs in hstore.
There was an incorrect Assert in hstoreValidOldFormat(), which would cause
immediate core dumps when attempting to work with pre-9.0 hstore data,
but of course only in an assert-enabled build.

Also, ghstore_decompress() incorrectly applied DatumGetHStoreP() to a datum
that wasn't actually an hstore, but rather a ghstore (ie, a gist signature
bitstring).  That used to be harmless, but could now result in misbehavior
if the hstore format conversion code happened to trigger.  In reality,
since ghstore is not marked toastable (and doesn't need to be), this
function is useless anyway; we can lobotomize it down to returning the
passed-in pointer.

Both bugs found by Andrew Gierth, though this isn't exactly his proposed
patch.
2010-09-16 02:54:01 +00:00
Bruce Momjian c5d94a34fb Modify pg_upgrade to set/restore all environment variables related to
collation/encoding to match English when reading controldata.  This now
matches the English variable setting used by pg_regress.c.

Backpatch to 9.0.X.
2010-09-07 14:10:30 +00:00
Tom Lane e57cd3936f Make pg_archivecleanup log messages more consistent.
Erik Rijkers
2010-08-23 02:56:24 +00:00
Peter Eisentraut 3f11971916 Remove extra newlines at end and beginning of files, add missing newlines
at end of files.
2010-08-19 05:57:36 +00:00
Tom Lane a0b7b717a4 Add xml_is_well_formed, xml_is_well_formed_document, xml_is_well_formed_content
functions to the core XML code.  Per discussion, the former depends on
XMLOPTION while the others do not.  These supersede a version previously
offered by contrib/xml2.

Mike Fowler, reviewed by Pavel Stehule
2010-08-13 18:36:26 +00:00
Tom Lane 00f76dbffa Get rid of a bunch of dubious error handling code in pgbench by just erroring
out immediately on any out-of-memory condition.  It's rather pointless to
imagine that pgbench will be able to continue usefully after a malloc
failure, and in any case there were a number of unchecked mallocs.
2010-08-12 21:10:59 +00:00
Tom Lane 5a4e19abe6 Add the ability to compute per-statement latencies (ie, average execution
times) to pgbench.

Florian Pflug, reviewed by Greg Smith
2010-08-12 20:39:39 +00:00
Tom Lane c04fd1b9db Remove the arbitrary (and undocumented) limit on the number of parameter=value
pairs that can be handled by xslt_process().

There is much else to do here, but this patch seems useful in its own right
for as long as this code survives.

Pavel Stehule, reviewed by Mike Fowler
2010-08-10 23:02:00 +00:00
Robert Haas fd1843ff89 Standardize get_whatever_oid functions for other object types.
- Rename TSParserGetPrsid to get_ts_parser_oid.
- Rename TSDictionaryGetDictid to get_ts_dict_oid.
- Rename TSTemplateGetTmplid to get_ts_template_oid.
- Rename TSConfigGetCfgid to get_ts_config_oid.
- Rename FindConversionByName to get_conversion_oid.
- Rename GetConstraintName to get_constraint_oid.
- Add new functions get_opclass_oid, get_opfamily_oid, get_rewrite_oid,
  get_rewrite_oid_without_relid, get_trigger_oid, and get_cast_oid.

The name of each function matches the corresponding catalog.

Thanks to KaiGai Kohei for the review.
2010-08-05 15:25:36 +00:00
Robert Haas 90a391c645 Regression tests for new btree_gist "not equals" support.
Jeff Davis, with minor adjustments by me.
2010-08-03 19:53:20 +00:00
Robert Haas 57d9aefcaa Teach levenshtein() about multi-byte characters.
Based on a patch by, and further ideas from, Alexander Korotkov.
2010-08-02 23:20:23 +00:00
Robert Haas ad17ff95cf Add btree_gist support for searching on "not equals".
Jeff Davis, with slight editorialization by me.
2010-08-02 16:26:48 +00:00
Robert Haas 8a4dc94ca0 Make details of the Numeric representation private to numeric.c.
Review by Tom Lane.
2010-07-30 04:30:23 +00:00
Robert Haas 980341b3c2 Avoid using text_to_cstring() in levenshtein functions.
Operating directly on the underlying varlena saves palloc and memcpy
overhead, which testing shows to be significant.

Extracted from a larger patch by Alexander Korotkov.
2010-07-29 20:11:48 +00:00
Peter Eisentraut f0790a642c Remove wildly obsolete type attribute externallength from chkpass 2010-07-28 20:34:34 +00:00
Robert Haas 6d16902eda Add ssl_cipher() and ssl_version() functions to contrib/sslinfo.
Review by Dave Page.
2010-07-27 23:43:42 +00:00
Bruce Momjian 8af787ea24 Adjust check_for_isn_and_int8_passing_mismatch() so it is called for all
migrations.

Backpatch to 9.0.
2010-07-25 03:47:29 +00:00
Bruce Momjian f31b1fd7c1 Prevent pg_upgrade from migrating databases that use reg* data types
where the oid is not preserved by pg_upgrade (everything but pg_type).
Update documentation.

Per bug report from depstein@alliedtesting.com.
2010-07-25 03:28:32 +00:00
Robert Haas 0e22e08fe5 Make hstore regression tests independent of standard_conforming_strings.
Per buildfarm.
2010-07-20 01:22:52 +00:00
Bruce Momjian 4504a1bc01 On Win32, pg_upgrade cannot sent any server log output to the log file
because of file access limitations on that platform.
2010-07-13 20:03:32 +00:00
Bruce Momjian 477c01b00d Remove incorrect email address for pg_upgrade bug reports. 2010-07-13 18:14:14 +00:00
Bruce Momjian f87bd25f00 In pg_upgrade, report /bin directory checks independent of /data checks. 2010-07-13 18:09:55 +00:00
Bruce Momjian 804f96accb In pg_upgrade, prevent psql AUTOCOMMIT=off by not loading .psqlrc. 2010-07-13 15:56:53 +00:00
Bruce Momjian a0d7c5f689 Properly report errno/out-of-disk-space error from pg_upgrade when in
copy mode, per report from depstein@alliedtesting.com.

Patch suggestion from Magnus.

Backpatch to 9.0.X.
2010-07-09 16:51:23 +00:00
Bruce Momjian 239d769e7e pgindent run for 9.0, second run 2010-07-06 19:19:02 +00:00
Tom Lane f9e9da6664 Fix a few single-file (MODULES, not MODULE_big) contrib makefiles that were
supposing that they should set SHLIB_LINK rather than LDFLAGS_SL.  Since these
don't go through Makefile.shlib that was a no-op on most platforms.  Also
regularize the few platform-specific Makefiles that did pay attention to
SHLIB_LINK: it seems that the real value of that is to pull in BE_DLLLIBS,
so do that instead.  Per buildfarm failures on cygwin.
2010-07-05 23:15:56 +00:00
Bruce Momjian da254e3d16 Make pg_upgrade copyrights just 2010, not 2010-2010. 2010-07-03 16:33:15 +00:00
Bruce Momjian de255a6eb1 Add copyrights to pg_upgrade and pg_upgrade_tools files, per Tom. 2010-07-03 16:25:01 +00:00
Bruce Momjian ccbe0c14e6 Add CVS tags to pg_upgrade and pg_upgrade_support files, per request
from Tom.
2010-07-03 14:23:14 +00:00
Robert Haas ce51747673 Remove hstore % text[] operator; use slice() function instead.
David Wheeler, with one small correction by me.
2010-07-02 20:36:49 +00:00
Tom Lane 600fc1dc9d Get rid of some more stuff that duplicates c.h or port.h. 2010-07-01 15:52:52 +00:00
Bruce Momjian 14bd1c3d9e Remove port.h prototypes from pg_upgrade.h, per report from Robert Haas. 2010-07-01 14:37:53 +00:00
Bruce Momjian c1b617987d Add username designations to all pg_upgrade utility calls that support it. 2010-06-23 20:04:50 +00:00
Bruce Momjian 601d1eeddc Fix pg_upgrade's use of pg_ctl on Win32 to not send command and sever
output to the same file, because it is impossible.

Also set user name for pg_dumpall in pg_upgrade.
2010-06-22 16:45:10 +00:00
Robert Haas 8327060dc2 Updated expected-output file for hstore.
This is an oversight in my previous patch to deprecate => as an operator
name.  Per buildfarm.
2010-06-22 12:54:22 +00:00
Robert Haas 31c47e53aa Rename hstore => text[] operator to %
This is not yet in any released version, so we still have the option to
change the name.  We may want to reserve the token => in a future release.
2010-06-18 03:52:03 +00:00
Tom Lane 449c73f466 Clean up pg_archivecleanup's error and logging output: put newlines in
sane places, make messages follow project's message style guidelines.

Also, avoid closedir(NULL).

Fujii Masao and Tom Lane
2010-06-17 17:31:27 +00:00
Bruce Momjian 1aa117506d Fix pg_upgrade to remove malloc(0) call. 2010-06-16 19:43:11 +00:00
Bruce Momjian 24cb6ab9af Fix storage of getopt() return, should be 'int', for pg_upgrade.
Steve Singer
2010-06-15 23:25:01 +00:00
Tom Lane c0989c67fa Change the interpretation of the primary_key_attnums parameter of
dblink_build_sql_insert() and related functions.  Now the column numbers
are treated as logical not physical column numbers.  This will provide saner
behavior in the presence of dropped columns; furthermore, if we ever get
around to allowing rearrangement of logical column ordering, the original
definition would become nearly untenable from a usability standpoint.
Per recent discussion of dblink's handling of dropped columns.
Not back-patched for fear of breaking existing applications.
2010-06-15 20:29:01 +00:00
Robert Haas b17129b589 Remove hstore's text[] => text[] operator.
This is not yet in any released version, so we still have the option to
backtrack.  Instead, document hstore(text[], text[]).  Per discussion.
2010-06-15 19:48:30 +00:00
Tom Lane 3b3706d2cf Fix dblink_build_sql_insert() and related functions to handle dropped
columns correctly.  In passing, get rid of some dead logic in the
underlying get_sql_insert() etc functions --- there is no caller that
will pass null value-arrays to them.

Per bug report from Robert Voinea.
2010-06-15 19:04:15 +00:00
Tom Lane 48a7245391 Consolidate and improve checking of key-column-attnum arguments for
dblink_build_sql_insert() and related functions.  In particular, be sure to
reject references to dropped and out-of-range column numbers.  The numbers
are still interpreted as physical column numbers, though, for backward
compatibility.

This patch replaces Joe's patch of 2010-02-03, which handled only some aspects
of the problem.
2010-06-15 16:22:19 +00:00
Bruce Momjian 8141523e35 Properly define pg_upgrade global variable, per bug report from Chris
Ruprecht on Mac (64 bit).
2010-06-15 02:08:01 +00:00
Tom Lane 6bbaa3148d Rearrange dblink's dblink_build_sql_insert() and related routines to open and
lock the target relation just once per SQL function call.  The original coding
obtained and released lock several times per call.  Aside from saving a
not-insignificant number of cycles, this eliminates possible race conditions
if someone tries to modify the relation's schema concurrently.  Also
centralize locking and permission-checking logic.

Problem noted while investigating a trouble report from Robert Voinea --- his
problem is still to be fixed, though.
2010-06-14 20:49:33 +00:00
Simon Riggs ca65f2190a Files for pg_archivecleanup 2010-06-14 16:19:24 +00:00
Simon Riggs 25fee5cfbd New contrib module for use as an archive_cleanup_command, or as a
standalone utility for removing files from archive.
2010-06-14 16:17:56 +00:00
Bruce Momjian 785c2acc12 Update pg_upgrade C comment about cwd. 2010-06-12 17:45:28 +00:00
Bruce Momjian 1dc7c796c9 Have pg_upgrade create its output files in the current directory, rather
than in a subdirectory of the $HOME directory, or $TMP in Windows.
2010-06-12 17:05:29 +00:00
Itagaki Takahiro 5a41c317c5 Avoid "identifier will be truncated" warning in dblink
when connection string is longer than NAMEDATALEN.
The previous fix for long connection name broke the behavior.
2010-06-09 03:39:26 +00:00
Itagaki Takahiro a624356072 Fix connection leak in dblink when dblink_connect() or dblink_connect_u()
end with "duplicate connection name" errors.

Backported to release 7.4.
2010-06-09 00:56:02 +00:00
Teodor Sigaev 3e7451a6df Add missed function dblink_connect_u(text[,text]) to uninstall script 2010-06-07 15:14:36 +00:00
Itagaki Takahiro 7dff7260af Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Now long names are adjusted with truncate_identifier() and NOTICE messages
are raised if names are actually truncated.

Backported to release 8.0.
2010-06-03 09:38:33 +00:00
Bruce Momjian 9b6dba1193 Remove IMPLEMENTATION.jp file from pg_upgrade docs; still in pgFoundry
for pg_migrator, per suggestion from Magnus.
2010-05-25 16:53:24 +00:00
Bruce Momjian 02265f06b7 Update pg_upgrade IMPLEMENTATION doc file to match current 9.0 behavior. 2010-05-25 16:09:29 +00:00
Bruce Momjian 238d21d7d2 Modify pg_standby, pgbench, and pg_upgrade manual pages to be consistent
in their display of command-line options with other client applications.
2010-05-25 15:55:28 +00:00
Bruce Momjian f4e9436026 Add Japanese Implementation file to CVS. 2010-05-25 02:56:36 +00:00
Bruce Momjian 7a74d70e71 Re-order pg_upgrade 'help' options to be alphabetical. 2010-05-25 02:55:58 +00:00
Bruce Momjian 6368682788 In pg_upgrade, test for datallowconn instead of hardcoding template0. 2010-05-24 19:52:33 +00:00
Bruce Momjian 00be75415c Split apart pg_upgrade user lookup and root check so '--help' shows
proper default username.
2010-05-24 16:34:35 +00:00
Tom Lane add8044778 issue_warnings() has no business freeing its parameter, especially not when
its sole caller does that too.  Jan Matousek, via Pavel Stehule
2010-05-23 16:54:13 +00:00
Bruce Momjian 3245bd5240 Simplify pg_upgrade queries by using IN instead of multiple OR clauses
comparing the same column to multiple values.
2010-05-19 18:56:47 +00:00
Bruce Momjian 573e446f6f For pg_upgrade, update template0's datfrozenxid and its relfrozenxids to
match the behavior of autovacuum, which does this as the xid advances
even if autovacuum is turned off.
2010-05-19 18:27:43 +00:00
Bruce Momjian 64719a18db Use a 'datallowconn' check for avoiding 'template0', rather than
hardcoding a 'template0' check, per suggestion from Alvaro.

This might fix a problem where someone has allowed 'template0'
connections, but it is a cleaner approach even if doesn't fix the
bug.
2010-05-18 18:40:51 +00:00
Bruce Momjian 37953b2d20 Add pg_upgrade TESTING files explaining a testing method. 2010-05-18 03:26:12 +00:00
Bruce Momjian 5c337fb45c Adjust pg_upgrade BSD defines for scandir(), per report from Giles Lean 2010-05-15 10:21:54 +00:00
Bruce Momjian 5781d96dc3 Change bsdi define to __bsdi__ 2010-05-15 10:08:28 +00:00
Heikki Linnakangas de4e18a34d Fix typos in comments, spotted by Josh Kupershmidt. 2010-05-15 09:31:57 +00:00
Tom Lane 88fba7089e Fix another obvious bug pointed out by a compiler warning. 2010-05-14 00:43:42 +00:00
Tom Lane 0546906064 Remove another unsafe use of random data as a format string. 2010-05-14 00:39:51 +00:00
Tom Lane 8eac39780d Get rid of unsafe sprintf and snprintf usages. Per compiler warnings. 2010-05-14 00:32:21 +00:00
Tom Lane adf6b8edfb Spell __darwin__ correctly, to suppress compiler warning on OSX. 2010-05-14 00:19:46 +00:00
Bruce Momjian e9ad14f9f4 Use NAMEDATALEN instead of local define.
Modify path separators for Win32.

Per ideas from Takahiro Itagaki
2010-05-14 00:13:38 +00:00
Bruce Momjian 36d3afd2d4 Remove all mentions of EnterpriseDB Advanced Server from pg_upgrade;
EDB must maintain their own patch set for this.
2010-05-13 22:51:00 +00:00
Tom Lane 382ff21203 Fix up lame idea of not using autoconf to determine if platform has scandir().
Should fix buildfarm failures.
2010-05-13 22:07:43 +00:00
Magnus Hagander 2b61b3e507 Assorted fixes to make pg_upgrade build on MSVC.
* There is no chmod() on Windows.
* Must always use the 3-parameter version of open()
* There is no dynloader.h - but it also appears unnecessary on all platforms
* Don't include shlobj.h because it causes compile errors, and from what I can
  see it's not actually used. This may need to be added back for mingw
  and/or cygwin in the worst case.
2010-05-13 15:58:15 +00:00
Tom Lane c2e7f78abe Fix wrong subdir. Per buildfarm. 2010-05-13 05:17:16 +00:00
Bruce Momjian 9885206cab Move pg_upgrade shared library out into its own /contrib directory
(pg_upgrade_support).
2010-05-13 01:03:01 +00:00
Tom Lane 44e55690fd Hook pg_upgrade into the contrib makefile structure so it gets built
on the buildfarm.
2010-05-12 16:50:58 +00:00
Tom Lane c9c25a982c Clean up unnecessary unportability and compiler warnings by removing the
cmp parameter for pg_scandir().  The code failed to support this anyway
for Sun/Windows, so pretending we could accept a parameter other than
NULL was just asking for trouble.
2010-05-12 16:50:00 +00:00
Bruce Momjian b460b5cd11 Move pg_upgrade TODO to TODO wiki. 2010-05-12 13:59:21 +00:00
Bruce Momjian 395d1259ad Add PGFILEDESC description to Makefiles for all /contrib executables.
Add PGAPPICON to all executable makefiles.
2010-05-12 11:33:10 +00:00
Bruce Momjian 561afa534d Small formatting adjustment. 2010-05-12 11:07:24 +00:00
Bruce Momjian a898199df5 Add pg_upgrade IMPLEMENTATION file to CVS. 2010-05-12 02:24:43 +00:00
Bruce Momjian 6c4a98d99c Add TODO file to CVS. 2010-05-12 02:23:56 +00:00
Bruce Momjian c2e9b2f288 Add pg_upgrade to /contrib; will be in 9.0 beta2.
Add documentation.

Supports migration from PG 8.3 and 8.4.
2010-05-12 02:19:11 +00:00
Tom Lane 77acab75df Modify ShmemInitStruct and ShmemInitHash to throw errors internally,
rather than returning NULL for some-but-not-all failures as they used to.
Remove now-redundant tests for NULL from call sites.

We had to do something about this because many call sites were failing to
check for NULL; and changing it like this seems a lot more useful and
mistake-proof than adding checks to the call sites without them.
2010-04-28 16:54:16 +00:00
Tom Lane a2de4826e9 Fix contrib/tsearch2 expected results to match recent changes in URL parsing. 2010-04-28 15:07:59 +00:00
Robert Haas 33980a0640 Fix various instances of "the the".
Two of these were pointed out by Erik Rijkers; the rest I found.
2010-04-23 23:21:44 +00:00
Andrew Dunstan ce36151ac7 Make dmetaphone.c safe for pgindent and fussy compilers. Still to do: make it properly encoding aware w.r.t. chars U+00C7 and U+00D1. 2010-04-05 02:46:20 +00:00
Tom Lane 33065ef8bc Ensure that contrib/pgstattuple functions respond to cancel interrupts
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara
2010-04-02 16:16:51 +00:00
Magnus Hagander 4c10623306 Update a number of broken links in comments.
Josh Kupershmidt
2010-04-02 15:21:20 +00:00
Magnus Hagander 337b217572 Fix minor typos in comments.
Josh Kupershmidt
2010-04-02 15:19:22 +00:00
Tom Lane 5ceb13c8a1 Fix ginint4_queryextract() to actually do what it was intended to do for an
unsatisfiable query, such as indexcol && empty_array.  It should return -1
to tell GIN no scan is required; but silly typo disabled the logic for that,
resulting in unnecessary "GIN indexes do not support whole-index scans" error.
Per bug report from Jeff Trout.

Back-patch to 8.3 where the logic was introduced.
2010-03-25 15:50:10 +00:00
Itagaki Takahiro a887c486d5 Each worker thread will have its own log file in pgbench to avoid interleaved
writes. The first worker still uses "pgbench_log.<pid>" for the name, but
additional workers use "pgbench_log.<pid>.<serial-number>" instead.

Reported by Greg Smith.
2010-03-23 01:29:22 +00:00
Tom Lane 5e47403be3 Make contrib/xml2 use core xml.c's error handler, when available (that is,
in versions >= 8.3).  The core code is more robust and efficient than what
was there before, and this also reduces risks involved in swapping different
libxml error handler settings.

Before 8.3, there is still some risk of problems if add-on modules such as
Perl invoke libxml without setting their own error handler.  Given the lack
of reports I'm not sure there's a risk in practice, so I didn't take the
step of actually duplicating the core code into older contrib/xml2 branches.
Instead I just tweaked the existing code to ensure it didn't leave a dangling
pointer to short-lived memory when throwing an error.
2010-03-03 19:10:22 +00:00
Tom Lane d6a6f8c6be Fix contrib/xml2 so regression test still works when it's built without libxslt.
This involves modifying the module to have a stable ABI, that is, the
xslt_process() function still exists even without libxslt.  It throws a
runtime error if called, but doesn't prevent executing the CREATE FUNCTION
call.  This is a good thing anyway to simplify cross-version upgrades.
2010-03-01 18:07:59 +00:00
Tom Lane a102090995 Remove xmlCleanupParser calls from contrib/xml2.
These are unnecessary and probably dangerous.  I don't see any immediate
risk situations in the core XML support or contrib/xml2 itself, but there
could be issues with external uses of libxml2, and in any case it's an
accident waiting to happen.
2010-03-01 05:16:35 +00:00
Tom Lane 936c4af1c6 Fix up memory management problems in contrib/xml2.
Get rid of the code that attempted to funnel libxml2's memory allocations
into palloc.   We already knew from experience with the core xml datatype
that trying to do this is simply not reliable.  Unlike the core code, I
did not bother adding a lot of PG_TRY/PG_CATCH logic to try to ensure that
everything is cleaned up on error exit.  Hence, we might leak some memory
if one of these functions fails partway through.  Given the deprecated
status of this contrib module and the fact that errors partway through
the functions shouldn't be too common, it doesn't seem worth worrying about.

Also fix a separate bug in xpath_table, that it did the wrong things
if given a result tuple descriptor with less than 2 columns.  While
such a case isn't very useful in practice, we shouldn't fail or stomp
memory when it occurs.

Add some simple regression tests based on all the reported crash cases
that I have on hand.

This should be back-patched, but let's see if the buildfarm likes it first.
2010-02-28 21:31:57 +00:00
Tom Lane a12333eed2 Assorted code cleanup for contrib/xml2. No change in functionality,
just make it a bit less ugly in places.
2010-02-28 19:51:37 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane 29d2f86a31 Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.
The main motivation for changing this is bug #4921, in which it's pointed out
that it's no longer safe to apply ltree operations to the result of
ARRAY(SELECT ...) if the sub-select might return no rows.  Before 8.3,
the ARRAY() construct would return NULL, which might or might not be helpful
but at least it wouldn't result in an error.  Now it returns an empty array
which results in a failure for no good reason, since the ltree operations
are all perfectly capable of dealing with zero-element arrays.

As far as I can find, these ltree functions are the only places where zero
array dimensionality is rejected unnecessarily.

Back-patch to 8.3 to prevent behavioral regression of queries that worked
in older releases.
2010-02-24 18:02:24 +00:00
Itagaki Takahiro 912eb88c7d Remove useless codes to initialize TupleDesc from dblink_exec. 2010-02-24 05:20:49 +00:00
Bruce Momjian c4fc082a5a Modify freebsd start script to just exit 0 with message. 2010-02-23 22:17:25 +00:00
Bruce Momjian 1f0cf56be2 Update startup scripts for Linux and FreeBSD.
Kevin Grittner
2010-02-23 22:15:35 +00:00
Tom Lane 50a90fac40 Stamp HEAD as 9.0devel, and update various places that were referring to 8.5
(hope I got 'em all).  Per discussion, this release will be 9.0 not 8.5.
2010-02-17 04:19:41 +00:00
Andrew Dunstan fc5173ad51 Add query text to auto_explain output.
Still to be done: fix docs and fix regression failures under auto_explain.
2010-02-16 22:19:59 +00:00
Robert Haas e26c539e9f Wrap calls to SearchSysCache and related functions using macros.
The purpose of this change is to eliminate the need for every caller
of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists,
GetSysCacheOid, and SearchSysCacheList to know the maximum number
of allowable keys for a syscache entry (currently 4).  This will
make it far easier to increase the maximum number of keys in a
future release should we choose to do so, and it makes the code
shorter, too.

Design and review by Tom Lane.
2010-02-14 18:42:19 +00:00
Tom Lane d5768dce10 Create an official API function for C functions to use to check if they are
being called as aggregates, and to get the aggregate transition state memory
context if needed.  Use it instead of poking directly into AggState and
WindowAggState in places that shouldn't know so much.

We should have done this in 8.4, probably, but better late than never.

Revised version of a patch by Hitoshi Harada.
2010-02-08 20:39:52 +00:00
Tom Lane b9b8831ad6 Create a "relation mapping" infrastructure to support changing the relfilenodes
of shared or nailed system catalogs.  This has two key benefits:

* The new CLUSTER-based VACUUM FULL can be applied safely to all catalogs.

* We no longer have to use an unsafe reindex-in-place approach for reindexing
  shared catalogs.

CLUSTER on nailed catalogs now works too, although I left it disabled on
shared catalogs because the resulting pg_index.indisclustered update would
only be visible in one database.

Since reindexing shared system catalogs is now fully transactional and
crash-safe, the former special cases in REINDEX behavior have been removed;
shared catalogs are treated the same as non-shared.

This commit does not do anything about the recently-discussed problem of
deadlocks between VACUUM FULL/CLUSTER on a system catalog and other
concurrent queries; will address that in a separate patch.  As a stopgap,
parallel_schedule has been tweaked to run vacuum.sql by itself, to avoid
such failures during the regression tests.
2010-02-07 20:48:13 +00:00
Bruce Momjian 7027aba980 Remove /contrib/isn copyright mention for German Mendez Bravo, with
author's permission.
2010-02-05 04:34:51 +00:00
Bruce Momjian a141ec13de Rewrite intagg/Makefile from scratch, to avoid copyright mention. 2010-02-05 03:06:30 +00:00
Joe Conway fdac8cf998 Check to ensure the number of primary key fields supplied does not
exceed the total number of non-dropped source table fields for
dblink_build_sql_*(). Addresses bug report from Rushabh Lathia.

Backpatch all the way to the 7.3 branch.
2010-02-03 23:01:11 +00:00
Joe Conway 56cbb611ec Rewrite dblink_record_internal() and dblink_fetch() to use a tuplestore
(SFRM_Materialize mode) to return tuples. Since we don't return from the
dblink function in tuplestore mode, release the PGresult with a PG_CATCH
block on error. Also rearrange to share the same code to materialize the
tuplestore. Patch by Takahiro Itagaki.
2010-01-24 22:19:38 +00:00