pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stuart Bishop <stuart@stuartbishop.net>
To: pgsql-bugs@postgresql.org
Subject: BUG #5857: pg_restore --clean dropping type too soon
Date: Mon, 31 Jan 2011 13:44:59 GMT
Message-ID: <201101311344.p0VDixSt089341@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      5857
Logged by:          Stuart Bishop
Email address:      stuart@stuartbishop.net
PostgreSQL version: 8.4.6
Operating system:   Ubuntu 10.10
Description:        pg_restore --clean dropping type too soon
Details: 

"pg_restore --clean" appears to have an ordering problem, where a custom
type is being dropped before some functions that use that custom type as a
parameter, which fails.


$ psql -d foo -f /usr/share/postgresql/8.4/contrib/debversion.sql >
/dev/null
psql:/usr/share/postgresql/8.4/contrib/debversion.sql:28: NOTICE:  return
type debversion is only a shell
psql:/usr/share/postgresql/8.4/contrib/debversion.sql:34: NOTICE:  argument
type debversion is only a shell
psql:/usr/share/postgresql/8.4/contrib/debversion.sql:40: NOTICE:  return
type debversion is only a shell
psql:/usr/share/postgresql/8.4/contrib/debversion.sql:46: NOTICE:  argument
type debversion is only a shell

$ pg_dump --format=c foo | pg_restore --clean | grep debversion
[...]
DROP FUNCTION public.debversion(character);
DROP TYPE public.debversion CASCADE;
DROP FUNCTION public.debversionsend(debversion);
[...]



The relevant part of debversion.sql seems to be:

CREATE TYPE debversion;

CREATE OR REPLACE FUNCTION debversionin(cstring)
  RETURNS debversion
  AS 'textin'
  LANGUAGE 'internal'
  IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION debversionout(debversion)
  RETURNS cstring
  AS 'textout'
  LANGUAGE 'internal'
  IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION debversionrecv(internal)
  RETURNS debversion
  AS 'textrecv'
  LANGUAGE 'internal'
  STABLE STRICT;

CREATE OR REPLACE FUNCTION debversionsend(debversion)
  RETURNS bytea
  AS 'textsend'
  LANGUAGE 'internal'
  STABLE STRICT;

CREATE TYPE debversion (
    LIKE           = text,
    INPUT          = debversionin,
    OUTPUT         = debversionout,
    RECEIVE        = debversionrecv,
    SEND           = debversionsend,
    -- make it a non-preferred member of string type category
    CATEGORY       = 'S',
    PREFERRED      = false
);



view thread (3+ messages)  latest in thread

Message-ID: <201101311344.p0VDixSt089341@wwwmaster.postgresql.org>
Permalink:  ../201101311344.p0VDixSt089341@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201101311344.p0VDixSt089341@wwwmaster.postgresql.org

 · 

reply

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: stuart@stuartbishop.net
  Subject: Re: BUG #5857: pg_restore --clean dropping type too soon
  In-Reply-To: <201101311344.p0VDixSt089341@wwwmaster.postgresql.org>
  References: <201101311344.p0VDixSt089341@wwwmaster.postgresql.org>

* 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