Commit Graph

17753 Commits

Author SHA1 Message Date
Tom Lane 6cbb2353cb Tweak recently-added tests to suppress scary-looking warnings on 64-bit
machines about casts between pointers and integers of different sizes.
While they're harmless, we shouldn't expect users to have to go through
and figure that out for themselves.
2007-10-03 15:59:13 +00:00
Michael Meskes 2b0e46eef0 Argh, missing dll in filename 2007-10-03 15:24:19 +00:00
Tom Lane fdbce93b85 Minor improvements to hack for old OpenSSL libraries: avoid unused
variable warning on Windows, improve comment.
2007-10-03 15:12:45 +00:00
Tom Lane a248dbc4f8 Fix command for fetching snprintf.c. 2007-10-03 15:04:23 +00:00
Michael Meskes f06a2b0ecc This could be what's missing on some systems. 2007-10-03 14:42:16 +00:00
Michael Meskes c95f5e80a9 Stripped two symbols that are needed. 2007-10-03 14:01:28 +00:00
Magnus Hagander 76a6ddfa47 Attempt to open certificate file "manually" using fopen before
trying BIO functions.
Helps problem with older versions of OpenSSL that lacks error
stack functions and would show an incorrect error message for
file-not-found-or-not-openable. The problem may still exist for
other errors, but file open error is by far the most common one.
2007-10-03 13:57:52 +00:00
Magnus Hagander 2890c33084 Build two more .DEF files for ecpg instead of using default ones. 2007-10-03 13:43:24 +00:00
Michael Meskes ab8d123a3c Also build snprintf from pgport if needed. 2007-10-03 13:40:52 +00:00
Michael Meskes 449fcf47fb Remove exports.list in clean target. 2007-10-03 13:24:54 +00:00
Magnus Hagander bdf6b888a8 More detailed error msg (with stack trace) if a file copy fails. 2007-10-03 13:20:40 +00:00
Michael Meskes fa8a9f373c Also created export list for pgytpeslib and compatlib.
Set pgtypes library version to 3.0.
Set compat library version to 3.0.
2007-10-03 13:20:19 +00:00
Magnus Hagander f83e44aecd Use snprintf from libpgport in ecpg compatlib. Required since
we restricted exports from ecpglib.
2007-10-03 12:34:29 +00:00
Magnus Hagander 7b4453e5c1 Fix commandlines for final two ECPG regression tests 2007-10-03 12:31:18 +00:00
Magnus Hagander 5d0f18d6ad Fix typo 2007-10-03 12:11:37 +00:00
Magnus Hagander c8792c86f2 Build DEF file for libecpg instead of generating a default one. 2007-10-03 12:11:00 +00:00
Magnus Hagander 6ddbc1164d Make ECPG regression tests run with -c only for array_of_struct.pgc
on MSVC.

Fix strange nonstandard version of __stdcall specifyer in thread
tests on win32.
2007-10-03 11:57:36 +00:00
Magnus Hagander ebade3f5bf Fix typo 2007-10-03 11:34:11 +00:00
Michael Meskes 7793c6ecca Cleaned up ecpglib and renamed functions that do not need to be exported.
Created export list for ecpglib.
2007-10-03 11:11:12 +00:00
Michael Meskes c4a6c2f871 Hopefully fixed some stuff that causes Windows builds to fail. 2007-10-03 08:55:23 +00:00
Neil Conway fc470ca334 Fix a compiler warning on Win32. Hannes Eder. 2007-10-02 22:01:02 +00:00
Magnus Hagander de1172fa06 Default to thread safety on, and support more CPU options. Also
make sure that a CPU option is actually chosen.

Hiroshi Saito
2007-10-02 19:01:45 +00:00
Michael Meskes 5a0d31d3dc Made new test also work without threading enabled. 2007-10-02 14:01:57 +00:00
Michael Meskes b5efdbac5c No idea where this file came from. 2007-10-02 09:51:41 +00:00
Michael Meskes 0c2eb200d6 ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> added thread-safe
descriptor handling
2007-10-02 09:50:00 +00:00
Tom Lane f1d37a9997 Cope with ERR_set_mark() and ERR_pop_to_mark() not existing in older
OpenSSL libraries --- just don't call them if they're not there.  This
might possibly lead to misleading error messages, but we'll just have
to live with that.
2007-10-02 00:25:20 +00:00
Magnus Hagander ec4b6a81f6 Use BIO functions to avoid passing FILE * pointers to OpenSSL functions.
This fixes potential crashes on old versions of OpenSSL and the requirement on
"Applink" in new versions when building with MSVC and using different
runtimes.

Dave Page with fixes from me.
2007-10-01 20:30:06 +00:00
Tom Lane b526462f9e Avoid assuming that struct varattrib_pointer doesn't get padded by the
compiler --- at least on ARM, it does.  I suspect that the varvarlena patch
has been creating larger-than-intended toast pointers all along on ARM,
but it wasn't exposed until the latest tweak added some Asserts that
calculated the expected size in a different way.  We could probably have
fixed this by adding __attribute__((packed)) as is done for ItemPointerData,
but struct varattrib_pointer isn't really all that useful anyway, so it
seems cleanest to just get rid of it and have only struct varattrib_1b_e.
Per results from buildfarm member quagga.
2007-10-01 16:25:56 +00:00
Magnus Hagander b8ce3d3494 Build with /GS on 64-bit to work with modern Platform SDK.
Hiroshi Saito
2007-10-01 14:32:02 +00:00
Bruce Momjian 8ddeb48cd5 Update pgcvslog text to simply "<branch>" 2007-10-01 13:04:55 +00:00
Magnus Hagander 4164e6636e Enable __FUNCTION__ on MSVC builds.
Hannes Eder
2007-10-01 10:54:29 +00:00
Bruce Momjian 2d5dfd9516 Fixup for new pgcvslog feature. 2007-10-01 03:01:38 +00:00
Bruce Momjian 7d4dd3ab41 Have pgcvslog mark back-branch commits with "<back-patch>". 2007-10-01 02:59:03 +00:00
Tom Lane 27b8922221 Add an extra header byte to TOAST-pointer datums to represent their size
explicitly.  This means a TOAST pointer takes 18 bytes instead of 17 --- still
smaller than in 8.2 --- which seems a good tradeoff to ensure we won't have
painted ourselves into a corner if we want to support multiple types of TOAST
pointer later on.  Per discussion with Greg Stark.
2007-09-30 19:54:58 +00:00
Tom Lane 3ff0018c2e In hopes of un-breaking the buildfarm, add missing file from
ITAGAKI Takahiro's patch.
2007-09-30 17:50:56 +00:00
Tom Lane ab051bd293 Adjust recovery PS display as agreed with Simon: 'waiting for XXX'
while the restore_command does its thing, then 'recovering XXX' while
processing the segment file.  These operations are heavyweight enough
that an extra PS display set shouldn't bother anyone.
2007-09-30 17:28:56 +00:00
Michael Meskes 60e83cec57 Applied another patch by ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>
to get memory allocation thread-safe. He also did some cleaning up.
2007-09-30 11:38:48 +00:00
Tom Lane 77ccbe64dd Make recovery show the current input WAL segment name in the startup
process' PS display.  After a suggestion by Simon (not exactly his
patch though).
2007-09-29 18:32:56 +00:00
Tom Lane f6a54b8c42 Disallow CLUSTER using an invalid index (that is, one left over from a failed
CREATE INDEX CONCURRENTLY).  Such an index might not have entries for every
heap row and thus clustering with it would result in silent data loss.
The scenario requires a pretty foolish DBA, but still ...
2007-09-29 18:05:20 +00:00
Tom Lane 34b44c3ba2 Improve consistency of the error messages generated when you try to use
ALTER TABLE on a composite type or ALTER TYPE on a table's rowtype.
We already rejected these cases, but the error messages were a bit
random and didn't always provide a HINT to use the other command type.
2007-09-29 17:18:58 +00:00
Bruce Momjian e6022e7470 In the release checklist, mention packagers will see the minor upgrade
numbering for additional functions.
2007-09-29 12:19:16 +00:00
Magnus Hagander bdee83e7e4 Add chklocale.c to pgport files for msvc builds, per
buildfarm failures.
2007-09-29 07:15:33 +00:00
Tom Lane b46bd55a6c Make archive recovery always start a new timeline, rather than only when a
recovery stop time was used.  This avoids a corner-case risk of trying to
overwrite an existing archived copy of the last WAL segment, and seems
simpler and cleaner all around than the original definition.  Per example
from Jon Colverson and subsequent analysis by Simon.
2007-09-29 01:36:10 +00:00
Tom Lane b37e1770c5 Make use of additional chklocale.c entries to reject locales that we
cannot support.
2007-09-29 00:14:40 +00:00
Tom Lane d5459671a3 Teach chklocale.c about a few names for frontend-only encodings,
since this will allow initdb to reject attempts to initdb in a locale
that uses such an encoding.  We'll probably find out more such names
during beta ...
2007-09-29 00:01:43 +00:00
Tom Lane 1f32999039 On OS X, assume that an empty-string result for nl_langinfo(CODESET)
means UTF-8.  Per examination of /usr/share/locale in 10.4.10.
2007-09-28 23:36:06 +00:00
Bruce Momjian 304750f8d0 Update TCL comment:
* We can only fix this with Tcl >= 8.4, when Tcl_SetNotifier()
2007-09-28 22:33:20 +00:00
Tom Lane 70b9b9b788 Change initdb and CREATE DATABASE to actively reject attempts to create
databases with encodings that are incompatible with the server's LC_CTYPE
locale, when we can determine that (which we can on most modern platforms,
I believe).  C/POSIX locale is compatible with all encodings, of course,
so there is still some usefulness to CREATE DATABASE's ENCODING option,
but this will insulate us against all sorts of recurring complaints
caused by mismatched settings.

I moved initdb's existing LC_CTYPE-to-encoding mapping knowledge into
a new src/port/ file so it could be shared by CREATE DATABASE.
2007-09-28 22:25:49 +00:00
Tom Lane 834f45014b Tweak initdb's text search configuration selection code so it can
cope with LANG settings like 'es_ES@euro'.
2007-09-28 15:25:44 +00:00
Andrew Dunstan c0a8276061 exclude contrib/tsearch2 from regression tests. 2007-09-28 00:14:58 +00:00
Andrew Dunstan 3396d1c695 Turn build and vcregress .bat files into pure one line wrappers for
the perl scripts. Remove the now superfluous getregress.pl.
2007-09-27 21:13:11 +00:00
Tom Lane aedc5ed571 Fix typos in two comments. Spotted by Brendan Jurd 2007-09-27 21:01:59 +00:00
Tom Lane 314ed5de6d Define the FRONTEND symbol in postgres_fe.h, which allows us to eliminate
duplicative -DFRONTEND flags from many Makefiles.  We still need Makefile
control of the symbol in a few places that compile frontend-or-backend
src/port/ files, but it's a lot cleaner than before.

Hiroshi Saito
2007-09-27 19:53:44 +00:00
Tom Lane 77c166ba6c Add virtual transaction IDs to CSVLOG output, so that messages coming from
the same transaction can be identified even when no regular XID was assigned.
This seems essential after addition of the lazy-XID patch.  Also some
minor code cleanup in write_csvlog().
2007-09-27 18:15:36 +00:00
Tom Lane a62a359ba2 Fix Assert failure in ExpandColumnRefStar --- what I thought was a can't
happen condition can happen given incorrect input.  The real problem is that
gram.y should try harder to distinguish * from "*" --- the latter is a legal
column name per spec, and someday we ought to treat it that way.  However
fixing that is too invasive for a back-patch, and it's too late for the 8.3
cycle too.  So just reduce the Assert to a plain elog for now.  Per report
from NikhilS.
2007-09-27 17:42:03 +00:00
Tom Lane 84fe8990ae Some small tuptoaster improvements from Greg Stark. Avoid unnecessary
decompression of an already-compressed external value when we have to copy
it; save a few cycles when a value is too short for compression; and
annotate various lines that are currently unreachable.
2007-09-26 23:29:10 +00:00
Tom Lane f18dfc4835 Minor improvements in backup and recovery:
- create a separate archive_mode GUC, on which archive_command is dependent

- %r option in recovery.conf sends last restartpoint to recovery command

- %r used in pg_standby, updated README

- minor other code cleanup in pg_standby

- doc on Warm Standby now mentions pg_standby and %r

- log_restartpoints recovery option emits LOG message at each restartpoint

- end of recovery now displays last transaction end time, as requested
  by Warren Little; also shown at each restartpoint

- restart archiver if needed to carry away WAL files at shutdown

Simon Riggs
2007-09-26 22:36:30 +00:00
Alvaro Herrera b83e11639b Adjust the new memory limit in the lazy vacuum code to use MaxHeapTuplesPerPage
tuples per page instead of fixed 200, to better cope with systems that use a
different block size.
2007-09-26 20:16:28 +00:00
Tom Lane cdf0231c88 Create a function variable "join_search_hook" to let plugins override the
join search order portion of the planner; this is specifically intended to
simplify developing a replacement for GEQO planning.  Patch by Julius
Stroffek, editorialized on by me.  I renamed make_one_rel_by_joins to
standard_join_search and make_rels_by_joins to join_search_one_level to better
reflect their place within this scheme.
2007-09-26 18:51:51 +00:00
Magnus Hagander 149af068ff Properly pass -c parameter to ecpg when building regression tests.
Per Michael.
2007-09-26 11:19:09 +00:00
Michael Meskes d49b20fbe6 Applied patch by ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> to get prepare thread-safe. 2007-09-26 10:57:01 +00:00
Teodor Sigaev 689df1bc77 Fix crash of to_tsvector() function on huge input: compareWORD()
function didn't return correct result for word position greate than
limit.

Per report from Stuart Bishop <stuart@stuartbishop.net>
2007-09-26 10:09:57 +00:00
Tom Lane 6f21c57a97 In the integer-datetimes case, date2timestamp and date2timestamptz need
to check for overflow because the legal range of type date is actually
wider than timestamp's.  Problem found by Neil Conway.
2007-09-26 01:10:42 +00:00
Tom Lane 93407d3998 Use SYSV semaphores rather than POSIX on Darwin >= 6.0 (i.e., OS X 10.2
and up), per Chris Marcellino.  This avoids consuming O(N^2) file
descriptors to support N backends.  Tests suggest it's about a wash for
small installations, but large ones would have a problem.
2007-09-26 00:32:46 +00:00
Tom Lane f828f878e9 Change on-disk representation of NUMERIC datatype so that the sign_dscale
word comes before the weight instead of after.  This will allow future
binary-compatible extension of the representation to support compact formats,
as discussed on pgsql-hackers around 2007/06/18.  The reason to do it now is
that we've already pretty well broken any chance of simple in-place upgrade
from 8.2 to 8.3, but it's possible that 8.3 to 8.4 (or whenever we get around
to squeezing NUMERIC) could otherwise be data-compatible.
2007-09-25 22:21:55 +00:00
Tom Lane 7a315a09dc Dept. of second thoughts: fix loop in BgBufferSync so that the exit when
bgwriter_lru_maxpages is exceeded leaves the loop variables in the
expected state.  In the original coding, we'd fail to advance
next_to_clean, causing that buffer to be probably-uselessly rechecked next
time, and also have an off-by-one idea of the number of buffers scanned.
2007-09-25 22:11:48 +00:00
Tom Lane 6f5c38dcd0 Just-in-time background writing strategy. This code avoids re-scanning
buffers that cannot possibly need to be cleaned, and estimates how many
buffers it should try to clean based on moving averages of recent allocation
requests and density of reusable buffers.  The patch also adds a couple
more columns to pg_stat_bgwriter to help measure the effectiveness of the
bgwriter.

Greg Smith, building on his own work and ideas from several other people,
in particular a much older patch from Itagaki Takahiro.
2007-09-25 20:03:38 +00:00
Peter Eisentraut 588901df84 Small string tweaks 2007-09-25 16:29:34 +00:00
Andrew Dunstan e5b5739a2d Use proper search for contrib makefiles in vcregress.pl 2007-09-24 21:42:34 +00:00
Andrew Dunstan 3f2a191b44 fix typo in vcregress.pl 2007-09-24 21:14:54 +00:00
Andrew Dunstan a1b14ae1dd Add comments re text <-> bytea internal equivalence in convert routines. 2007-09-24 16:38:24 +00:00
Andrew Dunstan 82467e4e70 Use correct PG_GETARG macro in pg_convert 2007-09-24 14:59:37 +00:00
Alvaro Herrera 45cbdaa038 Avoid having autovacuum read pgstats data too many times in quick succession.
This is problematic for the autovac launcher when there are many databases,
so we keep data for a full second before reading it again.
2007-09-24 04:12:01 +00:00
Alvaro Herrera 5853662630 Reduce the size of memory allocations by lazy vacuum when processing a small
table, by allocating just enough for a hardcoded number of dead tuples per
page.  The current estimate is 200 dead tuples per page.

Per reports from Jeff Amiel, Erik Jones and Marko Kreen, and subsequent
discussion.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: 	commands/vacuumlazy.c
CVS: ----------------------------------------------------------------------
2007-09-24 03:52:55 +00:00
Tom Lane 48f7e64395 Simplify and rename some GUC variables, per various recent discussions:
* stats_start_collector goes away; we always start the collector process,
unless prevented by a problem with setting up the stats UDP socket.

* stats_reset_on_server_start goes away; it seems useless in view of the
availability of pg_stat_reset().

* stats_block_level and stats_row_level are merged into a single variable
"track_counts", which controls all reports sent to the collector process.

* stats_command_string is renamed to track_activities.

* log_autovacuum is renamed to log_autovacuum_min_duration to better reflect
its meaning.

The log_autovacuum change is not a compatibility issue since it didn't exist
before 8.3 anyway.  The other changes need to be release-noted.
2007-09-24 03:12:23 +00:00
Andrew Dunstan 02138357ff Remove "convert 'blah' using conversion_name" facility, because if it
produces text it is an encoding hole and if not it's incompatible
with the spec, whatever the spec means (which we're not sure about anyway).
2007-09-24 01:29:30 +00:00
Tom Lane c3b193a5c3 Replace linear searches with binary searches in pg_dump's code to
lookup objects by OID.  Per gripe from nikitathespider.
2007-09-23 23:39:36 +00:00
Andrew Dunstan aabb7000dc Add perl replacements for build.bat and vcregress.bat. In due course
the .bat files will be altered to become tiny wrappers for these scripts,
and one or two other .bat files will disappear.
2007-09-23 21:52:56 +00:00
Tom Lane f71c7b9dfd Fix bugs in XML binary I/O functions. Heikki and Tom 2007-09-23 21:36:42 +00:00
Andrew Dunstan a8da5761a3 Restrict overly broad searches, and fix typo, in recent fix. Per Hannes Eder. 2007-09-23 20:32:40 +00:00
Tom Lane ea72d37ff7 Make autovacuum report the start time of its current activity in
pg_stat_activity.  Per gripe from Jim Nasby.
2007-09-23 20:07:33 +00:00
Tom Lane 1b3d400cac TransactionIdIsInProgress can skip scanning the ProcArray if the target XID is
later than latestCompletedXid, per Florian Pflug.  Also some minor
improvements in the XIDCACHE_DEBUG code --- make sure each call of
TransactionIdIsInProgress is counted one way or another.
2007-09-23 18:50:38 +00:00
Tom Lane 33b9c8bd68 Temporarily modify tsearch regression tests to suppress notice that comes
out at erratic times, because it is creating a totally unacceptable level
of noise in our buildfarm results.  This patch can be reverted when and if
the code is fixed to not issue notices during cache reload events.
2007-09-23 15:58:58 +00:00
Tom Lane 7125687511 Fix cost estimates for EXISTS subqueries that are evaluated as initPlans
(because they are uncorrelated with the immediate parent query).  We were
charging the full run cost to the parent node, disregarding the fact that
only one row need be fetched for EXISTS.  While this would only be a
cosmetic issue in most cases, it might possibly affect planning outcomes
if the parent query were itself a subquery to some upper query.
Per recent discussion with Steve Crawford.
2007-09-22 21:36:40 +00:00
Andrew Dunstan 576b8903f7 Replace calls to external dir program with perlish globs and File::Find
calls. Fixes complaint fron Hannes Eder, whose environment found a different
dir program.
2007-09-22 20:38:10 +00:00
Tom Lane f316222930 Fix erroneous Assert() in syslogger process start in EXEC_BACKEND case,
per ITAGAKI Takahiro.  Also, rewrite syslogger_forkexec() in hopes of
eliminating the confusion in the first place.
2007-09-22 18:19:18 +00:00
Tom Lane bbda96d76d Fix bogus calculation of potential output string length in translate(). 2007-09-22 05:35:42 +00:00
Tom Lane 571340a00e Parenthesize macro arguments safely. I see no bug among the current
uses of PG_DETOAST_DATUM_SLICE, but it's clearly trouble waiting to
happen.
2007-09-22 04:41:19 +00:00
Tom Lane 5e87ebb0c3 Although I'd misdiagnosed the reason for the recent failures on
buildfarm member grebe, I see no reason to revert the 1-byte-header-friendly
changes I made in varlena.c.  Instead, tweak the code a little bit to
get more advantage out of that.
2007-09-22 04:40:03 +00:00
Tom Lane 94470b9499 Doh --- what's really happening on buildfarm member grebe is that its
malloc returns NULL for malloc(0).  Defend against that case.
2007-09-22 04:37:53 +00:00
Andrew Dunstan e152893305 Go back to using a separate method for doing ILIKE for single byte
character encodings that doesn't involve calling lower(). This should
cure the performance regression in this case complained of by Guillaume
Smet. It still leaves the horrid performance for multi-byte encodings
introduced in 8.2, but there's no obvious solution for that in sight.
2007-09-22 03:58:34 +00:00
Tom Lane b5d1608b0a Fix varlena.c routines to allow 1-byte-header text values. This is now
demonstrably necessary for text_substring() since regexp_split functions
may pass it such a value; and we might as well convert the whole file
at once.  Per buildfarm results (though I wonder why most machines aren't
showing a failure).
2007-09-22 00:36:38 +00:00
Tom Lane 7583f9a7ca Fix regex, LIKE, and some other second-rank text-manipulation functions
to not cause needless copying of text datums that have 1-byte headers.
Greg Stark, in response to performance gripe from Guillaume Smet and
ITAGAKI Takahiro.
2007-09-21 22:52:52 +00:00
Tom Lane cc59049daf Improve handling of prune/no-prune decisions by storing a page's oldest
unpruned XMAX in its header.  At the cost of 4 bytes per page, this keeps us
from performing heap_page_prune when there's no chance of pruning anything.
Seems to be necessary per Heikki's preliminary performance testing.
2007-09-21 21:25:42 +00:00
Tom Lane 386a5d4268 Change tqual.c tests to use !TransactionIdIsCurrentTransactionId, rather than
TransactionIdDidAbort, when handling the case that xmin is one of the current
transaction's XIDs and the tuple has been deleted.  xmax must also be one of
the current transaction's XIDs, since no one else can see it yet, and it's
cheaper to look at local state than shared state to find out if xmax aborted.
Per an idea of Heikki's.
2007-09-21 18:24:28 +00:00
Tom Lane da072ab2ab Make some simple performance improvements in TransactionIdIsInProgress().
For XIDs of our own transaction and subtransactions, it's cheaper to ask
TransactionIdIsCurrentTransactionId() than to look in shared memory.
Also, the xids[] work array is always the same size within any given
process, so malloc it just once instead of doing a palloc/pfree on every
call; aside from being faster this lets us get rid of some goto's, since
we no longer have any end-of-function pfree to do.  Both ideas by Heikki.
2007-09-21 17:36:53 +00:00
Tom Lane bd0af827da Fix comments that misspelled TransactionIdIsInProgress, per Heikki. 2007-09-21 16:32:19 +00:00
Michael Meskes 3e77c8c6c6 Removed superfluous ECPGfree() call. 2007-09-21 10:59:27 +00:00
Tom Lane 017daed0dd If we're gonna provide an --enable-profiling configure option, surely
it ought to know that you need -DLINUX_PROFILE on Linux.
2007-09-21 02:33:46 +00:00
Tom Lane 02185a0716 Insert a hack in pl/tcl to disable Tcl's built-in Notifier subsystem, which
has a bad habit of launching multiple threads within the backend and thereby
causing all kinds of havoc.  Fortunately, we don't need it, and recent Tcl
versions provide an easy way to disable it.  Diagnosis and fix by
Steve Marshall, Paul Bayer, and Doug Knight of WSI Corporation.
2007-09-21 00:30:49 +00:00
Tom Lane d22ae3ecc2 Solaris portability fix that was previously made in contrib/tsearch2
but got lost from the version committed to main tree.  Per Greg Stark.
2007-09-20 23:27:11 +00:00
Tom Lane eb5f4d6c5c Revert ill-fated patch to release exclusive lock early after vacuum
truncates a table.  Introduces race condition, as shown by buildfarm
failures.
2007-09-20 21:43:27 +00:00
Andrew Dunstan ad8fbb549a Cleanup items from csvlog changes, per ITAGAKI Takahiro. 2007-09-20 18:19:08 +00:00
Teodor Sigaev bab16af807 Fix msvc warnings, patch by Hannes Eder <Hannes@HannesEder.net> 2007-09-20 18:10:57 +00:00
Tom Lane 282d2a03dd HOT updates. When we update a tuple without changing any of its indexed
columns, and the new version can be stored on the same heap page, we no longer
generate extra index entries for the new version.  Instead, index searches
follow the HOT-chain links to ensure they find the correct tuple version.

In addition, this patch introduces the ability to "prune" dead tuples on a
per-page basis, without having to do a complete VACUUM pass to recover space.
VACUUM is still needed to clean up dead index entries, however.

Pavan Deolasee, with help from a bunch of other people.
2007-09-20 17:56:33 +00:00
Neil Conway bbf4fdc253 Prevent corr() from returning the wrong results for negative correlation
values. The previous coding essentially assumed that x = sqrt(x*x), which
does not hold for x < 0.

Thanks to Jie Zhang at Greenplum and Gavin Sherry for reporting this
issue.
2007-09-19 22:31:48 +00:00
Andrew Dunstan 55613bf9cd Close previously open holes for invalidly encoded data to enter the
database via builtin functions, as recently discussed on -hackers.

chr() now returns a character in the database encoding. For UTF8 encoded databases
the argument is treated as a Unicode code point. For other multi-byte encodings
the argument must designate a strict ascii character, or an error is raised,
as is also the case if the argument is 0.

ascii() is adjusted so that it remains the inverse of chr().

The two argument form of convert() is gone, and the three argument form now
takes a bytea first argument and returns a bytea. To cover this loss three new
functions are introduced:
. convert_from(bytea, name) returns text - converts the first argument from the
  named encoding to the database encoding
. convert_to(text, name) returns bytea - converts the first argument from the
  database encoding to the named encoding
. length(bytea, name) returns int - gives the length of the first argument in
  characters in the named encoding
2007-09-18 17:41:17 +00:00
Teodor Sigaev 8544110042 Avoid possibly-unportable initializer, per buildfarm warning
per notice by Gregory Stark <stark@enterprisedb.com>
2007-09-18 15:03:23 +00:00
Bruce Momjian dc29d703d8 Doc reminder that integer pg version also needs updating. 2007-09-18 01:52:39 +00:00
Bruce Momjian 851745a97a Remove extra tab in postgresql.conf 2007-09-17 21:40:40 +00:00
Tom Lane 039dc49d55 Remove Assert(BgWriterShmem != NULL), which is rather pointless since
we'd dump core anyway immediately afterward if it were null; and it
seems to confuse some versions of icc into generating bad code.
Per report from Sergey Koposov.  Patched in HEAD only, for the moment,
since this is only likely to affect developers.
2007-09-16 16:33:04 +00:00
Tom Lane 22d98e7934 Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.
Seems to have been introduced in 8.1 by careless SECS_PER_DAY
search-and-replace.
2007-09-16 15:56:20 +00:00
Tom Lane 43b0c9182f Fix aboriginal mistake in lazy VACUUM's code for truncating away
no-longer-needed pages at the end of a table.  We thought we could throw away
pages containing HEAPTUPLE_DEAD tuples; but this is not so, because such
tuples very likely have index entries pointing at them, and we wouldn't have
removed the index entries.  The problem only emerges in a somewhat unlikely
race condition: the dead tuples have to have been inserted by a transaction
that later aborted, and this has to have happened between VACUUM's initial
scan of the page and then rechecking it for empty in count_nondeletable_pages.
But that timespan will include an index-cleaning pass, so it's not all that
hard to hit.  This seems to explain a couple of previously unsolved bug
reports.
2007-09-16 02:37:46 +00:00
Bruce Momjian 63490ddf1e Remove GIN interface section, which is now documented in SGML.
Heikki Linnakangas
2007-09-14 16:28:17 +00:00
Bruce Momjian 7f9de5407a Fix GSS API pointer checking.
Kris Jurka
2007-09-14 15:58:02 +00:00
Bruce Momjian f6a168e2c3 Add LDAP URL documentation.
Albe Laurenz
2007-09-14 14:31:22 +00:00
Bruce Momjian 17aae41afd Add tsearch tab completion support:
* adds a few missing words to some commands (like adding GIN as a valid
index type or OWNED BY for ALTER SEQUENCE,...)

* support for ALTER TABLE foo ENABLE/DISABLE REPLICA TRIGGER/RULE

* autocomplete CREATE DATABASE foo TEMPLATE (mostly done to prevent
conflicts with the TEMPLATE keyword for text search)

* support for ALTER/CREATE/DROP TEXT SEARCH as well as COMMENT ON TEXT
SEARCH and the corresponding psql backslash commands.
This proved a little more difficult than expected due to the fact that
words_after_create[] is used for two purposes - one is to provide a list
of words that follow immediatly after CREATE (or DROP) and the other
purpose is to use it for autocompleting anywhere in the statement if the
word in that struct is found with a query.
Since TEXT SEARCH CONFIGURATION|DICTIONARY|TEMPLATE|PARSER results in 3
words instead of one (as all the other words in that list are) I added a
flag to the struct to tell create_command_generator() to skip that entry
 for autocompleting immediatly after CREATE which feels like a dirty
hack (but that holds true for a lot of code in tab-complete.c).


Stefan Kaltenbrunner
2007-09-14 04:25:24 +00:00
Teodor Sigaev 3e805fdcf7 Fix typo in typecasting.
patch from  ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>
2007-09-13 06:54:35 +00:00
Alvaro Herrera 945ba50dc3 Fix a memory leak in the autovacuum launcher code. Noted by Darcy Buskermolen,
who reported it privately to me.
2007-09-12 22:14:59 +00:00
Tom Lane 6889303531 Redefine the lp_flags field of item pointers as having four states, rather
than two independent bits (one of which was never used in heap pages anyway,
or at least hadn't been in a very long time).  This gives us flexibility to
add the HOT notions of redirected and dead item pointers without requiring
anything so klugy as magic values of lp_off and lp_len.  The state values
are chosen so that for the states currently in use (pre-HOT) there is no
change in the physical representation.
2007-09-12 22:10:26 +00:00
Andrew Dunstan eb0a7735ba Perform post-escaping encoding validity checks on SQL literals and COPY input
so that invalidly encoded data cannot enter the database by these means.
2007-09-12 20:49:27 +00:00
Bruce Momjian 22b613ebd9 Whitespace improvement. 2007-09-12 19:27:16 +00:00
Magnus Hagander 6ee3b2dfe4 Install dictionary sample files.
Per buildfarm and Teodor.
2007-09-12 13:58:23 +00:00
Bruce Momjian 1e0eeab155 Document an efficient way to create documentation for back branches. 2007-09-12 03:21:20 +00:00
Alvaro Herrera 9588e1bd65 Add a CHECK_FOR_INTERRUPTS call in the site where the vacuum delay point
was removed.
2007-09-12 02:05:48 +00:00
Tom Lane 16f8a9e4e1 Sync timezone data with 2007g zic release. 2007-09-11 17:43:27 +00:00
Tom Lane f181f9e1e4 Make sure that open hash table scans are cleaned up when bgwriter tries to
recover from elog(ERROR).  Problem was created by introduction of hash seq
search tracking awhile back, and affects all branches that have bgwriter;
in HEAD the disease has snuck into autovacuum and walwriter too.  (Not sure
that the latter two use hash_seq_search at the moment, but surely they might
someday.)  Per report from Sergey Koposov.
2007-09-11 17:15:33 +00:00
Tom Lane 5cf785a4de Include hash table name in all the internal-error elog messages in
dynahash.c.  Sergey Koposov's current open problem shows the possible
usefulness of this, and it doesn't add much code.
2007-09-11 16:17:46 +00:00
Teodor Sigaev 476045a21b Remove QueryOperand->istrue flag, it was used only in cover ranking
(ts_rank_cd). Use palloc'ed array in ranking instead of flag.
2007-09-11 16:01:40 +00:00
Teodor Sigaev 13553cbbff Fix header's size of structs defines in ispell.
Backpatch is needed for contrib version.
2007-09-11 12:57:05 +00:00
Teodor Sigaev 64def09592 Add regression tests for ispell, synonym and thesaurus dictionaries.
Rename synonym.syn.sample and thesaurs.ths.sample to
synonym_sample.syn and thesaurs_sample.ths accordingly to be able to use they
in regression test.

Ispell dictionary uses synthetic simple dictionary files.
2007-09-11 11:54:42 +00:00
Teodor Sigaev c4b2b2960a Fix ts_debug function to prevent unneeded calls of ts_lexize().
It will be mush better to reimplement ts_debug in C (instead of SQL as now),
but it's planned for the future.
2007-09-11 08:51:22 +00:00
Teodor Sigaev 57cafe7982 Refactor from Heikki Linnakangas <heikki@enterprisedb.com>:
* Defined new struct WordEntryPosVector that holds a uint16 length and a
variable size array of WordEntries. This replaces the previous
convention of a variable size uint16 array, with the first element
implying the length. WordEntryPosVector has the same layout in memory,
but is more readable in source code. The POSDATAPTR and POSDATALEN
macros are still used, though it would now be more readable to access
the fields in WordEntryPosVector directly.

* Removed needfree field from DocRepresentation. It was always set to false.

* Miscellaneous other commenting and refactoring
2007-09-11 08:46:29 +00:00
Tom Lane ef4d38c86c Rename recently-added pg_stat_activity column from txn_start to xact_start,
for consistency with other column names such as in pg_stat_database.
2007-09-11 03:28:05 +00:00
Tom Lane 82a47982f3 Arrange for SET LOCAL's effects to persist until the end of the current top
transaction, unless rolled back or overridden by a SET clause for the same
variable attached to a surrounding function call.  Per discussion, these
seem the best semantics.  Note that this is an INCOMPATIBLE CHANGE: in 8.0
through 8.2, SET LOCAL's effects disappeared at subtransaction commit
(leading to behavior that made little sense at the SQL level).

I took advantage of the opportunity to rewrite and simplify the GUC variable
save/restore logic a little bit.  The old idea of a "tentative" value is gone;
it was a hangover from before we had a stack.  Also, we no longer need a stack
entry for every nesting level, but only for those in which a variable's value
actually changed.
2007-09-11 00:06:42 +00:00
Alvaro Herrera b366562e43 Make CLUSTER and REINDEX silently skip remote temp tables in their
database-wide editions.

Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.
2007-09-10 21:59:37 +00:00
Alvaro Herrera 6a10f0f749 Release the exclusive lock on the table early after truncating it in lazy
vacuum, instead of waiting till commit.
2007-09-10 21:40:03 +00:00
Teodor Sigaev f7379f5c88 Heikki Linnakangas <heikki@enterprisedb.com>:
Add tsearch subdirectory is added to Makefile to allow
compile  custom tsearch dictionary as an external module.
2007-09-10 20:37:36 +00:00
Teodor Sigaev 53ef36cb4a Fix recently introduced bugs about parsing ispell/hunspell files.
In most cases it cause because of unneeded lowercasing of flags.

Per experiment with regression checks with ispell dictionary.
2007-09-10 20:27:12 +00:00
Alvaro Herrera 21c27af65f Remove the vacuum_delay_point call in count_nondeletable_pages, because we hold
an exclusive lock on the table at this point, which we want to release as soon
as possible.  This is called in the phase of lazy vacuum where we truncate the
empty pages at the end of the table.

An alternative solution would be to lower the vacuum delay settings before
starting the truncating phase, but this doesn't work very well in autovacuum
due to the autobalancing code (which can cause other processes to change our
cost delay settings).  This case could be considered in the balancing code, but
it is simpler this way.
2007-09-10 17:58:45 +00:00
Teodor Sigaev d982daae0b Change void* opaque argument to Datum type, add argument's
name to PushFunction type definition.

Per suggestion by Tome Lane <tgl@sss.pgh.pa.us>
2007-09-10 12:36:41 +00:00
Teodor Sigaev 83d0b9f3ca Fixes from Heikki Linnakangas <heikki@enterprisedb.com>:
Apparently it's a bug I introduced when I refactored spell.c to use the
readline function for reading and recoding the input file. I didn't
notice that some calls to STRNCMP used the non-lowercased version of the
input line.
2007-09-10 10:39:56 +00:00
Tom Lane f243a1a1bd Revert temporary patch that made synchronous_commit default to OFF. 2007-09-10 02:01:19 +00:00
Tom Lane b7adf47eda Set the correct context (PGC_SIGHUP) for log_autovacuum, per ITAGAKI Takahiro.
Fix grammatical errors in its description.
2007-09-10 01:39:19 +00:00
Tom Lane 40fda15dce Code review for GUC revert-values-if-removed-from-postgresql.conf patch;
and in passing, fix some bogosities dating from the custom_variable_classes
patch.  Fix guc-file.l to correctly check changes in custom_variable_classes
that are attempted concurrently with additions/removals of custom variables,
and don't allow the new setting to be applied in advance of checking it.
Clean up messy and undocumented situation for string variables with NULL
boot_val.  Fix DefineCustomVariable functions to initialize boot_val
correctly.  Prevent find_option from inserting bogus placeholders for custom
variables that are simply inquired about rather than being set.
2007-09-10 00:57:22 +00:00
Andrew Dunstan 43df609daa fix typo in regression Makefile. 2007-09-09 22:53:33 +00:00
Andrew Dunstan 0cb74d3cec Provide for a file specifying non-standard config options for temp install
for pg_regress, via --temp-config option. Pick this up in the make file
via TEMP_CONFIG setting.
2007-09-09 20:40:54 +00:00
Tom Lane 6bd4f401b0 Replace the former method of determining snapshot xmax --- to wit, calling
ReadNewTransactionId from GetSnapshotData --- with a "latestCompletedXid"
variable that is updated during transaction commit or abort.  Since
latestCompletedXid is written only in places that had to lock ProcArrayLock
exclusively anyway, and is read only in places that had to lock ProcArrayLock
shared anyway, it adds no new locking requirements to the system despite being
cluster-wide.  Moreover, removing ReadNewTransactionId from snapshot
acquisition eliminates the need to take both XidGenLock and ProcArrayLock at
the same time.  Since XidGenLock is sometimes held across I/O this can be a
significant win.  Some preliminary benchmarking suggested that this patch has
no effect on average throughput but can significantly improve the worst-case
transaction times seen in pgbench.  Concept by Florian Pflug, implementation
by Tom Lane.
2007-09-08 20:31:15 +00:00
Tom Lane 0a51e7073c Don't take ProcArrayLock while exiting a transaction that has no XID; there is
no need for serialization against snapshot-taking because the xact doesn't
affect anyone else's snapshot anyway.  Per discussion.  Also, move various
info about the interlocking of transactions and snapshots out of code comments
and into a hopefully-more-cohesive discussion in access/transam/README.

Also, remove a couple of now-obsolete comments about having to force some WAL
to be written to persuade RecordTransactionCommit to do its thing.
2007-09-07 20:59:26 +00:00
Teodor Sigaev 0392ea5097 Improve page split in rtree emulation. Now if splitted result has
big misalignement, then it tries to split page basing on distribution
of boxe's centers.

Per report from  Dolafi, Tom <dolafit@janelia.hhmi.org>

 Backpatch is needed, change doesn't affect on-disk storage.
2007-09-07 17:04:26 +00:00
Teodor Sigaev 978de9d06d Improvements from Heikki Linnakangas <heikki@enterprisedb.com>
- change the alignment requirement of lexemes in TSVector slightly.
Lexeme strings were always padded to 2-byte aligned length to make sure
that if there's position array (uint16[]) it has the right alignment.
The patch changes that so that the padding is not done when there's no
positions. That makes the storage of tsvectors without positions
slightly more compact.

- added some #include "miscadmin.h" lines I missed in the earlier when I
added calls to check_stack_depth().

- Reimplement the send/recv functions, and added a comment
above them describing the on-wire format. The CRC is now recalculated in
tsquery as well per previous discussion.
2007-09-07 16:03:40 +00:00
Teodor Sigaev 8983852e34 Improving various checks by Heikki Linnakangas <heikki@enterprisedb.com>
- add code to check that the query tree is well-formed. It was indeed
  possible to send malformed queries in binary mode, which produced all
  kinds of strange results.

- make the left-field a uint32. There's no reason to
  arbitrarily limit it to 16-bits, and it won't increase the disk/memory
  footprint either now that QueryOperator and QueryOperand are separate
  structs.

- add check_stack_depth() call to all recursive functions I found.
  Some of them might have a natural limit so that you can't force
  arbitrarily deep recursions, but check_stack_depth() is cheap enough
  that seems best to just stick it into anything that might be a problem.
2007-09-07 15:35:11 +00:00
Teodor Sigaev e5be89981f Refactoring by Heikki Linnakangas <heikki@enterprisedb.com> with
small editorization by me

- Brake the QueryItem struct into QueryOperator and QueryOperand.
  Type was really the only common field between them. QueryItem still
  exists, and is used in the TSQuery struct as before, but it's now a
  union of the two. Many other changes fell from that, like separation
  of pushval_asis function into pushValue, pushOperator and pushStop.

- Moved some structs that were for internal use only from header files
  to the right .c-files.

- Moved tsvector parser to a new tsvector_parser.c file. Parser code was
  about half of the size of tsvector.c, it's also used from tsquery.c, and
  it has some data structures of its own, so it seems better to separate
  it. Cleaned up the API so that TSVectorParserState is not accessed from
  outside tsvector_parser.c.

- Separated enumerations (#defines, really) used for QueryItem.type
  field and as return codes from gettoken_query. It was just accidental
  code sharing.

- Removed ParseQueryNode struct used internally by makepol and friends.
  push*-functions now construct QueryItems directly.

- Changed int4 variables to just ints for variables like "i" or "array
  size", where the storage-size was not significant.
2007-09-07 15:09:56 +00:00
Teodor Sigaev da1248401d Add turkish stopword list. Thanks to Devrim GUNDUZ <devrim@CommandPrompt.com> 2007-09-07 14:46:43 +00:00
Tom Lane cd1aae5864 Allow CREATE INDEX CONCURRENTLY to disregard transactions in other
databases, per gripe from hubert depesz lubaczewski.  Patch from
Simon Riggs.
2007-09-07 00:58:57 +00:00
Tom Lane f8942f4a15 Make eval_const_expressions() preserve typmod when simplifying something like
null::char(3) to a simple Const node.  (It already worked for non-null values,
but not when we skipped evaluation of a strict coercion function.)  This
prevents loss of typmod knowledge in situations such as exhibited in bug
#3598.  Unfortunately there seems no good way to fix that bug in 8.1 and 8.2,
because they simply don't carry a typmod for a plain Const node.

In passing I made all the other callers of makeNullConst supply "real" typmod
values too, though I think it probably doesn't matter anywhere else.
2007-09-06 17:31:58 +00:00
Tom Lane 0ecb4ea773 Volatile-qualify the ProcArray PGPROC pointer in a bunch of routines
that examine fields that could change under them.  This is just to make
really sure that when we are fetching a value 'only once', that's what
actually happens.  Possibly this is a bug that should be back-patched,
but in the absence of solid evidence that it's needed, I won't bother.
2007-09-05 21:11:19 +00:00
Tom Lane 4bf2dfb9a2 Quick hack to make the VXID of a prepared transaction be -1/XID,
so that different prepared xacts can be told apart in the pg_locks
view.  Per suggestion from Florian.
2007-09-05 20:53:17 +00:00
Tom Lane 295e63983d Implement lazy XID allocation: transactions that do not modify any database
rows will normally never obtain an XID at all.  We already did things this way
for subtransactions, but this patch extends the concept to top-level
transactions.  In applications where there are lots of short read-only
transactions, this should improve performance noticeably; not so much from
removal of the actual XID-assignments, as from reduction of overhead that's
driven by the rate of XID consumption.  We add a concept of a "virtual
transaction ID" so that active transactions can be uniquely identified even
if they don't have a regular XID.  This is a much lighter-weight concept:
uniqueness of VXIDs is only guaranteed over the short term, and no on-disk
record is made about them.

Florian Pflug, with some editorialization by Tom.
2007-09-05 18:10:48 +00:00
Andrew Dunstan 2e74c53ec1 Provide for binary input/output of enums, to fix complaint from Merlin Moncure.
This just provides text values, we're not exposing the underlying Oid representation.
Catalog version bumped.
2007-09-04 16:41:43 +00:00
Michael Meskes a6b5765c7e Synced parser and keyword list. 2007-09-04 10:02:29 +00:00
Tom Lane 6d871a2538 Restrict tsearch config file base names to contain a-z, 0-9, and underscore,
instead of the initial policy of whatever isalpha() likes.  Per discussion.
2007-09-04 02:16:56 +00:00
Tom Lane e7889b83b7 Support SET FROM CURRENT in CREATE/ALTER FUNCTION, ALTER DATABASE, ALTER ROLE.
(Actually, it works as a plain statement too, but I didn't document that
because it seems a bit useless.)  Unify VariableResetStmt with
VariableSetStmt, and clean up some ancient cruft in the representation of
same.
2007-09-03 18:46:30 +00:00
Tom Lane dd4594e332 Fix MSVC build (I think) for recent pg_proc.h column addition.
This business with two independent build systems does kinda suck.
2007-09-03 02:51:47 +00:00
Tom Lane 7ab43b88d7 Improve stylistic consistency of descriptions of built-in objects by avoiding
initcap style --- the vast majority of the existing descriptions do not use
an initial cap.  I didn't change places where the first word was all-cap.

initdb not forced because this doesn't change any regression test results.
2007-09-03 02:30:45 +00:00
Tom Lane 6f4a5462b4 Add an ORDER BY to nail down the expected row order from a query that's
been shown to be sensitive to concurrent autovacuum.  Per Alvaro.
2007-09-03 01:28:40 +00:00
Tom Lane a4df52f95f Fix breakage of GIN support for varchar[] and cidr[] that I introduced in the
operator-family rewrite.  I had mistakenly supposed that these could use the
pg_amproc entries for text[] and inet[] respectively.  However, binary
compatibility of the underlying types does not make two array types binary
compatible (since they must differ in the header field that gives the element
type OID), and so the index support code doesn't consider those entries
applicable.  Add back the missing pg_amproc entries, and add an opr_sanity
query to try to catch such mistakes in future.  Per report from Gregory
Maxwell.
2007-09-03 01:18:33 +00:00
Tom Lane 2abae34a2e Implement function-local GUC parameter settings, as per recent discussion.
There are still some loose ends: I didn't do anything about the SET FROM
CURRENT idea yet, and it's not real clear whether we are happy with the
interaction of SET LOCAL with function-local settings.  The documentation
is a bit spartan, too.
2007-09-03 00:39:26 +00:00
Tom Lane d2825e1c85 Since sort_bounded_heap makes state changes that should be made
regardless of the number of tuples involved, it's incorrect to skip it
when memtupcount = 1; the number of cycles saved is minuscule anyway.
An alternative solution would be to pull the state changes out to the
call site in tuplesort_performsort, but keeping them near the corresponding
changes in make_bounded_heap seems marginally cleaner.  Noticed by
Greg Stark.
2007-09-01 18:47:39 +00:00
Tom Lane 0ee5a39862 Apply a band-aid fix for the problem that 8.2 and up completely misestimate
the number of rows likely to be produced by a query such as
	SELECT * FROM t1 LEFT JOIN t2 USING (key) WHERE t2.key IS NULL;
What this is doing is selecting for t1 rows with no match in t2, and thus
it may produce a significant number of rows even if the t2.key table column
contains no nulls at all.  8.2 thinks the table column's null fraction is
relevant and thus may estimate no rows out, which results in terrible plans
if there are more joins above this one.  A proper fix for this will involve
passing much more information about the context of a clause to the selectivity
estimator functions than we ever have.  There's no time left to write such a
patch for 8.3, and it wouldn't be back-patchable into 8.2 anyway.  Instead,
put in an ad-hoc test to defeat the normal table-stats-based estimation when
an IS NULL test is evaluated at an outer join, and just use a constant
estimate instead --- I went with 0.5 for lack of a better idea.  This won't
catch every case but it will catch the typical ways of writing such queries,
and it seems unlikely to make things worse for other queries.
2007-08-31 23:35:22 +00:00
Tom Lane 68e40998d0 Extend whole-row Var evaluation to cope with the case that the sub-plan
generating the tuples has resjunk output columns.  This is not possible for
simple table scans but can happen when evaluating a whole-row Var for a view.
Per example from Patryk Kordylewski.  The problem exists back to 8.0 but
I'm not going to risk back-patching further than 8.2 because of the many
changes in this area.
2007-08-31 18:33:40 +00:00
Tom Lane 79048ca1a4 Install check_stack_depth() protection in two recursive tsquery
processing routines.  Per Heikki.
2007-08-31 02:26:29 +00:00
Tom Lane b4c806faa8 Rewrite make_outerjoininfo's construction of min_lefthand and min_righthand
sets for outer joins, in the light of bug #3588 and additional thought and
experimentation.  The original methodology was fatally flawed for nests of
more than two outer joins: it got the relationships between adjacent joins
right, but didn't always come to the right conclusions about whether a join
could be interchanged with one two or more levels below it.  This was largely
caused by a mistaken idea that we should use the min_lefthand + min_righthand
sets of a sub-join as the minimum left or right input set of an upper join
when we conclude that the sub-join can't commute with the upper one.  If
there's a still-lower join that the sub-join *can* commute with, this method
led us to think that that one could commute with the topmost join; which it
can't.  Another problem (not directly connected to bug #3588) was that
make_outerjoininfo's processing-order-dependent method for enforcing outer
join identity #3 didn't work right: if we decided that join A could safely
commute with lower join B, we dropped all information about sub-joins under B
that join A could perhaps not safely commute with, because we removed B's
entire min_righthand from A's.

To fix, make an explicit computation of all inner join combinations that occur
below an outer join, and add to that the full syntactic relsets of any lower
outer joins that we determine it can't commute with.  This method gives much
more direct enforcement of the outer join rearrangement identities, and it
turns out not to cost a lot of additional bookkeeping.

Thanks to Richard Harris for the bug report and test case.
2007-08-31 01:44:06 +00:00
Tom Lane e75d365633 Fix int8mul so that overflow check is applied correctly for INT64_IS_BUSTED
case, per Florian Pflug.
Not back-patched since it's unclear that anyone but me still cares ...
2007-08-30 05:27:29 +00:00
Tom Lane 8bc225e799 Relax permissions checks on dbsize functions, per discussion. Revert out all
checks for individual-table-size functions, since anyone in the database could
get approximate values from pg_class.relpages anyway.  Allow database-size to
users with CONNECT privilege for the target database (note that this is
granted by default).  Allow tablespace-size if the user has CREATE privilege
on the tablespace (which is *not* granted by default), or if the tablespace is
the default tablespace for the current database (since we treat that as
implicitly allowing use of the tablespace).
2007-08-29 17:24:29 +00:00
Tom Lane 3b5f5d9873 Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(),
the wrong variable's value was printed, and so the message made no sense.
Clean up a couple other coding infelicities while at it.
2007-08-29 16:31:36 +00:00
Michael Meskes c7b6593042 Fixed bug in Informix define handling. 2007-08-29 13:58:13 +00:00
Tom Lane a52e4408b9 Add a debug logging message when a resource manager rejects an attempted
restart point.  Per suggestion from Simon Riggs.
2007-08-28 23:17:47 +00:00
Tom Lane 24d4517b3b Improve behavior of log_lock_waits patch. Ensure that something gets logged
even if the "deadlock detected" ERROR message is suppressed by an exception
catcher.  Be clearer about the event sequence when a soft deadlock is fixed:
the fixing process might or might not still have to wait, so log that
separately.  Fix race condition when someone releases us from the lock partway
through printing all this junk --- we'd not get confused about our state, but
the log message sequence could have been misleading, ie, a "still waiting"
message with no subsequent "acquired" message.  Greg Stark and Tom Lane.
2007-08-28 03:23:44 +00:00
Magnus Hagander 69e86a5daf Exclude tsearch2 contrib tests in regression tests,
pending decision on exactly what will happen with
contrib/tsearch2 now that it's in core.
2007-08-27 12:10:47 +00:00
Magnus Hagander 90d9fc0aa9 Install stopword files 2007-08-27 10:51:15 +00:00
Magnus Hagander 3b1e04c3e9 Fix generation of snowball_create.sql on msvc builds. 2007-08-27 10:29:49 +00:00
Tom Lane 862861ee77 Fix a couple of misbehaviors rooted in the fact that the default creation
namespace isn't necessarily first in the search path (there could be implicit
schemas ahead of it).  Examples are

test=# set search_path TO s1;

test=# create view pg_timezone_names as select * from pg_timezone_names();
ERROR:  "pg_timezone_names" is already a view

test=# create table pg_class (f1 int primary key);
ERROR:  permission denied: "pg_class" is a system catalog

You'd expect these commands to create the requested objects in s1, since
names beginning with pg_ aren't supposed to be reserved anymore.  What is
happening is that we create the requested base table and then execute
additional commands (here, CREATE RULE or CREATE INDEX), and that code is
passed the same RangeVar that was in the original command.  Since that
RangeVar has schemaname = NULL, the secondary commands think they should do a
path search, and that means they find system catalogs that are implicitly in
front of s1 in the search path.

This is perilously close to being a security hole: if the secondary command
failed to apply a permission check then it'd be possible for unprivileged
users to make schema modifications to system catalogs.  But as far as I can
find, there is no code path in which a check doesn't occur.  Which makes it
just a weird corner-case bug for people who are silly enough to want to
name their tables the same as a system catalog.

The relevant code has changed quite a bit since 8.2, which means this patch
wouldn't work as-is in the back branches.  Since it's a corner case no one
has reported from the field, I'm not going to bother trying to back-patch.
2007-08-27 03:36:08 +00:00
Tom Lane 6c96188cb5 Remove the 'not in' operator (!!=). This was a hangover from Berkeley
days that was obsolete the moment we had IN (SELECT ...) capability.
It's arguably a security hole since it applied no permissions check to
the table it searched, and since it was never documented anywhere,
removing it seems more appropriate than fixing it.
2007-08-27 01:39:25 +00:00
Tom Lane cc26599b72 Restrict pg_relation_size to relation owner, pg_database_size to DB owner,
and pg_tablespace_size to superusers.  Perhaps we could weaken the first
case to just require SELECT privilege, but that doesn't work for the
other cases, so use ownership as the common concept.
2007-08-27 01:19:14 +00:00
Tom Lane 741e952b54 Make currtid() functions require SELECT privileges on the target table.
While it's not clear that TID linkage info is of any great use to a
nefarious user, it's certainly unexpected that these functions wouldn't
insist on read privileges.
2007-08-27 00:57:36 +00:00
Tom Lane 67bf7b919e Make ARRAY(SELECT ...) return an empty array, rather than a NULL, when the
sub-select returns zero rows.  Per complaint from Jens Schicke.  Since this
is more in the nature of a definition change than a bug, not back-patched.
2007-08-26 21:44:25 +00:00
Tom Lane 75d5f6fe79 Adjust with-system-tzdata patch to not attempt to install a symlink,
but just hardwire the specified timezone database path into the executable.
Per discussion, this avoids some packaging disadvantages of using a
symlink.
2007-08-25 20:29:25 +00:00
Tom Lane 75d091a0d7 Fix brain fade in DefineIndex(): it was continuing to access the table's
relcache entry after having heap_close'd it.  This could lead to misbehavior
if a relcache flush wiped out the cache entry meanwhile.  In 8.2 there is a
very real risk of CREATE INDEX CONCURRENTLY using the wrong relid for locking
and waiting purposes.  I think the bug is only cosmetic in 8.0 and 8.1,
because their transgression is limited to using RelationGetRelationName(rel)
in an ereport message immediately after heap_close, and there's no way (except
with special debugging options) for a cache flush to occur in that interval.
Not quite sure that it's cosmetic in 7.4, but seems best to patch anyway.

Found by trying to run the regression tests with CLOBBER_CACHE_ALWAYS enabled.
Maybe we should try to do that on a regular basis --- it's awfully slow,
but perhaps some fast buildfarm machine could do it once in awhile.
2007-08-25 19:08:19 +00:00
Tom Lane 21168267b9 Simplify implementation of ts_debug() function --- use a join instead
of redundant sub-selects.  initdb not forced, since this is just a
cosmetic change, but the new code won't show up till you do one.
2007-08-25 17:47:44 +00:00
Tom Lane a13cefafb1 Fix synonym-dict breakage introduced in last patch :-(.
Minor other cleanups.
2007-08-25 02:29:45 +00:00
Tom Lane 93eab9312f Rename built-in Snowball stemmer dictionaries to be english_stem,
russian_stem, etc.  Per discussion.
2007-08-25 01:06:25 +00:00
Tom Lane 7351b5fa17 Cleanup for some problems in tsearch patch:
- ispell initialization crashed on empty dictionary file
- ispell initialization crashed on affix file with prefixes but no suffixes
- stop words file was run through pg_verify_mbstr, with database
  encoding, but it's supposed to be UTF-8; similar bug for synonym files
- bunch of comments added, typos fixed, and other cleanup

Introduced consistent encoding checking/conversion of data read from tsearch
configuration files, by doing this in a single t_readline() subroutine
(replacing direct usages of fgets).  Cleaned up API for readstopwords too.

Heikki Linnakangas
2007-08-25 00:03:59 +00:00
Andrew Dunstan 44b5efbae6 Reduce memory requirements for writing CSVlogs, so it will work with about
the same amount of memory in ErrorContext as standard logs.
2007-08-23 01:24:43 +00:00
Andrew Dunstan 1535f26c70 unbreak ECPG tests for VPATH builds. 2007-08-23 00:38:17 +00:00
Tom Lane 11fee4e3b5 Suppress testing the options of CREATE TEXT SEARCH DICTIONARY during
initdb.  We should create all the standard dictionaries even though
some of them may not work in template1's encoding.  Per Teodor.
2007-08-22 22:30:20 +00:00
Michael Meskes fefe7034e2 More cleaning up and removed some duplicates. 2007-08-22 08:20:58 +00:00
Tom Lane 34dc9abd6b Propagate Magnus' fix for Windows snowball build into Makefile.cygwin. 2007-08-22 06:34:18 +00:00
Tom Lane f4ccdb3a17 Fix VPATH-build problem in new tsearch makefile, per Chad Wagner. 2007-08-22 06:11:56 +00:00
Tom Lane 8a5592daf1 Remove option to change parser of an existing text search configuration.
This prevents needing to do complex and poorly-defined updates of the
mapping table if the new parser has different token types than the old.
Per discussion.
2007-08-22 05:13:50 +00:00