Search Postgresql Archives

psql meta-command string interpolation differs from SQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mostly looking for affirmation though it was somewhat surprising that I had no recollection of this dynamic even though I've been a fairly avid reader of the documentation.

Executing the following in psql:

\set name_regexp '^\S+'
CREATE TABLE testtbl ( textid NOT NULL PRIMARY KEY CHECK (textid ~ :'name_regexp');

The constraint that ends up being saved is:

textid ~ '^S+'

This is a default 9.3 box.  Typically I write my SQL literal regular expressions without E'' in order to avoid escaping all of the back-slashes.  It seemed that using \set would be useful since I am using psql to execute the DDL anyway.

psql --file ^^^

Any thoughts or suggestions?

At what point is the "\S" that I wrote being turned into an escaped "S"?  By the "\set" before going into the variable or at the :'name_regexp' output conversion?  Not that it likely matters to me, the end-user.  It would aid in deciding where it might be possible to introduce new syntax, like the E'' that SQL uses, to gain a measure of conformity.

TIA

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux