Feature Request: Allow additional special characters at the beginning of the name.

Started by Mark Simonover 4 years ago2 messages
#1Mark Simon
mark@manngo.net

I am very new to this list, so I don’t know whether this is the right place.

Microsoft SQL and MySQL both use the @ sign at the beginning of their
variables. The most obvious benefit of this is that it is very easy to
distinguish between variable names and column names.

I’m not asking for a change in how PostgreSQL manages variables, but
whether it’s possible to allow the @ sign, and possibly the $ sign to
start a variable name. I am aware that the _ can start a variable name,
but the other characters are a little more eye-catching.

Does that make sense?

--

Mark Simon

Manngo Net Pty Ltd

mobile:0411 246 672

email:mark@manngo.net <mailto:mark@comparity.net>
web:http://www.manngo.net

Resume:http://mark.manngo.net

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mark Simon (#1)
Re: Feature Request: Allow additional special characters at the beginning of the name.

Mark Simon <mark@manngo.net> writes:

I’m not asking for a change in how PostgreSQL manages variables, but
whether it’s possible to allow the @ sign, and possibly the $ sign to
start a variable name.

@ is allowed in operator names, and indeed is used in (mumble select
count(*) ...) 59 built-in operators. So we could not support that
without breaking a lot of applications. Is "a<@b" to be parsed as
"a <@ b" or "a < @b"? For that matter, is "@a" a name or an invocation
of the built-in prefix operator "@" on variable "a"?

As for allowing $ to start a name, there are also issues:

* It'd be rather ambiguous with the $id$ string delimiter syntax [1]https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING,
which is a Postgres-ism for sure, but a lot of people use it.

* It'd not be entirely clear whether $1 is a variable name
or a parameter reference.

* I think there are client interfaces that allow $name to be
a parameter symbol, so we'd also be breaking anything that
works that way.

Maybe we could have done this twenty years ago, but I think
compatibility considerations preclude it now.

regards, tom lane

[1]: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING