Tom Lane [Sun, 11 Aug 2002 00:08:48 +0000 (00:08 +0000)]
Now that we allow ANALYZE to run inside a transaction block, the locks
it takes could be held for quite awhile after the analyze step completes.
Rethink locking of pg_statistic in light of this fact. The original
scheme took an exclusive lock on pg_statistic, which was okay when the
lock could be expected to be released shortly, but that doesn't hold
anymore. Back off to a normal writer's lock (RowExclusiveLock). This
allows concurrent ANALYZE of nonoverlapping sets of tables, at the price
that concurrent ANALYZEs of the same table may fail with 'tuple
concurrently updated'.
Bruce Momjian [Sat, 10 Aug 2002 21:00:34 +0000 (21:00 +0000)]
Update with newer version of CLUSTER patch posted August 8.
> Looks like Alvaro got sideswiped by the system catalog indexing changes
> I made over the weekend. It's a simple change, just reduce the whole
> mess to a "CatalogUpdateIndexes()" call.
I update two tuples, so I manually CatalogOpenIndexes() and
CatalogIndexInsert() two times, as per comments in
CatalogUpdateIndexes().
I also removed a couple of useless CommandCounterIncrement(), some
useless definitions in src/include/commands/cluster.h and useless
includes in src/backend/commands/cluster.c. This version passes the
regression test I had made for previous versions.
Bruce Momjian [Sat, 10 Aug 2002 20:45:48 +0000 (20:45 +0000)]
The patch solves this problem, I hope...
Christopher Kings-Lynne wrote:
> I'm still getting ltree failures on 64bit freebsd:
>
> sed 's,MODULE_PATHNAME,$libdir/ltree,g' ltree.sql.in >ltree.sql
> gcc -pipe -O -g -Wall -Wmissing-prototypes -Wmissing-declarations -fpic -DPI
> C -DLOWER_NODE -I. -I../../src/include -c -o ltree_io.o ltree_io.c -MMD
> ltree_io.c: In function `ltree_in':
> ltree_io.c:57: warning: int format, different type arg (arg 3)
> ltree_io.c:63: warning: int format, different type arg (arg 4)
> ltree_io.c:68: warning: int format, different type arg (arg 3)
Reported by Neil Conway -- I never implemented readfuncs.c support for
ColumnDef or TypeName, which is needed so that views can be created on
functions returning type RECORD. Here's a patch.
Bruce Momjian [Sat, 10 Aug 2002 20:43:46 +0000 (20:43 +0000)]
Major improvement in CLUSTER which preserves table characteristics using
relfilenode.
I sent the CLUSTER patch a few days ago and I think it was missed. I
append it again, this time including the regression test files. For the
committer, please note that you have to cvs add the files as they don't
exist. Maybe add to the parallel and serial schedules also, but I don't
know such stuff.
Bruce Momjian [Sat, 10 Aug 2002 20:38:29 +0000 (20:38 +0000)]
August 6, 2002
1. Reworked patch from Andrey Oktyabrski (ano@spider.ru) with
functions: icount, sort, sort_asc, uniq, idx, subarray
operations: #, +, -, |, &
FUNCTIONS:
int icount(int[]) - the number of elements in intarray
int[] sort(int[], 'asc' | 'desc') - sort intarray
int[] sort(int[]) - sort in ascending order
int[] sort_asc(int[]),sort_desc(int[]) - shortcuts for sort
int[] uniq(int[]) - returns unique elements
int idx(int[], int item) - returns index of first intarray matching element
to item, or '0' if matching failed.
int[] subarray(int[],int START [, int LEN]) - returns part of intarray
starting from element number START (from 1)
and length LEN.
OPERATIONS:
int[] && int[] - overlap - returns TRUE if arrays has at least one common elements.
int[] @ int[] - contains - returns TRUE if left array contains right array
int[] ~ int[] - contained - returns TRUE if left array is contained in right array
# int[] - return the number of elements in array
int[] + int - push element to array ( add to end of array)
int[] + int[] - merge of arrays (right array added to the end of left one)
int[] - int - remove entries matched by right argument from array
int[] - int[] - remove left array from right
int[] | int - returns intarray - union of arguments
int[] | int[] - returns intarray as a union of two arrays
int[] & int[] - returns intersection of arrays
Bruce Momjian [Sat, 10 Aug 2002 20:29:18 +0000 (20:29 +0000)]
This patch removes a lot of unused code related to assertions and
error handling, and simplifies the code that remains. Apparently,
the code that left Berkeley had a whole "error handling subsystem",
which exceptions and whatnot. Since we don't use that anymore,
there's no reason to keep it around.
The regression tests pass with the patch applied. Unless anyone
sees a problem, please apply.
Tom Lane [Sat, 10 Aug 2002 19:35:01 +0000 (19:35 +0000)]
psql prints its version number in its startup message, per recent
discussion. Also, cause the \timing command to display time in a
format consistent with the backend's EXPLAIN ANALYZE output.
Peter Eisentraut [Sat, 10 Aug 2002 16:57:32 +0000 (16:57 +0000)]
Make sure all clients have the same understanding of default user name
and database. In particular, make script wrappers understand the
PGDATABASE environment variable.
Tom Lane [Sat, 10 Aug 2002 03:56:24 +0000 (03:56 +0000)]
psql backslash commands are schema-aware. Pattern matching behavior
follows recent pghackers discussion. This commit includes all the
relevant fixes from Greg Mullane's patch of 24-June.
Tom Lane [Fri, 9 Aug 2002 16:45:16 +0000 (16:45 +0000)]
has_table_privilege spawns scions has_database_privilege, has_function_privilege,
has_language_privilege, has_schema_privilege to let SQL queries test
all the new privilege types in 7.3. Also, add functions pg_table_is_visible,
pg_type_is_visible, pg_function_is_visible, pg_operator_is_visible,
pg_opclass_is_visible to test whether objects contained in schemas are
visible in the current search path. Do some minor cleanup to centralize
accesses to pg_database, as well.
Tom Lane [Thu, 8 Aug 2002 19:39:05 +0000 (19:39 +0000)]
Make the standard system views schema-aware.
I did not force an initdb via catversion ... but the rules
regression test will fail until you do an initdb.
Tom Lane [Thu, 8 Aug 2002 01:44:31 +0000 (01:44 +0000)]
Cause schema-qualified FROM items and schema-qualified variable references
to behave according to SQL92 (or according to my current understanding
of same, anyway). Per pghackers discussion way back in March 2002:
thread 'Do FROM items of different schemas conflict?'
Tom Lane [Thu, 8 Aug 2002 01:36:05 +0000 (01:36 +0000)]
Clean up plpgsql identifier handling: process quoted identifiers
correctly, truncate to NAMEDATALEN where needed, allow whitespace
around dots in qualified identifiers. Get rid of T_RECFIELD and
T_TGARGV token categories, which weren't accomplishing anything
except to create room for sins of omission in the grammar, ie,
places that should have allowed them and didn't. Fix a few other
bugs en passant.
Tom Lane [Tue, 6 Aug 2002 19:41:23 +0000 (19:41 +0000)]
Still more paranoia in PageAddItem: disallow specification of an item
offset past the last-used-item-plus-one, since that would result in
leaving uninitialized holes in the item pointer array. AFAICT the only
place that was depending on this was btree index build, which was being
cavalier about when to fill in the P_HIKEY pointer; easily fixed.
Also a small performance improvement: shuffle itemid's by means of
memmove, not a one-at-a-time loop.
Tom Lane [Tue, 6 Aug 2002 14:11:06 +0000 (14:11 +0000)]
Move pg_convert3 declaration to suppress compile warning. Really
pg_convert3 does not belong in a backend/catalog file at all, IMHO;
it should be in utils/adt.
Bruce Momjian [Tue, 6 Aug 2002 05:34:10 +0000 (05:34 +0000)]
>> Hm. I'd sort of expect the "z" to become both the table and column
>> alias in this case. What do you think?
>
> I guess that would make sense. I'll make a separate patch just for
that
> change if that's OK.
>
Simple change -- patch attached.
test=# select * from myfoo1() as z;
z
----
1
2
3
(3 rows)
Bruce Momjian [Tue, 6 Aug 2002 05:33:29 +0000 (05:33 +0000)]
The attached patch disallows the use of coldeflists for functions that
don't return type RECORD. It also catches a core dump condition when a
function returning RECORD had an alias list instead of a coldeflist.
Bruce Momjian [Tue, 6 Aug 2002 05:24:04 +0000 (05:24 +0000)]
This patch changes the behavior of PostgreSQL so that if any queries are
executed in an implicitely aborted transaction (e.g. after an occur
occurs), we return an error (and not just a warning). For example:
nconway=# begin;
BEGIN
nconway=# insert; -- syntax error
ERROR: parser: parse error at or near ";"
nconway=# select * from a;
ERROR: current transaction is aborted, queries ignored until end of
transaction block
The old behavior was:
nconway=# begin;
BEGIN
nconway=# insert;
ERROR: parser: parse error at or near ";"
nconway=# select * from a;
WARNING: current transaction is aborted, queries ignored until end
of transaction block
*ABORT STATE*
Which can be confusing: if the client isn't paying careful attention,
they will conclude that the query has executed (because no error is
returned).
Tom Lane [Tue, 6 Aug 2002 02:36:35 +0000 (02:36 +0000)]
Restructure local-buffer handling per recent pghackers discussion.
The local buffer manager is no longer used for newly-created relations
(unless they are TEMP); a new non-TEMP relation goes through the shared
bufmgr and thus will participate normally in checkpoints. But TEMP relations
use the local buffer manager throughout their lifespan. Also, operations
in TEMP relations are not logged in WAL, thus improving performance.
Since it's no longer necessary to fsync relations as they move out of the
local buffers into shared buffers, quite a lot of smgr.c/md.c/fd.c code
is no longer needed and has been removed: there's no concept of a dirty
relation anymore in md.c/fd.c, and we never fsync anything but WAL.
Still TODO: improve local buffer management algorithms so that it would
be reasonable to increase NLocBuffer.
Add User's Guide chapters on Data Definition and Data Manipulation.
Still needs to be filled with more information, but it gives us a
framework to have a User's Guide with complete coverage of the basic
SQL operations. Move arrays into data type chapter, inheritance into
DDL chapter (for now).
Make <comment>s show up in the output while the version number ends in
"devel".
Allow cross-book references with entities &cite-user; etc.
Tom Lane [Mon, 5 Aug 2002 03:29:17 +0000 (03:29 +0000)]
Restructure system-catalog index updating logic. Instead of having
hardwired lists of index names for each catalog, use the relcache's
mechanism for caching lists of OIDs of indexes of any table. This
reduces the common case of updating system catalog indexes to a single
line, makes it much easier to add a new system index (in fact, you
can now do so on-the-fly if you want to), and as a nice side benefit
improves performance a little. Per recent pghackers discussion.
Tom Lane [Mon, 5 Aug 2002 02:30:50 +0000 (02:30 +0000)]
Preliminary code review for anonymous-composite-types patch: fix breakage
of functions returning domain types, update documentation for typtype,
move get_typtype to lsyscache.c (actually, resurrect the old version),
add defense against creating pseudo-typed table columns, fix some
bogus list-parsing in grammar. Issues remain with respect to alias
handling and type checking; Joe is on those.
Bruce Momjian [Sun, 4 Aug 2002 19:48:11 +0000 (19:48 +0000)]
Attached are two patches to implement and document anonymous composite
types for Table Functions, as previously proposed on HACKERS. Here is a
brief explanation:
1. Creates a new pg_type typtype: 'p' for pseudo type (currently either
'b' for base or 'c' for catalog, i.e. a class).
2. Creates new builtin type of typtype='p' named RECORD. This is the
first of potentially several pseudo types.
3. Modify FROM clause grammer to accept:
SELECT * FROM my_func() AS m(colname1 type1, colname2 type1, ...)
where m is the table alias, colname1, etc are the column names, and
type1, etc are the column types.
4. When typtype == 'p' and the function return type is RECORD, a list
of column defs is required, and when typtype != 'p', it is
disallowed.
5. A check was added to ensure that the tupdesc provide via the parser
and the actual return tupdesc match in number and type of
attributes.
When creating a function you can do:
CREATE FUNCTION foo(text) RETURNS setof RECORD ...
When using it you can do:
SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp)
Included in the patches are adjustments to the regression test sql and
expected files, and documentation.
p.s.
This potentially solves (or at least improves) the issue of builtin
Table Functions. They can be bootstrapped as returning RECORD, and
we can wrap system views around them with properly specified column
defs. For example:
CREATE VIEW pg_settings AS
SELECT s.name, s.setting
FROM show_all_settings()AS s(name text, setting text);
Then we can also add the UPDATE RULE that I previously posted to
pg_settings, and have pg_settings act like a virtual table, allowing
settings to be queried and set.
Implement IS OF and IS NOT OF type predicate.
Can now do queries of the form: SELECT value IS OF (integer, float8);
Define macros for handling typmod manipulation for date/time types.
Should be more robust than all of that brute-force inline code.
Rename macros for masking and typmod manipulation to put TIMESTAMP_
or INTERVAL_ in front of the macro name, to reduce the possibility
of name space collisions.
Allow bit string constants without fully-specified length declaration.
Try implementing CREATE TABLE/OF as a mapping to inheritance.
May be appropriate, or may be replace later with something more exactly
like one might expect from databases without the feature.
Add guard code to protect from buffer overruns on long date/time input
strings. Should go back in and look at doing this a bit more elegantly
and (hopefully) cheaper. Probably not too bad anyway, but it seems a
shame to scan the strings twice: once for length for this buffer overrun
protection, and once to parse the line.
Remove use of pow() in date/time handling; was already gone from everything
*but* the time data types.
Define macros for handling typmod manipulation for date/time types.
Should be more robust than all of that brute-force inline code.
Rename macros for masking and typmod manipulation to put TIMESTAMP_
or INTERVAL_ in front of the macro name, to reduce the possibility
of name space collisions.
Define macros for handling typmod manipulation for date/time types.
Should be more robust than all of that brute-force inline code.
Rename macros for masking and typmod manipulation to put TIMESTAMP_
or INTERVAL_ in front of the macro name, to reduce the possibility
of name space collisions.
Implement hex literal conversion to bit string literal.
May not be the long-term solution (some continuing discussion with
Peter E.) but better than the current mapping of a conversion to integer
which I'd put in years ago before we had any bit string types at all.
This is already supported in the bit string implementation elsewhere.
Allow bit string constants without fully-specified length declaration.
Implement conversion between 8-byte integers and bit strings.
Similar to what is done for 4-byte integers.
Bruce Momjian [Sun, 4 Aug 2002 05:11:37 +0000 (05:11 +0000)]
[ Previous patch reversed.]
Please use this patch instead of my previously submitted one.
It is just remerged against HEAD for new alter_table.out stuff.
Another reason this patch is useful for _interactive_ users: imagine a
view based on a many way join. Imagine creating a complicated insert
rule that inserts into all the joined tables and when you insert you get
a check failure, but you need to know which actual table the constraint
was on that failed!
Bruce Momjian [Sun, 4 Aug 2002 05:09:36 +0000 (05:09 +0000)]
This patch fixes a probably harmless write of uninitialized memory in
the statistics collector and makes a number of corrections to the
documentation for SET, SHOW, and COPY.
Bruce Momjian [Sun, 4 Aug 2002 05:02:50 +0000 (05:02 +0000)]
please find attached patch to current CVS ( contrib/ltree )
Changes:
July 31, 2002
Now works on 64-bit platforms.
Added function lca - lowest common ancestor
Version for 7.2 is distributed as separate package -
http://www.sai.msu.su/~megera/postgres/gist/ltree/ltree-7.2.tar.gz
Bruce Momjian [Sun, 4 Aug 2002 04:31:44 +0000 (04:31 +0000)]
The attached patch implements START TRANSACTION, per SQL99. The
functionality of the command is basically identical to that of
BEGIN; it just accepts a few extra options (only one of which
PostgreSQL currently implements), and is standards-compliant.
The patch includes a simple regression test and documentation.
Bruce Momjian [Sun, 4 Aug 2002 04:28:10 +0000 (04:28 +0000)]
This patch fixes in intermittent failure in the regression tests:
there was a race condition between the "alter_table" and "rules"
regression tests. Depending on scheduling, sometimes an ALTER
TABLE command would operate on a relation created by the "rules"
tests, leading to unexpected results.
Bruce Momjian [Sun, 4 Aug 2002 03:59:09 +0000 (03:59 +0000)]
I send a simple patch for PL/pgSQL parser which allow now to use
whitespaces in identifers of any kind(table names,attribute
names,variables ...) in Pl/pgSQL procedural language.Explicit definition
of bug can be found in Re: [HACKERS] Bug of PL/pgSQL parser
TODO item completed:
o -Fix PL/PgSQL to handle quoted mixed-case identifiers
Tom Lane [Fri, 2 Aug 2002 22:36:05 +0000 (22:36 +0000)]
When compiling with --enable-cassert, check for reference count leaks
in the relcache. It's rather silly that we have reference count leak
checks in bufmgr and in catcache, but not in relcache which will normally
have many fewer entries. Chris K-L would have caught at least one bug
in his recent DROP patch if he'd had this.
Tom Lane [Fri, 2 Aug 2002 21:54:34 +0000 (21:54 +0000)]
RemoveAttrDefaultById() neglected to obtain exclusive lock on the
relation being modified. In most paths of control we'd already have
such a lock, but if we were dropping the default due to a cascaded
delete of some function it depended on, maybe not.
Tom Lane [Fri, 2 Aug 2002 18:15:10 +0000 (18:15 +0000)]
ALTER TABLE DROP COLUMN works. Patch by Christopher Kings-Lynne,
code review by Tom Lane. Remaining issues: functions that take or
return tuple types are likely to break if one drops (or adds!)
a column in the table defining the type. Need to think about what
to do here.
Along the way: some code review for recent COPY changes; mark system
columns attnotnull = true where appropriate, per discussion a month ago.