Re: [pgsql-jdbc] dollar-quoted CREATE FUNCTION statement fails

From: Michael Paesold <mpaesold(at)gmx(dot)at>
To: Michael Paesold <mpaesold(at)gmx(dot)at>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, Grégory Chazalon <Gregory(dot)Chazalon(at)advestigo(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [pgsql-jdbc] dollar-quoted CREATE FUNCTION statement fails
Date: 2006-10-01 13:46:53
Message-ID: 451FC6CD.6060904@gmx.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Michael Paesold wrote:
> Dave Cramer wrote:
> >> I guess it's just a matter of coding, right? Would the JDBC
> >> maintainers accept a patch for the 8.2 release of the driver?
> > Absolutely!
>
> Ok, I am going to write support for this... [snip]

Here is a first version of the patch. It works well for me so far, so I
am asking for comments now.

This patch only adds knowledge about dollar-quotes to
v3.QueryExecutorImpl.parseQuery() for now, but there are other possible
candidates:
- V2Query: for people connecting to postgres >= 8.0 using
?protocolVersion=2
- AbstractJdbc2Statement.modifyJdbcCall() for prepareCall: I would not
expect someone to use dollar-quoting here, but single-quotes are
supported, so adding dollar-quoting does not seem completely off
track.

I have tried to make the patch rather non-invasive. I thought about
improving parseQuery to be more efficient, but without having done any
profiling, I did not want to considerably change the existing code
paths. All JUnit tests still pass running against an 8.1 server.

p1-remove-unused-var.patch:

org/postgresql/core/v3/QueryExecutorImpl.java:
- Remove an unused variable from parseQuery

p2-v3protocol-dolquot.patch:

org/postgresql/core/Utils.java:
- Add static methods isDollarQuoteStartChar(char) and
isDollarQuoteContChar(char)

org/postgresql/core/v3/QueryExecutorImpl.java:
- Add support for dollar-quoting in parseQuery

org/postgresql/test/jdbc3/Jdbc3DollarQuotingTest.java:
- New file with JUnit tests for new code

org/postgresql/test/jdbc3/Jdbc3TestSuite.java:
- Add the new JUnit TestCase to the test suite if server >= 8.0 and
protocolVersion == 3

Best Regards
Michael Paesold

Attachment Content-Type Size
p1-remove-unused-var.patch text/plain 559 bytes
p2-v3protocol-dolquot.patch text/plain 11.9 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2006-10-01 14:15:03 Re: Query ResultSet parsing speedup patch (resend)
Previous Message Holger Schulz 2006-10-01 10:57:17 Bug extracting bit value