From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Derek Nelson <derek@pipelinedb.com>
To: pgsql-bugs@postgresql.org
Subject: Re: Tables created WITH OIDS cannot be dumped/restored properly
Date: Fri, 9 Nov 2018 09:26:53 +0100
Message-ID: <abbb973b-1d5c-520e-2e78-b52a682286a5@2ndquadrant.com> (raw)
In-Reply-To: <e002deb9-dbe2-25c0-3e71-7bd9a756138a@pipelinedb.com>
References: <e002deb9-dbe2-25c0-3e71-7bd9a756138a@pipelinedb.com>
On 01/11/2018 20:56, Derek Nelson wrote:
> Hello PG community! I'm one of the PipelineDB developers (PostgreSQL
> extension) and as we've begun adding support for PG 11 our test
> infrastructure identified an issue with dumping/restoring tables created
> WITH OIDs. Naturally this also affects pg_upgrade.
>
> If a table is created WITH OIDS, dumped and then restored, the resulting
> table will not contain the OID column.
Good catch. It's actually only if the affected table is the first table
in the output (or perhaps some other narrow circumstances). We do have
a test case for WITH OIDS tables, but that table ends up not the first
in the output.
I propose to apply the attached patch. It's slightly different from
yours in that I don't think we need to change the type of the withOids
field.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:0001-pg_dump-Fix-dumping-of-WITH-OIDS-tables.patch (text/plain, 1.4K) download
From 873a4086f1c2939e714743ec2c706bfdf0744855 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Fri, 9 Nov 2018 09:17:25 +0100
Subject: [PATCH] pg_dump: Fix dumping of WITH OIDS tables
A table with OIDs that was the first in the dump output would not get
dumped with OIDs enabled. Fix that.
The reason was that the currWithOids flag was declared to be bool but
actually also takes a -1 value for "don't know yet". But under
stdbool.h semantics, that is coerced to true, so the required SET
default_with_oids command is not output again. Change the variable
type to char to fix that.
Reported-by: Derek Nelson <derek@pipelinedb.com>
---
src/bin/pg_dump/pg_backup_archiver.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.hindex 26dd0442e8..05e9de632f 100644--- a/src/bin/pg_dump/pg_backup_archiver.h+++ b/src/bin/pg_dump/pg_backup_archiver.h@@ -347,7 +347,8 @@ struct _archiveHandle
char *currUser; /* current username, or NULL if unknown */
char *currSchema; /* current schema, or NULL */
char *currTablespace; /* current tablespace, or NULL */
- bool currWithOids; /* current default_with_oids setting */+ char currWithOids; /* current default_with_oids setting: true,+ * false, or -1 for unknown, forcing a SET */
void *lo_buf;
size_t lo_buf_used;
--
2.19.1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, derek@pipelinedb.com
Subject: Re: Tables created WITH OIDS cannot be dumped/restored properly
In-Reply-To: <abbb973b-1d5c-520e-2e78-b52a682286a5@2ndquadrant.com>
References: <e002deb9-dbe2-25c0-3e71-7bd9a756138a@pipelinedb.com> <abbb973b-1d5c-520e-2e78-b52a682286a5@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox