Tom Lane [Wed, 28 Sep 2005 21:17:50 +0000 (21:17 +0000)]
Repair planning bug introduced in 7.4: outer-join ON clauses that referenced
only the inner-side relation would be considered as potential equijoin clauses,
which is wrong because the condition doesn't necessarily hold above the point
of the outer join. Per test case from Kevin Grittner (bug#1916).
Bruce Momjian [Sun, 25 Sep 2005 03:18:16 +0000 (03:18 +0000)]
[ Patch to 7.4.X.]
In several places PL/Python was calling PyObject_Str() and then
PyString_AsString() without checking if the former had returned
NULL to indicate an error. PyString_AsString() doesn't expect a
NULL argument, so passing one causes a segmentation fault. This
patch adds checks for NULL and raises errors via PLy_elog(), which
prints details of the underlying Python exception. The patch also
adds regression tests for these checks. All tests pass on my
Solaris 9 box running HEAD and Python 2.4.1.
Update Snowball. I have to update it because of
old version doesn't available on Snowball's site and new version
of stemmers can't be compiled with old interface.
Tom Lane [Thu, 25 Aug 2005 22:07:21 +0000 (22:07 +0000)]
Back-patch fixes for problems with VACUUM destroying t_ctid chains too soon,
and with insufficient paranoia in code that follows t_ctid links.
This patch covers the 7.4 branch.
Michael Meskes [Wed, 24 Aug 2005 10:35:54 +0000 (10:35 +0000)]
- Check for NULL before checking whether argument is an array.
- Removed stray character from string quoting.
- Fixed check to report missing varchar pointer implementation.
Tom Lane [Tue, 16 Aug 2005 00:48:43 +0000 (00:48 +0000)]
Reject operator names >= NAMEDATALEN characters. These will not work
anyway, and in assert-enabled builds you are likely to get an assertion
failure. Backpatch as far as 7.3; 7.2 seems not to have the problem.
Tom Lane [Mon, 15 Aug 2005 19:41:06 +0000 (19:41 +0000)]
array_in() and array_recv() need to be more paranoid about validating
their OID parameter. It was possible to crash the backend with
select array_in('{123}',0,0); because that would bypass the needed step
of initializing the workspace. These seem to be the only two places
with a problem, though (record_in and record_recv don't have the issue,
and the other array functions aren't depending on user-supplied input).
Back-patch as far as 7.4; 7.3 does not have the bug.
Tom Lane [Mon, 15 Aug 2005 19:05:43 +0000 (19:05 +0000)]
int_array_enum function should be using fcinfo->flinfo->fn_extra for
working state, not fcinfo->context. Silly oversight on my part in last
go-round of fixes.
Tom Lane [Sun, 7 Aug 2005 18:48:00 +0000 (18:48 +0000)]
Fix count_usable_fds() to stop trying to open files once it reaches
max_files_per_process. Going further than that is just a waste of
cycles, and it seems that current Cygwin does not cope gracefully
with deliberately running the system out of FDs. Per Andrew Dunstan.
Tom Lane [Mon, 18 Jul 2005 15:54:11 +0000 (15:54 +0000)]
MemSet() must not cast its pointer argument to int32* until after it has
checked that the pointer is actually word-aligned. Casting a non-aligned
pointer to int32* is technically illegal per the C spec, and some recent
versions of gcc actually generate bad code for the memset() when given
such a pointer. Per report from Andrew Morrow.
Tom Lane [Sun, 17 Jul 2005 18:29:37 +0000 (18:29 +0000)]
Make pg_regress accept a command-line option for the temporary installation's
port number, and use a default value for it that is dependent on the
configuration-time DEF_PGPORT. Should make the world safe for running
parallel 'make check' in different branches. Back-patch as far as 7.4
so that this actually is useful.
Tom Lane [Sun, 17 Jul 2005 04:06:04 +0000 (04:06 +0000)]
Back-patch recent changes to alter the order of -L flags inserted from
LDFLAGS versus those built into the Makefiles. This looks like it will
fix several buildfarm failures in the back branches.
Tom Lane [Sat, 16 Jul 2005 20:39:24 +0000 (20:39 +0000)]
ecpglib depends on last_path_separator from src/port/path.c, so we'd
better include that in the library build. This was fixed in 8.0 and
later, backport to 7.4 to fix buildfarm failure.
Tom Lane [Sat, 16 Jul 2005 20:20:49 +0000 (20:20 +0000)]
Back-patch 8.0's tightening of ORDER BY clauses in join regression test,
in hopes of eliminating buildfarm regression failure. (Not clear if we
will need a join_1.out variant in this branch.)
Tom Lane [Sat, 25 Jun 2005 16:54:12 +0000 (16:54 +0000)]
Fix ancient memory leak in index_create(): RelationInitIndexAccessInfo
was being called twice in normal operation, leading to a leak of one set
of relcache subsidiary info. Per report from Jeff Gold.
Neil Conway [Wed, 22 Jun 2005 02:12:19 +0000 (02:12 +0000)]
Correct some code in pg_restore when reading the header of a tar archive:
(1) The code doesn't initialize `sum', so the initial "does the checksum
match?" test is wrong.
(2) The loop that is intended to check for a "null block" just checks
the first byte of the tar block 512 times, rather than each of the
512 bytes one time (!), which I'm guessing was the intent.
It was only through sheer luck that this worked in the first place.
Per Coverity static analysis performed by EnterpriseDB.
Tom Lane [Mon, 20 Jun 2005 20:44:57 +0000 (20:44 +0000)]
plpgsql's exec_assign_value() freed the old value of a variable before
copying/converting the new value, which meant that it failed badly on
"var := var" if var is of pass-by-reference type. Fix this and a similar
hazard in exec_move_row(); not sure that the latter can manifest before
8.0, but patch it all the way back anyway. Per report from Dave Chapeskie.
Tom Lane [Sat, 18 Jun 2005 20:51:59 +0000 (20:51 +0000)]
When using C-string lookup keys in a dynahash.c hash table, use strncpy()
not memcpy() to copy the offered key into the hash table during HASH_ENTER.
This avoids possible core dump if the passed key is located very near the
end of memory. Per report from Stefan Kaltenbrunner.
Tom Lane [Tue, 14 Jun 2005 14:21:31 +0000 (14:21 +0000)]
The random selection in function linear() could deliver a value equal to max
if geqo_rand() returns exactly 1.0, resulting in failure due to indexing
off the end of the pool array. Also, since this is using inexact float math,
it seems wise to guard against roundoff error producing values slightly
outside the expected range. Per report from bug@zedware.org.
Tom Lane [Thu, 2 Jun 2005 21:04:08 +0000 (21:04 +0000)]
Push enable/disable of notify and catchup interrupts all the way down
to just around the bare recv() call that gets a command from the client.
The former placement in PostgresMain was unsafe because the intermediate
processing layers (especially SSL) use facilities such as malloc that are
not necessarily re-entrant. Per report from counterstorm.com.
Tom Lane [Tue, 31 May 2005 19:10:57 +0000 (19:10 +0000)]
Add test to WAL replay to verify that xl_prev points back to the previous
WAL record; this is necessary to be sure we recognize stale WAL records
when a WAL page was only partially written during a system crash.
Tom Lane [Sun, 29 May 2005 17:10:52 +0000 (17:10 +0000)]
expandRTE and get_rte_attribute_type mistakenly always imputed typmod -1
to columns of an RTE that was a function returning RECORD with a column
definition list. Apparently no one has tried to use non-default typmod
with a function returning RECORD before.
Neil Conway [Thu, 26 May 2005 02:14:32 +0000 (02:14 +0000)]
Adjust datetime parsing to be more robust. We now pass the length of the
working buffer into ParseDateTime() and reject too-long input there,
rather than checking the length of the input string before calling
ParseDateTime(). The old method was bogus because ParseDateTime() can use
a variable amount of working space, depending on the content of the
input string (e.g. how many fields need to be NUL terminated). This fixes
a minor stack overrun -- I don't _think_ it's exploitable, although I
won't claim to be an expert.
Along the way, fix a bug reported by Mark Dilger: the working buffer
allocated by interval_in() was too short, which resulted in rejecting
some perfectly valid interval input values. I added a regression test for
this fix.
Tatsuo Ishii [Tue, 24 May 2005 23:15:05 +0000 (23:15 +0000)]
Inserting 5 characters into char(10) does not produce 5 padding spaces
if they are two-byte multibyte characters. Same thing can be happen
if octet_length(multibyte_chars) == n where n is char(n).
Long standing bug since 7.3 days. Per report and fix from Yoshiyuki Asaba.
Tom Lane [Tue, 24 May 2005 18:03:24 +0000 (18:03 +0000)]
Previous fix for "x FULL JOIN y ON true" failed to handle the case
where there was also a WHERE-clause restriction that applied to the
join. The check on restrictlist == NIL is really unnecessary anyway,
because select_mergejoin_clauses already checked for and complained
about any unmergejoinable join clauses. So just take it out.
Tom Lane [Sat, 7 May 2005 21:33:21 +0000 (21:33 +0000)]
Repair very-low-probability race condition between relation extension
and VACUUM: in the interval between adding a new page to the relation
and formatting it, it was possible for VACUUM to come along and decide
it should format the page too. Though not harmful in itself, this would
cause data loss if a third transaction were able to insert tuples into
the vacuumed page before the original extender got control back.
Tom Lane [Sat, 7 May 2005 21:23:02 +0000 (21:23 +0000)]
Adjust time qual checking code so that we always check TransactionIdIsInProgress
before we check commit/abort status. Formerly this was done in some paths
but not all, with the result that a transaction might be considered
committed for some purposes before it became committed for others.
Per example found by Jan Wieck.
Tom Lane [Tue, 3 May 2005 19:18:31 +0000 (19:18 +0000)]
Alter the signature for encoding conversion functions to declare the
output area as INTERNAL not CSTRING. This is to prevent people from
calling the functions by hand. This is a permanent solution for the
back branches but I hope it is just a stopgap for HEAD.
Tom Lane [Tue, 3 May 2005 16:51:45 +0000 (16:51 +0000)]
Change tsearch2 to not use the unsafe practice of creating functions
that return INTERNAL without also having INTERNAL arguments. Since the
functions in question aren't meant to be called by hand anyway, I just
redeclared them to take 'internal' instead of 'text'. Also add code
to ProcedureCreate() to enforce the restriction, as I should have done
to start with :-(
Neil Conway [Sat, 30 Apr 2005 08:36:18 +0000 (08:36 +0000)]
GCC 4.0 includes a new warning option, -Wformat-literal, that emits
a warning when a variable is used as a format string for printf()
and similar functions (if the variable is derived from untrusted
data, it could include unexpected formatting sequences). This
emits too many warnings to be enabled by default, but it does
flag a few dubious constructs in the Postgres tree. This patch
fixes up the obvious variants: functions that are passed a variable
format string but no additional arguments.
Most of these are harmless (e.g. the ruleutils stuff), but there
is at least one actual bug here: if you create a trigger named
"%sfoo", pg_dump will read uninitialized memory and fail to dump
the trigger correctly.
Neil Conway [Sat, 30 Apr 2005 08:00:55 +0000 (08:00 +0000)]
This patch fixes a bug in the error message emitted by pg_restore on an
incorrect -F argument: write_msg() expects its first parameter to be a
"module name", not the format string.
Tom Lane [Sat, 23 Apr 2005 22:53:44 +0000 (22:53 +0000)]
Repair two TIME WITH TIME ZONE bugs found by Dennis Vshivkov. Comparison
of timetz values misbehaved in --enable-integer-datetime cases, and
EXTRACT(EPOCH) subtracted the zone instead of adding it in all cases.
Backpatch to all supported releases (except --enable-integer-datetime code
does not exist in 7.2).
Updatable ResultSets need to check for an empty ResultSet because
isBeforeFirst and isAfterLast both return false for an empty result
so the checking to make sure the user is on a valid row wasn't
working.
Also don't allow an insert without specifying at least one column
value because INSERT INTO tab() values() is a syntax error.
When moveToCurrentRow is called and the current row is off the
end of the ResultSet we can't try to load that row because it
doesn't exist and will throw an Exception.
Tom Lane [Thu, 14 Apr 2005 21:44:35 +0000 (21:44 +0000)]
Don't try to constant-fold functions returning RECORD, since the optimizer
isn't presently set up to pass them an expected tuple descriptor. Bug has
been there since 7.3 but was just recently reported by Thomas Hallgren.
Tom Lane [Sun, 10 Apr 2005 20:58:03 +0000 (20:58 +0000)]
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs. Fixes crash
reported by Michael Williamson.
Tom Lane [Thu, 31 Mar 2005 23:21:32 +0000 (23:21 +0000)]
Flush any remaining statistics counts out to the collector at process
exit. Without this, operations triggered during backend exit (such as
temp table deletions) won't be counted ... which given heavy usage of
temp tables can lead to pg_autovacuum falling way behind on the need
to vacuum pg_class and pg_attribute. Per reports from Steve Crawford
and others.
Tom Lane [Thu, 24 Mar 2005 21:51:04 +0000 (21:51 +0000)]
array_map can't use the fn_extra field of the provided fcinfo struct as
its private storage, because that belongs to the function that it is
supposed to call. Per report from Ezequiel Tolnay.
Tom Lane [Wed, 23 Mar 2005 19:07:03 +0000 (19:07 +0000)]
Previous "64-bit fix" for intagg didn't actually work. This is already
fixed properly in CVS tip, but we need a band-aid for back branches.
Per report from Ron Mayer.
Tom Lane [Sat, 12 Mar 2005 21:12:18 +0000 (21:12 +0000)]
Fix ALTER DATABASE RENAME to allow the operation if user is a superuser
who for some reason isn't marked usecreatedb. Per report from Alexander
Pravking. Also fix sloppy coding in have_createdb_privilege().
Neil Conway [Sat, 12 Mar 2005 06:55:14 +0000 (06:55 +0000)]
Some builds (depends on crypto engine support?) of OpenSSL
0.9.7x have EVP_DigestFinal function which which clears all of
EVP_MD_CTX. This makes pgcrypto crash in functions which
re-use one digest context several times: hmac() and crypt()
with md5 algorithm.
Following patch fixes it by carring the digest info around
EVP_DigestFinal and re-initializing cipher.
Tom Lane [Tue, 1 Mar 2005 21:15:26 +0000 (21:15 +0000)]
Release proclock immediately in RemoveFromWaitQueue() if it represents
no held locks. This maintains the invariant that proclocks are present
only for procs that are holding or awaiting a lock; when this is not
true, LockRelease will fail. Per report from Stephen Clouse.
Tom Lane [Sat, 19 Feb 2005 19:33:42 +0000 (19:33 +0000)]
Ensure that the resolved datatype of any unknown Param is propagated
into the sub-SELECT targetlist when it appears in the context
INSERT INTO foo SELECT $1 ... Per report from Abhijit Menon-Sen.
Neil Conway [Mon, 7 Feb 2005 03:55:28 +0000 (03:55 +0000)]
Prevent 4 more buffer overruns in the PL/PgSQL parser. This is just a
minimally-invasive fix for stable branches; a cleaner fix will be
committed to HEAD soon.
Tom Lane [Sun, 6 Feb 2005 20:19:42 +0000 (20:19 +0000)]
Repair CLUSTER failure after ALTER TABLE SET WITHOUT OIDS. Turns out
there are corner cases involving dropping toasted columns in which the
previous coding would fail, too: the new version of the table might not
have any TOAST table, but we'd still propagate possibly-wide values of
dropped columns forward.
Tom Lane [Wed, 26 Jan 2005 17:09:21 +0000 (17:09 +0000)]
Back-patch 8.0 version of plperl_hash_from_tuple() into prior releases
to fix failure to cope with quote marks in field values; not to mention
that it is shorter and faster. Per report from Charles Haron.
Tom Lane [Sun, 23 Jan 2005 02:23:30 +0000 (02:23 +0000)]
The result of a FULL or RIGHT join can't be assumed to be sorted by the
left input's sorting, because null rows may be inserted at various points.
Per report from Ferenc Lutischá¸n.
Neil Conway [Fri, 21 Jan 2005 00:31:21 +0000 (00:31 +0000)]
Prevent overrunning a heap-allocated buffer if more than 1024 parameters
to a refcursor declaration are specified. This is a minimally-invasive fix
for the buffer overrun -- a more thorough cleanup will be checked into
HEAD.