1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +03:00
Commit Graph

5539 Commits

Author SHA1 Message Date
Tom Lane
152dbad1eb Clean up rather sloppy fix in HEAD for the ancient bug that CREATE CONVERSION
didn't create a dependency from the new conversion to its schema.  Back-patch
to all supported releases.
2006-08-31 17:32:01 +00:00
Tom Lane
fe090f0778 Back-patch 7.4-era fix for memory leak with SSL connections due to
missing X509_free() calls.  Per a request from a Red Hat customer;
seems silly for Red Hat to be shipping a patch that's not in upstream.
2006-06-23 14:42:52 +00:00
Tom Lane
9e63275633 Back-port Postgres 7.4 spinlock code into 7.3 branch. This adds
previously-missing spinlock code for x86_64 and ppc64 architectures,
converts the ppc/ppc64 code into gcc inlines, and provides a better
spinlock backoff algorithm on all architectures.  Aside from being
almost identical to the community 7.4 source code, this exact patch
has been in use for awhile in Red Hat's RHEL3 RPMs, so I have pretty
good confidence in it.  Why bother, you ask?  I'm taking pity on a
couple of buildfarm members that have been vainly trying to build 7.3
on these 64-bit architectures.
2006-06-01 23:18:11 +00:00
Tom Lane
16e77740ea Add a new GUC parameter backslash_quote, which determines whether the SQL
parser will allow "\'" to be used to represent a literal quote mark.  The
"\'" representation has been deprecated for some time in favor of the
SQL-standard representation "''" (two single quote marks), but it has been
used often enough that just disallowing it immediately won't do.  Hence
backslash_quote allows the settings "on", "off", and "safe_encoding",
the last meaning to allow "\'" only if client_encoding is a valid server
encoding.  That is now the default, and the reason is that in encodings
such as SJIS that allow 0x5c (ASCII backslash) to be the last byte of a
multibyte character, accepting "\'" allows SQL-injection attacks as per
CVE-2006-2314 (further details will be published after release).  The
"on" setting is available for backward compatibility, but it must not be
used with clients that are exposed to untrusted input.

Thanks to Akio Ishida and Yasuo Ohgaki for identifying this security issue.
2006-05-21 20:12:20 +00:00
Tom Lane
5c4de67044 Change the backend to reject strings containing invalidly-encoded multibyte
characters in all cases.  Formerly we mostly just threw warnings for invalid
input, and failed to detect it at all if no encoding conversion was required.
The tighter check is needed to defend against SQL-injection attacks as per
CVE-2006-2313 (further details will be published after release).  Embedded
zero (null) bytes will be rejected as well.  The checks are applied during
input to the backend (receipt from client or COPY IN), so it no longer seems
necessary to check in textin() and related routines; any string arriving at
those functions will already have been validated.  Conversion failure
reporting (for characters with no equivalent in the destination encoding)
has been cleaned up and made consistent while at it.

Also, fix a few longstanding errors in little-used encoding conversion
routines: win1251_to_iso, win866_to_iso, euc_tw_to_big5, euc_tw_to_mic,
mic_to_euc_tw were all broken to varying extents.

Patches by Tatsuo Ishii and Tom Lane.  Thanks to Akio Ishida and Yasuo Ohgaki
for identifying the security issues.
2006-05-21 20:07:13 +00:00
Bruce Momjian
583a472f7b Change \' to '', for SQL standards compliance. Backpatch to 7.3, 7.4,
and 8.0.  Later releases already patched.
2006-05-21 19:56:41 +00:00
Tom Lane
506747337b Fix the sense of the test on DH_check()'s return value. This was preventing
custom-generated DH parameters from actually being used by the server.
Found by Michael Fuhr.
2006-05-12 22:45:06 +00:00
Tom Lane
76dc24091f Remove unnecessary .seg/.section directives, per Alan Stange. 2006-05-11 22:00:12 +00:00
Tatsuo Ishii
342fae3dc5 Minor teak. 2006-03-04 12:35:08 +00:00
Tatsuo Ishii
52c4e32d5f Tighten up SJIS byte sequence check. Now we reject invalid SJIS byte
sequence such as "0x95 0x27". Patches from Akio Ishida.
2006-03-04 12:32:59 +00:00
Tom Lane
118f54d06d Fix bug in SET SESSION AUTHORIZATION that allows unprivileged users to crash
the server, if it has been compiled with Asserts enabled (CVE-2006-0553).
Thanks to Akio Ishida for reporting this problem.
2006-02-12 22:33:47 +00:00
Tom Lane
3cbc8b6fb4 Repair longstanding bug in slru/clog logic: it is possible for two backends
to try to create a log segment file concurrently, but the code erroneously
specified O_EXCL to open(), resulting in a needless failure.  Before 7.4,
it was even a PANIC condition :-(.  Correct code is actually simpler than
what we had, because we can just say O_CREAT to start with and not need a
second open() call.  I believe this accounts for several recent reports of
hard-to-reproduce "could not create file ...: File exists" errors in both
pg_clog and pg_subtrans.
2006-01-21 04:38:54 +00:00
Tom Lane
a6cc7db9a6 Repair "Halloween problem" in EvalPlanQual: a tuple that's been inserted by
our own command (or more generally, xmin = our xact and cmin >= current
command ID) should not be seen as good.  Else we may try to update rows
we already updated.  This error was inserted last August while fixing the
even bigger problem that the old coding wouldn't see *any* tuples inserted
by our own transaction as good.  Per report from Euler Taveira de Oliveira.
2006-01-12 21:49:41 +00:00
Tom Lane
88f2145326 Fix failure to apply domain constraints to a NULL constant that's added to
an INSERT target list during rule rewriting.  Per report from John Supplee.
2006-01-06 20:11:36 +00:00
Tom Lane
040d3e63a7 Arrange to set the LC_XXX environment variables to match our locale setup.
Back-patch of previous fix in HEAD for plperl-vs-locale issue.
2006-01-05 00:55:36 +00:00
Tatsuo Ishii
951f2bdd23 Fix long standing Asian multibyte charsets bug.
See:

Subject: [HACKERS] bugs with certain Asian multibyte charsets
From: Tatsuo Ishii <ishii@sraoss.co.jp>
To: pgsql-hackers@postgresql.org
Date: Sat, 24 Dec 2005 18:25:33 +0900 (JST)

for more details.
2005-12-24 12:08:10 +00:00
Tom Lane
cd726e1cf8 Adjust string comparison so that only bitwise-equal strings are considered
equal: if strcoll claims two strings are equal, check it with strcmp, and
sort according to strcmp if not identical.  This fixes inconsistent
behavior under glibc's hu_HU locale, and probably under some other locales
as well.  Also, take advantage of the now-well-defined behavior to speed up
texteq, textne, bpchareq, bpcharne: they may as well just do a bitwise
comparison and not bother with strcoll at all.

NOTE: affected databases may need to REINDEX indexes on text columns to be
sure they are self-consistent.
2005-12-22 22:50:29 +00:00
Tom Lane
237afd453f Fix longstanding race condition in transaction log management: there was a
very narrow window in which SimpleLruReadPage or SimpleLruWritePage could
think that I/O was needed when it wasn't (and indeed the buffer had already
been assigned to another page).  This would result in an Assert failure if
Asserts were enabled, and probably in silent data corruption if not.
Reported independently by Jim Nasby and Robert Creager.

