summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-01-09 21:16:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-01-09 21:16:25 +0000
commitd3934a3f388ff8058605e72c4c32f324e9eef1da (patch)
tree3ab6cc19b6d441ae80a0c1bc007d278e6ce03a4d /src
parented47146f1e376a1dc3dbef4ea9a53cac9eebe3c6 (diff)
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 :-(
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 37c9bd6c193..17541d0d57c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.422.2.1 2005/11/22 18:23:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.422.2.2 2006/01/09 21:16:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -6027,9 +6027,10 @@ convertRegProcReference(const char *proc)
*
* Returns what to print, or NULL to print nothing
*
- * In 7.3 the input is a REGOPERATOR display; we have to strip the
- * argument-types part. In prior versions, the input is just a
- * numeric OID, which we search our operator list for.
+ * In 7.3 and up the input is a REGOPERATOR display; we have to strip the
+ * argument-types part, and add OPERATOR() decoration if the name is
+ * schema-qualified. In older versions, the input is just a numeric OID,
+ * which we search our operator list for.
*/
static const char *
convertOperatorReference(const char *opr)
@@ -6043,23 +6044,34 @@ convertOperatorReference(const char *opr)
if (g_fout->remoteVersion >= 70300)
{
char *name;
- char *paren;
+ char *oname;
+ char *ptr;
bool inquote;
+ bool sawdot;
name = strdup(opr);
- /* find non-double-quoted left paren */
+ /* find non-double-quoted left paren, and check for non-quoted dot */
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;
}
- 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));