Commit Graph

10978 Commits

Author SHA1 Message Date
Tom Lane 8bf14182cf Export xml.c's libxml-error-handling support so that contrib/xml2 can use it
too, instead of duplicating the functionality (badly).

I renamed xml_init to pg_xml_init, because the former seemed just a bit too
generic to be safe as a global symbol.  I considered likewise renaming
xml_ereport to pg_xml_ereport, but felt that the reference to ereport probably
made it sufficiently PG-centric already.
2010-03-03 17:29:45 +00:00
Magnus Hagander 8373490607 It's clearly now pointless to do backwards compatible parsing of this,
since we released a version without it, so remove the comment that
says we might want to do that.
2010-03-01 16:02:01 +00:00
Tom Lane 4d17a2146c Insert a hack into get_float8_nan (both core and ecpg copies) to deal with
the fact that NetBSD/mips is currently broken, as per buildfarm member pika.

Also add regression tests to ensure that get_float8_nan and get_float4_nan
are exercised even on platforms where they are not needed by
float8in/float4in.

Zoltán Böszörményi and Tom Lane
2010-02-27 21:53:21 +00:00
Bruce Momjian bf379837dc Back out unintended change to pg_locale.c. 2010-02-27 20:20:44 +00:00
Bruce Momjian 9295eea839 Document ATAPI FLUSH CACHE EXT. 2010-02-27 20:16:17 +00:00
Tom Lane 5667a53b78 Undo some more pgindent breakage. Per buildfarm. 2010-02-27 03:55:52 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane 99419d36f2 Allow predicate_refuted_by() to deduce that NOT A refutes A.
We had originally made the stronger assumption that NOT A refutes any B
if B implies A, but this fails in three-valued logic, because we need to
prove B is false not just that it's not true.  However the logic does
go through if B is equal to A.

Recognizing this limited case is enough to handle examples that arise when
we have simplified "bool_var = true" or "bool_var = false" to just "bool_var"
or "NOT bool_var".  If we had not done that simplification then the
btree-operator proof logic would have been able to prove that the expressions
were contradictory, but only for identical expressions being compared to the
constants; so handling identical A and B covers all the same cases.

The motivation for doing this is to avoid unexpected asymmetrical behavior
when a partitioned table uses a boolean partitioning column, as in today's
gripe from Dominik Sander.

Back-patch to 8.2, which is as far back as predicate_refuted_by attempts to
do anything at all with NOTs.
2010-02-25 20:59:53 +00:00
Bruce Momjian 89ce2bfc13 Add C comment that do_to_timestamp() lacks error checking. 2010-02-25 18:36:14 +00:00
Magnus Hagander 413d34be4e Add configuration parameter ssl_renegotiation_limit to control
how often we do SSL session key renegotiation. Can be set to
0 to disable renegotiation completely, which is required if
a broken SSL library is used (broken patches to CVE-2009-3555
a known cause) or when using a client library that can't do
renegotiation.
2010-02-25 13:26:16 +00:00
Heikki Linnakangas cd2b7d3c4d Fix streaming replication starting at the very first WAL segment.
Per complaint from Greg Stark.
2010-02-25 07:31:40 +00:00
Tom Lane a2239b96e0 Make pg_stop_backup's reporting a bit more verbose in hopes of making
error cases less intimidating for novices.  Per discussion.

Greg Smith
2010-02-25 02:17:50 +00:00
Tom Lane 11b5847058 Add an OR REPLACE option to CREATE LANGUAGE.
This operates in the same way as other CREATE OR REPLACE commands, ie,
it replaces everything but the ownership and ACL lists of an existing
entry, and requires the caller to have owner privileges for that entry.

While modifying an existing language has some use in development scenarios,
in typical usage all the "replaced" values come from pg_pltemplate so there
will be no actual change in the language definition.  The reason for adding
this is mainly to allow programs to ensure that a language exists without
triggering an error if it already does exist.

This commit just adds and documents the new option.  A followon patch
will use it to clean up some unpleasant cases in pg_dump and pg_regress.
2010-02-23 22:51:43 +00:00
Bruce Momjian a54803149a Revert recent change of to_char('HH12') handling for intervals; instead
improve documentation, and add C comment.
2010-02-23 16:14:26 +00:00
Bruce Momjian 4f56dc3fb4 Secondary patch to fix interval to_char() for "HH" where hours >= 12. 2010-02-23 06:29:01 +00:00
Bruce Momjian 7cdadc62ea Supress convertion of zero hours to '12' for intervals when using
to_char with HH, e.g.

	to_char(interval '0d 0h 12m 44s', 'DD HH24 MI SS');

now returns:

	 00 00 12 44

not:

	 00 12 12 44
2010-02-23 01:42:19 +00:00
Tom Lane e9a383303c Adjust pg_fsync_writethrough so that it will set errno when failing
on a platform that doesn't support this operation.  The former coding
would allow an unrelated errno to be reported, which would be quite
misleading.  Not sure if this has anything to do with the current
buildfarm failures, but it's certainly bogus as-is.
2010-02-22 15:26:14 +00:00
Tom Lane 05d8a561ff Clean up handling of XactReadOnly and RecoveryInProgress checks.
Add some checks that seem logically necessary, in particular let's make
real sure that HS slave sessions cannot create temp tables.  (If they did
they would think that temp tables belonging to the master's session with
the same BackendId were theirs.  We *must* not allow myTempNamespace to
become set in a slave session.)

Change setval() and nextval() so that they are only allowed on temp sequences
in a read-only transaction.  This seems consistent with what we allow for
table modifications in read-only transactions.  Since an HS slave can't have a
temp sequence, this also provides a nicer cure for the setval PANIC reported
by Erik Rijkers.

Make the error messages more uniform, and have them mention the specific
command being complained of.  This seems worth the trifling amount of extra
code, since people are likely to see such messages a lot more than before.
2010-02-20 21:24:02 +00:00
Tom Lane 3f56ca1d49 Reduce the rescan cost estimate for Materialize nodes to cpu_operator_cost per
tuple, instead of the former cpu_tuple_cost.  It is sane to charge less than
cpu_tuple_cost because Materialize never does any qual-checking or projection,
so it's got less overhead than most plan node types.  In particular, we want
to have the same charge here as is charged for readout in cost_sort.  That
avoids the problem recently exhibited by Teodor wherein the planner prefers
a useless sort over a materialize step in a context where a lot of rescanning
will happen.  The rescan costs should be just about the same for both node
types, so make their estimates the same.

Not back-patching because all of the current logic for rescan cost estimates
is new in 9.0.  The old handling of rescans is sufficiently not-sane that
changing this in that structure is a bit pointless, and might indeed cause
regressions.
2010-02-19 21:49:10 +00:00
Heikki Linnakangas ad458cfe81 Don't use O_DIRECT when writing WAL files if archiving or streaming is
enabled. Bypassing the kernel cache is counter-productive in that case,
because the archiver/walsender process will read from the WAL file
soon after it's written, and if it's not cached the read will cause
a physical read, eating I/O bandwidth available on the WAL drive.

Also, walreceiver process does unaligned writes, so disable O_DIRECT
in walreceiver process for that reason too.
2010-02-19 10:51:04 +00:00
Heikki Linnakangas 94f610b163 Forbid setval() during recovery. This prevents the PANIC reported by
Erik Rijkers. Patch by Andres Freund.
2010-02-19 06:29:19 +00:00
Itagaki Takahiro 3230fd056a Fix STOP WAL LOCATION in backup history files no to return the next
segment of XLOG_BACKUP_END record even if the the record is placed
at a segment boundary. Furthermore the previous implementation could
return nonexistent segment file name when the boundary is in segments
that has "FE" suffix; We never use segments with "FF" suffix.

Backpatch to 8.0, where hot backup was introduced.

Reported by Fujii Masao.
2010-02-19 01:04:03 +00:00
Peter Eisentraut a39f02e369 Translation updates for 9.0alpha4 2010-02-19 00:40:05 +00:00
Tom Lane 858d1699f2 Provide some rather hokey ways for EXPLAIN to print FieldStore and assignment
ArrayRef expressions that are not in the immediate context of an INSERT or
UPDATE targetlist.  Such cases never arise in stored rules, so ruleutils.c
hadn't tried to handle them.  However, they do occur in the targetlists of
plans derived from such statements, and now that EXPLAIN VERBOSE tries to
print targetlists, we need some way to deal with the case.

I chose to represent an assignment ArrayRef as "array[subscripts] := source",
which is fairly reasonable and doesn't omit any information.  However,
FieldStore is problematic because the planner will fold multiple assignments
to fields of the same composite column into one FieldStore, resulting in a
structure that is hard to understand at all, let alone display comprehensibly.
So in that case I punted and just made it print the source expression(s).

Backpatch to 8.4 --- the lack of functionality exists in older releases,
but doesn't seem to be important for lack of anything that would call it.
2010-02-18 22:43:31 +00:00
Tom Lane 11d5ba97f8 Fix ExecEvalArrayRef to pass down the old value of the array element or slice
being assigned to, in case the expression to be assigned is a FieldStore that
would need to modify that value.  The need for this was foreseen some time
ago, but not implemented then because we did not have arrays of composites.
Now we do, but the point evidently got overlooked in that patch.  Net result
is that updating a field of an array element doesn't work right, as
illustrated if you try the new regression test on an unpatched backend.
Noted while experimenting with EXPLAIN VERBOSE, which has also got some issues
in this area.

Backpatch to 8.3, where arrays of composites were introduced.
2010-02-18 18:41:47 +00:00
Heikki Linnakangas 3e87ba6ef7 Fix pq_getbyte_if_available() function. It was confused on what it
returns if no data is immediately available. Patch by me with numerous
fixes from Fujii Masao and Magnus Hagander.
2010-02-18 11:13:46 +00:00
Itagaki Takahiro 1a1ad6320c date_recv should accept infinities.
Reported by James William Pye.
2010-02-18 04:31:16 +00:00
Tom Lane 7981c34279 Force READY portals into FAILED state when a transaction or subtransaction
is aborted, if they were created within the failed xact.  This prevents
ExecutorEnd from being run on them, which is a good idea because they may
contain references to tables or other objects that no longer exist.
In particular this is hazardous when auto_explain is active, but it's
really rather surprising that nobody has seen an issue with this before.
I'm back-patching this to 8.4, since that's the first version that contains
auto_explain or an ExecutorEnd hook, but I wonder whether we shouldn't
back-patch further.
2010-02-18 03:06:46 +00:00
Tom Lane 2b44d74dd4 Take care to reprocess an uncommitted notify message.
Oversight in my changes to cope with possible errors during message
processing; spotted by Joachim Wieland.
2010-02-17 16:54:06 +00:00
Magnus Hagander 075d43a01a Another typo fix.
Thom Brown
2010-02-17 05:51:40 +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
Tom Lane c64339face When updating ShmemVariableCache from a checkpoint record, be sure to set
all the values derived from oldestXid, not just that field.  Brain fade in
one of my patches associated with flat file removal, exposed by a report
from Fujii Masao.

