public inbox for [email protected]  
help / color / mirror / Atom feed
From: Chapman Flack <[email protected]>
To: [email protected]
Subject: Re: Fail to create distributed table in Citus
Date: Thu, 19 Nov 2020 13:54:04 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAB0C2fnf6yw6vgtrCkmD6Y8tTV-o3Vh1YQAvjY7DtqTQGTMqbw@mail.gmail.com>
References: <CAB0C2fn42hT7RQGK+MwTG-rnxj6eKEhnBr3vyjvZsVOu0gv7qQ@mail.gmail.com>
	<[email protected]>
	<CAB0C2fnf6yw6vgtrCkmD6Y8tTV-o3Vh1YQAvjY7DtqTQGTMqbw@mail.gmail.com>

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






view thread (4+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Fail to create distributed table in Citus
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox