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.