Commit e4a6bd22 authored by Tom Lane's avatar Tom Lane

Fix pg_dump to add the required OPERATOR() decoration to schema-qualified

operator names.  This is needed when dumping operator definitions that have
COMMUTATOR (or similar) links to operators in other schemas.
Apparently Daniel Whitter is the first person ever to try this :-(
parent 894829a3
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.425 2006/01/06 19:08:33 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.426 2006/01/09 21:16:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -6054,9 +6054,10 @@ convertRegProcReference(const char *proc) ...@@ -6054,9 +6054,10 @@ convertRegProcReference(const char *proc)
* *
* Returns what to print, or NULL to print nothing * Returns what to print, or NULL to print nothing
* *
* In 7.3 the input is a REGOPERATOR display; we have to strip the * In 7.3 and up the input is a REGOPERATOR display; we have to strip the
* argument-types part. In prior versions, the input is just a * argument-types part, and add OPERATOR() decoration if the name is
* numeric OID, which we search our operator list for. * schema-qualified. In older versions, the input is just a numeric OID,
* which we search our operator list for.
*/ */
static const char * static const char *
convertOperatorReference(const char *opr) convertOperatorReference(const char *opr)
...@@ -6070,23 +6071,34 @@ convertOperatorReference(const char *opr) ...@@ -6070,23 +6071,34 @@ convertOperatorReference(const char *opr)
if (g_fout->remoteVersion >= 70300) if (g_fout->remoteVersion >= 70300)
{ {
char *name; char *name;
char *paren; char *oname;
char *ptr;
bool inquote; bool inquote;
bool sawdot;
name = strdup(opr); name = strdup(opr);
/* find non-double-quoted left paren */ /* find non-double-quoted left paren, and check for non-quoted dot */
inquote = false; inquote = false;
for (paren = name; *paren; paren++) sawdot = false;
for (ptr = name; *ptr; ptr++)
{ {
if (*paren == '(' && !inquote) if (*ptr == '"')
inquote = !inquote;
else if (*ptr == '.' && !inquote)
sawdot = true;
else if (*ptr == '(' && !inquote)
{ {
*paren = '\0'; *ptr = '\0';
break; break;
} }
if (*paren == '"')
inquote = !inquote;
} }
return name; /* If not schema-qualified, don't need to add OPERATOR() */
if (!sawdot)
return name;
oname = malloc(strlen(name) + 11);
sprintf(oname, "OPERATOR(%s)", name);
free(name);
return oname;
} }
oprInfo = findOprByOid(atooid(opr)); oprInfo = findOprByOid(atooid(opr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment