Tom Lane [Tue, 27 Nov 2007 19:58:44 +0000 (19:58 +0000)]
Fix plpgsql to not lookup block labels except in contexts where a block label
is sane (eg, EXIT argument or first part of a qualified identifier), and cause
more-closely-nested record variables to take precedence over outer block
labels. This cures the breakage exhibited by Marko Kreen that 8.3 no longer
allowed a function's name to be used for a variable within the function, and
makes plpgsql's handling of block labels more like Oracle's. It's important
to fix this now because we are documenting the use of block labels as variable
qualifiers for the first time in 8.3.
Tom Lane [Tue, 27 Nov 2007 18:29:11 +0000 (18:29 +0000)]
Add quote_literal(anyelement) to preserve (and, in fact, extend) a
useful consequence of the former liberal implicit casting to text;
namely that you can feed non-string values to quote_literal() and get
unsurprising results. Per discussion.
Peter Eisentraut [Tue, 27 Nov 2007 12:21:05 +0000 (12:21 +0000)]
Make casts from xml to text independent of the XML option setting, thus
immutable and indexable. Also fix the volatility settings of some other
XML-related functions.
Bruce Momjian [Mon, 26 Nov 2007 23:31:09 +0000 (23:31 +0000)]
Add:
< * -Make 64-bit version of the MONEY data type
< * Add locale-aware MONEY type, and support multiple currencies
<
< http://archives.postgresql.org/pgsql-general/2005-08/msg01432.php
< http://archives.postgresql.org/pgsql-hackers/2007-03/msg01181.php
<
< * MONEY dumps in a locale-specific format making it difficult to
< restore to a system with a different locale
>
> * MONEY data type
>
> o -Make 64-bit version of the MONEY data type
> * Add locale-aware MONEY type, and support multiple currencies
>
> http://archives.postgresql.org/pgsql-general/2005-08/msg01432.php
> http://archives.postgresql.org/pgsql-hackers/2007-03/msg01181.php
>
> * MONEY dumps in a locale-specific format making it difficult to
> restore to a system with a different locale
> * Allow MONEY to be cast to/from other numeric data types
Tom Lane [Mon, 26 Nov 2007 16:46:51 +0000 (16:46 +0000)]
Fix select_common_type() so that it can select a domain type, if all inputs
to a UNION, CASE, or related construct are of the same domain type. The
main part of this routine smashes domains to their base types, which seems
necessary because the logic involves TypeCategory() and IsPreferredType(),
neither of which work usefully on domains. However, we can add a first
pass that just detects whether all the inputs are exactly the same type,
and if so accept that without question (so long as it's not UNKNOWN).
Per recent gripe from Dean Rasheed.
In passing, remove some tests for InvalidOid, which have clearly been dead
code for quite some time now, because getBaseType() would fail on that input.
Also, clarify the manual's not-very-precise description of the existing
algorithm's behavior.
Tom Lane [Sat, 24 Nov 2007 21:20:07 +0000 (21:20 +0000)]
Fix (I think) broken usage of MultiByteToWideChar. I had missed the
subtlety that this function only returns a null terminator if it's
fed input that includes one; which, in the usage here, it's not.
This probably fixes bugs reported by Thomas Haegi.
Tom Lane [Sat, 24 Nov 2007 20:26:49 +0000 (20:26 +0000)]
Move resetting of currSchema to a spot where it's not vulnerable to getting
missed in possible future partial-drop scenarios. Improve comment.
Per report from Zoltan Boszormenyi.
Tom Lane [Sat, 24 Nov 2007 19:08:51 +0000 (19:08 +0000)]
Save another little bit of planner overhead on simple queries, by having
clauselist_selectivity skip some analysis that's useless when there's only
one clause in the given list. Actually this can win even for not-so-simple
queries, because we also apply clauselist_selectivity to sublists such as the
quals matching an index; which are likely to have only a single entry even
when the total query is quite complicated.
Bruce Momjian [Sat, 24 Nov 2007 17:45:32 +0000 (17:45 +0000)]
If pg_dump drops a schema, make sure 'search_path' it SET the next time
it is needed --- basically don't remember the previous 'search_path'
after a drop schema because it might have failed but be created later.
Bruce Momjian [Sat, 24 Nov 2007 15:28:02 +0000 (15:28 +0000)]
Make the MONEY data type have a thousands separator != decimal symbol,
if the locale has the thousands separator as "". This now matches the
to_char and psql numericlocale behavior. (Previously this data type was
basically useless for such setups.)
Tom Lane [Sat, 24 Nov 2007 00:39:44 +0000 (00:39 +0000)]
Change fix_scan_expr() to avoid copying the input node tree in the common case
where rtoffset == 0. In that case there is no need to change Var nodes,
and since filling in unset opfuncid fields is always safe, scribbling on the
input tree to that extent is not objectionable. This brings the cost of this
operation back down to what it was in 8.2 for simple queries. Per
investigation of performance gripe from Guillaume Smet.
Tom Lane [Fri, 23 Nov 2007 19:57:44 +0000 (19:57 +0000)]
Avoid uselessly building a duplicate of the original clause in trivial cases
where the EquivalenceClass machinery is unable to deduce anything more from a
simple "var = const" qual clause. There are probably some more cases where
this could be done, but this seems to take care of most of the added overhead
for simple queries. Per gripe from Guillaume Smet.
In passing, fix a problem that was exposed by this change:
reconsider_outer_join_clause and friends were passing the wrong relids to
build_implied_join_equality, resulting in RestrictInfos with the wrong
required_relids. This mistake was masked in typical cases since the bogus
RestrictInfos would never have escaped from the EquivalenceClass machinery,
but I think there might be corner cases involving "broken" ECs where there
would have been a visible failure even without the new optimization. In any
case the code was certainly not operating as intended.
Bruce Momjian [Fri, 23 Nov 2007 16:37:55 +0000 (16:37 +0000)]
Update text:
< * Prevent long-lived temporary tables from causing frozen-Xid advancement
> * Prevent long-lived temporary tables from causing frozen-xid advancement
>
> The problem is that autovacuum cannot vacuum them to set frozen xids;
> only the session that created them can do that.
>
>
>
Alvaro Herrera [Fri, 23 Nov 2007 01:46:34 +0000 (01:46 +0000)]
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.
Tom Lane [Thu, 22 Nov 2007 19:40:25 +0000 (19:40 +0000)]
Actually ... it's pretty silly that parse_oper.c doesn't set up the
opfuncid of an OpExpr initially, considering that it has the information
at hand already. We'll still treat opfuncid as a cache rather than a
guaranteed-valid value, but this change saves one more syscache lookup
in the normal code path.
Tom Lane [Thu, 22 Nov 2007 19:09:23 +0000 (19:09 +0000)]
Save one syscache lookup when examining volatility or strictness of
OpExpr and related nodes. We're going to have to set the opfuncid of
such nodes eventually (if we haven't already), so we might as well
exploit the opportunity to cache the function OID. Buys back some
of the extra planner overhead noted by Guillaume Smet, though I still
need to fool with equivclass.c to really respond to that.
Tom Lane [Thu, 22 Nov 2007 17:47:28 +0000 (17:47 +0000)]
Prevent Perl from introducing a possibly-incompatible definition of type
"bool" into plperl.c. This has always been a hazard since Perl allows a
platform-specific choice to define bool as int rather than char, but
evidently this didn't happen on any platform we support ... until OS X 10.5.
Per report from Brandon Maust.
Back-patch as far as 8.0 --- a bit arbitrary, but it seems unlikely anyone
will be trying to port 7.x onto new platforms.
Tom Lane [Tue, 20 Nov 2007 23:14:41 +0000 (23:14 +0000)]
Fix bogus length calculation that could lead to crash if the string
happened to be right up against the end of memory, per report from
Matt Magoffin. While at it, avoid useless multiple copying of string
by not depending on xmlStrncatNew.
Andrew Dunstan [Tue, 20 Nov 2007 02:25:22 +0000 (02:25 +0000)]
Change descriptions of entity and tag objects to "XML entity" and "XML tag".
Allow tag and entity names that follow XML rules. Provide for hexadecimal
as well as decimal numeric entities. Adjust code names to coincide with
new descriptions.
Bruce Momjian [Tue, 20 Nov 2007 00:18:46 +0000 (00:18 +0000)]
Update COMMENT item:
< o Prevent COMMENT ON dbname from issuing a warning when loading
< into a database with a different name, perhaps using COMMENT ON
< CURRENT DATABASE
> o Change pg_dump so that a comment on the dumped database is
> applied to the loaded database, even if the database has a
> different name. This will require new backend syntax, perhaps
> COMMENT ON CURRENT DATABASE.
Bruce Momjian [Mon, 19 Nov 2007 23:48:46 +0000 (23:48 +0000)]
Update wording:
< o Allow COMMENT ON dbname to work when loading into a database
< with a different name, perhaps using COMMENT ON CURRENT
< DATABASE
> o Prevent COMMENT ON dbname from issuing a warning when loading
> into a database with a different name, perhaps using COMMENT ON
> CURRENT DATABASE
Tom Lane [Fri, 16 Nov 2007 21:55:59 +0000 (21:55 +0000)]
Improve GIN index build's tracking of memory usage by using
GetMemoryChunkSpace, not just the palloc request size. This brings the
allocatedMemory counter close enough to reality (as measured by
MemoryContextStats printouts) that I think we can get rid of the arbitrary
factor-of-2 adjustment that was put into the code initially. Given the
sensitivity of GIN build to work memory size, not using as much of work
memory as we're allowed to seems a pretty bad idea.
Tom Lane [Fri, 16 Nov 2007 21:50:06 +0000 (21:50 +0000)]
GIN index build's allocatedMemory counter needs to be long, not uint32.
Else, in a 64-bit machine with maintenance_work_mem set to above 4Gb,
the counter overflows and we never recognize having reached the
maintenance_work_mem limit. I believe this explains out-of-memory
failure recently reported by Sean Davis.
Tom Lane [Fri, 16 Nov 2007 19:53:50 +0000 (19:53 +0000)]
Repair still another bug in the btree page split WAL reduction patch:
it failed for splits of non-leaf pages because in such pages the first
data key on a page is suppressed, and so we can't just copy the first
key from the right page to reconstitute the left page's high key.
Problem found by Koichi Suzuki, patch by Heikki.
Tom Lane [Fri, 16 Nov 2007 00:34:54 +0000 (00:34 +0000)]
Add snb_ru_init(internal) to list of stub functions in tsearch2
compatibility module. Needed to support loading of 8.1-era tsearch2
configuration data.
Bruce Momjian [Fri, 16 Nov 2007 00:13:02 +0000 (00:13 +0000)]
Modify LOOPBYTE/LOOPBIT macros to be more logical; rather than have the
for() body passed as a parameter, make the macros act as simple headers
to code blocks.
Bruce Momjian [Thu, 15 Nov 2007 23:23:44 +0000 (23:23 +0000)]
Fix pgindent to properly handle 'else' and single-line comments on the
same line; previous fix was only partial. Re-run pgindent on files
that need it.