Commit Graph

17272 Commits

Author SHA1 Message Date
Michael Meskes
a27b961a0c Fixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract. 2008-04-10 10:46:56 +00:00
Tom Lane
0bcf76311f Defend against JOINs having more than 32K columns altogether. We cannot
currently support this because we must be able to build Vars referencing
join columns, and varattno is only 16 bits wide.  Perhaps this should be
improved in future, but considering that it never came up before, I'm not
sure the problem is worth much effort.  Per bug #4070 from Marcello
Ceschia.

The problem seems largely academic in 8.0 and 7.4, because they have
(different) O(N^2) performance issues with such wide joins, but
back-patch all the way anyway.
2008-04-05 01:59:01 +00:00
Tom Lane
e409f5f145 Adjust DatumGetBool macro so that it isn't fooled by garbage in the Datum
to the left of the actual bool value.  While in most cases there won't be
any, our support for old-style user-defined functions violates the C spec
to the extent of calling functions that might return char or short through
a function pointer declared to return "char *", which we then coerce to
Datum.  It is not surprising that the result might contain garbage
high-order bits ... what is surprising is that we didn't see such cases
long ago.  Per report from Magnus.

This is a back-patch of a change that was made in HEAD almost exactly
a year ago.  I had refrained from back-patching at the time, but now
we find that this is *necessary* for contrib to work with gcc 4.3.
2008-03-25 19:31:53 +00:00
Heikki Linnakangas
cb59875d07 Add the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
ISO_8859-5 <-> MULE_INTERNAL conversion tables.

This was discovered when trying to convert a string containing those characters
from ISO_8859-5 to Windows-1251, because we use MULE_INTERNAL/KOI8R as an
intermediate encoding between those two.

While the missing "Yo" was just an omission in the conversion tables, there are
a few other characters like the "Numero" sign ("No" as a single character) that
exists in all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
not in KOI8R. Added comments about that.

Patch by Sergey Burladyan. Back-patch to 7.4.
2008-03-20 10:52:57 +00:00
Tom Lane
a1453f121b Fix regexp substring matching (substring(string from pattern)) for the corner
case where there is a match to the pattern overall but the user has specified
a parenthesized subexpression and that subexpression hasn't got a match.
An example is substring('foo' from 'foo(bar)?').  This should return NULL,
since (bar) isn't matched, but it was mistakenly returning the whole-pattern
match instead (ie, 'foo').  Per bug #4044 from Rui Martins.

This has been broken since the beginning; patch in all supported versions.
The old behavior was sufficiently inconsistent that it's impossible to believe
anyone is depending on it.
2008-03-19 02:41:15 +00:00
Tom Lane
0d52d7a71e Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
pg_listener modifications commanded by LISTEN and UNLISTEN until the end
of the current transaction.  This allows us to hold the ExclusiveLock on
pg_listener until after commit, with no greater risk of deadlock than there
was before.  Aside from fixing the race condition, this gets rid of a
truly ugly kludge that was there before, namely having to ignore
HeapTupleBeingUpdated failures during NOTIFY.  There is a small potential
incompatibility, which is that if a transaction issues LISTEN or UNLISTEN
and then looks into pg_listener before committing, it won't see any resulting
row insertion or deletion, where before it would have.  It seems unlikely
that anyone would be depending on that, though.
2008-03-12 20:12:48 +00:00
Alvaro Herrera
25a87d0f07 Add support for dlopen on recent NetBSD/MIPS, per Rémi Zara. 2008-03-05 21:20:51 +00:00
Tom Lane
69e676f77d If RelationBuildDesc() fails to open a critical system index, PANIC with
a relevant error message instead of just dumping core.  Odd that nobody
reported this before Darren Reed.
2008-02-27 17:45:02 +00:00
Tom Lane
a45d896b01 Use our own getopt() and getopt_long() on Solaris, because that platform's
versions don't handle long options the way we want.  Per Zdenek Kotala.
2008-02-24 05:22:44 +00:00
Tom Lane
8355df550d Avoid trying to print a NULL char pointer in --describe-config. On some
platforms this works, but on some it crashes.  Zdenek Kotala
2008-02-23 19:24:09 +00:00
Tom Lane
bb4b179b5e Repair VACUUM FULL bug introduced by HOT patch: the original way of
calculating a page's initial free space was fine, and should not have been
"improved" by letting PageGetHeapFreeSpace do it.  VACUUM FULL is going to
reclaim LP_DEAD line pointers later, so there is no need for a guard
against the page being too full of line pointers, and having one risks
rejecting pages that are perfectly good move destinations.

This also exposed a second bug, which is that the empty_end_pages logic
assumed that any page with no live tuples would get entered into the
fraged_pages list automatically (by virtue of having more free space than
the threshold in the do_frag calculation).  This assumption certainly
seems risky when a low fillfactor has been chosen, and even without
tunable fillfactor I think it could conceivably fail on a page with many
unused line pointers.  So fix the code to force do_frag true when notup
is true, and patch this part of the fix all the way back.

Per report from Tomas Szepe.
2008-02-11 19:15:00 +00:00
Tom Lane
d85096ce12 Fix an ancient oversight in libpq's handling of V3-protocol COPY OUT mode:
we need to be able to swallow NOTICE messages, and potentially also
ParameterStatus messages (although the latter would be a bit weird),
without exiting COPY OUT state.  Fix it, and adjust the protocol documentation
to emphasize the need for this.  Per off-list report from Alexander Galler.
2008-01-14 18:46:49 +00:00
Tom Lane
ec59b6deb8 A long time ago, Peter pointed out that ruleutils.c didn't dump simple
constant ORDER/GROUP BY entries properly:
http://archives.postgresql.org/pgsql-hackers/2001-04/msg00457.php
The original solution to that was in fact no good, as demonstrated by
today's report from Martin Pitt:
http://archives.postgresql.org/pgsql-bugs/2008-01/msg00027.php
We can't use the column-number-reference format for a constant that is
a resjunk targetlist entry, a case that was unfortunately not thought of
in the original discussion.  What we can do instead (which did not work
at the time, but does work in 7.3 and up) is to emit the constant with
explicit ::typename decoration, even if it otherwise wouldn't need it.
This is sufficient to keep the parser from thinking it's a column number
reference, and indeed is probably what the user must have done to get
such a thing into the querytree in the first place.
2008-01-06 01:03:46 +00:00
Tom Lane
56a2a41763 Stamp release 7.4.19.
Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067, CVE-2007-6600, CVE-2007-6601
2008-01-03 21:42:17 +00:00
Tom Lane
63ee91fc45 Update release notes for security releases.
Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067, CVE-2007-6600, CVE-2007-6601
2008-01-03 21:36:15 +00:00
Tom Lane
1f42e1cb68 The original patch to disallow non-passworded connections to non-superusers
failed to cover all the ways in which a connection can be initiated in dblink.
Plug the remaining holes.  Also, disallow transient connections in functions
for which that feature makes no sense (because they are only sensible as
part of a sequence of operations on the same connection).  Joe Conway

Security: CVE-2007-6601
2008-01-03 21:28:55 +00:00
Tom Lane
230d5cfc47 Make standard maintenance operations (including VACUUM, ANALYZE, REINDEX,
and CLUSTER) execute as the table owner rather than the calling user, using
the same privilege-switching mechanism already used for SECURITY DEFINER
functions.  The purpose of this change is to ensure that user-defined
functions used in index definitions cannot acquire the privileges of a
superuser account that is performing routine maintenance.  While a function
used in an index is supposed to be IMMUTABLE and thus not able to do anything
very interesting, there are several easy ways around that restriction; and
even if we could plug them all, there would remain a risk of reading sensitive
information and broadcasting it through a covert channel such as CPU usage.

To prevent bypassing this security measure, execution of SET SESSION
AUTHORIZATION and SET ROLE is now forbidden within a SECURITY DEFINER context.

Thanks to Itagaki Takahiro for reporting this vulnerability.

Security: CVE-2007-6600
2008-01-03 21:25:34 +00:00
Tom Lane
0776cb2116 Fix assorted security-grade bugs in the regex engine. All of these problems
are shared with Tcl, since it's their code to begin with, and the patches
have been copied from Tcl 8.5.0.  Problems:

CVE-2007-4769: Inadequate check on the range of backref numbers allows
crash due to out-of-bounds read.
CVE-2007-4772: Infinite loop in regex optimizer for pattern '($|^)*'.
CVE-2007-6067: Very slow optimizer cleanup for regex with a large NFA
representation, as well as crash if we encounter an out-of-memory condition
during NFA construction.

Part of the response to CVE-2007-6067 is to put a limit on the number of
states in the NFA representation of a regex.  This seems needed even though
the within-the-code problems have been corrected, since otherwise the code
could try to use very large amounts of memory for a suitably-crafted regex,
leading to potential DOS by driving the system into swap, activating a kernel
OOM killer, etc.

Although there are certainly plenty of ways to drive the system into effective
DOS with poorly-written SQL queries, these problems seem worth treating as
security issues because many applications might accept regex search patterns
from untrustworthy sources.

Thanks to Will Drewry of Google for reporting these problems.  Patches by Will
Drewry and Tom Lane.

Security: CVE-2007-4769, CVE-2007-4772, CVE-2007-6067
2008-01-03 20:49:15 +00:00
Tom Lane
bcbaee69ae Insert ARST into the list of known timezone abbreviations. 2008-01-02 22:05:36 +00:00
Magnus Hagander
2fb6911f22 Fix invalid ipv6 address in example. Per doc comment 7211. 2008-01-02 19:53:15 +00:00
Bruce Momjian
89d4770c25 Provide a more helpful error message when there is an autoconf version
mismatch;  backpatch.
2007-12-31 17:27:57 +00:00
Tom Lane
11b709714c Make path_recv() and poly_recv() reject paths/polygons containing no points.
The zero-point case is sensible so far as the data structure is concerned,
so maybe we ought to allow it sometime; but right now the textual input
routines for these types don't allow it, and it seems that not all the
functions for the types are prepared to cope.
Report and patch by Merlin Moncure.
2007-12-18 00:04:37 +00:00
Peter Eisentraut
86f6837ac3 Require a specific Autoconf version, instead of a lower bound only. 2007-11-26 12:09:58 +00:00
Alvaro Herrera
d289da2c16 Fix buggy usage of vsnprintf in PL/Python by removing it altogether, instead
relying on stringinfo.c.  This fixes a problem reported by Marko Kreen, but I
didn't use his patch, per subsequent discussion.
2007-11-23 01:48:08 +00:00
Tatsuo Ishii
0e7d9e5c50 Fix "Page Layout" table. The second row should be ItemIdData, not
ItemPointerData.
2007-11-23 00:39:59 +00:00
Teodor Sigaev
505292eb41 Backpatch: Fix tsvector_out() and tsquery_out() to escape backslesh, add test of that.
Patch by Bruce Momjian <bruce@momjian.us>
2007-11-16 17:31:16 +00:00
Joe Conway
8145f00f27 Have crosstab variants treat NULL rowid as a category in its own right,
per suggestion from Tom Lane. This fixes crash-bug reported by Stefan
Schwarzer.
2007-11-10 05:02:22 +00:00
Tom Lane
fcc3ac19fd If an index depends on no columns of its table, give it a dependency on the
whole table instead, to ensure that it goes away when the table is dropped.
Per bug #3723 from Sam Mason.

