Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6F31DB5DBE5 for ; Tue, 28 Jun 2011 17:42:32 -0300 (ADT) 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 47762-01 for ; Tue, 28 Jun 2011 20:42:32 +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 A78E8B5DBE4 for ; Tue, 28 Jun 2011 17:42:31 -0300 (ADT) 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 p5SKgVMT044970 for ; Tue, 28 Jun 2011 20:42:31 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p5SKgVjo044969; Tue, 28 Jun 2011 20:42:31 GMT (envelope-from www) Date: Tue, 28 Jun 2011 20:42:31 GMT Message-Id: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6080: information_schema.columns.column_default contains NULL inconsistently From: "Chris Bandy" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/213 X-Sequence-Number: 30592 The following bug has been logged online: Bug reference: 6080 Logged by: Chris Bandy Email address: bandy.chris@gmail.com PostgreSQL version: 9.0.3 Operating system: Gentoo Description: information_schema.columns.column_default contains NULL inconsistently Details: While using the information_schema to examine my tables, I found that "columns"."column_default" does not consistently represent the DEFAULT constraint/definition of a column. I would expect a column without a DEFAULT definition to return a null value, while a column with a DEFAULT definition would return the defined expression as a character value. In the following log, columns "a", "b" and "c" appear identical though their definitions differ. -- Chris $ psql -P null='' testing psql (9.0.3) Type "help" for help. testing=> select version(); version ---------------------------------------------------------------------------- --------------------------------------------------- PostgreSQL 9.0.3 on x86_64-pc-linux-gnu, compiled by GCC x86_64-pc-linux-gnu-gcc (Gentoo 4.4.5 p1.2, pie-0.4.5) 4.4.5, 64-bit (1 row) testing=> create table tt (a varchar, b varchar default null, c varchar default null::varchar, d varchar(1) default null, e varchar(1) default null::varchar); CREATE TABLE testing=> \d tt Table "public.tt" Column | Type | Modifiers --------+----------------------+--------------------------------- a | character varying | b | character varying | c | character varying | d | character varying(1) | default NULL::character varying e | character varying(1) | default NULL::character varying testing=> select column_name, data_type, column_default from information_schema.columns where table_name = 'tt'; column_name | data_type | column_default -------------+-------------------+------------------------- a | character varying | b | character varying | c | character varying | d | character varying | NULL::character varying e | character varying | NULL::character varying (5 rows)