Deprecate the use of => as an operator name.
authorRobert Haas <rhaas@postgresql.org>
Tue, 22 Jun 2010 11:36:16 +0000 (11:36 +0000)
committerRobert Haas <rhaas@postgresql.org>
Tue, 22 Jun 2010 11:36:16 +0000 (11:36 +0000)
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
doc/src/sgml/ref/create_operator.sgml
src/backend/commands/operatorcmds.c

index d5d320adf9028e026b16768adf4d4c56fe900da2..ef09a4ca869ad44b217c9ae3829fb031f0d09077 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.10 2010/06/18 03:52:03 rhaas Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.11 2010/06/22 11:36:16 rhaas Exp $ -->
 
 <sect1 id="hstore">
  <title>hstore</title>
    </para>
   </note>
 
+  <note>
+  <para>
+   The <literal>=&gt;</> operator is deprecated and may be removed in a
+   future release.  Use the <literal>hstore(text, text)</literal> function
+   instead.
+   </para>
+  </note>
+
   <table id="hstore-func-table">
    <title><type>hstore</> Functions</title>
 
       <entry><literal>"a"=&gt;"1","b"=&gt;"2"</literal></entry>
      </row>
 
+     <row>
+      <entry><function>hstore(text, text)</function></entry>
+      <entry><type>hstore</type></entry>
+      <entry>make single-item <type>hstore</></entry>
+      <entry><literal>hstore('a', 'b')</literal></entry>
+      <entry><literal>"a"=&gt;"b"</literal></entry>
+     </row>
+
      <row>
       <entry><function>akeys(hstore)</function></entry>
       <entry><type>text[]</type></entry>
index a5595e6e69c8343f7faa01de8903d6ca61347bed..d70fefcf05c93a15570944d29cb09b9912502a59 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.52 2010/04/03 07:22:58 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.53 2010/06/22 11:36:16 rhaas Exp $
 PostgreSQL documentation
 -->
 
@@ -71,6 +71,12 @@ CREATE OPERATOR <replaceable>name</replaceable> (
      parse SQL-compliant commands without requiring spaces between tokens.
      </para>
     </listitem>
+    <listitem>
+     <para>
+     The use of <literal>=&gt;</> as an operator name is deprecated.  It may
+     be disallowed altogether in a future release.
+     </para>
+    </listitem>
    </itemizedlist>
   </para>
 
index ff94aea42d4a1c39c6e64d01b4b3ee0c0517a810..2936c92a94e4c793e656ba482ffd8504acf5abab 100644 (file)
@@ -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)