proposal: disallow operator "=>" and use it for named parameters

Started by Pavel Stehuleabout 11 years ago28 messageshackers
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

two years a operator "=>" is marked as deprecated (from PostgreSQL 9.2).

Isn't time to use it for named parameters now (for PostgreSQL 9.5) ?

I am sending a implementation where syntax based on "=>" symbol is second
(but preferred) variant of ":=" syntax .. syntax ":=" will be supported
still.

Here is a patch

comments, notices?

Regards

Pavel

Attachments:

ansi-sql-named-parameters.patchtext/x-patch; charset=US-ASCII; name=ansi-sql-named-parameters.patchDownload+125-14
#2Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#1)
Re: proposal: disallow operator "=>" and use it for named parameters

On Sat, Jan 17, 2015 at 8:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

two years a operator "=>" is marked as deprecated (from PostgreSQL 9.2).

Isn't time to use it for named parameters now (for PostgreSQL 9.5) ?

I'm cool with that. It's possible that there are installations out
there that still have => operators installed, but every
still-supported release warns you not to do that, and the hstore
change exists in three released versions. Anyway, no amount of
waiting will eliminate the hazard completely.

I am sending a implementation where syntax based on "=>" symbol is second
(but preferred) variant of ":=" syntax .. syntax ":=" will be supported
still.

Here is a patch

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Robert Haas (#2)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-01-19 4:54 GMT+01:00 Robert Haas <robertmhaas@gmail.com>:

On Sat, Jan 17, 2015 at 8:27 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

two years a operator "=>" is marked as deprecated (from PostgreSQL 9.2).

Isn't time to use it for named parameters now (for PostgreSQL 9.5) ?

I'm cool with that. It's possible that there are installations out
there that still have => operators installed, but every
still-supported release warns you not to do that, and the hstore
change exists in three released versions. Anyway, no amount of
waiting will eliminate the hazard completely.

I am sending a implementation where syntax based on "=>" symbol is second
(but preferred) variant of ":=" syntax .. syntax ":=" will be supported
still.

Here is a patch

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

I have no problem with it. Just I'll try if there are no some unexpected
problem and I'll send a updated patch

Regards

Pavel

Show quoted text

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Pavel Stehule
pavel.stehule@gmail.com
In reply to: Robert Haas (#2)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-01-19 4:54 GMT+01:00 Robert Haas <robertmhaas@gmail.com>:

On Sat, Jan 17, 2015 at 8:27 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

two years a operator "=>" is marked as deprecated (from PostgreSQL 9.2).

Isn't time to use it for named parameters now (for PostgreSQL 9.5) ?

I'm cool with that. It's possible that there are installations out
there that still have => operators installed, but every
still-supported release warns you not to do that, and the hstore
change exists in three released versions. Anyway, no amount of
waiting will eliminate the hazard completely.

I am sending a implementation where syntax based on "=>" symbol is second
(but preferred) variant of ":=" syntax .. syntax ":=" will be supported
still.

Here is a patch

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Regards

Pavel

Show quoted text

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#5Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#4)
Re: proposal: disallow operator "=>" and use it for named parameters

On Mon, Jan 19, 2015 at 2:59 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Well then the error check is just dead code. Either way, you don't need it.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Pavel Stehule (#4)
Re: proposal: disallow operator "=>" and use it for named parameters

Pavel Stehule wrote:

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Does it work to use OPERATOR(=>) syntax? I don't think identifier
quoting works for operators.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Pavel Stehule
pavel.stehule@gmail.com
In reply to: Alvaro Herrera (#6)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-01-19 14:30 GMT+01:00 Alvaro Herrera <alvherre@2ndquadrant.com>:

Pavel Stehule wrote:

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Does it work to use OPERATOR(=>) syntax? I don't think identifier
quoting works for operators.

it doesn't work too

Show quoted text

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#8Pavel Stehule
pavel.stehule@gmail.com
In reply to: Robert Haas (#5)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-01-19 14:27 GMT+01:00 Robert Haas <robertmhaas@gmail.com>:

On Mon, Jan 19, 2015 at 2:59 AM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Well then the error check is just dead code. Either way, you don't need
it.

yes, I removed it

Regards

Pavel

Show quoted text

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

ansi-sql-named-parameters-02.patchtext/x-patch; charset=US-ASCII; name=ansi-sql-named-parameters-02.patchDownload+136-48
#9Petr Jelinek
petr@2ndquadrant.com
In reply to: Pavel Stehule (#8)
Re: proposal: disallow operator "=>" and use it for named parameters

On 19/01/15 17:14, Pavel Stehule wrote:

2015-01-19 14:27 GMT+01:00 Robert Haas <robertmhaas@gmail.com
<mailto:robertmhaas@gmail.com>>:

On Mon, Jan 19, 2015 at 2:59 AM, Pavel Stehule
<pavel.stehule@gmail.com <mailto:pavel.stehule@gmail.com>> wrote:

I think you should just remove the WARNING, not change it to an error.
If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Well then the error check is just dead code. Either way, you don't
need it.

yes, I removed it

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be
too controversial either.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#10Pavel Stehule
pavel.stehule@gmail.com
In reply to: Petr Jelinek (#9)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-02-19 16:06 GMT+01:00 Petr Jelinek <petr@2ndquadrant.com>:

On 19/01/15 17:14, Pavel Stehule wrote:

2015-01-19 14:27 GMT+01:00 Robert Haas <robertmhaas@gmail.com
<mailto:robertmhaas@gmail.com>>:

On Mon, Jan 19, 2015 at 2:59 AM, Pavel Stehule
<pavel.stehule@gmail.com <mailto:pavel.stehule@gmail.com>> wrote:

I think you should just remove the WARNING, not change it to an

error.

If somebody wants to quote the operator name to be able to continue
using it, I think that's OK.

It looks so quoting doesn't help here

+ CREATE OPERATOR "=>" (
+    leftarg = int8,<--><------>-- right unary
+    procedure = numeric_fac
+ );
+ ERROR:  syntax error at or near "("
+ LINE 1: CREATE OPERATOR "=>" (
+                              ^

Well then the error check is just dead code. Either way, you don't
need it.

yes, I removed it

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be too
controversial either.

Thank you very much

Pavel

Show quoted text

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

#11Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#10)
Re: proposal: disallow operator "=>" and use it for named parameters

On Thu, Feb 19, 2015 at 3:15 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be too
controversial either.

Committed with a few documentation tweaks.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#12Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#11)
Re: proposal: disallow operator "=>" and use it for named parameters

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 19, 2015 at 3:15 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be too
controversial either.

Committed with a few documentation tweaks.

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#13Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#12)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-03-10 16:50 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 19, 2015 at 3:15 PM, Pavel Stehule <pavel.stehule@gmail.com>

wrote:

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be

too

controversial either.

Committed with a few documentation tweaks.

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I didn't think about it? I don't see any reason why it have to use
deprecated syntax.

Regards

Pavel

Show quoted text

regards, tom lane

#14Petr Jelinek
petr@2ndquadrant.com
In reply to: Pavel Stehule (#13)
Re: proposal: disallow operator "=>" and use it for named parameters

On 10/03/15 17:01, Pavel Stehule wrote:

2015-03-10 16:50 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us
<mailto:tgl@sss.pgh.pa.us>>:

Robert Haas <robertmhaas@gmail.com <mailto:robertmhaas@gmail.com>>
writes:

Committed with a few documentation tweaks.

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I didn't think about it? I don't see any reason why it have to use
deprecated syntax.

There is one, loading the output into older version of Postgres. Don't
know if that's important one though.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#15Pavel Stehule
pavel.stehule@gmail.com
In reply to: Petr Jelinek (#14)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-03-10 17:07 GMT+01:00 Petr Jelinek <petr@2ndquadrant.com>:

On 10/03/15 17:01, Pavel Stehule wrote:

2015-03-10 16:50 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us
<mailto:tgl@sss.pgh.pa.us>>:

Robert Haas <robertmhaas@gmail.com <mailto:robertmhaas@gmail.com>>
writes:

Committed with a few documentation tweaks.

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I didn't think about it? I don't see any reason why it have to use
deprecated syntax.

There is one, loading the output into older version of Postgres. Don't
know if that's important one though.

I don't think so it is a hard issue. We doesn't support downgrades - and if
somebody needs it, it can fix it with some regexp. We should to use
preferred syntax everywhere - and preferred syntax should be ANSI.

I forgot it :(

Pavel

Show quoted text

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

#16Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#12)
Re: proposal: disallow operator "=>" and use it for named parameters

On Tue, Mar 10, 2015 at 11:50 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

On Thu, Feb 19, 2015 at 3:15 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

I am marking this as Ready For Committer, the patch is trivial and works
as expected, there is nothing to be added to it IMHO.

The "=>" operator was deprecated for several years so it should not be too
controversial either.

Committed with a few documentation tweaks.

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I have to admit that I didn't consider that. What do you think? I
guess I'd be tentatively in favor of changing that to match, but I
could be convinced otherwise.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#17Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#16)
Re: proposal: disallow operator "=>" and use it for named parameters

Robert Haas <robertmhaas@gmail.com> writes:

On Tue, Mar 10, 2015 at 11:50 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I have to admit that I didn't consider that. What do you think? I
guess I'd be tentatively in favor of changing that to match, but I
could be convinced otherwise.

Well, as said upthread, the argument for not changing would be that it
would make it easier to dump views and reload them into older PG versions.
I'm not sure how big a consideration that is, or whether it outweighs
possible cross-DBMS compatibility benefits of dumping the more standard
syntax. Presumably we are going to change it at some point; maybe we
should just do it rather than waiting another 5 years.

IOW, I guess I lean mildly towards changing, but I've been beaten up
enough lately about backwards-compatibility worries that I'm not going
to fight for changing this.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#18Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: Tom Lane (#17)
Re: proposal: disallow operator "=>" and use it for named parameters

Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

On Tue, Mar 10, 2015 at 11:50 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Was there any consideration given to whether ruleutils should start
printing NamedArgExprs with "=>"? Or do we think that needs to wait?

I have to admit that I didn't consider that. What do you think? I
guess I'd be tentatively in favor of changing that to match, but I
could be convinced otherwise.

Presumably we are going to change it at some point; maybe we
should just do it rather than waiting another 5 years.

+1

It has been deprecated long enough that I don't see the point of waiting.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#19Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kevin Grittner (#18)
Re: proposal: disallow operator "=>" and use it for named parameters

Kevin Grittner <kgrittn@ymail.com> writes:

Tom Lane <tgl@sss.pgh.pa.us> wrote:

Presumably we are going to change it at some point; maybe we
should just do it rather than waiting another 5 years.

+1

It has been deprecated long enough that I don't see the point of waiting.

Uh, just to clarify, this has nothing to do with how long the operator has
been deprecated. The issue is whether pg_dump should dump a function-call
syntax that will not be recognized by any pre-9.5 release, when there is
an alternative that will be recognized back to 9.0.

BTW, I just noticed another place that probably should be changed:

regression=# select foo(x => 1);
ERROR: 42883: function foo(x := integer) does not exist
LINE 1: select foo(x => 1);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
LOCATION: ParseFuncOrColumn, parse_func.c:516

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#20Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#19)
Re: proposal: disallow operator "=>" and use it for named parameters

2015-03-10 19:02 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Kevin Grittner <kgrittn@ymail.com> writes:

Tom Lane <tgl@sss.pgh.pa.us> wrote:

Presumably we are going to change it at some point; maybe we
should just do it rather than waiting another 5 years.

+1

It has been deprecated long enough that I don't see the point of waiting.

Uh, just to clarify, this has nothing to do with how long the operator has
been deprecated. The issue is whether pg_dump should dump a function-call
syntax that will not be recognized by any pre-9.5 release, when there is
an alternative that will be recognized back to 9.0.

BTW, I just noticed another place that probably should be changed:

regression=# select foo(x => 1);
ERROR: 42883: function foo(x := integer) does not exist
LINE 1: select foo(x => 1);
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
LOCATION: ParseFuncOrColumn, parse_func.c:516

1. funcname_signature_string
2. get_rule_expr

Show quoted text

regards, tom lane

#21Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#20)
#22Bruce Momjian
bruce@momjian.us
In reply to: Robert Haas (#21)
#23Pavel Stehule
pavel.stehule@gmail.com
In reply to: Bruce Momjian (#22)
#24Bruce Momjian
bruce@momjian.us
In reply to: Pavel Stehule (#23)
#25Petr Jelinek
petr@2ndquadrant.com
In reply to: Bruce Momjian (#24)
#26Bruce Momjian
bruce@momjian.us
In reply to: Petr Jelinek (#25)
#27Petr Jelinek
petr@2ndquadrant.com
In reply to: Bruce Momjian (#26)
#28Robert Haas
robertmhaas@gmail.com
In reply to: Bruce Momjian (#22)