With this change, xidVacLimit should always be valid, so remove a couple of
bits of complexity associated with the previous assumption that sometimes
it wouldn't get set right away.
2010-02-17 03:10:33 +00:00
Tom Lane 9cbcfca44a log_error_verbosity is now LOGGING_WHAT category. 2010-02-17 01:39:35 +00:00
Tom Lane ee678fe30c Make NOTIFY_PAYLOAD_MAX_LENGTH depend explicitly on BLCKSZ and
NAMEDATALEN, so this code doesn't go nuts with smaller than default
BLCKSZ or larger than default NAMEDATALEN.  The standard value is
still exactly 8000.
2010-02-17 00:52:09 +00:00
Tom Lane d1e027221d Replace the pg_listener-based LISTEN/NOTIFY mechanism with an in-memory queue.
In addition, add support for a "payload" string to be passed along with
each notify event.

This implementation should be significantly more efficient than the old one,
and is also more compatible with Hot Standby usage.  There is not yet any
facility for HS slaves to receive notifications generated on the master,
although such a thing is possible in future.

Joachim Wieland, reviewed by Jeff Davis; also hacked on by me.
2010-02-16 22:34:57 +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
Bruce Momjian 813135d8c9 Move log_error_verbosity GUC setting to "What to log" section, and
document the behavior of terse and verbose output options.
2010-02-16 21:35:51 +00:00
Bruce Momjian 70d8a2c29e Honor to_char() "FM" specification in YYY, YY, and Y; it was already
honored by YYYY.  Also document Oracle "toggle" FM behavior.

Per report from Guy Rouillier
2010-02-16 21:18:02 +00:00
Bruce Momjian aa7e7ae9a6 Have SELECT and CREATE TABLE AS queries return a row count. While this
is invisible in psql, other interfaces, like libpq, make this value
visible.

Boszormenyi Zoltan
2010-02-16 20:58:14 +00:00
Bruce Momjian 346a721eed Remove personal copyright now that file has been rewritten using
existing *.pl conversion script.

Andreas 'ads' Scherbaum
2010-02-16 20:35:07 +00:00
Bruce Momjian 93a57c3b57 Clarify documentation on the behavior of unnamed bind queries. 2010-02-16 20:15:14 +00:00
Greg Stark 27cb626f7a revert to showing buffer counts in explain (buffers) 2010-02-16 20:07:13 +00:00
Magnus Hagander 215cbc90f8 Add emulation of non-blocking sockets to the win32 socket/signal layer,
and use this in pq_getbyte_if_available.

It's only a limited implementation which swithes the whole emulation layer
no non-blocking mode, but that's enough as long as non-blocking is only
used during a short period of time, and only one socket is accessed during
this time.
2010-02-16 19:26:02 +00:00
Alvaro Herrera dc11595193 Fix typo in comment 2010-02-15 16:10:34 +00:00
Greg Stark 34ebccddcd Display explain buffers measurements in memory units rather than blocks. Also show "Total Buffer Usage" to hint that these are totals not averages per loop 2010-02-15 02:36:26 +00:00
Greg Stark f8c183a1ac Speed up CREATE DATABASE by deferring the fsyncs until after copying
all the data and using posix_fadvise to nudge the OS into flushing it
earlier. This also hopefully makes CREATE DATABASE avoid spamming the
cache.

Tests show a big speedup on Linux at least on some filesystems.

Idea and patch from Andres Freund.
2010-02-15 00:50:57 +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
Bruce Momjian bbdf72b095 Improve C comment about why we return "0 0" for some tags. 2010-02-13 22:45:41 +00:00
Simon Riggs 8eccf7614b Improvements to ps message of startup process during Hot Standby.
Message is reset earlier and potential bug avoided.

Andres Freund
2010-02-13 16:29:38 +00:00
Simon Riggs dd428c79a4 Fix relcache init file invalidation during Hot Standby for the case
where a database has a non-default tablespaceid. Pass thru MyDatabaseId
and MyDatabaseTableSpace to allow file path to be re-created in
standby and correct invalidation to take place in all cases.
Update and rework xact_commit_desc() debug messages.
Bug report from Tom by code inspection. Fix by me.
2010-02-13 16:15:48 +00:00