pg_dump --oids fails when default_with_oids = off

Started by Michael Fuhrover 21 years ago2 messagesbugs
Jump to latest
#1Michael Fuhr
mike@fuhr.org

PostgreSQL 8.0.0rc3

When default_with_oids is set to "off", pg_dump --oids fails with
the following error:

% pg_dump --oids test
pg_dump: inserted invalid OID

This prevents the ability to dump OIDs for tables that were created
WITH OIDS. The workaround is to set default_with_oids to "on".

The problem appears to be in setMaxOid() in src/bin/pg_dump/pg_dump.c:

do_sql_command(g_conn,
"CREATE TEMPORARY TABLE pgdump_oid (dummy integer)");
res = PQexec(g_conn, "INSERT INTO pgdump_oid VALUES (0)");
check_sql_result(res, g_conn, "INSERT INTO pgdump_oid VALUES (0)",
PGRES_COMMAND_OK);
max_oid = PQoidValue(res);
if (max_oid == 0)
{
write_msg(NULL, "inserted invalid OID\n");
exit_nicely();
}

Should the temporary table be created WITH OIDS, or is this a case
of "Doctor, it hurts when I do that"?

pg_restore might have a similar problem but I'll have to look at
that later this afternoon.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Fuhr (#1)
Re: pg_dump --oids fails when default_with_oids = off

Michael Fuhr <mike@fuhr.org> writes:

When default_with_oids is set to "off", pg_dump --oids fails with
the following error:
% pg_dump --oids test
pg_dump: inserted invalid OID

Should the temporary table be created WITH OIDS,

Looks that way. Good catch.

regards, tom lane