Re: Alias hstore's ? to ~ so that it works with JDBC - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Alias hstore's ? to ~ so that it works with JDBC
Date
Msg-id 511BF910.5070507@vmware.com
Whole thread Raw
In response to Re: Alias hstore's ? to ~ so that it works with JDBC  (Kevin Grittner <kgrittn@ymail.com>)
Responses Re: Alias hstore's ? to ~ so that it works with JDBC  (Ants Aasma <ants.aasma@eesti.ee>)
List pgsql-hackers
On 13.02.2013 22:17, Kevin Grittner wrote:
> Seamus Abshere<seamus@abshere.net>  wrote:
>>       SELECT * FROM tbl WHERE data {postgres qm} 'abc'
>
> That suggestion makes a lot of sense to me.  The curly-brace
> escapes are in JDBC for portability, so this seems like a totally
> appropriate use; it's surprising it hasn't come up before.

+1 for something like this. Rather than a straight "{postgres qm}" to 
represent a question mark, though, perhaps it would be more readable to 
allow something like this though:

{postgres SELECT * FROM tbl WHERE data ? 'abc' AND column = $1}

Ie. within "{postgres ... }", ? means a question mark, not a parameter 
marker, and for parameter markers, you use the PostgreSQL syntax, $n.

Also, should we consider how to escape { and } characters? They're not a 
problem at the moment, but while we're at it...

>> I guess I see 2 simple options and 1 complex option:
>>
>> a) [simple] operator("+") per Heikki
>> b) [simple, but not popular] alias ? to ~ per Seamus
>> c) [complex] {postgres blah} per Lance/Mark
>>
>> How to decide?
>
> We already have code in the JDBC driver to recognize curly-brace
> escape sequences.  We just need to add "postgres" as another
> keyword for such escapes and we can do what we like for the rest of
> the escape sequence.  A mnemonic, such as Lance suggests, does seem
> like a good approach.

We could support operator("?") as well; belt and suspenders. That would 
help ODBC clients too.

- Heikki



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal or just idea for psql - show first N rows from relation backslash statement
Next
From: "Erik Rijkers"
Date:
Subject: Re: proposal or just idea for psql - show first N rows from relation backslash statement