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

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?


--
#signature { color: #00008B; font-family: sans-serif; font-size: 10pt; border: solid #00008B; border-width: 0px 0px 0px 8px; padding: 0px 12px; } #signature h1 { font-size: 125%; margin: 4px 0px; } #signature p { margin: 4px 0px; } #signature a { color: #005247; text-decoration: none; } #signature .label { display: inline-block; width: 60px; font-weight: bold; }

Mark Simon

Manngo Net Pty Ltd

mobile:0411 246 672

email:mark@manngo.net
web:http://www.manngo.net

Resume:http://mark.manngo.net

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],
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