From f974212320960452950921d68c6fea275c2257da Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 22 Jun 2010 11:36:16 +0000 Subject: [PATCH] Deprecate the use of => as an operator name. In HEAD, emit a warning when an operator named => is defined. In both HEAD and the backbranches (except in 8.2, where contrib modules do not have documentation), document that hstore's text => text operator may be removed in a future release, and encourage the use of the hstore(text, text) function instead. This function only exists in HEAD (previously, it was called tconvert), so backpatch it back to 8.2, when hstore was added. Per discussion. --- doc/src/sgml/hstore.sgml | 18 +++++++++++++++++- doc/src/sgml/ref/create_operator.sgml | 8 +++++++- src/backend/commands/operatorcmds.c | 12 +++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml index d5d320adf9..ef09a4ca86 100644 --- a/doc/src/sgml/hstore.sgml +++ b/doc/src/sgml/hstore.sgml @@ -1,4 +1,4 @@ - + hstore @@ -225,6 +225,14 @@ + + + The => operator is deprecated and may be removed in a + future release. Use the hstore(text, text) function + instead. + + + <type>hstore</> Functions @@ -265,6 +273,14 @@ "a"=>"1","b"=>"2" + + hstore(text, text) + hstore + make single-item hstore + hstore('a', 'b') + "a"=>"b" + + akeys(hstore) text[] diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml index a5595e6e69..d70fefcf05 100644 --- a/doc/src/sgml/ref/create_operator.sgml +++ b/doc/src/sgml/ref/create_operator.sgml @@ -1,5 +1,5 @@ @@ -71,6 +71,12 @@ CREATE OPERATOR name ( parse SQL-compliant commands without requiring spaces between tokens. + + + The use of => as an operator name is deprecated. It may + be disallowed altogether in a future release. + + diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index ff94aea42d..2936c92a94 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.45 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.46 2010/06/22 11:36:16 rhaas Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -88,6 +88,16 @@ DefineOperator(List *names, List *parameters) /* Convert list of names to a name and namespace */ oprNamespace = QualifiedNameGetCreationNamespace(names, &oprName); + /* + * The SQL standard committee has decided that => should be used for + * named parameters; therefore, a future release of PostgreSQL may + * disallow it as the name of a user-defined operator. + */ + if (strcmp(oprName, "=>") == 0) + ereport(WARNING, + (errmsg("=> is deprecated as an operator name"), + errdetail("This name may be disallowed altogether in future versions of PostgreSQL."))); + /* Check we have creation rights in target namespace */ aclresult = pg_namespace_aclcheck(oprNamespace, GetUserId(), ACL_CREATE); if (aclresult != ACLCHECK_OK) -- 2.40.0