Backpatch as far as 7.4; AFAICT 7.3 does not have the issue, because it doesn't
have general-purpose expression indexes and so there must be at least one
column referenced by an index.
2007-11-08 23:23:23 +00:00
Michael Meskes
ebec2bac88 Added missing clause to parser. 2007-11-06 08:33:32 +00:00
Tom Lane
ad8e3b37a7 Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.
2007-10-11 21:28:30 +00:00
Tom Lane
d9e961d527 Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
eval_const_expressions simplifies this to just "WHERE false", but we have
already done pull_up_IN_clauses so the IN join will be done, or at least
planned, anyway.  The trouble case comes when the sub-SELECT is itself a join
and we decide to implement the IN by unique-ifying the sub-SELECT outputs:
with no remaining reference to the output Vars in WHERE, we won't have
propagated the Vars up to the upper join point, leading to "variable not found
in subplan target lists" error.  Fix by adding an extra scan of in_info_list
and forcing all Vars mentioned therein to be propagated up to the IN join
point.  Per bug report from Miroslav Sulc.
2007-10-04 20:45:17 +00:00
Teodor Sigaev
45cd13c8ab 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:44:54 +00:00
Tom Lane
a51302deb3 Fix bogus calculation of potential output string length in translate(). 2007-09-22 05:36:14 +00:00
Tom Lane
0a3b51efa0 Update release notes for last-minute fix. 2007-09-16 03:03:55 +00:00
Tom Lane
11a8925afd 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:38:25 +00:00
Marc G. Fournier
2f2f9b9bae update configure for 7.4.18 2007-09-14 23:19:58 +00:00
Tom Lane
226b3129f5 Fix markup that doesn't work in back branches. 2007-09-14 16:01:03 +00:00
Tom Lane
b75ac35bfd Minor editorialization on release notes. 2007-09-14 15:51:47 +00:00
Peter Eisentraut
93bba446ce Translation updates 2007-09-13 20:56:32 +00:00
Alvaro Herrera
23df99783e Fix the database-wide version of CLUSTER to silently skip temp tables of
remote sessions, instead of erroring out in the middle of the operation.

This is a backpatch of a previous fix applied to CLUSTER to HEAD and 8.2, all
the way back that it is relevant to.
2007-09-12 15:16:24 +00:00
Bruce Momjian
59f7d47ed7 Stamp releases 8.2.5, 8.1.10, 8.0.14, 7.4.18, 7.3.20.
Update FAQs for 8.2.5.
2007-09-11 17:36:45 +00:00
Bruce Momjian
465ae004ce Stamp 2007-09-11 17:19:15 +00:00
Tom Lane
92cb599bd6 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:32:05 +00:00
Tom Lane
5a94a5fd0b 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:44 +00:00
Tom Lane
08e72a644a Fix combo_decrypt() to throw an error for zero-length input when using a
padded encryption scheme.  Formerly it would try to access res[(unsigned) -1],
which resulted in core dumps on 64-bit machines, and was certainly trouble
waiting to happen on 32-bit machines (though in at least the known case
it was harmless because that byte would be overwritten after return).
Per report from Ken Colson; fix by Marko Kreen.
2007-08-23 16:16:20 +00:00
Tom Lane
42110a6a6a Fix potential access-off-the-end-of-memory in varbit_out(): it fetched the
byte after the last full byte of the bit array, regardless of whether that
byte was part of the valid data or not.  Found by buildfarm testing.
Thanks to Stefan Kaltenbrunner for nailing down the cause.
2007-08-21 02:40:33 +00:00
Neil Conway
7824c695ac Fix a gradual memory leak in ExecReScanAgg(). Because the aggregation
hash table is allocated in a child context of the agg node's memory
context, MemoryContextReset() will reset but *not* delete the child
context. Since ExecReScanAgg() proceeds to build a new hash table
from scratch (in a new sub-context), this results in leaking the
header for the previous memory context. Therefore, use
MemoryContextResetAndDeleteChildren() instead.

Credit: My colleague Sailesh Krishnamurthy at Truviso for isolating
the cause of the leak.
2007-08-08 18:06:55 +00:00
Tom Lane
b58230005b Fix pg_restore to guard against unexpected EOF while reading an archive file.
Per report and partial patch from Chad Wagner.
2007-08-06 01:38:49 +00:00
Neil Conway
3ca3c71141 Fix a memory leak in tuplestore_end(). Unlikely to be significant during
normal operation, but tuplestore_end() ought to do what it claims to do.
2007-08-02 17:49:01 +00:00
Tom Lane
c14066aa70 Fix a bug in the original implementation of redundant-join-clause removal:
clauses in which one side or the other references both sides of the join
cannot be removed as redundant, because that expression won't have been
constrained below the join.  Per report from Sergey Burladyan.
2007-07-31 19:54:27 +00:00