*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.1 2003/01/27 00:23:49 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.2 2003/02/01 22:07:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* This is a bit yucky, but I don't want to make the binary format
- * very dependant on representation, and not knowing much about it, I
+ * very dependent on representation, and not knowing much about it, I
* write out a sign byte. If you change this, don't forget to change
* the file version #, and modify readInt to read the new format AS
* WELL AS the old formats.
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.43 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.43.2.1 2003/02/01 22:07:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*uRes;
int i,
n;
- char *attr;
if (strcmp(te->tag, BLOB_XREF_TABLE) == 0)
return;
fmtId(te->tag));
appendPQExpBuffer(tblQry,
- "SELECT a.attname FROM "
+ "SELECT a.attname, t.typname FROM "
"pg_catalog.pg_attribute a, pg_catalog.pg_type t "
"WHERE a.attnum > 0 AND a.attrelid = '%s'::pg_catalog.regclass "
"AND a.atttypid = t.oid AND t.typname in ('oid', 'lo')",
for (i = 0; i < n; i++)
{
+ char *attr;
+ char *typname;
+ bool typeisoid;
+
attr = PQgetvalue(res, i, 0);
+ typname = PQgetvalue(res, i, 1);
+
+ typeisoid = (strcmp(typname, "oid") == 0);
ahlog(AH, 1, "fixing large object cross-references for %s.%s\n",
te->tag, attr);
resetPQExpBuffer(tblQry);
- /* Can't use fmtId twice in one call... */
+ /*
+ * Note: we use explicit typename() cast style here because if we
+ * are dealing with a dump from a pre-7.3 database containing LO
+ * columns, the dump probably will not have CREATE CAST commands
+ * for lo<->oid conversions. What it will have is functions,
+ * which we will invoke as functions.
+ */
+
+ /* Can't use fmtId more than once per call... */
appendPQExpBuffer(tblQry,
- "UPDATE %s SET %s = %s.newOid",
- tblName->data, fmtId(attr),
- BLOB_XREF_TABLE);
+ "UPDATE %s SET %s = ",
+ tblName->data, fmtId(attr));
+ if (typeisoid)
+ appendPQExpBuffer(tblQry,
+ "%s.newOid",
+ BLOB_XREF_TABLE);
+ else
+ appendPQExpBuffer(tblQry,
+ "%s(%s.newOid)",
+ fmtId(typname),
+ BLOB_XREF_TABLE);
appendPQExpBuffer(tblQry,
- " FROM %s WHERE %s.oldOid = %s.%s",
- BLOB_XREF_TABLE,
+ " FROM %s WHERE %s.oldOid = ",
BLOB_XREF_TABLE,
- tblName->data, fmtId(attr));
+ BLOB_XREF_TABLE);
+ if (typeisoid)
+ appendPQExpBuffer(tblQry,
+ "%s.%s",
+ tblName->data, fmtId(attr));
+ else
+ appendPQExpBuffer(tblQry,
+ "oid(%s.%s)",
+ tblName->data, fmtId(attr));
ahlog(AH, 10, "SQL: %s\n", tblQry->data);