Commit Graph

15941 Commits

Author SHA1 Message Date
Bruce Momjian 069ad5fcc3 Add SSL CRL support to libpq. Recently added to the backend. 2006-05-06 02:24:39 +00:00
Bruce Momjian 3ecfdceaec Issue a log message if a CRL file exists and the SSL library does not
support CRL certificates.
2006-05-06 01:31:38 +00:00
Bruce Momjian 25c1c3cfd6 Seems some NetBSD 3.0 x86 systems still need float8-small-is-zero, so
patch reverted.
2006-05-05 18:10:35 +00:00
Bruce Momjian f454d6264d On Solaris ASM, / '/' is the comment for x86, while '!' is the comment
for Sparc

Robert Lor
2006-05-05 16:23:20 +00:00
Bruce Momjian c51c2777ec Use regression results float8-small-is-zero only for NetBSD < 3.0.
Backpatch to 8.1.X.

Simon Burge
2006-05-05 16:16:49 +00:00
Bruce Momjian e451014d8c Change Solaris comments from / to !.
Robert Lor
2006-05-05 12:22:42 +00:00
Tom Lane 1e3496f26a Don't try to compile SSL CRL support if local SSL installation hasn't
got it.  Per buildfarm failure on 'canary'.
2006-05-04 22:18:38 +00:00
Tom Lane 46287bd660 Simplify relcache startup sequence. With the new design of InitPostgres
it's not necessary to have three separate calls anymore.  This patch also
fixes things so we don't try to read pg_internal.init until after we've
obtained lock on the target database; which was fairly harmless, but it's
certainly cleaner this way.
2006-05-04 18:51:36 +00:00
Tom Lane 52667d56a3 Rethink the locking mechanisms used for CREATE/DROP/RENAME DATABASE.
The former approach used ExclusiveLock on pg_database, which being a
cluster-wide lock meant only one of these operations could proceed at
a time; worse, it also blocked all incoming connections in ReverifyMyDatabase.
Now that we have LockSharedObject(), we can use locks of different types
applied to databases considered as objects.  This allows much more
flexible management of the interlocking: two CREATE DATABASEs need not
block each other, and need not block connections except to the template
database being used.  Similarly DROP DATABASE doesn't block unrelated
operations.  The locking used in flatfiles.c is also much narrower in
scope than before.  Per recent proposal.
2006-05-04 16:07:29 +00:00
Tom Lane cb98e6fb8f Create a syscache for pg_database-indexed-by-oid, and make use of it
in various places that were previously doing ad hoc pg_database searches.
This may speed up database-related privilege checks a little bit, but
the main motivation is to eliminate the performance reason for having
ReverifyMyDatabase do such a lot of stuff (viz, avoiding repeat scans
of pg_database during backend startup).  The locking reason for having
that routine is about to go away, and it'd be good to have the option
to break it up.
2006-05-03 22:45:26 +00:00
Teodor Sigaev 2a58f3bff6 Fix typo noticed by Alvaro Herrera 2006-05-03 06:56:47 +00:00
Tom Lane f4923880b3 Fix calculation of plan node extParams to account for the possibility that one
initPlan sets a parameter for another.  This could not (I think) happen before
8.1, but it's possible now because the initPlans generated by MIN/MAX
optimization might themselves use initPlans.  We attach those initPlans as
siblings of the MIN/MAX ones, not children, to avoid duplicate computation
when multiple MIN/MAX aggregates are present; so this leads to the case of an
initPlan needing the result of a sibling initPlan, which is not possible with
ordinary query nesting.  Hadn't been noticed because in most contexts having
too much stuff listed in extParam is fairly harmless.  Fixes "plan should not
reference subplan's variable" bug reported by Catalin Pitis.
2006-05-03 00:24:56 +00:00
Tom Lane e57345975c Clean up API for ambulkdelete/amvacuumcleanup as per today's discussion.
This formulation requires every AM to provide amvacuumcleanup, unlike before,
but it's surely a whole lot cleaner.  Also, add an 'amstorage' column to
pg_am so that we can get rid of hardwired knowledge in DefineOpClass().
2006-05-02 22:25:10 +00:00
Tom Lane 67030eec1e Suppress some gcc warnings. 2006-05-02 15:48:11 +00:00
Tom Lane 2610a1fd5e Fix grammar of new error message. 2006-05-02 15:45:37 +00:00
Teodor Sigaev 2bee77e600 Add GIN opclases for another types 2006-05-02 15:23:16 +00:00
Teodor Sigaev 8a3631f8d8 GIN: Generalized Inverted iNdex.
text[], int4[], Tsearch2 support for GIN.
2006-05-02 11:28:56 +00:00
Tom Lane 427c6b5b98 Avoid assuming that statistics for a parent relation reflect the properties of
the union of its child relations as well.  This might have been a good idea
when it was originally coded, but it's a fatally bad idea when inheritance is
being used for partitioning.  It's better to have no stats at all than
completely misleading stats.  Per report from Mark Liberman.

The bug arguably exists all the way back, but I've only patched HEAD and 8.1
because we weren't particularly trying to support partitioning before 8.1.

Eventually we ought to look at deriving union statistics instead of just
punting, but for now the drop kick looks good.
2006-05-02 04:34:18 +00:00
Tom Lane a65a49429f Provide a namespace.c function for lookup of an operator with exact
input datatypes given, and use this before trying OpernameGetCandidates.
This is faster than the old method when there's an exact match, and it
does not seem materially slower when there's not.  And it definitely
makes some of the callers cleaner, because they didn't really want to
know about a list of candidates anyway.  Per discussion with Atsushi Ogawa.
2006-05-01 23:22:43 +00:00
Tom Lane 82a2881c5b Code review for GRANT CONNECT patch. Spell the privilege as CONNECT not
CONNECTION, fix a number of places that were missed (eg pg_dump support),
avoid executing an extra search of pg_database during startup.
2006-04-30 21:15:33 +00:00
Tom Lane 986085a7f0 Improve the representation of FOR UPDATE/FOR SHARE so that we can
support both FOR UPDATE and FOR SHARE in one command, as well as both
NOWAIT and normal WAIT behavior.  The more general code is actually
simpler and cleaner.
2006-04-30 18:30:40 +00:00
Bruce Momjian 4899aaf2d5 Add GRANT CONNECTION ON DATABASE, to be used in addition to pg_hba.conf.
Gevik Babakhani
2006-04-30 02:09:07 +00:00
Bruce Momjian 782df58a1c Revert patch pending more discussion:
Disallow changing DEFAULT expression of a SERIAL column.
2006-04-30 01:08:07 +00:00
Tom Lane 366682fb66 Remove sema.c, superseded by win32_sema.c. 2006-04-29 20:52:56 +00:00
Tom Lane f0df096785 Rearrange some configure.in comments for better readability.
Commit configure and pg_config.h.in, missed in last configure.in
update.
2006-04-29 20:47:31 +00:00
Tom Lane de762468aa We only need to add thread.c on non-WIN32 platforms, since get_home_path
doesn't use pqGetpwuid on WIN32.  Rather than try to figure out why it
won't build on WIN32, just remove it.
2006-04-29 20:13:07 +00:00
Bruce Momjian a0a0512182 Disallow changing DEFAULT expression of a SERIAL column.
Dhanaraj M
2006-04-29 16:43:54 +00:00
Bruce Momjian 908f317b73 Add Win32 semaphore implementation, rather than mimicking SysV
semaphores.

Qingqing Zhou
2006-04-29 16:34:41 +00:00
Bruce Momjian 291724dfa8 Solaris tas() uses 'int' now.
Theo Schlossnagle
2006-04-29 11:55:19 +00:00
Bruce Momjian a1ee621589 Fix s_lock_test to use tas.o file, if needed. 2006-04-28 22:54:31 +00:00
Tom Lane 53ee9f52ce Remove the restriction originally coded into optimize_minmax_aggregates() that
MIN/MAX not be converted to use an index if the query WHERE clause contains
any volatile functions or subplans.

I had originally feared that the conversion might alter the behavior of such a
query with respect to a volatile function.  Well, so it might, but only in the
sense that the function would get evaluated at a subset of the table rows
rather than all of them --- and we have never made any such guarantee anyway.
(For instance, we don't refuse to use an index for an ordinary non-aggregate
query when one of the non-indexable filter conditions contains a volatile
function.)

The prohibition against subplans was because of worry that that case wasn't
adequately tested, which it wasn't, but it turns out to be possible to make
8.1 fail anyway:

regression=# select o.ten, (select max(unique2) from tenk1 i where ten = o.ten
or ten = (select f1 from int4_tbl limit 1)) from tenk1 o;
ERROR:  direct correlated subquery unsupported as initplan