I intend a more extensive fix when 8.2 development starts, but this is a
reasonably low-impact patch for the existing branches.
2005-11-03 00:23:57 +00:00
Tom Lane
aaaacf0f6c Fix longstanding bug that would sometimes let the planner generate a bad plan
for an outer join; symptom is bogus error "RIGHT JOIN is only supported with
merge-joinable join conditions".  Problem was that select_mergejoin_clauses
did its tests in the wrong order.  We need to force left join not right join
for a merge join when there are non-mergeable join clauses; but the test for
this only accounted for mergejoinability of the clause operator, and not
whether the left and right Vars were of the proper relations.  Per report
from Jean-Pierre Pelletier.
2005-10-25 20:30:52 +00:00
Tom Lane
0fa322a14e Pass a strdup'd ident string to openlog(), to ensure that reallocation
of GUC memory doesn't cause us to start emitting a bogus ident string.
Per report from Han Holl.  Also some trivial code cleanup in write_syslog.
2005-10-14 16:41:41 +00:00
Tom Lane
10f14e6e0d Fix longstanding bug found by Atsushi Ogawa: _bt_check_unique would mark
the wrong buffer dirty when trying to kill a dead index entry that's on
a page after the one it started on.  No risk of data corruption, just
inefficiency, but still a bug.
2005-10-12 17:18:45 +00:00
Teodor Sigaev
ba5f900b3d Fix missing rows in query
update a=.. where a... with GiST index on column 'a'
Backpatch from 8.0 branch
2005-08-30 08:48:16 +00:00
Tom Lane
26f1202ca3 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.3 branch.
2005-08-26 20:07:17 +00:00
Tom Lane
bec2f429af 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.
2005-08-16 00:48:58 +00:00
Tom Lane
577759f8bf 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.
2005-06-25 16:54:30 +00:00
Tom Lane
d4b7dfacfa 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.
2005-06-14 14:21:37 +00:00
Tatsuo Ishii
8154f06301 Fix bug in MIC -> EUC_JP conversion. Per Atsushi Ogawa. 2005-06-11 07:44:40 +00:00
Tom Lane
7ef90f5aad Code for SET/SHOW TIME ZONE with a fixed-interval timezone was not
prepared for HAVE_INT64_TIMESTAMP.  Per report from Guillaume Beaudoin.
2005-06-05 01:49:06 +00:00
Tom Lane
cd48aa0e96 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.
2005-06-02 21:04:30 +00:00
Tom Lane
2e1229671a 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.
2005-05-31 19:11:14 +00:00
Tom Lane
4f142baf37 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.
2005-05-29 17:11:07 +00:00
Tatsuo Ishii
5454eb0456 Fix previous patch to exprTypmod. 2005-05-25 02:03:52 +00:00
Tatsuo Ishii
8f5702ebd5 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.
2005-05-24 23:52:02 +00:00
Tom Lane
ad12a7b9e2 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.
2005-05-07 21:33:47 +00:00
Tom Lane
4beb9cd5eb 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.
2005-05-07 21:23:24 +00:00
Tom Lane
5d0d60efe6 Make standalone backends ignore pg_database.datallowconn, so that there
is a way to recover from disabling connections to all databases at once.
2005-05-05 19:54:01 +00:00
Tom Lane
ecbc6dd3e9 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.
2005-05-03 19:18:48 +00:00
Tom Lane
2cfb3b6d4d 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).
2005-04-23 22:54:03 +00:00
Tom Lane
daa7e6604c Don't try to run clauseless index scans on index types that don't support
it.  Per report from Marinos Yannikos.
2005-04-20 21:48:31 +00:00
Tom Lane
7735c39aa0 Fix mis-display of negative fractional seconds in interval values for
--enable-integer-datetimes case.  Per report from Oliver Siegmar.
2005-04-20 17:15:19 +00:00
Tom Lane
aa4762e7c8 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.
2005-04-14 21:44:46 +00:00
Tom Lane
536b3af7e3 Prevent to_char(interval) from dumping core on month-related formats
when a zero-month interval is given.  Per discussion with Karel.
2005-03-26 00:42:44 +00:00
Tom Lane
1263d7b8d1 Check that aggregate creator has the right to execute the transition
functions of the aggregate, at both aggregate creation and execution times.
2005-01-27 23:43:45 +00:00
Tom Lane
a23133a4d7 Disallow LOAD to non-superusers. Per report from John Heasman. 2005-01-24 17:46:49 +00:00
Tom Lane
48a1dc0d5c 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.
2005-01-23 02:24:30 +00:00
Tom Lane
76f13fe78d interval_out failed to mention 'ago' for negative intervals in SQL and
GERMAN datestyles.  Ancient bug reported by Terry Lee Tucker.
2005-01-11 18:34:29 +00:00
Tom Lane
e333705b84 array_map failed to insert correct result type in an empty array.
Per example from Florian Pflug.
2004-12-17 20:58:47 +00:00
Tom Lane
bd677bb443 Back-patch fix for ALTER DATABASE failing to flush pg_database changes
to disk right away.  This is just a one-liner change rather than trying
to use FlushRelationBuffers().
2004-11-18 01:19:57 +00:00
Tom Lane
eac07f1fd7 Fix off-by-one memory allocation, as reported by Rod Taylor. Also
avoid repalloc'ing twice when once is sufficient.
2004-11-17 19:54:53 +00:00
Tom Lane
78c0692b15 Repair possible failure to update hint bits back to disk, per
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php.
I plan a more permanent fix in HEAD, but for the back branches it seems
best to just touch the places that actually have a problem.
2004-10-13 22:22:22 +00:00