Tom Lane [Sat, 24 Aug 2002 15:00:47 +0000 (15:00 +0000)]
The cstring datatype can now be copied, passed around, etc. The typlen
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.
Barry Lind [Fri, 23 Aug 2002 20:45:49 +0000 (20:45 +0000)]
Enhancements to how queries with bind values are stored internally and sent to
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.
Tom Lane [Fri, 23 Aug 2002 16:41:38 +0000 (16:41 +0000)]
Further cleanup around the edges of OPAQUE/pseudotype changes. Correct
the declarations of some index access method support functions. Support
SQL functions returning VOID.
Bruce Momjian [Fri, 23 Aug 2002 02:54:18 +0000 (02:54 +0000)]
This patch updates the CREATE OPERATOR sgml docs for the new default
settings of NAMEDATALEN. I looked through the docs for other
references to NAMEDATALEN, but this is the only one I could find.
Tom Lane [Thu, 22 Aug 2002 14:23:36 +0000 (14:23 +0000)]
Code review for recent TRUNCATE changes. Tighten relation-kind check,
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.
Bruce Momjian [Thu, 22 Aug 2002 04:56:44 +0000 (04:56 +0000)]
Fix for documention:
>>" It's also possible to select no escape character by writing ESCAPE ''.
>>In this case there is no way to turn off the special meaning of
>>underscore and percent signs in the pattern."
Bruce Momjian [Thu, 22 Aug 2002 04:55:05 +0000 (04:55 +0000)]
This patch should fix the problem. Doesn't include my previous patch
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.)
Bruce Momjian [Thu, 22 Aug 2002 04:45:11 +0000 (04:45 +0000)]
As suggested by Tom, this patch restricts the right-hand argument of
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.
Bruce Momjian [Thu, 22 Aug 2002 03:24:01 +0000 (03:24 +0000)]
Add:
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
Marc G. Fournier [Thu, 22 Aug 2002 00:15:14 +0000 (00:15 +0000)]
Okay, libpq++ is moved to GBorg, and all traces of it have been removed
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 ...
Tom Lane [Thu, 22 Aug 2002 00:01:51 +0000 (00:01 +0000)]
Add a bunch of pseudo-types to replace the behavior formerly associated
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 ...
Tom Lane [Tue, 20 Aug 2002 16:46:29 +0000 (16:46 +0000)]
Increase buffer size in cash_words(). Pure paranoia; I don't think the
code is broken, but any small change in the output format might overrun
the buffer with the old size.
Bruce Momjian [Tue, 20 Aug 2002 05:28:24 +0000 (05:28 +0000)]
This patch improves the behavior of FOUND in PL/PgSQL. In Oracle,
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.
Bruce Momjian [Tue, 20 Aug 2002 04:46:00 +0000 (04:46 +0000)]
Add current_database().
> 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.
Tom Lane [Mon, 19 Aug 2002 19:33:36 +0000 (19:33 +0000)]
Fix pg_dump to dump serial columns as serials. Per pghackers discussion,
cause SERIAL column declaration not to imply UNIQUE, so that this can be
done without creating an extra index.
Tom Lane [Mon, 19 Aug 2002 15:08:47 +0000 (15:08 +0000)]
Remove Ident nodetype in favor of using String nodes; this fixes some
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.
Tom Lane [Mon, 19 Aug 2002 00:11:53 +0000 (00:11 +0000)]
Add missing copyfuncs/equalfuncs entries, including T_Null which has
been missing forever; surprising it wasn't noticed before. The other
additions are, um, sloppiness in certain recent feature additions.
Tom Lane [Sun, 18 Aug 2002 18:46:15 +0000 (18:46 +0000)]
Remove optimization whereby parser would make only one sort-list entry
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.
Bruce Momjian [Sun, 18 Aug 2002 01:39:43 +0000 (01:39 +0000)]
Back out tcl patch, per Tom Lane:
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
Bruce Momjian [Sat, 17 Aug 2002 13:06:50 +0000 (13:06 +0000)]
In that case, attached is a patch which locates the beginning of 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
Bruce Momjian [Sat, 17 Aug 2002 13:04:19 +0000 (13:04 +0000)]
[ Newest version of patch applied.]
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...)
Bruce Momjian [Sat, 17 Aug 2002 12:19:31 +0000 (12:19 +0000)]
What I have done for libpgtcl:
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).
Tom Lane [Fri, 16 Aug 2002 23:01:21 +0000 (23:01 +0000)]
Modify pg_dump to dump foreign-key constraints as constraints, not as
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.