David Wheeler ([EMAIL PROTECTED]) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Backup Files Output Constraints Before Functions

Long Description
Bricolage has a table with a constraint that uses a custom function. The code to build 
it is functionally equivalent to this:

CREATE TABLE "testing" (
    first varchar(32),
    try_me numeric(1,0)
);

CREATE   FUNCTION try_it()
         RETURNS BOOLEAN
AS       'SELECT TRUE'
LANGUAGE 'sql'
WITH     (isstrict);

ALTER TABLE testing ADD CONSTRAINT ck_testing
  CHECK (try_it());


When backing up, however, this call to pg_dump:

% pg_dump -U postgres -Oxd testing > test-backup.sql

Outputs this:

--
-- PostgreSQL database dump
--

SET search_path = public, pg_catalog;

--
-- TOC entry 2 (OID 517307)
-- Name: testing; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE testing (
    first character varying(32),
    try_me numeric(1,0),
    CONSTRAINT ck_testing CHECK (try_it())
);


--
-- TOC entry 3 (OID 517309)
-- Name: try_it (); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION try_it () RETURNS boolean
    AS 'SELECT TRUE'
    LANGUAGE sql STRICT;


--
-- Data for TOC entry 4 (OID 517307)
-- Name: testing; Type: TABLE DATA; Schema: public; Owner: postgres
--

Any attempt to restore this database will unfortunately fail. The testing table won't 
exist because the ck_testing constraint references the try_it() function, which of 
course doesn't exist yet:

% psql -U postgres testing < ~/Desktop/test-backup.sql
SET
ERROR:  Function try_it() does not exist
        Unable to identify a function that satisfies the given argument types
        You may need to add explicit typecasts
CREATE FUNCTION

Would it be possible for pg_dump to do the right thing here? This issue exists with 
7.1 and later. I just ran the above tests on 7.3b1.

Thanks!

David

Sample Code


No file was uploaded with this report


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to