Commit Graph

1768 Commits

Author SHA1 Message Date
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
Magnus Hagander 94fa8301f7 Silence compiler warning, noted by Stefan Kaltenbrunner 2010-01-17 12:11:25 +00:00
Tom Lane d5e0029862 Add some simple support and documentation for using process-specific oom_adj
settings to prevent the postmaster from being OOM-killed on Linux systems.

Alex Hunsaker and Tom Lane
2010-01-11 18:39:32 +00:00
Itagaki Takahiro 8964dbd51e Add buffer access counters to pg_stat_statements.
This uses the same infrastructure with EXPLAIN BUFFERS to support
{shared|local}_blks_{hit|read|written} andtemp_blks_{read|written}
columns in the pg_stat_statements view. The dumped file format
also updated.

Thanks to Robert Haas for the review.
2010-01-08 00:38:20 +00:00
Tom Lane 901be0fad4 Remove all the special-case code for INT64_IS_BUSTED, per decision that
we're not going to support that anymore.

I did keep the 64-bit-CRC-with-32-bit-arithmetic code, since it has a
performance excuse to live.  It's a bit moot since that's all ifdef'd
out, of course.
2010-01-07 04:53:35 +00:00
Tom Lane cd958356bd Add missing 'static' keywords. 2010-01-06 18:07:19 +00:00
Itagaki Takahiro a8a198b10b Adjust headers to allow pgbench to be built with PGXS. 2010-01-06 01:30:03 +00:00
Itagaki Takahiro 660f532898 Add verification of variable names in pgbench.
Variables must consist of only alphabets, numerals and underscores.
We had allowed to set variables with invalid names, but could not
refer them in queries.

Thanks to Robert Haas for the review.
2010-01-06 01:12:14 +00:00
Bruce Momjian 0239800893 Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
Heikki Linnakangas 84d723b6ce Previous fix for temporary file management broke returning a set from
PL/pgSQL function within an exception handler. Make sure we use the right
resource owner when we create the tuplestore to hold returned tuples.

Simplify tuplestore API so that the caller doesn't need to be in the right
memory context when calling tuplestore_put* functions. tuplestore.c
automatically switches to the memory context used when the tuplestore was
created. Tuplesort was already modified like this earlier. This patch also
removes the now useless MemoryContextSwitch calls from callers.

Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
the previous patch that broke this.
2009-12-29 17:40:59 +00:00
Tom Lane a5495cd841 Add a hook to let loadable modules get control at ProcessUtility execution,
and use it to extend contrib/pg_stat_statements to track utility commands.

Itagaki Takahiro, reviewed by Euler Taveira de Oliveira.
2009-12-15 20:04:49 +00:00
Itagaki Takahiro 7d67e06297 Add \shell and \setshell meta commands to pgbench.
\shell command runs an external shell command.
\setshell also does the same and sets the result to a variable.

original patch by Michael Paquier with some editorialization by Itagaki,
and reviewed by Greg Smith.
2009-12-15 07:17:57 +00:00
Robert Haas cddca5ec13 Add an EXPLAIN (BUFFERS) option to show buffer-usage statistics.
This patch also removes buffer-usage statistics from the track_counts
output, since this (or the global server statistics) is deemed to be a better
interface to this information.

Itagaki Takahiro, reviewed by Euler Taveira de Oliveira.
2009-12-15 04:57:48 +00:00
Itagaki Takahiro 84f910a707 Additional fixes for large object access control.
Use pg_largeobject_metadata.oid instead of pg_largeobject.loid
to enumerate existing large objects in pg_dump, pg_restore, and
contrib modules.
2009-12-14 00:39:11 +00:00
Robert Haas 02490d4692 Export ExplainBeginOutput() and ExplainEndOutput() for auto_explain.
Without these functions, anyone outside of explain.c can't actually use
ExplainPrintPlan, because the ExplainState won't be initialized properly.
The user-visible result of this was a crash when using auto_explain with
the JSON output format.

Report by Euler Taveira de Oliveira.  Analysis by Tom Lane.  Patch by me.
2009-12-12 00:35:34 +00:00
Tom Lane 6b45e3b7aa Arrange to generate different random sequences in the different child
processes of a pgbench run, when we are using -j > 1 and are emulating
threads via fork().  Otherwise the children all inherit the same random
sequence state and produce the same random-number sequence.

In the threaded case the different threads will share one RNG state, so
they will produce different subsets of one sequence, which is maybe more
correlated than a purist would like but will not be "the same".  So we
leave that case alone.

First noticed by Takahiro Itagaki, and is also part of the explanation
for the pgbench misbehavior recently reported by Jaime Casanova.
2009-12-11 21:50:06 +00:00
Andrew Dunstan 324385d67f Add YAML to list of EXPLAIN formats. Greg Sabino Mullane, reviewed by Takahiro Itagaki. 2009-12-11 01:33:35 +00:00
Robert Haas da07641481 Fix levenshtein with costs. The previous code multiplied by the cost in only
3 of the 7 relevant locations.

Marcin Mank, slightly adjusted by me.
2009-12-10 01:54:17 +00:00
Teodor Sigaev aebc4e67ff Preventing intersection of ranges during page split. Changes are only
optimization, so don't backpatch.
2009-12-02 13:13:24 +00:00
Bruce Momjian ef51395e24 Revert due to Tom's concerns:
Add ProcessUtility_hook() to handle all DDL to
contrib/pg_stat_statements.
2009-12-01 02:31:13 +00:00
Bruce Momjian d85cb27293 ProcessUtility_hook:
Add ProcessUtility_hook() to handle all DDL to contrib/pg_stat_statements.

Itagaki Takahiro
2009-12-01 01:08:46 +00:00
Tom Lane 1753337cf5 Improve psql's tabular display of wrapped-around data by inserting markers
in the formerly-always-blank columns just to left and right of the data.
Different marking is used for a line break caused by a newline in the data
than for a straight wraparound.  A newline break is signaled by a "+" in the
right margin column in ASCII mode, or a carriage return arrow in UNICODE mode.
Wraparound is signaled by a dot in the right margin as well as the following
left margin in ASCII mode, or an ellipsis symbol in the same places in UNICODE
mode.  "\pset linestyle old-ascii" is added to make the previous behavior
available if anyone really wants it.

In passing, this commit also cleans up a few regression test files that
had unintended spacing differences from the current actual output.

Roger Leigh, reviewed by Gabrielle Roth and other members of PDXPUG.
2009-11-22 05:20:41 +00:00
Tom Lane c742b795dd Add a hook to CREATE/ALTER ROLE to allow an external module to check the
strength of database passwords, and create a sample implementation of
such a hook as a new contrib module "passwordcheck".

Laurenz Albe, reviewed by Takahiro Itagaki
2009-11-18 21:57:56 +00:00
Tom Lane 29faadcd27 Make unaccent's install/uninstall scripts look more like all the others.
Set search_path explicitly, don't use IF EXISTS, etc.
2009-11-14 18:24:32 +00:00
Heikki Linnakangas 48912acc08 Disable triggering failover with a signal in pg_standby on Windows, because
Windows doesn't do signal processing like other platforms do. It never
really worked, but recent changes to the signal handling made it crash.

This fixes bug #4961. Patch by Fujii Masao.
2009-11-04 12:51:30 +00:00
Tom Lane f7082f269e Fix bogus Assert, per buildfarm results. 2009-09-30 21:26:17 +00:00
Tom Lane 172eacba43 Assorted improvements in contrib/hstore.
Remove the 64K limit on the lengths of keys and values within an hstore.
(This changes the on-disk format, but the old format can still be read.)
Add support for btree/hash opclasses for hstore --- this is not so much
for actual indexing purposes as to allow use of GROUP BY, DISTINCT, etc.
Add various other new functions and operators.

Andrew Gierth
2009-09-30 19:50:22 +00:00
Joe Conway d6119d8091 plug dblink resource leak
dblink generates orphaned connections when called with a connection string,
fail_on_error = true, and an ERROR occurs. Discovery and patch by
Tatsuhito Kasahara. Introduced in 8.4.
2009-09-12 23:20:52 +00:00
Tatsuo Ishii f82d4d5302 pgbench has #defines for number of branches, tellers, and accounts. There
are used to populate the tables with -i, but when running actual benchmark
it has values separately hard-coded in the query metacommands.  This patch
makes the metacommands obtain their values from the relevant #defines.

Patch provided by Jeff Janes.
2009-09-10 13:59:57 +00:00
Peter Eisentraut 234c7ce9f2 Derived files that are shipped in the distribution used to be built in the
source directory even for out-of-tree builds.  They are now alsl built in
the build tree.  This should be more convenient for certain developers'
workflows, and shouldn't really break anything else.
2009-08-28 20:26:19 +00:00
Tom Lane 8f5500e6bd Make it reasonably safe to use pg_ctl to start the postmaster from a boot-time
script.

To do this, have pg_ctl pass down its parent shell's PID in an environment
variable PG_GRANDPARENT_PID, and teach CreateLockFile() to disregard that PID
as a false match if it finds it in postmaster.pid.  This allows us to cope
with one level of postgres-owned shell process even with pg_ctl in the way,
so it's just as safe as starting the postmaster directly.  You still have to
be careful about how you write the initscript though.

Adjust the comments in contrib/start-scripts/ to not deprecate use of
pg_ctl.  Also, fix the ROTATELOGS option in the OSX script, which was
indulging in exactly the sort of unsafe coding that renders this fix
pointless :-(.  A pipe inside the "sudo" will probably result in more
than one postgres-owned process hanging around.
2009-08-27 16:59:38 +00:00
Tom Lane 4b98b613f6 Print the actual DB encoding in the unaccent regression test.
This is to help make it more obvious what the problem is, if the
encoding isn't what the test expects.
2009-08-18 16:00:50 +00:00
Tom Lane 13845d261c Fix some *other* compiler warnings from a different gcc version. 2009-08-18 15:57:26 +00:00
Tom Lane ed05063d27 Fix copy-and-pasteo that might explain some of the buildfarm's
indigestion about this module.
2009-08-18 15:51:16 +00:00
Tom Lane ec8128465f Suppress compiler warnings about uninitialized variables. 2009-08-18 15:37:04 +00:00
Teodor Sigaev 92e05bc6a5 Unaccent dictionary. 2009-08-18 10:34:39 +00:00
Tom Lane 9bd27b7c9e Extend EXPLAIN to support output in XML or JSON format.
There are probably still some adjustments to be made in the details
of the output, but this gets the basic structure in place.

Robert Haas
2009-08-10 05:46:50 +00:00
Peter Eisentraut 7798147a76 Expand test coverage support to entire tree
Test coverage support now covers the entire source tree, including
contrib, instead of just src/backend.  In a related but independent
development, the commands make coverage and make coverage-html can be run
in any directory.

This turned out to be much easier than feared.  Besides a few ad hoc fixes
to pass the make target down the tree, change all affected makefiles to
list their directories in the SUBDIRS variable, changed from variants like
DIRS and WANTED_DIRS.  MSVC build fix was attempted as well.
2009-08-07 20:50:22 +00:00
Tom Lane 25bd9ce31b Add matchorig, matchsynonyms, and keepsynonyms options to contrib/dict_xsyn.
Sergey Karpov
2009-08-05 18:06:49 +00:00
Joe Conway f4095b4c4b Implement dblink_get_notify().
Adds the ability to retrieve async notifications using dblink,
via the addition of the function dblink_get_notify(). Original patch
by Marcus Kempe, suggestions by Tom Lane and Alvaro Herrera, patch
review and adjustments by Joe Conway.
2009-08-05 16:11:07 +00:00
Tom Lane c83d1fb155 Fix some more regression tests (missed these because they're only
run when built with --with-openssl).
2009-08-04 20:10:00 +00:00
Tom Lane bcba09e27c Ooops, missed that a couple of contrib modules have calls to byteacmp.
Add bytea.h inclusions as needed.  Some of the contrib regression tests
need to be de-hexified, too.  Per buildfarm.
2009-08-04 18:49:50 +00:00
Tom Lane 7ffb14f9db Portability and documentation fixes for threaded pgbench patch. 2009-08-03 18:30:55 +00:00
Tatsuo Ishii 3da0dfb4b1 Multi-threaded version of pgbench contributed by ITAGAKI Takahiro,
reviewed by Greg Smith and Josh Williams.

Following is the proposal from ITAGAKI Takahiro:

Pgbench is a famous tool to measure postgres performance, but nowadays
it does not work well because it cannot use multiple CPUs. On the other
hand, postgres server can use CPUs very well, so the bottle-neck of
workload is *in pgbench*.

Multi-threading would be a solution. The attached patch adds -j
(number of jobs) option to pgbench. If the value N is greater than 1,
pgbench runs with N threads. Connections are equally-divided into
them (ex. -c64 -j4 => 4 threads with 16 connections each). It can
run on POSIX platforms with pthread and on Windows with win32 threads.

Here are results of multi-threaded pgbench runs on Fedora 11 with intel
core i7 (8 logical cores = 4 physical cores * HT). -j8 (8 threads) was
the best and the tps is 4.5 times of -j1, that is a traditional result.

$ pgbench -i -s10
$ pgbench -n -S -c64 -j1   =>  tps = 11600.158593
$ pgbench -n -S -c64 -j2   =>  tps = 17947.100954
$ pgbench -n -S -c64 -j4   =>  tps = 26571.124001
$ pgbench -n -S -c64 -j8   =>  tps = 52725.470403
$ pgbench -n -S -c64 -j16  =>  tps = 38976.675319
$ pgbench -n -S -c64 -j32  =>  tps = 28998.499601
$ pgbench -n -S -c64 -j64  =>  tps = 26701.877815

Is it acceptable to use pthread in contrib module?
If ok, I will add the patch to the next commitfest.
2009-08-03 15:18:14 +00:00
Tom Lane b680ae4bdb Improve unique-constraint-violation error messages to include the exact
values being complained of.

In passing, also remove the arbitrary length limitation in the similar
error detail message for foreign key violations.

Itagaki Takahiro
2009-08-01 19:59:41 +00:00
Magnus Hagander a23c641578 Make sure FD_SETSIZE is set before we include any Windows
header files.

Josh Williams
2009-07-30 09:28:00 +00:00
Tom Lane cfbd2af95c Improve comment, per gripe from Alvaro. 2009-07-27 04:09:55 +00:00
Tom Lane e4b9e65393 Fix pg_stat_statements for EXEC_BACKEND case.
We should not try to load old statistics when re-attaching to existing
shared memory.  Per bug #4941.

Itagaki Takahiro
2009-07-27 03:34:40 +00:00
Tom Lane d4382c4ae7 Extend EXPLAIN to allow generic options to be specified.
The original syntax made it difficult to add options without making them
into reserved words.  This change parenthesizes the options to avoid that
problem, and makes provision for an explicit (and perhaps non-Boolean)
value for each option.  The original syntax is still supported, but only
for the two original options ANALYZE and VERBOSE.

As a test case, add a COSTS option that can suppress the planner cost
estimates.  This may be useful for including EXPLAIN output in the regression
tests, which are otherwise unable to cope with cross-platform variations in
cost estimates.

Robert Haas
2009-07-26 23:34:18 +00:00
Heikki Linnakangas fe1cc1e730 pg_standby doesn't need to be linked with libpq. Fujii Masao. 2009-07-16 09:59:46 +00:00
Bruce Momjian 6fafa6a0ae vacuumlo query cleanups
No need for VACUUM ANAYZE of newly created/populated temp table, just
use analyze.

No need to apologize for using subquery in DELETE anymore.
2009-07-13 22:56:30 +00:00
Tom Lane e7370babd1 Fix xslt_process() to ensure that it inserts a NULL terminator after the
last pair of parameter name/value strings, even when there are MAXPARAMS
of them.  Aboriginal bug in contrib/xml2, noted while studying bug #4912
(though I'm not sure whether there's something else involved in that
report).

This might be thought a security issue, since it's a potential backend
crash; but considering that untrustworthy users shouldn't be allowed
to get their hands on xslt_process() anyway, it's probably not worth
getting excited about.
2009-07-10 00:32:00 +00:00
Tom Lane 888bcdb9e0 Make prior patch pgindent-safe. 2009-06-25 19:33:25 +00:00
Heikki Linnakangas 8fd733bd19 Disable pg_standby -l option because the backend doesn't expect the recovered
file to be a symlink. We tried to fix this issue with an earlier server-side
patch, but it didn't fix the whole issue.

The same bug is present in older releases as well, but the 8.4 train is
about to leave the station, and I'm not sure if have consensus on whether
we can remove the -l option in back-branches or do we need to attempt a
server-side fix to make symlinking safe.

Patch by Simon Riggs, per discussion on bug identified by Fujii Masao.
2009-06-25 12:03:11 +00:00
Heikki Linnakangas efa8544fd5 Fix a few errors in comments. Patch by Fujii Masao, plus the one in
visibilitymap.c by me.
2009-06-18 10:08:08 +00:00
Tom Lane d94582f4f8 Mark contrib's GiST and GIN opclass support functions as STRICT, for safety.
(Note: GiST penalty functions could possibly be non-strict, but none are at
present.)
2009-06-11 18:30:03 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Tom Lane 15a3fe6d63 Properly mark pg_freespace() function as strict. Also update
uninstall script to match reality.
2009-06-10 22:12:28 +00:00
Tom Lane f3e122fcdf Restore dblink_current_query() to being a C-language function, so as to not
create an ABI break between 8.3 and 8.4.  It is still just a wrapper around
the built-in current_query() function, but at a different implementation
level.  Per my proposal.

Note: this change doesn't break 8.4beta installations, since their
SQL-language definition of the function still works fine.
2009-06-09 17:41:02 +00:00
Joe Conway e5de601267 Default client encoding to server encoding for dblink connections. Addresses
issue raised by Ruzsinszky Attila and confirmed by others.

 ----------------------------------------------------------------------
2009-06-09 16:35:36 +00:00
Tom Lane a1fd650d2b Fix contrib/pageinspect to not create an ABI breakage between 8.3 and 8.4.
The original implementation of the 3-argument form of get_raw_page() risked
core dumps if the 8.3 SQL function definition was mistakenly used with the
8.4 module, which is entirely likely after a dump-and-reload upgrade.  To
protect 8.4 beta testers against upgrade problems, add a check on PG_NARGS.

In passing, fix missed additions to the uninstall script, and polish the
docs a trifle.
2009-06-08 16:22:44 +00:00
Tom Lane 156475a589 Revert my patch of 2009-04-04 that removed contrib/intarray's definitions of
the <@ and @> operators.  These are not in fact equivalent to the built-in
anyarray operators of the same names, because they have different behavior for
empty arrays, namely they don't think empty arrays are contained in anything.
That is mathematically wrong, no doubt, but until we can persuade GIN indexes
to implement the mathematical definition we should probably not change this.
Another reason for not changing it now is that we can't yet ensure the
opclasses will be updated correctly in a dump-and-reload upgrade.  Per
recent discussions.
2009-06-07 20:09:34 +00:00
Joe Conway 4334695b30 Add support for using SQL/MED compliant FOREIGN DATA WRAPPER, SERVER,
and USER MAPPING as method to supply dblink connect parameters. Per
mailing list and PGCon discussions.
2009-06-06 21:27:56 +00:00
Joe Conway db02073305 Fix dblink_get_result() as reported by Oleksiy Shchukin. Refactor a bit
while we're at it per request by Tom Lane. Specifically, don't try to
perform dblink_send_query() via dblink_record_internal() -- it was
inappropriate and ugly.
2009-06-02 03:21:56 +00:00
Heikki Linnakangas 9e403c2587 Add recovery_end_command option to recovery.conf. recovery_end_command
is run at the end of archive recovery, providing a chance to do external
cleanup. Modify pg_standby so that it no longer removes the trigger file,
that is to be done using the recovery_end_command now.

Provide a "smart" failover mode in pg_standby, where we don't fail over
immediately, but only after recovering all unapplied WAL from the archive.
That gives you zero data loss assuming all WAL was archived before
failover, which is what most users of pg_standby actually want.

recovery_end_command by Simon Riggs, pg_standby changes by Fujii Masao and
myself.
2009-05-14 20:31:09 +00:00
Heikki Linnakangas a41e9ec0db Add alternative expected output files for cs_CZ locale for btree_gist and
tsearch2 tests. This should make 'comet_moth' buildfarm member pass
contrib check. Zdenek Kotala.
2009-05-08 14:48:06 +00:00
Tom Lane 48caf91b66 Change pgbench to use the table names pgbench_accounts, pgbench_branches,
pgbench_history, and pgbench_tellers, rather than just accounts, branches,
history, and tellers.  This is to prevent accidental conflicts with real
application tables, as has been reported to happen at least once.  Also
remove the automatic "SET search_path = public" that it did at startup,
as this seems to restrict testing flexibility without actually buying much.
Per proposal by Joshua Drake and ensuing discussion.

Joshua Drake and Tom Lane
2009-05-07 22:01:18 +00:00
Bruce Momjian 636edd553d Blank line Makefile cleanups. 2009-04-28 17:07:50 +00:00
Tom Lane 5efb84f213 Update citext expected output to exactly match the real output, rather
than having some whitespace discrepancy.  Although whitespace is supposed
to be ignored in our regression tests, for some reason buildfarm member
spoonbill doesn't like it.
2009-04-26 02:47:05 +00:00
Heikki Linnakangas 283939a321 varstr_cmp and any comparison function that piggybacks on it can return
any negative or positive number, not just -1 or 1. Fix comment on
varstr_cmp and citext test case accordingly.

As pointed out by Zdenek Kotala, and buildfarm member gothic moth.
2009-04-23 07:19:09 +00:00
Magnus Hagander 2377e8e508 Remove beer-ware license from crypt-md5.c, per
approval from Poul-Henning Kamp.

This makes the file the same standard 2-clause BSD as the
rest of PostgreSQL.
2009-04-15 18:58:24 +00:00
Tom Lane b89ab7e019 Remove useless (leftover?) extern declaration. 2009-04-07 17:57:50 +00:00
Tom Lane bb6bbc3277 Defend against non-ASCII letters in fuzzystrmatch code. The functions
still don't behave very sanely for multibyte encodings, but at least
they won't be indexing off the ends of static arrays.
2009-04-07 15:53:54 +00:00
Tom Lane 65e758a4d3 Remove contrib/intarray's definitions of the <@ and @> operators, so that they
don't cause confusion with the built-in anyarray versions of those operators.
Adjust the module's index opclasses to support the built-in operators in place
of the private ones.

The private implementations are still available under their historical
names @ and ~, so no functionality is lost.  Some quick testing suggests
that they offer no real benefit over the core operators, however.

Per a complaint from Rusty Conover.
2009-04-05 00:40:35 +00:00
Teodor Sigaev 3df4fa6968 Fix memory allocation for output of hstore type.
Per "maosen.zhang" <maosen.zhang@alibaba-inc.com> report.
2009-04-02 17:57:05 +00:00
Tom Lane c029a6a49e Fix contrib/pgstattuple and contrib/pageinspect to prevent attempts to read
temporary tables of other sessions; that is unsafe because of the way our
buffer management works.  Per report from Stuart Bishop.
This is redundant with the bufmgr.c checks in HEAD, but not at all redundant
in the back branches.
2009-03-31 22:54:31 +00:00
Tom Lane c7662960b1 Make pg_standby's maxretries option do what one would expect. Fujii Masao 2009-03-26 22:29:13 +00:00
Tom Lane 9151e1bb06 Add btree_gin contrib module.
Teodor Sigaev and Oleg Bartunov
2009-03-25 23:20:01 +00:00
Tom Lane 87b8db3774 Adjust the APIs for GIN opclass support functions to allow the extractQuery()
method to pass extra data to the consistent() and comparePartial() methods.
This is the core infrastructure needed to support the soon-to-appear
contrib/btree_gin module.  The APIs are still upward compatible with the
definitions used in 8.3 and before, although *not* with the previous 8.4devel
function definitions.

catversion bump for changes in pg_proc entries (although these are just
cosmetic, since GIN doesn't actually look at the function signature before
calling it...)

Teodor Sigaev and Oleg Bartunov
2009-03-25 22:19:02 +00:00
Tom Lane 050a78dd3d Fix old thinko in pgp.h: the idea is to declare some named enum types,
not global variables of anonymous enum types.  This didn't actually hurt
much because most linkers will just merge the duplicated definitions ...
but some will complain.  Per bug #4731 from Ceriel Jacobs.

Backpatch to 8.1 --- the declarations don't exist before that.
2009-03-25 15:03:13 +00:00
Heikki Linnakangas 753a040486 Don't set the signal handler for SIGQUIT on Windows. Buildfarm shows that
reinstalling the default signal handler doesn't work as it is on Windows.
Presumably core dumps on SIGQUIT are not a problem on Windows, so rather
than figure out what header files or other changes are required to make it
work, just don't bother.
2009-03-18 20:30:35 +00:00
Heikki Linnakangas 47ce595502 Don't intercept SIGQUIT as a signal to trigger failover; that's what
postmaster uses for immediate shutdown. Trap SIGUSR1 as the preferred
signal for that.

Per report by Fujii Masao and subsequent discussion on -hackers.
2009-03-18 19:27:28 +00:00
Tom Lane f3a72bd40b Fix contrib/hstore to throw an error for keys or values that don't fit in its
data structure, rather than silently truncating them.  Andrew Gierth
2009-03-15 22:05:17 +00:00
Peter Eisentraut b6e4c8f255 Equip the programs installed by contrib with proper --help and --version
options and normally formatted help output.
2009-02-27 09:30:21 +00:00
Peter Eisentraut 9de59fd191 Add a -w/--no-password option that prevents all password prompts to all
programs that have a -W/--password option.

In passing, remove the ancient PSQL_ALWAYS_GET_PASSWORDS compile option.
2009-02-26 16:02:39 +00:00
Peter Eisentraut b2f47aa325 Clean up help (-?) output. 2009-02-25 13:34:32 +00:00
Peter Eisentraut a3c502c89f Remove feof(stdin) calls related to when to prompt for a password,
leftovers from when the password was read from stdin.
2009-02-25 13:24:40 +00:00
Teodor Sigaev 3ca7eddbb7 Fix bug with multiple evaluation of tsearch2 compatibility trigger, trigger
data should be restored.
Backpatch only for 8.3 because previous versions haven't such layer.
2009-01-28 18:31:32 +00:00
Tom Lane 1cfd9e8834 Fix executor/spi.h to follow our usual conventions for include files, ie,
not include postgres.h nor anything else it doesn't directly need.  Add
#includes to calling files as needed to compensate.  Per my proposal of
yesterday.

This should be noted as a source code change in the 8.4 release notes,
since it's likely to require changes in add-on modules.
2009-01-07 13:44:37 +00:00
Tom Lane e228624011 Remove references to pgsql-ports and pgsql-patches mailing lists from
various documentation, since those lists are now dead/deprecated.
Point to pgsql-bugs and/or pgsql-hackers as appropriate.
2009-01-06 17:27:06 +00:00
Tatsuo Ishii 40e01e267d Remove outdated Japanese README files per discussion. 2009-01-06 13:43:31 +00:00
Tom Lane da2c1b8a27 Add EmitWarningsOnPlaceholders calls to contrib modules that are likely to
get listed in custom_variable_classes.
2009-01-05 13:35:38 +00:00
Tom Lane 7466eeac61 Add contrib/pg_stat_statements for server-wide tracking of statement execution
statistics.

Takahiro Itagaki
2009-01-04 22:19:59 +00:00
Tom Lane ccdb6627ee Tweak guc.c to allow underscores in the names of custom variable classes,
and change auto_explain's custom GUC variables to be named auto_explain.xxx
not just explain.xxx.  Per discussion in connection with the
pg_stat_statements patch, it seems like a good idea to have the convention
that custom variable classes are named the same as their defining module.
Committing separately since this should happen regardless of what happens
with pg_stat_statements itself.
2009-01-02 01:16:02 +00:00
Bruce Momjian 2dca07d54e Add comma so this copyright notice is picked up in 2010. 2009-01-01 18:21:19 +00:00
Tom Lane 62b64cbb48 Fix a couple of missed copyright dates. 2009-01-01 17:59:40 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Tom Lane 95b07bc7f5 Support window functions a la SQL:2008.
Hitoshi Harada, with some kibitzing from Heikki and Tom.
2008-12-28 18:54:01 +00:00
Bruce Momjian 1b92aeb93e Improve comment about why sleep is used by pg_standby to handle 'copy'
file size problem.
2008-12-15 22:13:02 +00:00
Bruce Momjian eb88e7ee2c Add comment about GNUWin32's cp not having the file system problem. 2008-12-15 21:39:25 +00:00
Bruce Momjian 78b25fd2e9 Add missing 'break' in Win32 switch statement, reported by Martin Zaun 2008-12-15 21:11:54 +00:00
Tom Lane cf407f164e Refactor crosstab() to build and return a tuplestore instead of using
value-per-call mode.  This should be more efficient in normal usage,
but the real problem with the prior coding was that it returned with
a SPI call still active.  That could cause problems if execution was
interleaved with anything else that might use SPI.
2008-12-01 01:30:18 +00:00
Tom Lane 76cc2fe6a1 Fix dblink and tablefunc to not return with the wrong CurrentMemoryContext.
Per buildfarm results.
2008-11-30 23:23:52 +00:00
Tom Lane 3f936aacc0 Add a "LIKE = typename" clause to CREATE TYPE for base types. This allows
the basic representational details (typlen, typalign, typbyval, typstorage)
to be copied from an existing type rather than listed explicitly in the
CREATE TYPE command.  The immediate reason for this is to provide a simple
solution for add-on modules that want to define types represented as int8,
float4, or float8: as of 8.4 the appropriate PASSEDBYVALUE setting is
platform-specific and so it's hard for a SQL script to know what to do.

This patch fixes the contrib/isn breakage reported by Rushabh Lathia.
2008-11-30 19:01:29 +00:00
Tom Lane 4cee672177 Fix an oversight in uninstall_isn.sql: must drop operator families explicitly. 2008-11-28 21:19:13 +00:00
Tom Lane 5f77b1ac51 Cosmetic cleanups in contrib/isn (doesn't fix the passbyval problem) 2008-11-28 18:04:00 +00:00
Peter Eisentraut a53536d031 Add %expect 0 to all parser input files to prevent conflicts slipping by. 2008-11-26 08:45:12 +00:00
Tom Lane e125e28e78 Add auto-explain contrib module for automatic logging of the plans of
slow-running queries.

Takahiro Itagaki
2008-11-19 02:59:28 +00:00
Tom Lane 32cc9e5533 Reduce contrib/intagg to a thin wrapper around the new core functions
array_agg() and unnest().  We could drop it entirely in the future,
but let's keep it for a release or two as a compatibility assist.
2008-11-14 19:58:45 +00:00
Teodor Sigaev b87b52bf04 Support of multibyte encoding for pg_trgm 2008-11-12 13:43:54 +00:00
Tom Lane d141e7493b Fix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
it was using too soon.  In a situation where pg_do_encoding_conversion is
a no-op, this led to garbage data returned.

In HEAD, also modify the code that's ensuring null termination to make it
a tad more obvious what's happening.
2008-11-10 14:57:38 +00:00
Tom Lane 13fdd0e4d1 Add some more citext test cases, per David Wheeler. Also remove the
citext-to-and-from-xml tests, since those caused variation between
installations with or without libxml without really proving much.  Instead
repurpose citext_1.out as the expected results in glibc en_US (and probably
other) locales.
2008-11-07 23:17:30 +00:00
Tom Lane 902d1cb35f Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple,
and heap_deformtuple in favor of the newer functions heap_form_tuple et al
(which do the same things but use bool control flags instead of arbitrary
char values).  Eliminate the former duplicate coding of these functions,
reducing the deprecated functions to mere wrappers around the newer ones.
We can't get rid of them entirely because add-on modules probably still
contain many instances of the old coding style.

Kris Jurka
2008-11-02 01:45:28 +00:00
Heikki Linnakangas 19c8dc839b Unite ReadBufferWithFork, ReadBufferWithStrategy, and ZeroOrReadBuffer
functions into one ReadBufferExtended function, that takes the strategy
and mode as argument. There's three modes, RBM_NORMAL which is the default
used by plain ReadBuffer(), RBM_ZERO, which replaces ZeroOrReadBuffer, and
a new mode RBM_ZERO_ON_ERROR, which allows callers to read corrupt pages
without throwing an error. The FSM needs the new mode to recover from
corrupt pages, which could happend if we crash after extending an FSM file,
and the new page is "torn".

Add fork number to some error messages in bufmgr.c, that still lacked it.
2008-10-31 15:05:00 +00:00
Tom Lane 05bba3d176 Be more tense about not creating tuplestores with randomAccess = true unless
backwards scan could actually happen.  In particular, pass a flag to
materialize-mode SRFs that tells them whether they need to require random
access.  In passing, also suppress unneeded backward-scan overhead for a
Portal's holdStore tuplestore.  Per my proposal about reducing I/O costs for
tuplestores.
2008-10-29 00:00:39 +00:00
Tom Lane e3e3d2a789 Extend ExecMakeFunctionResult() to support set-returning functions that return
via a tuplestore instead of value-per-call.  Refactor a few things to reduce
ensuing code duplication with nodeFunctionscan.c.  This represents the
reasonably noncontroversial part of my proposed patch to switch SQL functions
over to returning tuplestores.  For the moment, SQL functions still do things
the old way.  However, this change enables PL SRFs to be called in targetlists
(observe changes in plperl regression results).
2008-10-28 22:02:06 +00:00
Tom Lane 2f0d528291 Update citext expected output for recent change in error message location
pointers.  This is only a whitespace change, which ought to be ignored
by regression testing, but for some reason buildfarm member spoonbill
doesn't like it.
2008-10-14 21:39:41 +00:00
Heikki Linnakangas 5f853c6556 Use fork names instead of numbers in the file names for additional
relation forks. While the file names are not visible to users, for those
that do peek into the data directory, it's nice to have more descriptive
names. Per Greg Stark's suggestion.
2008-10-06 14:13:17 +00:00
Heikki Linnakangas 6736da5484 Make the blkno arguments bigints instead of int4s. A signed int4 is not
large enough for block numbers higher than 2^31. The old pre-FSM-rewrite
pg_freespacemap implementation got this right. While we're at it, remove
some unnecessary #includes.
2008-10-02 12:20:50 +00:00
Heikki Linnakangas d3de08a008 Rewrite pg_freespacemap to match the new FSM implementation. I missed these
changes from the main FSM commit for some reason.
2008-09-30 11:17:07 +00:00
Heikki Linnakangas 15c121b3ed Rewrite the FSM. Instead of relying on a fixed-size shared memory segment, the
free space information is stored in a dedicated FSM relation fork, with each
relation (except for hash indexes; they don't use FSM).

This eliminates the max_fsm_relations and max_fsm_pages GUC options; remove any
trace of them from the backend, initdb, and documentation.

Rewrite contrib/pg_freespacemap to match the new FSM implementation. Also
introduce a new variant of the get_raw_page(regclass, int4, int4) function in
contrib/pageinspect that let's you to return pages from any relation fork, and
a new fsm_page_contents() function to inspect the new FSM pages.
2008-09-30 10:52:14 +00:00
Tom Lane cae7ad906a Fix dblink_connect() so that it verifies that a password is supplied in the
conninfo string *before* trying to connect to the remote server, not after.
As pointed out by Marko Kreen, in certain not-very-plausible situations
this could result in sending a password from the postgres user's .pgpass file,
or other places that non-superusers shouldn't have access to, to an
untrustworthy remote server.  The cleanest fix seems to be to expose libpq's
conninfo-string-parsing code so that dblink can check for a password option
without duplicating the parsing logic.

Joe Conway, with a little cleanup by Tom Lane
2008-09-22 13:55:14 +00:00
Tom Lane cff4aa6ad6 Add a duration option to pgbench, so that test length can be specified in seconds
instead of by number of transactions to run.  Takahiro Itagaki
2008-09-11 23:52:48 +00:00
Tom Lane 5bc561a16a Add some additional casts and regression tests for the citext data type.
David Wheeler
2008-09-05 18:25:17 +00:00
Tom Lane fbb2b69c8f Prevent memory leaks in our various bison parsers when an error occurs
during parsing.  Formerly the parser's stack was allocated with malloc
and so wouldn't be reclaimed; this patch makes it use palloc instead,
so that flushing the current context will reclaim the memory.  Per
Marko Kreen.
2008-09-02 20:37:55 +00:00
Tom Lane b153c09209 Add a bunch of new error location reports to parse-analysis error messages.
There are still some weak spots around JOIN USING and relation alias lists,
but most errors reported within backend/parser/ now have locations.
2008-09-01 20:42:46 +00:00
Peter Eisentraut 7c31742a07 Remove all traces that suggest that a non-Bison yacc might be supported, and
change build system to use only Bison.  Simplify build rules, make file names
uniform.  Don't build the token table header file where it is not needed.
2008-08-29 13:02:33 +00:00
Tom Lane 3e4264ca35 Add %option noinput to contrib's flex scanners, to suppress gcc 4.3
warnings.  Peter did this for core awhile ago but evidently missed
contrib.
2008-08-25 23:12:45 +00:00
Bruce Momjian 6152de97d3 Minor patch on pgbench
1. -i option should run vacuum analyze only on pgbench tables, not *all*
tables in database.

2. pre-run cleanup step was DELETE FROM HISTORY then VACUUM HISTORY.
This is just a slow version of TRUNCATE HISTORY.

Simon Riggs
2008-08-22 17:57:34 +00:00
Heikki Linnakangas ef1c807c25 pg_buffercache needs to be taught about relation forks, as Greg Stark
pointed out.
2008-08-14 12:56:41 +00:00
Tom Lane c8572986ad Allow I/O conversion casts to be applied to or from any type that is a member
of the STRING type category, thereby opening up the mechanism for user-defined
types.  This is mainly for the benefit of citext, though; there aren't likely
to be a lot of types that are all general-purpose character strings.
Per discussion with David Wheeler.
2008-07-30 21:23:17 +00:00
Tom Lane 42be2c790f Adjust citext to make use of the new ability to declare its type category:
by putting it into the standard string category, we cause casts from citext
to text to be recognized as "preferred" casts.  This eliminates the need
for creation of alias functions and operators that only serve to prevent
ambiguous-function errors; get rid of the ones that were in the original
commit.
2008-07-30 17:08:52 +00:00
Tom Lane ab9907f5e5 Add a new, improved version of citext as a contrib module.
David E. Wheeler
2008-07-29 18:31:20 +00:00
Teodor Sigaev 2d6599f471 Add caching of query to GIN/GiST consistent function.
Per performance gripe from nomao.com
2008-07-11 11:56:48 +00:00
Heikki Linnakangas cac2f697ee Fix WAL file cutoff point calculation in pg_standby.
Patch by Simon Riggs, per bug report from Ferenc Felhoffer
2008-07-08 15:11:58 +00:00
Joe Conway c0241b9573 When an ERROR happens on a dblink remote connection, take
pains to pass the ERROR message components locally, including
using the passed SQLSTATE. Also wrap the passed info in an
appropriate CONTEXT message. Addresses complaint by Henry
Combrinck. Joe Conway, with much good advice from Tom Lane.
2008-07-03 03:56:57 +00:00