From: Adam Rauch <adam@labkey.com>
To: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: JDBC escaped scalar functions fail when used in function definition
Date: Thu, 10 Mar 2016 15:10:34 -0800
Message-ID: <56E1FEEA.1010302@labkey.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
While testing postgresql-9.4.1208.jar with our system, code is now
failing when it attempts to use {fn now()} in the body of a PostgreSQL
CREATE FUNCTION statement. This worked fine on 1207 and all previous
versions of the driver.
In other words, the code below succeeds on 1207 but fails on 1208
(passing in server, port, database, username, and password as parameters):
import java.sql.*;
public class PGTest
{
public static void main(String[] args)throws SQLException
{
try (Connection conn = DriverManager.getConnection("jdbc:postgresql://" + args[0] +":" + args[1] +"/" + args[2], args[3], args[4]))
{
try (PreparedStatement stmt = conn.prepareStatement(
"CREATE FUNCTION public.fn_now() RETURNS VOID AS $$\n" +
" BEGIN\n" +
" SELECT {fn now()};" +
" END;\n" +
"$$ LANGUAGE plpgsql;" +
"DROP FUNCTION public.fn_now();")) {
stmt.execute();
}
}
}
}
Bug? Intentional change in behavior? Thanks, Adam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: adam@labkey.com
Subject: Re: JDBC escaped scalar functions fail when used in function definition
In-Reply-To: <56E1FEEA.1010302@labkey.com>
References: <56E1FEEA.1010302@labkey.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox