Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 500B31336971 for ; Mon, 31 Jan 2011 09:45:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 30249-02 for ; Mon, 31 Jan 2011 13:44:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 71FFE133616B for ; Mon, 31 Jan 2011 09:44:59 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p0VDixwU089343 for ; Mon, 31 Jan 2011 13:44:59 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p0VDixSt089341; Mon, 31 Jan 2011 13:44:59 GMT (envelope-from www) Date: Mon, 31 Jan 2011 13:44:59 GMT Message-Id: <201101311344.p0VDixSt089341@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5857: pg_restore --clean dropping type too soon From: "Stuart Bishop" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201101/248 X-Sequence-Number: 29270 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 );