anonymous return type SRF code. It gets rid of the superflous
'pg_locks_result' that Bruce/Tom had commented on. Otherwise, no
changes in functionality.
Neil Conway
the 'override CPPFLAGS' to include the source directory during compile,
and makes the install target look in the proper place for the man page.
Changes are only required when building outside the source directory.
J. R. Nield
copying into a fixed-size buffer (in this case, a buffer of
NAMEDATALEN bytes). AFAICT nothing to worry about here, but worth
fixing anyway...
Neil Conway
bit on the indexes.
I also attach clusterdb and clusterdb.sgml; both of them are blatant
rips of vacuumdb and vacuumdb.sgml, but get the job done. Please review
them, as I'm probably making a lot of mistakes with SGML and I can't
compile it here.
vacuumdb itself is not very comfortable to use when the databases have
passwords, because it has to connect once for each table (I can probably
make it connect only once for each database; should I?). Because of
this I added a mention of PGPASSWORDFILE in the documentation, but I
don't know if that is the correct place for that.
Alvaro Herrera
that ANALYZE would not gather any stats for a CHAR(255) column. I still
think a width threshold is appropriate for the reasons mentioned in the
code, but we can loosen it at least.
array header, and to compute sizing and alignment of array elements
the same way normal tuple access operations do --- viz, using the
tupmacs.h macros att_addlength and att_align. This makes the world
safe for arrays of cstrings or intervals, and should make it much
easier to write array-type-polymorphic functions; as examples see
the cleanups of array_out and contrib/array_iterator. By Joe Conway
and Tom Lane.
width types and varlena types, since with the introduction of CSTRING as
a more-or-less-real type, these concepts aren't identical. I've tried to
use varlena consistently to denote datatypes with typlen = -1, ie, they
have a length word and are potentially TOASTable; while the term variable
width covers both varlena and cstring (and, perhaps, someday other types
with other rules for computing the actual width). No code changes in this
commit except for renaming a couple macros.
value '-2' is used to indicate a variable-width type whose width is
computed as strlen(datum)+1. Everything that looks at typlen is updated
except for array support, which Joe Conway is working on; at the moment
it wouldn't work to try to create an array of cstring.
the server. Previously we allocated a new String object for the entire final
query we were sending to the database. If you had a big query, or especially
if you had large bind values you ended up with essentially two copies in memory.
This change will reuse the existing objects and therefore should take 1/2 the
memory it does today for a given query. This restructuring will also allow
in the future the ability to stream bytea data to the server instead of the current approach of pulling it all into memory.
I also fixed a test that was failing on a 7.2 database.
Also renamed some internal variables and some minor cleanup.
Modified Files:
jdbc/org/postgresql/core/QueryExecutor.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
tighten foreign-key check (a self-reference should not prevent TRUNCATE),
improve error message, cause a relation's TOAST table to be truncated
along with the relation.
for repeat(). Again, somewhat off-the-cuff, so I might have missed
something...
test=# select lpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');
ERROR: Requested length too large
test=# select rpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');
ERROR: Requested length too large
(That's on a Unicode DB, haven't tested other encodings but AFAICT
this fix should still work.)
Neil Conway
> Neil Conway <neilc@samurai.com> writes:
> > + /* Check for integer overflow */
> > + if (tlen / slen != count)
> > + elog(ERROR, "Requested buffer is too large.");
>
> What about slen == 0?
Good point -- that wouldn't cause incorrect results or a security
problem, but it would reject input that we should really accept.
Revised patch is attached.
Neil Conway
constraints
The issue with finding and removing foreign key constraints is no longer
an issue, so please apply the attached.
It does NOT check for rules or on delete triggers (old style foreign
keys) as those are difficult to deal with (remove, truncate, re-add).
Rod Taylor
bytealike to TEXT.
This leaves like_escape_bytea() without anything to do, but I left it in
place in anticipation of the eventual bytea pattern selectivity
functions. If there is agreement that this would be the best long term
solution, I'll take it as a TODO for 7.4.
Joe Conway
replace(string, from, to)
-- replaces all occurrences of "from" in "string" to "to"
split(string, fldsep, column)
-- splits "string" on "fldsep" and returns "column" number piece
to_hex(int32_num) & to_hex(int64_num)
-- takes integer number and returns as hex string
Joe Conway
from the core repository ... I haven't *moved* the libpq++ files out of the
tree, mainly as we want to keep them in place for past branches ...
Peter, I think I've covered all the files I need, and re-ran autoconf to make
sure the configure file is in place properly ...
with OPAQUE, as per recent pghackers discussion. I still want to do some
more work on the 'cstring' pseudo-type, but I'm going to commit the bulk
of the changes now before the tree starts shifting under me ...
FOUND is set whenever a SELECT INTO returns > 0 rows, *or* when an
INSERT, UPDATE, or DELETE affects > 0 rows. We implemented the first
part of this behavior, but not the second.
I also improved the documentation on the various situations in which
FOUND can be set (excluding inside FOR loops, which I still need to
think about), and added some regression tests for this behavior.
Neil Conway
> Quick system function to pull out the current database.
>
> I've used this a number of times to allow stored procedures to find out
> where they are. Especially useful for those that do logging or hit a
> remote server.
>
> It's called current_database() to match with current_user().
It's also a necessity for an informational schema. The catalog
(database) name is required in a number of places.
Rod Taylor
for the last two releases.
Modified Files:
jdbc/org/postgresql/Driver.java.in
jdbc/org/postgresql/PG_Stream.java
Removed Files:
jdbc/org/postgresql/core/BytePoolDim1.java
jdbc/org/postgresql/core/BytePoolDim2.java
jdbc/org/postgresql/core/MemoryPool.java
jdbc/org/postgresql/core/ObjectPool.java
jdbc/org/postgresql/core/SimpleObjectPool.java
latent wrong-struct-type bugs and makes the coding style more uniform,
since the majority of places working with lists of column names were
already using Strings not Idents. While at it, remove vestigial
support for Stream node type, and otherwise-unreferenced nodes.h entries
for T_TupleCount and T_BaseNode.
NB: full recompile is recommended due to changes of Node type numbers.
This shouldn't force an initdb though.
when two equal() targetlist items were to be added to an ORDER BY or
DISTINCT list. Although indeed this would make sorting fractionally
faster by sometimes saving a comparison, it confuses the heck out of
later stages of processing, because it makes it look like the user
wrote DISTINCT ON rather than DISTINCT. Bug reported by joe@piscitella.com.
The -n and -N options were removed. Quoting is now smart enough to
supply quotes if and only if necessary.
Numerical types are now printed without quotes, except in cases of
special values such as NaN.
Boolean values printed as true and false.
Most string literals now do not escape whitespace characters (newlines,
etc.) for portability.
SET SESSION AUTHORIZATION argument is a string literal, to follow SQL.
Made commands output by pg_dump use consistent spacing and indentation.
Everytime if I do PQconsumeInput (when the backend channel gets
readable) I check for the return value. (0 == error) and generate a
notification manually, e.g. fixed string connection_closed) and pass it to the
offending token more efficiently (per your suggestion of using
scanbuf). The new patch does the same as before:
template1=# select * frum pg_class;
ERROR: parser: parse error at or near "frum" at character 10
It also implement's Tom's suggestion:
template1=# select * from pg_class where\g
ERROR: parse: parse error at end of input
Gavin Sherry
This patch is an updated version of the lock listing patch. I've made
the following changes:
- write documentation
- wrap the SRF in a view called 'pg_locks': all user-level
access should be done through this view
- re-diff against latest CVS
One thing I chose not to do is adapt the SRF to use the anonymous
composite type code from Joe Conway. I'll probably do that eventually,
but I'm not really convinced it's a significantly cleaner way to
bootstrap SRF builtins than the method this patch uses (of course, it
has other uses...)
Neil Conway
Everytime if I do PQconsumeInput (when the backend channel gets
readable) I check for the return value. (0 == error) and generate a
notification manually, e.g. fixed string connection_closed) and pass it to the
TCL event queue. The only other thing I had to do is to comment out removing
all pending events in PgStopNotifyEventSource whenever the connection was
unexpectedly closed (so the manually generated event will not be deleted).
A broken backend connection triggers a notify event to the client (fixed
notification string "connection_closed") so proper action can be taken to switch
to another database server etc. Remember that this is event driven. If you have
applications, that have idle database connections most of the time, you'll get
immediate feedback of a dying server. Upon connection to the server issue a
pg_notify for notify event "connection_closed" and whenever the backend crashes
(which it does do in very very rare cases) you get an event driven recovery. (of
course the Tcl-Event loop has to be processed). Issuing a notification
"connection_closed" on a still working database could be used for switching to
another db-server (which I've actually impelemented right now).
Gerhard Hintermayer
sets of triggers. Also modify psql \d command to show foreign key
constraints as such and hide the triggers. pg_get_constraintdef()
function added to backend to support these. From Rod Taylor, code
review and some editorialization by Tom Lane.
> There's no longer a separate call to heap_storage_create in that routine
> --- the right place to make the test is now in the storage_create
> boolean parameter being passed to heap_create. A simple change, but
> it passeth patch's understanding ...
Thanks.
Attached is a patch against cvs tip as of 8:30 PM PST or so. Turned out
that even after fixing the failed hunks, there was a new spot in
bufmgr.c which needed to be fixed (related to temp relations;
RelationUpdateNumberOfBlocks). But thankfully the regression test code
caught it :-)
Joe Conway
syscat.py scripts were both modified. pg.py uses it to cache a list of
pks (which is seemingly does for every db connection) and various
attributes. syscat uses it to walk the list of system tables and
queries the various attributes from these tables.
In both cases, it seemingly makes sense to apply what you've requested.
Greg Copeland
saw a fix offered up. Since I'm gearing up to use Postgres and Python
soon, I figured I'd have a hand at trying to get this sucker addressed.
Apologies if this has already been plugged. I looked in the archives
and never saw a response.
At any rate, I must admit I don't think I fully understand the
implications of some of the changes I made even though they appear to be
straight forward. We all know the devil is in the details. Anyone more
knowledgeable is requested to review my changes. :(
I also updated the advanced.py script in a somewhat nonsensical fashion
to make use of an int8 field in an effort to test this change. It seems
to run okay, however, this is by no means an all exhaustive test. So,
it's possible that a bumpy road may lay ahead for some. On the other
hand...overflows (hopefully) previously lurked (long -> int conversion).
Greg Copeland
PGPASSWORDFILE environment variable. I have modified libpq to make use
of this variable. I present the first cut here.
Currently the format for the file should be
host:port:database:user:password
Alvaro Herrera
CREATE DOMAIN newint as int4;
CREATE TABLE tab (col newint unique);
ERROR: data type newint has no default operator class for access method
"btree"
You must specify an operator class for the index or define a
default operator class for the data type
Specifically, GetDefaultOpClass() finds 0 exact matches and 3 binary
compatible matches. Fetching getBaseType() of the attribute fixes the
problem for domains (see attachment).
Rod Taylor
composite type capability makes it possible to create a system view
based on a table function in a way that is hopefully palatable to
everyone. The attached patch takes advantage of this, moving
show_all_settings() from contrib/tablefunc into the backend (renamed
all_settings(). It is defined as a builtin returning type RECORD. During
initdb a system view is created to expose the same information presently
available through SHOW ALL. For example:
test=# select * from pg_settings where name like '%debug%';
name | setting
-----------------------+---------
debug_assertions | on
debug_pretty_print | off
debug_print_parse | off
debug_print_plan | off
debug_print_query | off
debug_print_rewritten | off
wal_debug | 0
(7 rows)
Additionally during initdb two rules are created which make it possible
to change settings by updating the system view -- a "virtual table" as
Tom put it. Here's an example:
Joe Conway
This concludes my changes that restructured the code to support JDBC3.
The jdbc unit tests were also resturctured to allow different tests between
jdbc2 and jdbc3, although currently make check (aka ant test) for JDBC3 just
runs the JDBC2 tests. Of special note the largeobject/PGblob and PGclob
classes have been moved under the jdbc2/jdbc3 specific directories as they
now differ by jdbc version. Also note that this checkin removes the
PostgresqlDataSource and files in the xa directory. A recent checkin has
added new datasource support that replaces the functionality provided by these
classes.
Modified Files:
jdbc/build.xml
jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
jdbc/org/postgresql/jdbc2/Array.java
jdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java
jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
jdbc/org/postgresql/jdbc2/Jdbc2DatabaseMetaData.java
jdbc/org/postgresql/jdbc2/Jdbc2PreparedStatement.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java
jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java
jdbc/org/postgresql/test/jdbc2/BlobTest.java
jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java
jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
jdbc/org/postgresql/test/jdbc2/DateTest.java
jdbc/org/postgresql/test/jdbc2/DriverTest.java
jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
jdbc/org/postgresql/test/jdbc2/MiscTest.java
jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
jdbc/org/postgresql/test/jdbc2/TimeTest.java
jdbc/org/postgresql/test/jdbc2/TimestampTest.java
jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
Added Files:
jdbc/org/postgresql/jdbc2/AbstractJdbc2Blob.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Clob.java
jdbc/org/postgresql/jdbc2/Jdbc2Blob.java
jdbc/org/postgresql/jdbc2/Jdbc2Clob.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java
jdbc/org/postgresql/jdbc3/Jdbc3Blob.java
jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
jdbc/org/postgresql/jdbc3/Jdbc3Clob.java
jdbc/org/postgresql/jdbc3/Jdbc3Connection.java
jdbc/org/postgresql/jdbc3/Jdbc3DatabaseMetaData.java
jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
jdbc/org/postgresql/jdbc3/Jdbc3ResultSetMetaData.java
jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
jdbc/org/postgresql/test/TestUtil.java
jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
Removed Files:
jdbc/org/postgresql/PostgresqlDataSource.java
jdbc/org/postgresql/largeobject/PGblob.java
jdbc/org/postgresql/largeobject/PGclob.java
jdbc/org/postgresql/test/JDBC2Tests.java
jdbc/org/postgresql/xa/ClientConnection.java
jdbc/org/postgresql/xa/TwoPhaseConnection.java
jdbc/org/postgresql/xa/TxConnection.java
jdbc/org/postgresql/xa/XAConnectionImpl.java
jdbc/org/postgresql/xa/XADataSourceImpl.java
sys = malloc(strlen(editorName) + strlen(fname) + 10 + 1);
if (!sys)
return false;
sprintf(sys, "exec '%s' '%s'", editorName, fname);
(note the added quotes to provide a little protection against spaces
and such). Then it's perfectly obvious what the calculation is doing.
I don't care about wasting 20-some bytes, but confusing readers of the
code is worth avoiding.
regards, tom lane
(they are not part of a chain). When failing to find a parent tuple in
an update chain, emit a warning and abandon repair_frag, but do not give
an error as before. This should eliminate the infamous 'No one parent tuple
was found' failure, which we now realize is not a can't-happen condition
but a perfectly valid database state. Per recent pghackers discussion.
heap_mark4update; this avoids situations where a deleted tuple might
look like it is chained to something else. Also, cause all the WAL
redo routines to set t_ctid to equal t_self, rather than leaving it
undefined as before. Make heap_xlog_clean set the page's LSN and SUI
correctly. All per past discussions in pghackers, ranging back to
last December.
to make a reasonable attempt at accounting for palloc overhead, not just
the requested size of each memory chunk. Since in many scenarios this
will make for a significant reduction in the amount of space acquired,
partially compensate by doubling the default value of SORT_MEM to 1Mb.
Per discussion in pgsql-general around 9-Jun-2002..
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'.
> 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.
Alvaro Herrera
> l.mode, l.isgranted from pg_lock_info() as l(relation oid, database oid,
> backendpid int4, mode text, isgranted bool);
> ERROR: badly formatted planstring "COLUMNDEF "...
>
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.
Joe Conway
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.
Alvaro Herrera (<alvherre[a]atentus.com>)
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.
Neil Conway
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.
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?'
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.
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.
>> 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)
Joe Conway
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.
Now both conditions throw an ERROR.
Joe Conway
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).
Neil Conway
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.
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.
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.
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.
Joe Conway
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.
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.
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.
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.
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!
Christopher Kings-Lynne
ERROR: ExecInsert: rejected due to CHECK constraint insert_con
To be like this:
ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on
"insert_tbl"
Updated regression tests to match.
I got sick of seeing 'rejected due to CHECK constraint "$1" in my log and
not being able to find the bug in our website code...
Christopher Kings-Lynne
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.
[ Regression tests removed, per Peter.]
Neil Conway
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.
Neil Conway
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
eutm
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.
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.
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.
attstattarget to indicate 'use the default'. The default is now a GUC
variable default_statistics_target, and so may be changed on the fly. Along
the way we gain the ability to have pg_dump dump the per-column statistics
target when it's not the default. Patch by Neil Conway, with some kibitzing
from Tom Lane.
this only works against 7.3 or later databases; the pushups required
to do it without regprocedure/regtype/etc seem more trouble than they're
worth, considering that existing users aren't expecting pg_dump support
for this.
'tioga recipes', whatever those are -- Peter E. killed most
of it a couple days ago, but this patch removes the rest. Most
of it was #ifdef'ed out anyway.
Neil Conway
The attached patch completes the following TODO item:
* Generate failure on short COPY lines rather than pad NULLs
I also restructed a lot of the existing COPY code, did some code
review on the column list patch sent in by Brent Verner a little
while ago, and added some regression tests. I also added an
explicit check (and resultant error) for extra data before
the end-of-line.
Neil Conway
a few other things:
* Made all references to the pg_* tables absolute, by specifying
the pg_catalog schema.
* Added SCHEMA as a create/delete completion option.
* Added SCHEMA completion as: SELECT nspname FROM
pg_catalog.pg_namespace
WHERE substr(nspname,1,%d)='%s'
* Added completion of "INSERT INTO <table> (" with attribute names.
* Added completion of "INSERT INTO <table> (attribs)" with
VALUES or SELECT
* Added limited locking completion: only for one table:
"LOCK" and "LOCK TABLE" now both get a completion list of tables
Complete with "IN" for LOCK [TABLE] <table>
Complete LOCK [TABLE] <table> IN with a lock mode
* Added a very simple WHERE finisher that uses the previous word
as a table lookup for attributes.
* Added quote support when parsing "previous words". In other words,
hitting tab after INSERT INTO "foo bar baby"
now does the right thing and recognizes "foo bar baby" as one word.
Letting tab-complete quote things that should be quoted seems to be
temporarily ifdef'ed out due to readline compatibility problems.
Can anyone elaborate on this?
Greg Sabino Mullane
deleted that had another row inserted/updated to its old
value during the same statement or other statements before the
integrity check for noaction would incorrectly error. This
could happen in deferred constraints or due to triggers or
functions. It's effectively a reworking of the previous patch that
did a not exists to instead do a separate check.
Stephan Szabo
changes mentioned above, and also adds a new function to the tablefunc
API. The tablefunc API change adds the following function:
* Oid foidGetTypeId(Oid foid) - Get a function's typeid given the
* function Oid. Use this together with TypeGetTupleDesc() to get a
* TupleDesc which is derived from the function's declared return type.
In the next post I'll send the contrib/tablefunc patch, which
illustrates the usage of this new function. Also attached is a doc patch
for this change. The doc patch also adds a function that I failed to
document previously.
Joe Conway
copied more places than I first thought it would. This fixes a bug:
a couple of these places were neglecting to enforce USAGE access on
explicitly-referenced schemas.
documentation (xindex.sgml should be rewritten), need to teach pg_dump
about it, need to update contrib modules that currently build pg_opclass
entries by hand. Original patch by Bill Studenmund, grammar adjustments
and general update for 7.3 by Tom Lane.
pg_language.lancompiler
pg_operator.oprprec
pg_operator.oprisleft
pg_proc.proimplicit
pg_proc.probyte_pct
pg_proc.properbyte_cpu
pg_proc.propercall_cpu
pg_proc.prooutin_ratio
pg_shadow.usetrace
pg_type.typprtlen
pg_type.typreceive
pg_type.typsend
Attempts to use the obsoleted attributes of pg_operator or pg_proc
in the CREATE commands will be greeted by a warning. For pg_type,
there is no warning (yet) because pg_dump scripts still contain these
attributes.
Also remove new but already obsolete spellings
isVolatile, isStable, isImmutable in WITH clause. (Use new syntax
instead.)
of duplicated code between the jdbc1 and jdbc2. This checkin restructures
the code so that the duplication is removed so that the jdbc3 support
can be added without adding yet another copy of everything. Also many
classes were renamed to avoid confusion with multiple different objects
having the same name. The timestamp tests were also updated to add support
for testing timestamp without time zone in addition to timestamp with time zone
Modified Files:
jdbc/Makefile jdbc/build.xml jdbc/example/ImageViewer.java
jdbc/example/basic.java jdbc/example/blobtest.java
jdbc/example/threadsafe.java
jdbc/org/postgresql/Driver.java.in
jdbc/org/postgresql/Field.java
jdbc/org/postgresql/core/QueryExecutor.java
jdbc/org/postgresql/fastpath/Fastpath.java
jdbc/org/postgresql/jdbc1/CallableStatement.java
jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
jdbc/org/postgresql/jdbc1/PreparedStatement.java
jdbc/org/postgresql/jdbc2/Array.java
jdbc/org/postgresql/jdbc2/CallableStatement.java
jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
jdbc/org/postgresql/jdbc2/PreparedStatement.java
jdbc/org/postgresql/jdbc2/UpdateableResultSet.java
jdbc/org/postgresql/largeobject/LargeObjectManager.java
jdbc/org/postgresql/largeobject/PGblob.java
jdbc/org/postgresql/largeobject/PGclob.java
jdbc/org/postgresql/test/jdbc2/BlobTest.java
jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
jdbc/org/postgresql/test/jdbc2/TimestampTest.java
jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
jdbc/org/postgresql/util/Serialize.java
Added Files:
jdbc/org/postgresql/PGConnection.java
jdbc/org/postgresql/PGStatement.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc1/Jdbc1Connection.java
jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
Removed Files:
jdbc/org/postgresql/Connection.java
jdbc/org/postgresql/ResultSet.java
jdbc/org/postgresql/Statement.java
jdbc/org/postgresql/jdbc1/Connection.java
jdbc/org/postgresql/jdbc1/ResultSet.java
jdbc/org/postgresql/jdbc1/Statement.java
jdbc/org/postgresql/jdbc2/Connection.java
jdbc/org/postgresql/jdbc2/ResultSet.java
jdbc/org/postgresql/jdbc2/Statement.java