This is due to bogus code in SS_make_initplan_from_plan (it's an initplan,
ergo it can't have any parParams).  Having fixed that, we might as well allow
subplans as well as initplans.
2006-04-28 20:57:49 +00:00
Bruce Momjian 4c5eb2c2cb Modify Solaris compiler build rules to use the cpp preprocessor, the the
x86 file.
2006-04-28 17:09:16 +00:00
Bruce Momjian 83b692d9bb Darin -> Darwin. 2006-04-28 04:39:41 +00:00
Bruce Momjian e81b7b1dac Remove extra 'else' in solaris compiler code. 2006-04-28 04:32:10 +00:00
Bruce Momjian dfec2b070d Remove "volatile" from tas function, per TOm. 2006-04-28 03:43:19 +00:00
Bruce Momjian 9fc69d669e Update list of platforms that have a list of exported symbols. 2006-04-28 02:59:11 +00:00
Tom Lane 1e7bb2da57 Arrange to strip libpq.so of symbols that aren't officially supposed to
be exported on Linux and Darwin.  We already did this on Windows but
that's not enough, as evidenced by the fact that libecpg had an unexpected
dependency on one such symbol.  We should try to do it on more platforms.
Fix ecpg's oversight, and bump libpq's major .so version number to reflect
the unwanted but nonetheless real ABI break.
2006-04-28 02:53:20 +00:00
Bruce Momjian 35a0601d0a Add info on pgport linking requirements. 2006-04-28 02:52:57 +00:00
Bruce Momjian 128bed948f Rewrite Solaris compiler tas() assembly routines, merge i386 and x86_64
assembler files, renamed as solaris_x86.s.

Theo Schlossnagle
2006-04-27 22:28:42 +00:00
Tom Lane 0f0a33099c Generalize mcv_selectivity() to support both VAR OP CONST and CONST OP VAR
cases.  This was not needed in the existing uses within selfuncs.c, but if
we're gonna export it for general use, the extra generality seems helpful.
Motivated by looking at ltree example.
2006-04-27 17:52:40 +00:00
Bruce Momjian afab814a18 Change log message about vacuuming database name from LOG to DEBUG1.
Prevents duplicate meaningless log messsages.
2006-04-27 15:57:10 +00:00
Bruce Momjian 2fddd23b56 On second thought, keep SSL CRL as a log, and wait for feedback from 8.2. 2006-04-27 15:35:15 +00:00
Bruce Momjian d440c5b49d Downgrade SSL CRL file missing message from LOG to DEBUG1. 2006-04-27 15:25:04 +00:00
Bruce Momjian 203592dd88 Revert patch, causing plpython regression failues:
> >> >> > 1) named parameters additionally to args[]
> >> >> > 2) return composite-types from plpython as dictionary
> >> >> > 3) return result-set from plpython as list, iterator or generator
2006-04-27 14:18:07 +00:00
Bruce Momjian 8f10768feb Tab alignment cleanup. 2006-04-27 14:02:36 +00:00
Bruce Momjian 317ce6269a Add underscores to SSL CERT macro names, for clarity and consistency
with be-secure.c.
2006-04-27 14:01:46 +00:00
Bruce Momjian 2882241c23 Add SSL include needed for psql, after libpq adjustments. 2006-04-27 02:58:08 +00:00
Bruce Momjian e747f4935a Add support for SSL Certificate Revocation List (CRL) files, root.crl.
Libor Hoho?
2006-04-27 02:29:14 +00:00
Bruce Momjian 1a84275a7b plpython improvements:
1) named parameters additionally to args[]
	2) return composite-types from plpython as dictionary
	3) return result-set from plpython as list, iterator or generator

Hannu Krosing
Sven Suursoho
2006-04-27 01:05:05 +00:00
Bruce Momjian 3c4768d0d1 Change libpq's PQgetssl() to return a void*, rather than SSL *, so that
applications don't need the SSL headers.

Martijn van Oosterhout
2006-04-27 00:53:58 +00:00
Tom Lane a3c1a11fc1 If we're going to expose VariableStatData for contrib modules to use,
then we should export a reasonable set of the supporting routines too.
2006-04-27 00:46:59 +00:00
Bruce Momjian f1b3d5b02d Remove unused function SSL_CTX_set_tmp_dh_callback() from libpq:
In the SSL code in libpq it does some processing with DH parameters:

SSL_CTX_set_tmp_dh_callback()

This function is marked as server use only[1], the client always uses
the DH parameters in the server, so all the code in the client dealing
with the DH parameters is useless. This patch removes it.

It's not clear why the code was added in the first place, it's been
there almost since the beginning[2]. At the time there was a suggestion
of merging the front-end and backend SSL code, but looking at the
changes since, that seems unlikely.

As a further example, the s_server program allows you to specify DH
params, but s_client doesn't. In the GnuTLS documentation under
gnutls_dh_params_generate2() it says[3]:

  Also note that the DH parameters are only useful to servers. Since
  clients use the parameters sent by the server, it's of no use to call
  this in client side.
2006-04-27 00:36:34 +00:00
Bruce Momjian 02eb8f4f5c Use schema search path to find the first matching contraint name for SET
CONSTRAINT, rather than affecting all constraints in all schemas (which
is what we used to do).  Also allow schema specifications.

Kris Jurka
2006-04-27 00:33:46 +00:00
Bruce Momjian 944a17bf9f Delay write of pg_stats file to once every five minutes, during
shutdown, or when requested by a backend:

It changes so the file is only written once every 5 minutes (changeable
of course, I just picked something) instead of once every half second.
It's still written when the stats collector shuts down, just as before.
And it is now also written on backend request. A backend requests a
rewrite by simply sending a special stats message. It operates on the
assumption that the backends aren't actually going to read the
statistics file very often, compared to how frequent it's written today.

Magnus Hagander
2006-04-27 00:06:59 +00:00
Bruce Momjian a1e5331b07 Add tablespace display to psql \l+.
Philip Yarra
2006-04-26 23:15:45 +00:00
Bruce Momjian 59d61409cd Move ltree parentsel() selectivity function into /contrib/ltree. 2006-04-26 22:33:36 +00:00
Bruce Momjian cae5671945 In pg_resetxlog.c, uint -> uint32, for Win32 port. 2006-04-26 21:52:31 +00:00
Bruce Momjian 1865fb66fa Add missing ControlFile.checkPointCopy.ThisTimeLineID line for 'guess'
pg_resetxlog.

Simon
2006-04-26 18:56:56 +00:00
Bruce Momjian 0a646e801c Update catalog version for ltree changes. 2006-04-26 18:30:10 +00:00
Bruce Momjian b3e4aefcfb Enhanced containment selectivity function for /contrib/ltree
Matteo Beccati
2006-04-26 18:28:34 +00:00
Bruce Momjian 0df32e3cbe Allow pg_resetxlog -f to reset pg_control counters using xlog
information, and add a -r option to reset pg_control without affecting
xlog.

yuanjia lee
2006-04-26 02:17:15 +00:00
Tom Lane 486f994be7 Revise large-object access routines to avoid running with CurrentMemoryContext
set to the large object context ("fscxt"), as this is inevitably a source of
transaction-duration memory leaks.  Not sure why we'd not noticed it before;
maybe people weren't touching a whole lot of LOs in the same transaction
before the 8.1 pg_dump changes.  Per report from Wayne Conrad.

Backpatched as far as 8.1, but the problem doubtless goes all the way back.
I'm disinclined to spend the time to try to verify that the older branches
would still work if patched, seeing that this code was significantly modified
for 8.0 and again for 8.1, and that we don't have any trouble reports before
8.1.  (Maybe the leaks were smaller before?)
2006-04-26 00:34:57 +00:00
Tom Lane d2896a9ed1 Arrange to cache btree metapage data in the relcache entry for the index,
thereby saving a visit to the metapage in most index searches/updates.
This wouldn't actually save any I/O (since in the old regime the metapage
generally stayed in cache anyway), but it does provide a useful decrease
in bufmgr traffic in high-contention scenarios.  Per my recent proposal.
2006-04-25 22:46:05 +00:00
Tom Lane 1e3593ce16 The 8.1 planner removes WHERE quals from the plan when the quals are
implied by the predicate of a partial index being used to scan a table.
However, this optimization is unsafe in an UPDATE, DELETE, or SELECT FOR
UPDATE query, because the quals need to be rechecked by EvalPlanQual if
there's an update conflict.  Per example from Jean-Samuel Reynaud.
2006-04-25 16:54:09 +00:00
Bruce Momjian 59d591e79a Back out RESET CONNECTION until there is more discussion. 2006-04-25 14:11:59 +00:00
Bruce Momjian 6378fdd971 Add RESET CONNECTION, to reset all aspects of a session.
Hans-J?rgen Sch?nig
2006-04-25 14:09:21 +00:00
Bruce Momjian e6004f0151 Add statement_timestamp(), clock_timestamp(), and
transaction_timestamp() (just like now()).

Also update statement_timeout() to mention it is statement arrival time
that is measured.

Catalog version updated.
2006-04-25 00:25:22 +00:00
Bruce Momjian cd48ae8bf0 Back out patch, unintended. 2006-04-24 22:59:19 +00:00
Bruce Momjian ec9d01e8e2 Done:
o -Add support for day-time syntax, INTERVAL '1 2:03:04' DAY TO
        SECOND
2006-04-24 22:56:11 +00:00
Bruce Momjian 5bbea03f3b Suppress more compiler warnings caused by macro tests. 2006-04-24 22:24:58 +00:00
Bruce Momjian 7384e95b0c Add one more paren to macro. 2006-04-24 22:17:04 +00:00
Bruce Momjian 88fc941355 Suprress compiler warning in gcc 4.2.
Report by Kris Jurka
2006-04-24 22:06:32 +00:00
Tom Lane 332ea60d23 Improve our private implementation of cbrt() to give results of the
accuracy expected by the regression tests.  Per suggestion from
Martijn van Oosterhout.
2006-04-24 20:36:32 +00:00
Bruce Momjian 7e97b419df Remove compiler warning by casting SNPRINTF() call to void.
Report from Gevik Babakhani.
2006-04-24 19:51:13 +00:00
Michael Meskes 524d65d459 Fixed memory leak bugs found by Martijn Oosterhout. 2006-04-24 09:45:22 +00:00
Bruce Momjian a16ffee73b Fixes for BCC 5.5 compile of libpq. Backpatch to 8.1.X.
Mark Morgan Lloyd
2006-04-24 04:03:25 +00:00
Alvaro Herrera 732a1fd1d0 Don't add a shared dependency on the owner of a composite type in pg_class.
We track the owner in pg_type instead, as that is the place where the owner is
changed on ALTER TYPE ... OWNER TO.
2006-04-24 01:40:48 +00:00
Tom Lane 2206b498d8 Simplify ParamListInfo data structure to support only numbered parameters,
not named ones, and replace linear searches of the list with array indexing.
The named-parameter support has been dead code for many years anyway,
and recent profiling suggests that the searching was costing a noticeable
amount of performance for complex queries.
2006-04-22 01:26:01 +00:00
Tom Lane b5498a26de Add some optional code (conditionally compiled under #ifdef LWLOCK_STATS)
to track the number of LWLock acquisitions and the number of times we
block waiting for an LWLock, on a per-process basis.  After having needed
this twice in the past few months, seems like it should go into CVS.
2006-04-21 16:45:12 +00:00
Tom Lane efe222268f Eliminate some no-longer-needed workarounds for palloc's old behavior
of rejecting palloc(0).  Also, tweak like_selectivity() to avoid assuming
the presented pattern is nonempty; although that assumption is valid,
it doesn't really help much, and the new coding is more correct anyway
since it properly handles redundant wildcards.  In combination these
changes should eliminate a Coverity warning noted by Martijn.
2006-04-20 17:50:18 +00:00
Bruce Momjian ea6d54ee06 Add "retry another address" log message on statistics collector socket
failure, to reduce confusion in the log file.
2006-04-20 10:51:32 +00:00
Tom Lane eac825aa68 Ensure that we validate the page header of the first page of a WAL file
whenever we start to read within that file.  The first page carries
extra identification information that really ought to be checked, but
as the code stood, this was only checked when we switched sequentially
into a new WAL file, or if by chance the starting checkpoint record was
within the first page.  This patch ensures that we will detect bogus
'long header' information before we start replaying the WAL sequence.
2006-04-20 04:07:38 +00:00
Tom Lane cc7eab38dd Recognize __ppc64__, which seems to be Apple's spelling of the predefined
symbol for PPC64 hardware.  I hadn't known that Apple supported PPC64 at
all, but darn if there aren't 64-bit variant libraries in OS X as well
as support in their gcc.
2006-04-19 23:11:15 +00:00
Bruce Momjian 5d096d0127 Fix problem that sscanf(buf, "%d", &val) eats leading white space, but
our to_* functions were not handling that.
2006-04-19 18:49:09 +00:00
Tom Lane 04ca4caa81 Remove use of lorder and tsort while building static libraries. There's
no evidence that any currently-supported platform needs this, and good
reason to think that any platform that did need it couldn't use the static
libraries anyway --- libpq, at least, has circular references.  Removing
the code shuts up tsort warnings about the circular references on some
platforms.
2006-04-19 16:32:08 +00:00
Tom Lane 8f52496a05 Fix ancient memory leak in PQprintTuples(); our code no longer uses this
routine, but perhaps some applications do.  Found by Martijn van Oosterhout
using Coverity.
2006-04-19 16:15:29 +00:00
Tom Lane 3224f2ee25 Fix a couple of rather-pointless-but-easily-fixed Coverity warnings.
Per Martijn van Oosterhout.
2006-04-19 16:02:17 +00:00
Bruce Momjian e37a649e94 C code whitespace inprovement for formatting.c. 2006-04-19 14:48:06 +00:00
Bruce Momjian 5bd59b9c0a Document that errors are not output by log_statement (was they were in
8.0), and add as suggestion to use log_min_error_statement for this
purpose.  I also fixed the code so the first EXECUTE has it's prepare,
rather than the last which is what was in the current code.  Also remove
"protocol" prefix for SQL EXECUTE output because it is not accurate.

Backpatch to 8.1.X.
2006-04-18 00:52:23 +00:00
Tom Lane 0a87394956 Fix the torn-page hazard for PITR base backups by forcing full page writes
to occur between pg_start_backup() and pg_stop_backup(), even if the GUC
setting full_page_writes is OFF.  Per discussion, doing this in combination
with the already-existing checkpoint during pg_start_backup() should ensure
safety against partial page updates being included in the backup.  We do
not have to force full page writes to occur during normal PITR operation,
as I had first feared.
2006-04-17 18:55:05 +00:00
Tom Lane 3651a3e6fb Support the syntax
CREATE AGGREGATE aggname (input_type) (parameter_list)
along with the old syntax where the input type was named in the parameter
list.  This fits more naturally with the way that the aggregate is identified
in DROP AGGREGATE and other utility commands; furthermore it has a natural
extension to handle multiple-input aggregates, where the basetype-parameter
method would get ugly.  In fact, this commit fixes the grammar and all the
utility commands to support multiple-input aggregates; but DefineAggregate
rejects it because the executor isn't fixed yet.
I didn't do anything about treating agg(*) as a zero-input aggregate instead
of artificially making it a one-input aggregate, but that should be considered
in combination with supporting multi-input aggregates.
2006-04-15 17:45:46 +00:00
Tom Lane defe93463c Make the world safe for full_page_writes. Allow XLOG records that try to
update no-longer-existing pages to fall through as no-ops, but make a note
of each page number referenced by such records.  If we don't see a later
XLOG entry dropping the table or truncating away the page, complain at
the end of XLOG replay.  Since this fixes the known failure mode for
full_page_writes = off, revert my previous band-aid patch that disabled
that GUC variable.
2006-04-14 20:27:24 +00:00
Tom Lane 0fcc3c2f1d Repair a low-probability race condition identified by Qingqing Zhou.
If a process abandons a wait in LockBufferForCleanup (in practice,
only happens if someone cancels a VACUUM) just before someone else
sends it a signal indicating the buffer is available, it was possible
for the wakeup to remain in the process' semaphore, causing misbehavior
next time the process waited for an lmgr lock.  Rather than try to
prevent the race condition directly, it seems best to make the lock
manager robust against leftover wakeups, by having it repeat waiting
on the semaphore if the lock has not actually been granted or denied
yet.
2006-04-14 03:38:56 +00:00
Tom Lane cc39aca7d4 Fix similar_escape() so that SIMILAR TO works properly for patterns involving
alternatives ("|" symbol).  The original coding allowed the added ^ and $
constraints to be absorbed into the first and last alternatives, producing
a pattern that would match more than it should.  Per report from Eric Noriega.

I also changed the pattern to add an ARE director ("***:"), ensuring that
SIMILAR TO patterns do not change behavior if regex_flavor is changed.  This
is necessary to make the non-capturing parentheses work, and seems like a
good idea on general principles.

Back-patched as far as 7.4.  7.3 also has the bug, but a fix seems impractical
because that version's regex engine doesn't have non-capturing parens.
2006-04-13 18:01:31 +00:00
Tom Lane 49a7610c36 Fix an ancient oversight in btree xlog replay. When trying to determine if an
upper-level insertion completes a previously-seen split, we cannot simply grab
the downlink block number out of the buffer, because the buffer could contain
a later state of the page --- or perhaps the page doesn't even exist at all
any more, due to relation truncation.  These possibilities have been masked up
to now because the use of full_page_writes effectively ensured that no xlog
replay routine ever actually saw a page state newer than its own change.
Since we're deprecating full_page_writes in 8.1.*, there's no need to fix this
in existing release branches, but we need a fix in HEAD if we want to have any
hope of re-allowing full_page_writes.  Accordingly, adjust the contents of
btree WAL records so that we can always get the downlink block number from the
WAL record rather than having to depend on buffer contents.  Per report from
Kevin Grittner and Peter Brant.

Improve a few comments in related code while at it.
2006-04-13 03:53:05 +00:00
Tom Lane 3ef151e0b7 Fix pg_restore -n option to do what the man page says it does. The
original coding only worked if one of the selTypes restriction options
was also given.  Per report from Nick Johnson.
2006-04-12 22:18:48 +00:00
Neil Conway 6d06003fbf Fix typo. 2006-04-11 20:26:40 +00:00
Tom Lane 2f9b3ef7be Suppress unused-variable warning on platforms without HAVE_SYSLOG.
Magnus
2006-04-10 21:53:38 +00:00
Tom Lane 848692131a Fix another const-decoration mismatch, per Magnus. 2006-04-09 22:01:19 +00:00
Bruce Momjian a894a83381 Add comment for why we recompile pgport C files.
# Need to recomple any libpgport object files because we need these
# object files to use the same compile flags as libpq.  If we used
# the object files from libpgport, this would not be true on all
# platforms.
2006-04-09 20:27:27 +00:00
Tom Lane 513ec43ebd Suppress a couple of minor compiler warnings, per Magnus. 2006-04-09 19:21:34 +00:00
Tom Lane a81e281636 Revert my best_inner_indexscan patch of yesterday, which turns out to have
had a bad side-effect: it stopped finding plans that involved BitmapAnd
combinations of indexscans using both join and non-join conditions.  Instead,
make choose_bitmap_and more aggressive about detecting redundancies between
BitmapOr subplans.
2006-04-09 18:18:41 +00:00
Tom Lane 898eb25431 Fix best_inner_indexscan to actually enforce that an "inner indexscan" use
at least one join condition as an indexqual.  Before bitmap indexscans, this
oversight didn't really cost much except for redundantly considering the
same join paths twice; but as of 8.1 it could result in silly bitmap scans
that would do the same BitmapOr twice and then BitmapAnd these together :-(
2006-04-08 21:32:17 +00:00
Tom Lane c6e81aeef3 Fix EXPLAIN so that it can drill down through multiple levels of subplan
when trying to locate the referent of a RECORD variable.  This fixes the
'record type has not been registered' failure reported by Stefan
Kaltenbrunner about a month ago.  A side effect of the way I chose to
fix it is that most variable references in join conditions will now be
properly labeled with the variable's source table name, instead of the
not-too-helpful 'outer' or 'inner' we used to use.
2006-04-08 18:49:52 +00:00
Tom Lane 74bdf965a6 Fix pg_dumpall to do something sane when a pre-8.1 installation has
identically named user and group: we merge these into a single entity
with LOGIN permission.  Also, add ORDER BY commands to ensure consistent
dump ordering, for ease of comparing outputs from different installations.
2006-04-07 21:26:29 +00:00
Tom Lane 2f8a7bf290 Fix make_restrictinfo_from_bitmapqual() to preserve AND/OR flatness of its
output, ie, no OR immediately below an OR.  Otherwise we get Asserts or
wrong answers for cases such as
	select * from tenk1 a, tenk1 b
	where (a.ten = b.ten and (a.unique1 = 100 or a.unique1 = 101))
	   or (a.hundred = b.hundred and a.unique1 = 42);
Per report from Rafael Martinez Guerrero.
2006-04-07 17:05:39 +00:00
Tom Lane 0914ae1c14 Remove the pgstats logic for delaying destruction of stats table entries.
Per recent discussion, this seems to be making the stats less accurate
rather than more so, particularly on Windows where PID values may be
reused very quickly.  Patch by Peter Brant.
2006-04-06 20:38:00 +00:00
Peter Eisentraut 0bc2a8ca65 Build src/test/regress/README during tarball making like the other
generated text files.  Fix build of that file, too.

Put the text files in the right place during make dist, so there are no
extra manual steps required anymore.
2006-04-06 18:54:37 +00:00
Tom Lane 7fdb4305db Fix a bunch of problems with domains by making them use special input functions
that apply the necessary domain constraint checks immediately.  This fixes
cases where domain constraints went unchecked for statement parameters,
PL function local variables and results, etc.  We can also eliminate existing
special cases for domains in places that had gotten it right, eg COPY.

Also, allow domains over domains (base of a domain is another domain type).
This almost worked before, but was disallowed because the original patch
hadn't gotten it quite right.
2006-04-05 22:11:58 +00:00
Peter Eisentraut 89a67e523e When merging PO files, take into consideration translations in other PO
files of the same languages.  That way, similar or equal translations in
different programs are automatically propagated and the life of translators
becomes a little bit easier.
2006-04-05 13:40:15 +00:00
Tom Lane 09b5271ebd Add a field to the first page of each WAL file to indicate the
XLOG_BLCKSZ.  This ought to help in preventing configuration mismatch
problems if anyone tries to ship PITR files between servers compiled
with different XLOG_BLCKSZ settings.  Simon Riggs
2006-04-05 03:34:05 +00:00
Tom Lane e6140d9052 Don't use BLCKSZ for the physical length of the pg_control file, but
instead a dedicated symbol.  This probably makes no functional difference
for likely values of BLCKSZ, but it makes the intent clearer.
Simon Riggs, minor editorialization by Tom Lane.
2006-04-04 22:39:59 +00:00
Tom Lane 147d4bf3e5 Modify all callers of datatype input and receive functions so that if these
functions are not strict, they will be called (passing a NULL first parameter)
during any attempt to input a NULL value of their datatype.  Currently, all
our input functions are strict and so this commit does not change any
behavior.  However, this will make it possible to build domain input functions
that centralize checking of domain constraints, thereby closing numerous holes
in our domain support, as per previous discussion.

While at it, I took the opportunity to introduce convenience functions
InputFunctionCall, OutputFunctionCall, etc to use in code that calls I/O
functions.  This eliminates a lot of grotty-looking casts, but the main
motivation is to make it easier to grep for these places if we ever need
to touch them again.
2006-04-04 19:35:37 +00:00
Tom Lane eaef111396 Define a separately configurable XLOG_BLCKSZ symbol for the page size
used within WAL files.  Historically this was the same as the data file
BLCKSZ, but there's no necessary connection, and it's possible that
performance gains might ensue from reducing XLOG_BLCKSZ.  In any case
distinguishing two symbols should improve code clarity.  This commit
does not actually change the page size, only provide the infrastructure
to make it possible to do so.  initdb forced because of addition of a
field to pg_control.
Mark Wong, with some help from Simon Riggs and Tom Lane.
2006-04-03 23:35:05 +00:00
Tom Lane c9a2b6d4ca Fix thinko in gistRedoPageUpdateRecord: if XLR_BKP_BLOCK_1 is set, we
don't have anything to do to the page, but we still have to adjust the
incomplete_inserts list that we're maintaining in memory.
2006-04-03 16:45:50 +00:00
Teodor Sigaev 8d02b15e33 Eliminate ajust scan code. Since concurrent GiST it doesn't
do real work. That was missed during concurrence development.
2006-04-03 13:44:33 +00:00
Neil Conway 7815ca7bef Rewrite much of psql's \connect code, for the sake of code clarity and
to fix regressions introduced in the recent patch adding additional
\connect options. This is based on work by Volkan YAZICI, although
this version of the patch doesn't bear much resemblance to Volkan's
version.

\connect takes 4 optional arguments: database name, user name, host
name, and port number. If any of those parameters are omitted or
specified as "-", the value of that parameter from the previous
connection is used instead; if there is no previous connection,
the libpq default is used. Note that this behavior makes it
impossible to reuse the libpq defaults without quitting psql and
restarting it; I don't really see the use case for needing to do
that.
2006-04-02 20:08:22 +00:00
Tom Lane 23a1f015e5 Adjust interval-addition test so that it won't fail on DST transition days.
Strange that we missed this DST dependence while fixing the others.
2006-04-02 19:39:54 +00:00
Peter Eisentraut f7ae90041e Update information schema for SQL:2003 and new PostgreSQL features. 2006-04-02 17:38:13 +00:00
Alvaro Herrera 643b022bed Add tab-completion for REASSIGN OWNED BY and DROP OWNED BY. Also fix some
whitespace issues nearby.

DROP OWNED BY is actually a bit kludgy, but it seems better to do it this way
rather than duplicating the words_after_create list just to add a single
element.
2006-04-02 09:02:41 +00:00
Tom Lane 89bda95d82 Remove the 'slow' path for btree index build, which built the btree
incrementally by successive inserts rather than by sorting the data.
We were only using the slow path during bootstrap, apparently because
when first written it failed during bootstrap --- but it works fine now
AFAICT.  Removing it saves a hundred or so lines of code and produces
noticeably (~10%) smaller initial states of the system catalog indexes.
While that won't make much difference for heavily-modified catalogs,
for the more static ones there may be a useful long-term performance
improvement.
2006-04-01 03:03:37 +00:00
Tom Lane a8b8f4db23 Clean up WAL/buffer interactions as per my recent proposal. Get rid of the
misleadingly-named WriteBuffer routine, and instead require routines that
change buffer pages to call MarkBufferDirty (which does exactly what it says).
We also require that they do so before calling XLogInsert; this takes care of
the synchronization requirement documented in SyncOneBuffer.  Note that
because bufmgr takes the buffer content lock (in shared mode) while writing
out any buffer, it doesn't matter whether MarkBufferDirty is executed before
the buffer content change is complete, so long as the content change is
completed before releasing exclusive lock on the buffer.  So it's OK to set
the dirtybit before we fill in the LSN.
This eliminates the former kluge of needing to set the dirtybit in LockBuffer.
Aside from making the code more transparent, we can also add some new
debugging assertions, in particular that the caller of MarkBufferDirty must
hold the buffer content lock, not merely a pin.
2006-03-31 23:32:07 +00:00
Tom Lane 89395bfa6f Improve gist XLOG code to follow the coding rules needed to prevent
torn-page problems.  This introduces some issues of its own, mainly
that there are now some critical sections of unreasonably broad scope,
but it's a step forward anyway.  Further cleanup will require some
code refactoring that I'd prefer to get Oleg and Teodor involved in.
2006-03-30 23:03:10 +00:00
Tom Lane 4243f2387a Suppress attempts to report dropped tables to the stats collector from a
startup or recovery process.  Since such a process isn't a real backend,
pgstat.c gets confused.  This accounts for recent reports of strange
"invalid server process ID -1" log messages during crash recovery.
There isn't any point in attempting to make the report, since we'll discard
stats in such scenarios anyhow.
2006-03-30 22:11:55 +00:00
Andrew Dunstan bee34e9930 Fix bad SQL, per Stefan Kaltenbrunner. 2006-03-30 01:08:15 +00:00
Tom Lane 6d61cdec07 Clean up and document the API for XLogOpenRelation and XLogReadBuffer.
This commit doesn't make much functional change, but it does eliminate some
duplicated code --- for instance, PageIsNew tests are now done inside
XLogReadBuffer rather than by each caller.
The GIST xlog code still needs a lot of love, but I'll worry about that
separately.
2006-03-29 21:17:39 +00:00
Tom Lane 2154e1c11e TablespaceCreateDbspace should function normally even on platforms that do not
have symlinks (ie, Windows).  Although it'll never be called on to do anything
useful during normal operation on such a platform, it's still needed to
re-create dropped directories during WAL replay.
2006-03-29 15:15:43 +00:00
Tom Lane 0a971e2f20 Disable full_page_writes, because turning it off risks causing crash-recovery
failures even when the hardware and OS did nothing wrong.  Per recent analysis
of a problem report from Alex Bahdushka.

For the moment I've just diked out the test of the parameter, rather than
removing the GUC infrastructure and documentation, in case we conclude that
there's something salvageable there.  There seems no chance of it being
resurrected in the 8.1 branch though.
2006-03-28 22:01:16 +00:00
Tom Lane 288551fc60 Repair longstanding error in btree xlog replay: XLogReadBuffer should be
passed extend = true whenever we are reading a page we intend to reinitialize
completely, even if we think the page "should exist".  This is because it
might indeed not exist, if the relation got truncated sometime after the
current xlog record was made and before the crash we're trying to recover
from.  These two thinkos appear to explain both of the old bug reports
discussed here:
http://archives.postgresql.org/pgsql-hackers/2005-05/msg01369.php
2006-03-28 21:17:23 +00:00
Tom Lane 4e7d10c7cd Comments in IndexBuildHeapScan describe the indexing of recently-dead
tuples as needed "to keep VACUUM from complaining", but actually there is
a more compelling reason to do it: failure to do so violates MVCC semantics.
This is because a pre-existing serializable transaction might try to use
the index after we finish (re)building it, and it might fail to find tuples
it should be able to see.  We got this mostly right, but not in the case
of partial indexes: the code mistakenly discarded recently-dead tuples for
partial indexes.  Fix that, and adjust the comments.
2006-03-24 23:02:17 +00:00
Tom Lane 0a20207060 Arrange to emit a description of the current XLOG record as error context
when an error occurs during xlog replay.  Also, replace the former risky
'write into a fixed-size buffer with no overflow detection' API for XLOG
record description routines; use an expansible StringInfo instead.  (The
latter accounts for most of the patch bulk.)

Qingqing Zhou
2006-03-24 04:32:13 +00:00
Tom Lane 4fb92718be Fix plpgsql to pass only one copy of any given plpgsql variable into a SQL
command or expression, rather than one copy for each textual occurrence as
it did before.  This might result in some small performance improvement,
but the compelling reason to do it is that not doing so can result in
unexpected grouping failures because the main SQL parser won't see different
parameter numbers as equivalent.  Add a regression test for the failure case.
Per report from Robert Davidson.
2006-03-23 04:22:37 +00:00
Tom Lane 19956e0d53 Add error location info to ResTarget parse nodes. Allows error cursor to be supplied
for various mistakes involving INSERT and UPDATE target columns.
2006-03-23 00:19:30 +00:00
Tom Lane a3f0b3d68f Improve performance of our private version of qsort. Per recent testing,
the logic it contained to switch to insertion sort for near-sorted input was
in fact a big loss, because it could fairly easily be fooled into applying
insertion sort to large subfiles that weren't all that well ordered.  Remove
that, and instead add a simple check for already-perfectly-sorted input, as
per suggestion from Dann Corbit.  This adds at worst O(N*lgN) overhead, and
usually far less, while sometimes allowing a subfile sort to finish in O(N)
time.  Preliminary testing says this is an improvement over the basic
Bentley & McIlroy code for many nonrandom inputs, and it costs almost
nothing when the input is random.
2006-03-21 19:49:15 +00:00
Neil Conway 570b726533 Minor refactoring: initialize_SSL() only returns 0, so it should return
"void" rather than "int".
2006-03-21 18:18:35 +00:00
Alvaro Herrera c4826cf0b0 Merge the loading of shared object descriptions with regular descriptions,
both in code and in the messages emitted to the user.
2006-03-21 17:54:28 +00:00
Bruce Momjian af00c04c42 Fix psql history handling:
> 1) Fix the problems with the \s command.
> When the saveHistory is executed by the \s command we must not do the
> conversion \n -> \x01  (per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00317.php )
>
> 2) Fix the handling of Ctrl+C
>
> Now when you do
> wsdb=# select 'your long query here '
> wsdb-#
> and press afterwards the CtrlC the line "select 'your long query here
'"
> will be in the history
>
> (partly per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00297.php )
>
> 3) Fix the handling of commands with not closed brackets, quotes,
double
> quotes. (now those commands are not splitted in parts...)
>
> 4) Fix the behaviour when SINGLELINE mode is used. (before it was
almost
> broken ;(

Sergey E. Koposov
2006-03-21 13:38:12 +00:00
Bruce Momjian 3b7e2b140e Update comment that pgNotify.be_pid is pid of the notifying server process. 2006-03-20 15:07:05 +00:00
Neil Conway a323ede280 Fix a few places that were checking for the return value of palloc() to be
non-NULL: palloc() ereports on OOM, so we can safely assume it returns a
valid pointer.
2006-03-19 22:22:56 +00:00
Tom Lane 381cb046ed Adjust join_1.out to match Windows behavior for new mergejoin regression
test, per Dave Page and buildfarm.  Perhaps we will need a join_2 instead,
but for the moment assume that this test tracks the other diffs.
2006-03-19 01:19:42 +00:00
Neil Conway a5dba02359 The call to DNSServiceRegistrationCreate in postmaster.c does incorrect
byte-swapping on the port number which causes the call to fail on Intel
Macs.

This patch uses htons() instead of htonl() and fixes this bug.

Ashley Clark
2006-03-18 22:09:58 +00:00
Tom Lane b3358e2642 Fix bug introduced into mergejoin logic by performance improvement patch of
2005-05-13.  When we find that a new inner tuple can't possibly match any
outer tuple (because it contains a NULL), we can't immediately skip the
tuple when we are in NEXTINNER state.  Doing so can lead to emitting
multiple copies of the tuple in FillInner mode, because we may rescan the
tuple after returning to a previous marked tuple.  Instead, proceed to
NEXTOUTER state the same as we used to do.  After we've found that there's
no need to return to the marked position, we can go to SKIPINNER_ADVANCE
state instead of SKIP_TEST when the inner tuple is unmatchable; this
preserves the performance improvement.  Per bug report from Bruce.
I also made a couple of cosmetic code rearrangements and added a regression
test for the problem.
2006-03-17 19:38:12 +00:00
Michael Meskes 0941a8901b Fixed bug 2330: Wrong error code in case of a duplicate key 2006-03-17 15:46:13 +00:00
Tom Lane 92f5bfcc0f Fix invalid use of #if within a macro, per Laurenz Albe. Also try to
make the LDAP code's error messages look like they were written by someone
who had heard of our style guidelines.
2006-03-16 18:11:17 +00:00
Tom Lane 2316013961 Clean up representation of function RTEs for functions returning RECORD.
The original coding stored the raw parser output (ColumnDef and TypeName
nodes) which was ugly, bulky, and wrong because it failed to create any
dependency on the referenced datatype --- and in fact would not track type
renamings and suchlike.  Instead store a list of column type OIDs in the
RTE.

Also fix up general failure of recordDependencyOnExpr to do anything sane
about recording dependencies on datatypes.  While there are many cases where
there will be an indirect dependency (eg if an operator returns a datatype,
the dependency on the operator is enough), we do have to record the datatype
as a separate dependency in examples like CoerceToDomain.

initdb forced because of change of stored rules.
2006-03-16 00:31:55 +00:00
Bruce Momjian 5981b9d03e Fix typo in pgcvslog, used == instead of =. 2006-03-15 03:24:17 +00:00
Tom Lane 1349839c3c It seems the YYLLOC_DEFAULT macro recommended by the Bison 1.875 manual
just doesn't work with Bison 2.0 ... fix it ...
2006-03-14 23:03:20 +00:00
Tom Lane 35b5509782 Missed this file in previous commit :-( 2006-03-14 22:50:46 +00:00
Tom Lane 20ab467d76 Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages.
This is per my earlier proposal.  This commit includes all the basic
infrastructure, but locations are only tracked and reported for errors
involving column references, function calls, and operators.  More could
be done later but this seems like a good set to start with.  I've also
moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
which should make it available to more people --- even within psql this
is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
2006-03-14 22:48:25 +00:00
Bruce Momjian 4a85bf3eaf Remove Christof Petig copyright. He already approved removal from an
include file in the same area,.
2006-03-11 16:57:44 +00:00
Bruce Momjian 98d42c2450 Remove copyright notices from Jan (per author approval), and those files
derived from Jan's.
2006-03-11 16:43:22 +00:00
Bruce Momjian f3d99d160d Add CVS tag lines to files that were lacking them. 2006-03-11 04:38:42 +00:00
Neil Conway 7992d0fbca Remove a few places that attempted to define INT_MAX, SCHAR_MAX, and
similar constants if they were not previously defined. All these
constants must be defined by limits.h according to C89, so we can
safely assume they are present.
2006-03-11 01:19:22 +00:00
Tom Lane c65ab0bfa9 Recent changes in memory management in tuplesort.c had a problem: the
case where we run low on array slots before we run low on memory is much
more probable than I had thought, and so it's important to treat each
tape fairly in that case.  To fix this, track per-tape slot allocations
just like we track per-tape space allocation.  Also, in the FINALMERGE
code path avoid scanning all the input tapes when we really only need to
read from one.  This should fix poor behavior with very large work_mem
as exhibited by Stefan Kaltenbrunner.
I didn't do anything about putting an upper bound on the number of tapes,
but maybe we should still consider that.
2006-03-10 23:19:00 +00:00
Tom Lane 9f6192490e Add a CHECK_FOR_INTERRUPTS() in _bt_buildadd(). This fixes problem
with not responding to query cancel during the last stage of btree index
creation.
2006-03-10 20:18:15 +00:00
Neil Conway 0ebf1cc834 Implement 4 new aggregate functions from SQL2003. Specifically: var_pop(),
var_samp(), stddev_pop(), and stddev_samp(). var_samp() and stddev_samp()
are just renamings of the historical Postgres aggregates variance() and
stddev() -- the latter names have been kept for backward compatibility.
This patch includes updates for the documentation and regression tests.
The catversion has been bumped.

NB: SQL2003 requires that DISTINCT not be specified for any of these
aggregates. Per discussion on -patches, I have NOT implemented this
restriction: if the user asks for stddev(DISTINCT x), presumably they
know what they are doing.
2006-03-10 20:15:28 +00:00
Bruce Momjian ab812ef326 Remove unintened change to pg_proc.h. 2006-03-10 19:12:51 +00:00
Bruce Momjian 497b5ad928 Make $PostgreSQL CVS tags consistent for SGML files. 2006-03-10 19:10:50 +00:00
Tom Lane bbfa1c39a1 Add a CHECK_FOR_INTERRUPTS() to the loop in ExecMakeTableFunctionResult.
Otherwise you can't cancel queries like select ... from generate_series(1,1000000).
2006-03-10 01:51:23 +00:00
Bruce Momjian 5931737571 Remove Jan Wieck's name from copyrights, and put in standard
boilerplate, with approval of author.
2006-03-09 21:29:38 +00:00
Bruce Momjian 4c0efd3ae2 Remove Christof Petig copyright on include file, per author request. 2006-03-08 22:00:27 +00:00
Tom Lane c8cd76de28 Tweak trace_sort code to show the merge order (number of active input
tapes) for each merge step.  This will give us some idea of how effective
the merge distribution algorithm is.
2006-03-08 16:59:03 +00:00
Bruce Momjian d233ec299c Update pltcl expected file for E''. 2006-03-08 08:00:35 +00:00
Bruce Momjian c574106a66 Adjust plpython for escape_string_warning. 2006-03-08 04:01:29 +00:00
Bruce Momjian bc0be355c8 Adjust PL regression tests for escape_string_warning. 2006-03-08 03:58:53 +00:00
Tom Lane 43ceb3d449 Further examination of ltsReleaseBlock usage shows that it's got a
performance issue during regular merge passes not only the 'final merge'
case.  The original design contemplated that there would never be more
than about one free block per 'tape', hence no need for an efficient
method of keeping the free blocks sorted.  But given the later addition
of merge preread behavior in tuplesort.c, there is likely to be about
work_mem worth of free blocks, which is not so small ... and for that
matter the number of tapes isn't necessarily small anymore either.  So
we'd better get rid of the assumption entirely.  Instead, I'm assuming
that the usage pattern will involve alternation between merge preread
and writing of a new run.  This makes it reasonable to just add blocks
to the list without sorting during successive ltsReleaseBlock calls,
and then do a qsort() when we start getting ltsGetFreeBlock() calls.
Experimentation seems to confirm that there aren't many qsort calls
relative to the number of ltsReleaseBlock/ltsGetFreeBlock calls.
2006-03-07 23:46:24 +00:00
Tom Lane 8db05ba411 Repair old performance bug in tuplesort.c/logtape.c. In the case where
we are doing the final merge pass on-the-fly, and not writing the data
back onto a 'tape', the number of free blocks in the tape set will become
large, leading to a lot of time wasted in ltsReleaseBlock().  There is
really no need to track the free blocks anymore in this state, so add a
simple shutoff switch.  Per report from Stefan Kaltenbrunner.
2006-03-07 19:06:50 +00:00
Tom Lane e6107da53c Turn off zero_damaged_pages in the right place (ie, in the autovac
process not in the postmaster) and with the right GucSource (needs to
be a nontransactional source since we've not started an xact yet).
2006-03-07 17:32:22 +00:00
Bruce Momjian 8d51c276ca Use SetConfigOption() to turn off "zero_damaged_pages" in autovacuum. 2006-03-07 03:03:09 +00:00
Bruce Momjian 79d25cf775 Back out comment update about sighup, original was accurate. 2006-03-07 03:01:22 +00:00
Bruce Momjian ce1106d2fa Properly set "escape_string_warning" to default to true. 2006-03-07 02:54:23 +00:00
Tom Lane fb51ad3419 Make all our flex and bison files use %option prefix or %name-prefix
(respectively) to rename yylex and related symbols.  Some were doing
it this way already, while others used not-too-reliable sed hacks in
the Makefiles.  It's all nice and consistent now.
2006-03-07 01:03:12 +00:00
Tom Lane 012abebab1 Remove the stub support we had for UNION JOIN; per discussion, this is
not likely ever to be implemented seeing it's been removed from SQL2003.
This allows getting rid of the 'filter' version of yylex() that we had in
parser.c, which should save at least a few microseconds in parsing.
2006-03-07 01:00:19 +00:00
Tom Lane 48cf295742 'make clean' should NOT remove *~ files. 2006-03-07 00:48:07 +00:00
Bruce Momjian d694bd812a Default to ON for 8.2, as announced in the release notes:
escape_string_warning = on
2006-03-06 22:52:10 +00:00
Bruce Momjian d69b163247 Attached is the new patch. To summarize:
- new function justify_interval(interval)
   - modified function justify_hours(interval)
   - modified function justify_days(interval)

These functions are defined to meet the requirements as discussed in
this thread.  Specifically:

   - justify_hours makes certain the sign bit on the hours
     matches the sign bit on the days.  It only checks the
     sign bit on the days, and not the months, when
     determining if the hours should be positive or negative.
     After the call, -24 < hours < 24.

   - justify_days makes certain the sign bit on the days
     matches the sign bit on the months.  It's behavior does
     not depend on the hours, nor does it modify the hours.
     After the call, -30 < days < 30.

   - justify_interval makes sure the sign bits on all three
     fields months, days, and hours are all the same.  After
     the call, -24 < hours < 24 AND -30 < days < 30.

Mark Dilger
2006-03-06 22:49:17 +00:00
Bruce Momjian 19c21d115d Enable standard_conforming_strings to be turned on.
Kevin Grittner
2006-03-06 19:49:20 +00:00
Bruce Momjian a9c1047ebd Update comment on how sighup signal affects postgresql.conf reload.
Markus Bertheau
2006-03-06 18:38:11 +00:00
Bruce Momjian 526f773d2f * Stephen Frost (sfrost@snowman.net) wrote:
>   I've now tested this patch at home w/ 8.2HEAD and it seems to fix the
>   bug.  I plan on testing it under 8.1.2 at work tommorow with
>   mod_auth_krb5, etc, and expect it'll work there.  Assuming all goes
>   well and unless someone objects I'll forward the patch to -patches.
>   It'd be great to have this fixed as it'll allow us to use Kerberos to
>   authenticate to phppgadmin and other web-based tools which use
>   Postgres.

  While playing with this patch under 8.1.2 at home I discovered a
  mistake in how I manually applied one of the hunks to fe-auth.c.
  Basically, the base code had changed and so the patch needed to be
  modified slightly.  This is because the code no longer either has a
  freeable pointer under 'name' or has 'name' as NULL.

  The attached patch correctly frees the string from pg_krb5_authname
  (where it had been strdup'd) if and only if pg_krb5_authname returned
  a string (as opposed to falling through and having name be set using
  name = pw->name;).  Also added a comment to this effect.

Backpatch to 8.1.X.

Stephen Frost
2006-03-06 17:59:30 +00:00
Bruce Momjian 357cc01e57 This patch adds native LDAP auth, for those platforms that don't have
PAM (such as Win32, but also unixen without PAM). On Unix, uses
OpenLDAP. On win32, uses the builin WinLDAP library.

Magnus Hagander
2006-03-06 17:41:44 +00:00
Bruce Momjian 5e3bcac1d9 Fix psql history handling so 'execute' backslash commands (\g)
remain as part of the multi-line query.
2006-03-06 15:09:04 +00:00
Bruce Momjian 4c63b1f88e Prevent autovacuum from zeroing damaged pages. 2006-03-06 05:14:19 +00:00
Bruce Momjian ca8f27998a In psql, save history of backslash commands used in multi-line
statements before the multi-line statement, rather than inside the
multi-line statement.
2006-03-06 04:45:21 +00:00
Neil Conway 99114a2473 Per recent discussion on -hackers, we should sometimes reorder the
columns of the grouping clause to avoid redundant sorts. The optimizer
is not currently capable of doing this, so this patch implements a
simple hack in the analysis phase (transformGroupClause): if any
subset of the GROUP BY clause matches a prefix of the ORDER BY list,
that prefix is moved to the front of the GROUP BY clause. This
shouldn't change the semantics of the query, and allows a redundant
sort to be avoided for queries like "GROUP BY a, b ORDER BY b".
2006-03-05 21:34:34 +00:00
Andrew Dunstan 5d723d05c0 Prepared queries for PLPerl, plus fixing a small plperl memory leak. Patch
and docs from Dmitry Karasik, slightly editorialised.
2006-03-05 16:40:51 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Bruce Momjian e096406c05 Update to 2006. 2006-03-05 15:21:45 +00:00
Bruce Momjian a4a6ee4a5d Check for "msys" so it doesn't use 'con' by checking for an evironment
variable.
2006-03-05 05:33:12 +00:00
Bruce Momjian 5fde861375 Improve STRINGS_H macro test for MSVC extensions.
Add DLLIMPORT for V1 headers, in case Win32 don't export all symbols.
2006-03-05 04:43:57 +00:00
Tom Lane 5b8ac71042 Support include directives in postgresql.conf.
Patch by Joachim Wieland, somewhat reworked for clarity and portability.
2006-03-04 22:19:31 +00:00
Tom Lane 60d3c9fdf4 Declare the arguments of AllocateFile() as const char *, not char *.
This is consistent with the standard definition of fopen().
2006-03-04 21:32:47 +00:00
Tom Lane 2689abf078 Incorporate a couple of recent tuplesort.c improvements into tuplestore.c.
In particular, ensure that enlargement of the memtuples[] array doesn't
fall foul of MaxAllocSize when work_mem is very large, and don't bother
enlarging it if that would force an immediate switch into 'tape' mode anyway.
2006-03-04 19:30:12 +00:00
Tom Lane 20bdc71369 Prevent lazy_space_alloc from making requests that exceed MaxAllocSize,
per report from Stefan Kaltenbrunner.
2006-03-04 19:09:09 +00:00
Tom Lane 80cadb303c Prevent sorting from requesting a SortTuple array that exceeds MaxAllocSize;
we'll go over to disk-based sort if we reach that limit.
This fixes Stefan Kaltenbrunner's observation that sorting can suffer an
'invalid memory alloc request size' failure when sort_mem is set large
enough.  It's unfortunately not so easy to fix in 8.1 ...
2006-03-04 19:05:06 +00:00
Tatsuo Ishii b3d0442ab3 Tighten up SJIS byte sequence check. Now we reject invalid SJIS byte
sequence such as "0x95 0x27". Patches from Akio Ishida.
Also update copyright notice.
2006-03-04 10:57:35 +00:00
Bruce Momjian 3bce31f613 > gettimeofday.c:35: warning: integer constant is too large for "long"
> type

Wouldn't it be better to use the UINT64CONST macro?  I realize this
file is Windows-only, but we do worry about more than one compiler
on that platform.

Kris Jurka
2006-03-04 04:44:07 +00:00
Bruce Momjian 64e7c8a951 Use DEVTTY as 'con' on Win32 as a replacement for /dev/tty. 2006-03-04 04:30:41 +00:00
Bruce Momjian 295615a6ca This patch fixes this warning.
gettimeofday.c:35: warning: integer constant is too large for "long"
type

Kris Jurka
2006-03-03 23:59:14 +00:00
Bruce Momjian ef3f7c3f74 Avoid trying to open /dev/tty on Win32. Some Win32 systems have
/dev/tty, but it isn't a device file and doesn't work as expected.

This fixes a known bug where psql does not prompt for a password on some
Win32 systems.

Backpatch to 8.1.X.

Robert Kinberg
2006-03-03 23:49:12 +00:00
Tom Lane decdaf3592 Improve pg_dump and psql to use libpq's newer COPY support routines,
instead of the old deprecated ones.
Volkan Yazici, with some editorializing by moi.
2006-03-03 23:38:30 +00:00
Bruce Momjian 0b1b010c12 Fixes for Win32-client only compiles.
Hiroshi Saito
2006-03-03 23:11:48 +00:00
Bruce Momjian bf8337b8af Update ipcclean to use try 'id' first for root check. 2006-03-03 21:52:37 +00:00
Bruce Momjian 28edbdb7be Add workaround so MSVC doesn't try to load strings.h, which it doesn't
have.  This happens when MSVC uses pg_config.h generated by MinGW.

Per report from Charles F. I. Savage
2006-03-03 21:35:46 +00:00
Tom Lane 523adeb111 Teach PQcmdTuples() that a COPY command tag might contain a row count,
and tighten up its sanity checking of the tag as a safety measure.
Volkan Yazici.
2006-03-03 20:57:32 +00:00
Bruce Momjian 502e9aefdc Clarify macro layout for win32 IMPORT. 2006-03-03 20:52:36 +00:00
Tom Lane 023570f5e3 Make the COPY command return a command tag that includes the number of
rows copied.  Backend side of Volkan Yazici's recent patch, with
corrections and documentation.
2006-03-03 19:54:10 +00:00
Tom Lane 4e086f7cb5 Dept. of second thoughts: rejigger the TRUNCATE ... CASCADE patch so that
relations are still checked for permissions etc as soon as they are
opened.  The original form of the patch could hold exclusive lock for a
long time on relations that the user doesn't even have permissions to
access, let alone truncate.
2006-03-03 18:25:14 +00:00
Bruce Momjian a6add72ac3 In ipcclean, check LOGNAME only if USER is not set.
Fixes problem with 'su' on some platforms.
2006-03-03 16:49:21 +00:00
Neil Conway 587bc81887 Fix a typo. 2006-03-03 04:31:07 +00:00
Tom Lane 984a6ced3e Add CASCADE option to TRUNCATE. Joachim Wieland 2006-03-03 03:30:54 +00:00
Bruce Momjian 6839bc95d4 Add comment about localized month names for to_date and to_timestamp. 2006-03-03 02:17:30 +00:00
Tom Lane 9a506a6257 Arrange to call AbsorbFsyncRequests every so often while performing a
checkpoint in the bgwriter.  This forestalls overflow of the fsync request
queue, which is not fatal but causes considerable performance degradation
when it occurs (because backends then have to do their own fsyncs).  Per
patch from Itagaki Takahiro, modified a little bit by me.
2006-03-03 00:02:02 +00:00
Tom Lane f0bfc02001 Remove unnecessary lo_lseek call in lo_open. Apparently there was once
a need for it back in the neolithic era, but it's certainly dead code in
any PG release we would recognize as such.  Since it forces an additional
network round trip to the backend, getting rid of it should provide some
small performance improvement for large-object-using clients.
2006-03-02 21:56:14 +00:00
Tom Lane 56aa84a69c Fix ancient error in large objects usage example: overwrite() subroutine
was opening with INV_READ flag and then writing.  Prior to 8.1 the backend
did not reject this, but now it does.
2006-03-02 21:49:09 +00:00
Tom Lane 9356877bba Repair oidvectorrecv and int2vectorrecv, which I broke while changing
them to use array_recv :-(.  Per report from Tim Kordas.
2006-03-02 21:13:04 +00:00
Tom Lane fa7f6ff0db Fix possible crash at transaction end when a plpgsql function is used and
then modified within the same transaction.  The code was using a linked list
of active PLpgSQL_expr structs, which was OK when it was written because
plpgsql never released any parse data structures for the life of the backend.
But since Neil fixed plpgsql's memory management, elements of the linked list
could be freed, leading to crash when the list is chased.  Per report and test
case from Kris Jurka.
2006-03-02 05:34:12 +00:00
Tom Lane 181f55e5fb Fix up pg_dump to emit shell-type definitions at the proper time, to
make use of the recently added ability to create a shell type explicitly.

I also put in place some infrastructure to allow dump/no dump decisions
to be made separately for each database object, rather than the former
hardwired 'dump if in a dumpable schema' policy.  This was needed anyway
for shell types so now seemed a convenient time to do it.  The flexibility
isn't exposed to the user yet, but is ready for future extensions.
2006-03-02 01:18:26 +00:00
Neil Conway 485541a3aa Update the expected regression test results to account for the changes to
error messages I made yesterday -- thanks to Andrew Dunstan for reporting
this, and my apologies for missing it the first time.
2006-03-01 21:09:32 +00:00
Neil Conway 0d9742f99a Attached is a patch that replaces a bunch of places where StringInfos
are unnecessarily allocated on the heap rather than the stack. If the
StringInfo doesn't outlive the stack frame in which it is created,
there is no need to allocate it on the heap via makeStringInfo() --
stack allocation is faster.  While it's not a big deal unless the
code is in a critical path, I don't see a reason not to save a few
cycles -- using stack allocation is not less readable.

I also cleaned up a bit of code along the way: moved variable
declarations into a more tightly-enclosing scope where possible,
fixed some pointless copying of strings in dblink, etc.
2006-03-01 06:51:01 +00:00
Neil Conway 8e5a10d46c This patch makes the error message strings throughout the backend
more compliant with the error message style guide. In particular,
errdetail should begin with a capital letter and end with a period,
whereas errmsg should not. I also fixed a few related issues in
passing, such as fixing the repeated misspelling of "lexeme" in
contrib/tsearch2 (per Tom's suggestion).
2006-03-01 06:30:32 +00:00
Neil Conway e24cea8be5 Fix typo in comment. 2006-02-28 23:38:13 +00:00
Tom Lane 8e68d78390 Allow the syntax CREATE TYPE foo, with no parameters, to permit explicit
creation of a shell type.  This allows a less hacky way of dealing with
the mutual dependency between a datatype and its I/O functions: make a
shell type, then make the functions, then define the datatype fully.
We should fix pg_dump to handle things this way, but this commit just deals
with the backend.

Martijn van Oosterhout, with some corrections by Tom Lane.
2006-02-28 22:37:27 +00:00
Neil Conway 2b8afe6193 Tweak the error message emitted when a void-returning PL/Python function
does not return None, per suggestion from Tom.
2006-02-28 20:56:14 +00:00
Neil Conway 87daae1143 Allow PL/Python functions to return void, per gripe from James Robinson
(I didn't use his patch, however). A void-returning PL/Python function
must return None (from Python), which is translated into a void datum
(and *not* NULL) for Postgres. I also added some regression tests for
this functionality.
2006-02-28 20:03:52 +00:00
Bruce Momjian 03024ca5a1 Add PG_VERSION_NUM for use by 3rd party applications wanting to test the
backend version in C using > and < comparisons.
2006-02-28 16:41:21 +00:00
Tom Lane d2c555ee53 Teach nodeSort and nodeMaterial to optimize out unnecessary overhead
when the passed-down eflags indicate they can.
Simon Riggs and Tom Lane
2006-02-28 05:48:44 +00:00
Tom Lane 2c0ef9777c Extend the ExecInitNode API so that plan nodes receive a set of flag
bits indicating which optional capabilities can actually be exercised
at runtime.  This will allow Sort and Material nodes, and perhaps later
other nodes, to avoid unnecessary overhead in common cases.
This commit just adds the infrastructure and arranges to pass the correct
flag values down to plan nodes; none of the actual optimizations are here
yet.  I'm committing this separately in case anyone wants to measure the
added overhead.  (It should be negligible.)

Simon Riggs and Tom Lane
2006-02-28 04:10:28 +00:00
Peter Eisentraut 7f4f42fa10 Clean up CREATE FUNCTION syntax usage in contrib and elsewhere, in
particular get rid of single quotes around language names and old WITH ()
construct.
2006-02-27 16:09:50 +00:00
Bruce Momjian d46fbef386 Add mention that tid perhaps someday should be output as a record. 2006-02-27 01:41:16 +00:00
Tom Lane 909ca1407c Improve sorting speed by pre-extracting the first sort-key column of
each tuple, as per my proposal of several days ago.  Also, clean up
sort memory management by keeping all working data in a separate memory
context, and refine the handling of low-memory conditions.
2006-02-26 22:58:12 +00:00
Neil Conway e1f06d8057 Fix a few minor typos in comments in PL/Perl. 2006-02-26 22:26:39 +00:00
Neil Conway 41cba49e95 Implement the <> operator for the tid type. Original patch from Mark
Kirkwood, minor improvements by Neil Conway. The regression tests have
been updated and the catversion has been bumped.
2006-02-26 18:36:23 +00:00
Neil Conway 4d39c6bcf5 Fix typo in comment. 2006-02-26 02:23:41 +00:00
Peter Eisentraut 268c1b6077 The Makefile was invoking perl scripts as ./script.pl. This fails when
the script is not executable as UCS_to_most.pl is in CVS.  It also won't
pick up any custom setting of the perl version/location to use.  This
patch calls perl scripts like $(PERL) $(srcdir)/script.pl.

Kris Jurka
2006-02-24 13:25:44 +00:00
Andrew Dunstan 2b695717a7 Make restricted_exec feature for Windows more robust by using the environment
to pass the flag instead of the command line - some implementations of
getopt fail if getopt arguments are present after non-getopt arguments.
2006-02-24 02:02:41 +00:00
Andrew Dunstan b5fe16d09f make initdb -U username work as advertised; back out bogus patch at rev 1.42
and supply real fix for problem it tried to address.
2006-02-24 00:55:49 +00:00
Neil Conway 737651f6be Cleanup the usage of ScanDirection: use the symbolic names for the
possible ScanDirection alternatives rather than magic numbers
(-1, 0, 1).  Also, use the ScanDirection macros in a few places
rather than directly checking whether `dir == ForwardScanDirection'
and the like. Per patch from James William Pye. His patch also
changed ScanDirection to be a "char" rather than an enum, which
I haven't applied.
2006-02-21 23:01:54 +00:00
Tom Lane 3666260ffd Fix old pg_dump oversight: default values for domains really need to be dumped
by decompiling the typdefaultbin expression, not just printing the typdefault
text which may be out-of-date or assume the wrong schema search path.  (It's
the same hazard as for adbin vs adsrc in column defaults.)  The catalogs.sgml
spec for pg_type implies that the correct procedure is to look to
typdefaultbin first and consider typdefault only if typdefaultbin is NULL.
I made dumping of both domains and base types do that, even though in the
current backend code typdefaultbin is always correct for domains and
typdefault for base types --- might as well try to future-proof it a little.
Per bug report from Alexander Galler.
2006-02-21 18:01:32 +00:00
Tom Lane af49a1634f Adjust probe for getaddrinfo to cope with macro-ized definitions, such
as Tru64's.  Per previous discussion.
2006-02-21 06:06:50 +00:00
Neil Conway 45594a6859 Fix three Python reference leaks in PLy_traceback(). This would result
in leaking memory when invoking a PL/Python procedure that raises an
exception. Unfortunately this still leaks memory, but at least the
largest leak has been plugged.

This patch also fixes a reference counting mistake in PLy_modify_tuple()
for 8.0, 8.1 and HEAD: we don't actually own a reference to `platt', so
we shouldn't Py_DECREF() it.
2006-02-20 20:10:37 +00:00
Tom Lane 21e2544aa7 Update obsolete comment. 2006-02-19 19:59:53 +00:00
Tom Lane b34aa3372f Modify logtape.c so that the initial LogicalTapeSetCreate call only
allocates the control data.  The per-tape buffers are allocated only
on first use.  This saves memory in situations where tuplesort.c
overestimates the number of tapes needed (ie, there are fewer runs
than tapes).  Also, this makes legitimate the coding in inittapes()
that includes tape buffer space in the maximum-memory calculation:
when inittapes runs, we've already expended the whole allowed memory
on tuple storage, and so we'd better not allocate all the tape buffers
until we've flushed some tuples out of memory.
2006-02-19 05:58:36 +00:00
Tom Lane df700e6b40 Improve tuplesort.c to support variable merge order. The original coding
with fixed merge order (fixed number of "tapes") was based on obsolete
assumptions, namely that tape drives are expensive.  Since our "tapes"
are really just a couple of buffers, we can have a lot of them given
adequate workspace.  This allows reduction of the number of merge passes
with consequent savings of I/O during large sorts.

Simon Riggs with some rework by Tom Lane
2006-02-19 05:54:06 +00:00
Neil Conway 85c0eac1af Add TABLESPACE and ON COMMIT clauses to CREATE TABLE AS. ON COMMIT is
required by the SQL standard, and TABLESPACE is useful functionality.
Patch from Kris Jurka, minor editorialization by Neil Conway.
2006-02-19 00:04:28 +00:00
Peter Eisentraut 3228a92ccd &apos; is not valid HTML 4.01, so print the plain character instead. 2006-02-18 22:54:50 +00:00
Peter Eisentraut 1b658473ea Add support for Windows codepages 1253, 1254, 1255, and 1257 and clean
up a bunch of the support utilities.

In src/backend/utils/mb/Unicode remove nearly duplicate copies of the
UCS_to_XXX perl script and replace with one version to handle all generic
files.  Update the Makefile so that it knows about all the map files.
This produces a slight difference in some of the map files, using a
uniform naming convention and not mapping the null character.

In src/backend/utils/mb/conversion_procs create a master utf8<->win
codepage function like the ISO 8859 versions instead of having a separate
handler for each conversion.

There is an externally visible change in the name of the win1258 to utf8
conversion.  According to the documentation notes, it was named
incorrectly and this changes it to a standard name.

Running the Unicode mapping perl scripts has shown some additional mapping
changes in koi8r and iso8859-7.
2006-02-18 16:15:23 +00:00
Neil Conway a6d3b5b944 Mark unescape_single_char() "static": as far as I can see this function
is only used by scan.l/scan.c
2006-02-18 01:44:35 +00:00
Neil Conway ea9eca2c20 Fix typo in comment. 2006-02-17 03:29:02 +00:00
Peter Eisentraut 15a3c33164 Change MemSet to use long instead of int32, for better performance on
64-bit platforms.

by ITAGAKI Takahiro
2006-02-16 23:23:50 +00:00
Tom Lane 0ad14ebc8d Repair --single-transaction patch so it handles blobs correctly.
Simon Riggs
2006-02-14 23:30:43 +00:00