Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfp4N-0002Wx-GB for pljava-dev@arkaria.postgresql.org; Thu, 19 Nov 2020 18:54:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfp4M-0003Ng-78 for pljava-dev@arkaria.postgresql.org; Thu, 19 Nov 2020 18:54:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfp4M-0003NY-2F for pljava-dev@lists.postgresql.org; Thu, 19 Nov 2020 18:54:10 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfp4J-0003lY-Ku for pljava-dev@lists.postgresql.org; Thu, 19 Nov 2020 18:54:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wslOtQ+gb01C6J0PaU6dUdXcf6BmIDi0991ddjiRMcw=; b=wYM3i+XLzZcsm9ocJi6Q3JJ2fs QrSW5eVF+eU8kKlp5MgCr+C7VdPB7OuusiY8MW865KhK6pw23SwW91/GATp7F2EwzqsUjPaPaibVT 2WGUZPt72fHJd85JY8FtZ+Dp18yR7UfTjZ8iYH2b3uTonT7kPzul+3a54MjB5Y50qlDqjcuPo+g9/ 8K4PZZ9DZpieqO5f1EfQQR8yDvNqW1K1RvV6HBWKxCNtqXMD9JynSwyQ+qLXXzyUcAvjOwaBcvawA q5dsO/bebkARGC/4i56ZZa8kApEjBrt9pb08tG/QRjpeyiuqhk9XPWnV/dWPcMBDZPWFzGxuHo/CZ ZJqYXr2A==; Received: from [184.19.31.139] (port=55064) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kfp4H-008b4B-4x for pljava-dev@lists.postgresql.org; Thu, 19 Nov 2020 13:54:05 -0500 Subject: Re: Fail to create distributed table in Citus To: pljava-dev@lists.postgresql.org References: <5FB6AB35.5060101@anastigmatix.net> From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5FB6BF4C.3060209@anastigmatix.net> Date: Thu, 19 Nov 2020 13:54:04 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/19/20 13:20, Erik Mata wrote: > ... > stmt.executeQuery("SELECT create_distributed_table('test1', 'a', > colocate_with => 'none')"); > } > ... > I was wondering if it could be something with the single quotes surrounding > the parameters, but I've tried to use double single quotes and also to > escape the single quotes, but then it really fails with an error. Looking No, that's fine the way you've written it, as long as those values are constant strings as you've shown. The times you want to be careful are when the parameters are being passed to you and you don't know what characters they might contain. In those cases you would typically use ps = connection.prepareStatement( "SELECT create_distributed_table(?, ?, colocate_with => ?)"); ps.setString(1, tableName); ps.setString(2, columnName); ps.setString(3, colocated); ps.execute(); so the driver takes care of how to pass the parameters correctly. With data-definition language like CREATE TABLE, it's a little different, because it can't be prepared and parameterized like a DML statement. Those are the cases where, if you were being passed the table name or column name, you would have to be careful about constructing the CREATE TABLE and using the right quoting rules, getting familiar with Statement.enquoteIdentifier() or, even better, org.postgresql.pljava.sqlgen.Lexicals.Identifier.deparse(). And there are more tricks to getting that right than I should go into here, because they're probably off-topic for this particular issue. Regards, -Chap