Skip site navigation (1) Skip section navigation (2)

pretty print for check constraints broken

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: pretty print for check constraints broken
Date: 2003-09-26 07:48:09
Message-ID: 3F73EF39.7090400@familyhealth.com.au (view raw or flat)
Thread:
Lists: pgsql-patches
Hi,

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.

Chris


Attachment: ruleutils.txt
Description: text/plain (1.0 KB)

Responses

pgsql-patches by date

Next:From: Hiroshi InoueDate: 2003-09-26 21:52:44
Subject: Re: pgsql-server/src/backend catalog/index.c comma ...
Previous:From: Aleksander KmetecDate: 2003-09-26 05:20:46
Subject: psql translation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group