Tom Lane [Thu, 21 Jul 2005 04:15:04 +0000 (04:15 +0000)]
Fix storage size for btree_gist interval indexes. Fix penalty
calculations for interval and time/timetz to behave sanely for both
integer and float timestamps; up to now I think it's been doing
something pretty strange...
Tom Lane [Mon, 18 Jul 2005 22:34:14 +0000 (22:34 +0000)]
Fix some bogosities in geometric-function documentation: add an entry
for circle(polygon), which was missing; remove bogus entry for
point(lseg, lseg), which does not exist, and the documentation seemed to
describe lseg_interpt, which we already document as an operator not a
function. Also remove entry for box_intersect, which likewise is
preferentially used via the operator #.
Tom Lane [Mon, 18 Jul 2005 17:40:14 +0000 (17:40 +0000)]
Adjust psql describe queries so that any pg_foo_is_visible() condition
is applied last, after other constraints such as name patterns. This
is useful first because the pg_foo_is_visible() functions are relatively
expensive, and second because it minimizes the prospects for race
conditions. The change is fragile though since it makes unwarranted
assumptions about planner behavior, ie, that WHERE clauses will be
executed in the original order if there's not reason to change it.
This should fix ... or at least hide ... an intermittent failure in the
prepared_xacts regression test, while we think about what else to do.
Tom Lane [Mon, 18 Jul 2005 15:53:28 +0000 (15:53 +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:28:45 +0000 (18:28 +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 [Fri, 15 Jul 2005 22:02:51 +0000 (22:02 +0000)]
Fix create_unique_plan() so it doesn't generate useless entries in the
output targetlist of the Unique or HashAgg plan. This code was OK when
written, but subsequent changes to use "physical tlists" where possible
had broken it: given an input subplan that has extra variables added to
avoid a projection step, it would copy those extra variables into the
upper tlist, which is pointless since a projection has to happen anyway.
Tom Lane [Fri, 15 Jul 2005 18:39:59 +0000 (18:39 +0000)]
Check for out-of-range varoattno in deparse_context_for_subplan.
I have seen this case in CVS tip due to new "physical tlist" optimization
for subqueries. I believe it probably can't happen in existing releases,
but the check is not going to hurt anything, so backpatch to 8.0 just
in case.
Tom Lane [Fri, 15 Jul 2005 17:09:26 +0000 (17:09 +0000)]
Fix overenthusiastic optimization of 'x IN (SELECT DISTINCT ...)' and related
cases: we can't just consider whether the subquery's output is unique on its
own terms, we have to check whether the set of output columns we are going to
use will be unique. Per complaint from Luca Pireddu and test case from
Michael Fuhr.
Tom Lane [Thu, 14 Jul 2005 21:46:30 +0000 (21:46 +0000)]
Adjust permissions checking for ALTER OWNER commands: instead of
requiring superuserness always, allow an owner to reassign ownership
to any role he is a member of, if that role would have the right to
create a similar object. These three requirements essentially state
that the would-be alterer has enough privilege to DROP the existing
object and then re-CREATE it as the new role; so we might as well
let him do it in one step. The ALTER TABLESPACE case is a bit
squirrely, but the whole concept of non-superuser tablespace owners
is pretty dubious anyway. Stephen Frost, code review by Tom Lane.
Neil Conway [Thu, 14 Jul 2005 07:12:27 +0000 (07:12 +0000)]
Mark xml2 CREATE FUNCTIONs as IMMUTABLE, and use the "STRICT" syntax
rather than the deprecated "WITH (isStrict)" syntax. Patch from Ilia
Kantor, minor editorializing by Neil Conway.
Neil Conway [Thu, 14 Jul 2005 06:17:36 +0000 (06:17 +0000)]
This doc patch replaces all inappropriate references to SQL:1999 when it
is used as if it were the latest (and/or still valid) SQL standard.
SQL:2003 is used in its place. Patch from Simon Riggs.
Tom Lane [Thu, 14 Jul 2005 05:13:45 +0000 (05:13 +0000)]
Integrate autovacuum functionality into the backend. There's still a
few loose ends to be dealt with, but it seems to work. Alvaro Herrera,
based on the contrib code by Matthew O'Connor.
Bruce Momjian [Wed, 13 Jul 2005 02:11:57 +0000 (02:11 +0000)]
Move -L flag around for shared builds:
I wrote:
> So either we code up some intelligence to put the "C" in the right
> position or we have to pass down "A B" and "D" separately from the
> main makefile.
The following patch might just do the former. Please try it out.
Tom Lane [Tue, 12 Jul 2005 23:06:48 +0000 (23:06 +0000)]
Hack around the discrepancy between default library search paths for
gcc and for HP's ld on HPUX. There may be better ways to do this,
but this seems to work for me...
Tom Lane [Mon, 11 Jul 2005 15:07:59 +0000 (15:07 +0000)]
More pgcrypto fixes: avoid bogus alignment assumptions in sha2,
be more wary about having a value for BYTE_ORDER, clean up randomly-
chosen ways of including Postgres core headers.
Marko Kreen and Tom Lane
Tom Lane [Sun, 10 Jul 2005 21:14:00 +0000 (21:14 +0000)]
Change typreceive function API so that receive functions get the same
optional arguments as text input functions, ie, typioparam OID and
atttypmod. Make all the datatypes that use typmod enforce it the same
way in typreceive as they do in typinput. This fixes a problem with
failure to enforce length restrictions during COPY FROM BINARY.
Bruce Momjian [Sun, 10 Jul 2005 15:32:47 +0000 (15:32 +0000)]
Following up a previous thought I had, yesterday I realised how to
return arays nicely without having to make the plperl programmer aware
of anything. The attached patch allows plperl to return an arrayref
where the function returns an array type. It silently calls a perl
function to stringify the array before passing it to the pg array
parser. Non-array returns are handled as before (i.e. passed through
this process) so it is backwards compatible. I will presently submit
regression tests and docs.
example:
andrew=# create or replace function blah() returns text[][] language
plperl as $$ return [['a"b','c,d'],['e\\f','g']]; $$;
CREATE FUNCTION
andrew=# select blah();
blah
-----------------------------
{{"a\"b","c,d"},{"e\\f",g}}
This would complete half of the TODO item:
. Pass arrays natively instead of as text between plperl and postgres
(The other half is translating pg array arguments to perl arrays - that
will have to wait for 8.1).
Some of this patch is adapted from a previously submitted patch from
Sergej Sergeev. Both he and Abhijit Menon-Sen have looked it over
briefly and tentatively said it looks ok.
Bruce Momjian [Sun, 10 Jul 2005 15:19:43 +0000 (15:19 +0000)]
The attached patch implements spi_query() and spi_fetchrow() functions
for PL/Perl, to avoid loading the entire result set into memory as the
existing spi_exec_query() function does.
Bruce Momjian [Sun, 10 Jul 2005 15:08:52 +0000 (15:08 +0000)]
Add --encoding to pg_dump.
The Problem: Occassionally a DBA needs to dump a database to a new
encoding. In instances where the current encoding, (or lack of an
encoding, like SQL_ASCII) is poorly supported on the target database
server, it can be useful to dump into a particular encoding. But,
currently the only way to set the encoding of a pg_dump file is to
change client_encoding in postgresql.conf and restart postmaster.
This is more than a little awkward for production systems.
Bruce Momjian [Sun, 10 Jul 2005 14:26:30 +0000 (14:26 +0000)]
This patch implements putting language handlers for the optional PLs
into pg_catalog rather than public, and supports dumping languages whose
handlers are found there. This will make it easier to drop the public
schema if desired.
Unlike the previous patch, the comments have been updated and I have
reformatted some code to meet Alvarro's request to stick to 80 cols. (I
actually aghree with this - it makes printing the code much nicer).
I think I did the right thing w.r.t versions earlier than 7.3, but I
have no real way of checking, so that should be checked by someone with
more/older knowledge than me ;-)
Bruce Momjian [Sun, 10 Jul 2005 13:54:34 +0000 (13:54 +0000)]
As Kris Jurka found out, pgcrypto does not work with
OpenSSL 0.9.6x. The DES functions use the older 'des_'
API, but the newer 3DES functions use the 0.9.7x-only
'DES_' API.
I think I just used /usr/include/openssl/des.h for reference
when implementing them, and had upgraded OpenSSL in the
meantime.
Following patch converts DES also to newer API and provides
compatibility functions for OpenSSL < 0.9.7.
I chose this route because:
- openssl.c uses few DES functions.
- compatibility for old 'des_' API is going away at some point
of time from OpenSSL.
- as seen from macros, new API is saner
- Thus pgcrypto supports any OpenSSL version from 0.9.5 to 1.0
Bruce Momjian [Sun, 10 Jul 2005 05:06:42 +0000 (05:06 +0000)]
Update.
< computations should adjust based on the time zone rules, e.g.
< adding 24 hours to a timestamp would yield a different result from
< adding one day.
<
> computations should adjust based on the time zone rules.
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.
In one place the patch doesn't call PLy_elog() because that could
cause infinite recursion; see the comment I added. I'm not sure
how to test that particular case or whether it's even possible to
get an error there: the value that the code should check is the
Python exception type, so I wonder if a NULL value "shouldn't
happen." This patch converts NULL to "Unknown Exception" but I
wonder if an Assert() would be appropriate.
The patch is against HEAD but the same changes should be applied
to earlier versions because they have the same problem. The patch
might not apply cleanly against earlier versions -- will the committer
take care of little differences or should I submit different versions
of the patch?
Bruce Momjian [Sun, 10 Jul 2005 04:54:33 +0000 (04:54 +0000)]
I made the patch that implements regexp_replace again.
The specification of this function is as follows.
regexp_replace(source text, pattern text, replacement text, [flags
text])
returns text
Replace string that matches to regular expression in source text to
replacement text.
- pattern is regular expression pattern.
- replacement is replace string that can use '\1'-'\9', and '\&'.
'\1'-'\9': back reference to the n'th subexpression.
'\&' : entire matched string.
- flags can use the following values:
g: global (replace all)
i: ignore case
When the flags is not specified, case sensitive, replace the first
instance only.
Bruce Momjian [Sun, 10 Jul 2005 03:57:55 +0000 (03:57 +0000)]
Major pgcrypto changes:
of password-based encryption from RFC2440 (OpenPGP).
The goal of this code is to be more featureful encryption solution
than current encrypt(), which only functionality is running cipher
over data.
Compared to encrypt(), pgp_encrypt() does following:
* It uses the equvialent of random Inital Vector to get cipher
into random state before it processes user data
* Stores SHA-1 of the data into result so any modification
will be detected.
* Remembers if data was text or binary - thus it can decrypt
to/from text data. This was a major nuisance for encrypt().
* Stores info about used algorithms with result, so user needs
not remember them - more user friendly!
* Uses String2Key algorithms (similar to crypt()) with random salt
to generate full-length binary key to be used for encrypting.
* Uses standard format for data - you can feed it to GnuPG, if needed.
Optional features (off by default):
* Can use separate session key - user data will be encrypted
with totally random key, which will be encrypted with S2K
generated key and attached to result.
* Data compression with zlib.
* Can convert between CRLF<->LF line-endings - to get fully
RFC2440-compliant behaviour. This is off by default as
pgcrypto does not know the line-endings of user data.
For text data, pgp_encrypt simply encrypts the PostgreSQL internal data.
This maps to RFC2440 data type 't' - 'extenally specified encoding'.
But this may cause problems if data is dumped and reloaded into database
which as different internal encoding. My next goal is to implement data
type 'u' - which means data is in UTF-8 encoding by converting internal
encoding to UTF-8 and back. And there wont be any compatibility
problems with current code, I think its ok to submit this without UTF-8
encoding by converting internal encoding to UTF-8 and back. And there
wont be any compatibility problems with current code, I think its ok to
submit this without UTF-8 support.
Here is v4 of PGP encrypt. This depends on previously sent
Fortuna-patch, as it uses the px_add_entropy function.
- New function: pgp_key_id() for finding key id's.
- Add SHA1 of user data and key into RNG pools. We need to get
randomness from somewhere, and it is in user best interests
to contribute.
- Regenerate pgp-armor test for SQL_ASCII database.
- Cleanup the key handling so that the pubkey support is less
hackish.
Bruce Momjian [Sun, 10 Jul 2005 03:55:28 +0000 (03:55 +0000)]
- Add Fortuna PRNG to pgcrypto.
- Move openssl random provider to openssl.c and builtin provider
to internal.c
- Make px_random_bytes use Fortuna, instead of giving error.
- Retarget random.c to aquiring system randomness, for initial seeding
of Fortuna. There is ATM 2 functions for Windows,
reader from /dev/urandom and the regular time()/getpid() silliness.
Tom Lane [Fri, 8 Jul 2005 16:51:30 +0000 (16:51 +0000)]
Try connecting to both postgres and template1 databases to do the initial
inspection of shared catalogs. This allows pg_dumpall to continue to
work with pre-8.1 servers that likely won't have a database named postgres.
Also, suppress output of SYSID options for users and groups, since server
no longer does anything with these except emit a rude message.
There is much more to be done to update pg_dumpall for the roles feature,
but this at least makes it usable again. Per gripe from Chris K-L.
Neil Conway [Fri, 8 Jul 2005 04:27:49 +0000 (04:27 +0000)]
This patch updates the DDL for contrib/pgcrypto to create all
functions as STRICT, and all functions except gen_salt() as IMMUTABLE.
gen_salt() is VOLATILE.
Although the functions are now STRICT, I left their PG_ARGISNULL()
checks in place as a protective measure for users who install the
new code but use old (non-STRICT) catalog entries (e.g., restored
from a dump). Per recent discussion in pgsql-hackers.
Neil Conway [Fri, 8 Jul 2005 04:12:27 +0000 (04:12 +0000)]
Remove some dead code for handling XLOG_DBASE_CREATE_OLD and
XLOG_DBASE_DROP_OLD WAL records -- these records are no longer created in
current sources. Adjust numbering of XLOG_DBASE_CREATE and XLOG_DBASE_DROP
and bump the catversion. Patch from Gavin Sherry, adjusted by Neil Conway.
Tom Lane [Fri, 8 Jul 2005 04:07:26 +0000 (04:07 +0000)]
Even though I'd like to see full_page_writes go away before 8.1,
a minimum requirement is that it not completely break the system
meanwhile. Put the test in the right place.
Tom Lane [Thu, 7 Jul 2005 20:40:02 +0000 (20:40 +0000)]
Track dependencies on shared objects (which is to say, roles; we already
have adequate mechanisms for tracking the contents of databases and
tablespaces). This solves the longstanding problem that you can drop a
user who still owns objects and/or has access permissions.
Alvaro Herrera, with some kibitzing from Tom Lane.
Bruce Momjian [Thu, 7 Jul 2005 16:02:06 +0000 (16:02 +0000)]
Update:
< writer.
> writer. It might cause problems for applying WAL on recovery
> into a partially-written page, but later the full page will be
> replaced from WAL.
Bruce Momjian [Thu, 7 Jul 2005 15:18:26 +0000 (15:18 +0000)]
Update:
>
> o -Add ability to turn off full page writes
> o When off, write CRC to WAL and check file system blocks
> on recovery
> o Write full pages during file system write and not when
> the page is modified in the buffer cache
>
> This allows most full page writes to happen in the background
> writer.
Bruce Momjian [Wed, 6 Jul 2005 22:44:49 +0000 (22:44 +0000)]
Currently, nonfatal warnings are not trapped (as they should be) by
plperl - the attached small patch remedies that omission, and adds a
small regression test for error and warning output - the new regression
input and expected output are in separate attached files.
Support cross compilation by compiling "zic" with a native compiler.
This relies on the output of zic being platform independent, but that is
currently the case.
Tom Lane [Wed, 6 Jul 2005 16:42:10 +0000 (16:42 +0000)]
Add a check for trigger function with declared arguments. This path
could not be reached before, but now that there is a plpgsql validator
function, it can be. Check is needed to prevent core dump reported by
Satoshi Nagayasu. Besides, this gives a more specific and useful
error message for a fairly common novice error.