Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ae9jV-0006q7-7n for pgsql-jdbc@arkaria.postgresql.org; Thu, 10 Mar 2016 23:11:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ae9jU-0000qx-QN for pgsql-jdbc@arkaria.postgresql.org; Thu, 10 Mar 2016 23:11:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ae9jU-0000oB-4A for pgsql-jdbc@postgresql.org; Thu, 10 Mar 2016 23:11:04 +0000 Received: from mail-ig0-x22b.google.com ([2607:f8b0:4001:c05::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ae9jR-0001AK-68 for pgsql-jdbc@postgresql.org; Thu, 10 Mar 2016 23:11:02 +0000 Received: by mail-ig0-x22b.google.com with SMTP id vf5so4755436igb.0 for ; Thu, 10 Mar 2016 15:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labkey-com.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version; bh=zRfDdc3maq/xNPSWwRuIoumIuC/iWcuYRHePFRwUKR0=; b=Q6jydl9QbROLYw3Ebr6HZ/fV717VaoZsLmdEIGUHdQIKRpJeIIfZzoOH4O7cihZAOk tTqVu/7qrjbpmGX0bht8trK9WSH7mno7YTzMT8/eyYdTwiQzn8acWp3H3I2PFfEcV0d0 A55xzfgcVl9MVpmZuLFZ50CLlP8EabxGileZRjEUAaijxn3eFbhgeQUAldawg5Zk4aqx HXiyRSc8vp4G49Zf1yJEd1bmHInkccSzpPNmumdhT5sL2oXc+aCEc1ALVNtVqngKYig4 pkloGx87BtRFMKrLiLoLAHOxp7sDh5JylRLLsBfv1nroFAcmJsHY0Q9xB43O5KFMO2I7 YGAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=zRfDdc3maq/xNPSWwRuIoumIuC/iWcuYRHePFRwUKR0=; b=R2MsCMmad1LtXPStpeNN/cycoD02JhWRya/I6xz6zyTtAf6+ivvy6ODdWFQeQmWACt 5RHHCAyoWdrmkRZ6jBsEGTkT4BEiVKbJRcuTIsL2CpJSLZK0uMFpMTOEtPFjtnJ7YhZR ovkH/wBEn5MJHB8p+MgYzMt/UnKDaIx7BJSZO4lYVvig4X09NQFOBpmGlrtz+rcHVk4I KhKgugtJqOb1KADrLAsdqRLyRBI4rAelcVnpUP2KGhinjzcdYz6dHMdThCnyKjYmEgkz eAI9t309JYN7o+q0KiaDj3nkTCf5t2dsYbxwD9rhl8iApSi943zg+jhv4/JHNCbebOQk VoHg== X-Gm-Message-State: AD7BkJLLTEd1IVEKHJ9PfQGplmi2gjlDF0m8Lt6AktkAM1Z+VqHp55M2ejW5N/Ms0ZBlUA== X-Received: by 10.50.155.1 with SMTP id vs1mr624515igb.14.1457651459935; Thu, 10 Mar 2016 15:10:59 -0800 (PST) Received: from [10.10.10.184] ([74.202.208.74]) by smtp.googlemail.com with ESMTPSA id l17sm186395igf.1.2016.03.10.15.10.58 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Mar 2016 15:10:58 -0800 (PST) To: "pgsql-jdbc@postgresql.org" From: Adam Rauch Subject: JDBC escaped scalar functions fail when used in function definition Message-ID: <56E1FEEA.1010302@labkey.com> Date: Thu, 10 Mar 2016 15:10:34 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------020202030309020202000001" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------020202030309020202000001 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------020202030309020202000001 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit 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 --------------020202030309020202000001--