Bruce Momjian [Thu, 6 Sep 2001 03:11:59 +0000 (03:11 +0000)]
Attached is a patch for current CVS, consisting of a cvs diff -c
for the changed files and a few new files:
- test/jdbc2/BatchExecuteTest.java
- util/MessageTranslator.java
- jdbc2/PBatchUpdateException.java
As an aside, is this the best way to submit a patch consisting
of both changed and new files? Or is there a smarter cvs command
which gets them all in one patch file?
This patch fixes batch processing in the JDBC driver to be
JDBC-2 compliant. Specifically, the changes introduced by this
patch are:
1) Statement.executeBatch() no longer commits or rolls back a
transaction, as this is not prescribed by the JDBC spec. Its up
to the application to disable autocommit and to commit or
rollback the transaction. Where JDBC talks about "executing the
statements as a unit", it means executing the statements in one
round trip to the backend for better performance, it does not
mean executing the statements in a transaction.
2) Statement.executeBatch() now throws a BatchUpdateException()
as required by the JDBC spec. The significance of this is that
the receiver of the exception gets the updateCounts of the
commands that succeeded before the error occurred. In order for
the messages to be translatable, java.sql.BatchUpdateException
is extended by org.postgresql.jdbc2.PBatchUpdateException() and
the localization code is factored out from
org.postgresql.util.PSQLException to a separate singleton class
org.postgresql.util.MessageTranslator.
3) When there is no batch or there are 0 statements in the batch
when Statement.executeBatch() is called, do not throw an
SQLException, but silently do nothing and return an update count
array of length 0. The JDBC spec says "Throws an SQLException if
the driver does not support batch statements", which is clearly
not the case. See testExecuteEmptyBatch() in
BatchExecuteTest.java for an example. The message
postgresql.stat.batch.empty is removed from the language
specific properties files.
4) When Statement.executeBatch() is performed, reset the
statement's list of batch commands to empty. The JDBC spec isn't
100% clear about this. This behaviour is only documented in the
Java tutorial
(http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/batchupdates.html).
Note that the Oracle JDBC driver also resets the statement's
list in executeBatch(), and this seems the most reasonable
interpretation.
5) A new test case is added to the JDBC test suite which tests
various aspects of batch processing. See the new file
BatchExecuteTest.java.
Bruce Momjian [Thu, 6 Sep 2001 02:58:33 +0000 (02:58 +0000)]
On Sat, Aug 25, 2001 at 08:15:45PM -0400, Bruce Momjian wrote:
> Can someone research this and figure out what the proper solution for
> this is? Seems we are going around in circles if we keep
> adding/removing DLLIMPORT.
I believe that the attached patch is the correct solution -- I apologize
for the gyrations. With the attached patch, Cygwin libpq++ builds
cleanly again. The root cause was that DLLIMPORT was defaulting to
__declspec(dllimport) since BUILDING_DLL was *not* defined when building
the libpq++ DLL.
Unfortunately, to test my patch requires changing the following makefile:
src/interfaces/libpq++/examples/Makefile
and the #includes in all of the *.cc to build against the source tree
instead of the following hardcoded installation directory structure:
/usr/local/pgsql
I was able to manually build
src/interfaces/libpq++/examples/testlibpq0.exe
against my Cygwin libpq++ without errors. However, I have not tried to
actually test testlibpq0.exe.
Is this sufficient? Or, do you want me to clean up libpq++/examples too?
(Or, is it silly to even ask? :,)) Let me know how you want to proceed and
I will submit a patch to pgsql-patches.
Bruce Momjian [Thu, 6 Sep 2001 02:56:32 +0000 (02:56 +0000)]
Next version of patch.
Now with documentation update and disabling of UTF conversion for Tcl <=8.0
On Fri, 24 Aug 2001, Vsevolod Lobko wrote:
> On Thu, 23 Aug 2001, Tom Lane wrote:
>
> > > Is this looks better?
> >
> > It does, but one small gripe: the lack of semicolons will probably cause
> > pg_indent to mess up the indentation. (I know emacs' autoindent mode
> > will not work nicely with it, either.) Please set up the macros so that
> > you write
> >
> > UTF_BEGIN;
> > Tcl_DStringAppend(&unknown_src, UTF_E2U(part), -1);
> > UTF_END;
> >
> > and then I'll be happy.
>
> Attached revised patch
>
> > Your point about overhead is a good one, so I retract the gripe about
> > using a configure switch. But please include documentation patches to
> > describe the configure option in the administrator's guide (installation
> > section).
>
> This patch still uses configure switch for enabling feature.
>
> For enabling based on tcl version we have 2 posibilites:
> 1) having feature enabled by default, but in pltcl.c check for tcl
> version and disable it for old versions
> 2) enable or disable at configure time based on tcl version, but there
> are problem - current configure don't checks for tcl version at all
> and my configure skills not enought for adding this
>
Bruce Momjian [Thu, 6 Sep 2001 02:54:56 +0000 (02:54 +0000)]
Below is the patch against current cvs for libpgtcl and
two additional files win32.mak and libpgtcl.def.
This patch allows to compile libpgtcl.dll on Windows
with tcl > 8.0. I've tested it on WinNT (VC6.0), SUSE Linux (7.0)
and Solaris 2.6 with tcl 8.3.3.
Bruce Momjian [Thu, 6 Sep 2001 02:52:00 +0000 (02:52 +0000)]
Hello, i just reviewed the win32 errno patch and i saw that maybe i didn't
really played it totally safe in my last suggestion, the system table might
pick up the msg but not the netmsg.dll, so better try both.
I also added a hex printout of the "errno" appended to all messages, that's
nicer.
If anyone hate my coding style, or that i'm using goto constructs, just tell
me, and i'll rework it into a nested if () thing.
Tom Lane [Thu, 6 Sep 2001 02:07:42 +0000 (02:07 +0000)]
Fix handling of pg_type.typdefault per bug report from Dave Blasby.
If there's anyone out there who's actually using datatype-defined
default values, this will be an incompatible change in behavior ...
but the old behavior was so broken that I doubt anyone was using it.
Tom Lane [Thu, 6 Sep 2001 02:02:48 +0000 (02:02 +0000)]
Add some debugging details to some of the elog(STOP) conditions for WAL.
Standardize on %X/%X as the formatting for XLOG position display --- we
had a couple of different formats before, and none of 'em were as useful
as hex offsets IMHO.
Tom Lane [Tue, 4 Sep 2001 21:42:17 +0000 (21:42 +0000)]
Fix code so that we recover cleanly if there are no free semaphores
available in freeSemMap. As noted by Tatsuo, this is now a likely
scenario for detecting MaxBackends-exceeded; if MaxBackends is a multiple
of PROC_NSEMS_PER_SET then we will fail here and not in sinval.c. The
cleanup path did not work correctly before, anyway.
Tom Lane [Tue, 4 Sep 2001 02:26:57 +0000 (02:26 +0000)]
Clean up the lock state properly when aborting because of early deadlock
detection in ProcSleep(). Bug noted by Tomasz Zielonka --- how did this
escape detection for this long??
Peter Eisentraut [Wed, 29 Aug 2001 19:14:40 +0000 (19:14 +0000)]
Install the SQL command man pages into a section appropriate for each
system. Some systems did not understand the 'l' section, and in general
it wasn't entirely appropriate.
On SCO OpenServer, the man pages won't be installed at all until someone
figures out their man system.
Tom Lane [Mon, 27 Aug 2001 23:02:25 +0000 (23:02 +0000)]
Suppress definitions of 'true' and 'false' macros if __cplusplus.
Since we're assuming a C++ compiler knows what 'bool' is, seems we
should assume it knows 'true' and 'false' too. This prevents problems
on some systems, per report from Leandro Fanzone.
Tom Lane [Mon, 27 Aug 2001 20:33:07 +0000 (20:33 +0000)]
Use a cursor for fetching data in -d or -D mode, so that pg_dump doesn't
run out of memory with large tables in these modes. Patch from
Martijn van Oosterhout.
Tom Lane [Mon, 27 Aug 2001 00:44:40 +0000 (00:44 +0000)]
Un-break pg_dump --- pg_class.indproc is now regproc not oid, which
for some reason displays a zero oid differently. Possibly we should
revert that schema change, but it's easy to make pg_dump accept both
spellings so I'll do that for now.
Peter Eisentraut [Sun, 26 Aug 2001 23:54:41 +0000 (23:54 +0000)]
VPATH and DESTDIR support for PL/Perl, using the same techniques employed
in interfaces/perl5 a brief while ago.
Also, since building PL/Perl without a shared libperl actually works on
some platforms we can enable it there to get some development happening.
I've only checked off linux right now, but others should be added in the
future.
Tom Lane [Sun, 26 Aug 2001 21:17:12 +0000 (21:17 +0000)]
Documentation for transaction-ID-wraparound changes. Add a chapter to
the Admin Guide about routine maintenance tasks. Currently this only
discusses the various reasons for doing VACUUM, but perhaps it could be
fleshed out with topics like log rotation.
Bruce Momjian [Sun, 26 Aug 2001 17:08:48 +0000 (17:08 +0000)]
Please pull this patch. It breaks JDBC1 support. The JDBC1 code no
longer compiles, due to objects being referenced in this patch that do
not exist in JDK1.1.
Barry Lind
---------------------------------------------------------------------------
in the policy file of the application using the JDBC driver
in the postgresql.jar file. Since the Socket() call in the
driver is not protected by AccessController.doPrivileged() this
permission must also be granted to the entire application.
Bruce Momjian [Sun, 26 Aug 2001 01:06:20 +0000 (01:06 +0000)]
>>>>The JDBC driver requires
>>>>
>>>> permission java.net.SocketPermission "host:port", "connect";
>>>>
>>>>in the policy file of the application using the JDBC driver
>>>>in the postgresql.jar file. Since the Socket() call in the
>>>>driver is not protected by AccessController.doPrivileged() this
>>>>permission must also be granted to the entire application.
>>>>
>>>>The attached diff fixes it so that the connect permission can be
>>>>restricted just the the postgresql.jar codeBase if desired.
Bruce Momjian [Sun, 26 Aug 2001 00:54:42 +0000 (00:54 +0000)]
The attached file: SerializePatch2.tgz, contains a patch for
org.postgresql.util.Serialize and org.postgresql.jdbc2.PreparedStatement
that fixes the ability to "serialize" a simple java class into a
postgres table.
The current cvs seems completely broken in this support, so the patch
puts it into working condition, granted that there are many limitations
with serializing java classes into Postgres.
The code to do serialize appears to have been in the driver since
Postgres 6.4, according to some comments in the source. My code is not
adding any totally new ability to the driver, rather just fixing what
is there so that it actually is usable. I do not think that it should
affect any existing functions of the driver that people regularly
depend on.
The code is activated if you use jdbc2.PreparedStatement and try to
setObject some java class type that is unrecognized, like not String or
not some other primitive type. This will cause a sequence of function
calls that results in an instance of Serialize being instantiated for
the class type passed. The Serialize constructor will query pg_class
to see if it can find an existing table that matches the name of the
java class. If found, it will continue and try to use the table to
store the object, otherwise an SQL exception is thrown and no harm is
done. Serialize.create() has to be used to setup the table for a java
class before anything can really happen with this code other than an
SQLException (unless by some freak chance a table exists that it thinks
it can use).
I saw a difference in Serialize.java between 7.1.3 and 7.2devel that I
didn't notice before, so I had to redo my changes from the 7.2devel
version (why I had to resend this patch now). I was missing the
fixString stuff, which is nice and is imporant to ensure the inserts
will not fail due to embedded single quote or unescaped backslashes. I
changed that fixString function in Serialize just a little since there
is no need to muddle with escaping newlines: only escaping single quote
and literal backslashes is needed. Postgres appears to insert newlines
within strings without trouble.
Tom Lane [Sat, 25 Aug 2001 18:52:43 +0000 (18:52 +0000)]
Replace implementation of pg_log as a relation accessed through the
buffer manager with 'pg_clog', a specialized access method modeled
on pg_xlog. This simplifies startup (don't need to play games to
open pg_log; among other things, OverrideTransactionSystem goes away),
should improve performance a little, and opens the door to recycling
commit log space by removing no-longer-needed segments of the commit
log. Actual recycling is not there yet, but I felt I should commit
this part separately since it'd still be useful if we chose not to
do transaction ID wraparound.
Bruce Momjian [Fri, 24 Aug 2001 16:50:18 +0000 (16:50 +0000)]
Attached is a patch to fix the current issues with building under jdbc1.
This patch moves the logic that looks up TypeOid, PGTypeName, and
SQLTypeName from Field to Connection. It is moved to connection since
it needs to differ from the jdbc1 to jdbc2 versions and Connection
already has different subclasses for the two driver versions. It also
made sense to move the logic to Connection as some of the logic was
already there anyway.
Tom Lane [Thu, 23 Aug 2001 23:06:38 +0000 (23:06 +0000)]
Ensure that all TransactionId comparisons are encapsulated in macros
(TransactionIdPrecedes, TransactionIdFollows, etc). First step on the
way to transaction ID wrap solution ...
Tom Lane [Thu, 23 Aug 2001 15:10:17 +0000 (15:10 +0000)]
Remove test of 'inf' since it introduces a platform dependency (some
Unixen spell it 'Inf'). Not worth adding multiple expected files and
a resultmap just for this.
Tom Lane [Thu, 23 Aug 2001 00:49:46 +0000 (00:49 +0000)]
Allow the return value of an SQL function to be binary-compatible with
the declared result type, rather than requiring exact type match as
before. Per pghackers discusssion of 14-Aug.
Peter Eisentraut [Wed, 22 Aug 2001 20:23:24 +0000 (20:23 +0000)]
Add option to output SET SESSION AUTHORIZATION commands rather than
\connect, to avoid possible password prompts and such, at the drawback of
having to have superuser access.