Thread: pgsql-server/src/backend/utils/adt ruleutils.c

pgsql-server/src/backend/utils/adt ruleutils.c

From
momjian@svr1.postgresql.org (Bruce Momjian)
Date:
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@svr1.postgresql.org    03/09/29 15:55:56

Modified files:
    src/backend/utils/adt: ruleutils.c

Log message:
    The brackets aren't put on the CHECK constraints properly.

    Before patch:

    test=# select pg_get_constraintdef(oid) from pg_constraint;
    pg_get_constraintdef
    -------------------------------------------------------------------------------------------------
    CHECK (VALUE >= 0)
    CHECK ((((a)::text = 'asdf'::text) OR ((a)::text = 'fdsa'::text)) OR
    ((a)::text = 'dfd'::text))
    PRIMARY KEY (b)
    FOREIGN KEY (a) REFERENCES test2(b)
    UNIQUE (b)
    (5 rows)

    test=# select pg_get_constraintdef(oid, true) from pg_constraint;
    pg_get_constraintdef
    -----------------------------------------------------------------------------------
    CHECK VALUE >= 0
    CHECK a::text = 'asdf'::text OR a::text = 'fdsa'::text OR a::text =
    'dfd'::text
    PRIMARY KEY (b)
    FOREIGN KEY (a) REFERENCES test2(b)
    UNIQUE (b)
    (5 rows)

    After patch:

    test=# select pg_get_constraintdef(oid) from pg_constraint;
    pg_get_constraintdef
    -------------------------------------------------------------------------------------------------
    CHECK (VALUE >= 0)
    CHECK ((((a)::text = 'asdf'::text) OR ((a)::text = 'fdsa'::text)) OR
    ((a)::text = 'dfd'::text))
    PRIMARY KEY (b)
    FOREIGN KEY (a) REFERENCES test2(b)
    UNIQUE (b)
    (5 rows)

    test=# select pg_get_constraintdef(oid, true) from pg_constraint;
    pg_get_constraintdef
    -----------------------------------------------------------------------------------
    CHECK (VALUE >= 0)

    `  CHECK (a::text = 'asdf'::text OR a::text = 'fdsa'::text OR a::text =
    'dfd'::text)
    PRIMARY KEY (b)
    FOREIGN KEY (a) REFERENCES test2(b)
    UNIQUE (b)
    (5 rows)

    It's important that those brackets are there to (a) match all other
    constraints and (b) so that people can just copy and paste them and it
    will work as SQL.

    Christopher Kings-Lynne