Thread: Corrupted string length for bit(n) in information schema

Corrupted string length for bit(n) in information schema

From
Claus Colloseus
Date:
Your name        :   Claus Colloseus
Your email address    :   collos@physik.tu-berlin.de

System Configuration
---------------------
  Architecture         :   AMD Athlon XP 2000+

  Operating System     :   Windows 2000 V. 5.00.2195

  PostgreSQL version    :   PostgreSQL-7.4

  Compiler used        :   precompiled for Cygwin distribution:
                postgresql-7.4-1.tar.bz2 from 23.11.2003


Please enter a FULL description of your problem:
------------------------------------------------

After creating a domain of type bit(n), the length n is given back
with another number from the information schema. The same distended
number shows up f. e. in the SQL script or the Property table
of pgAdmin.

In the tested case, instead of n=10 as input, n=6 was given back.

Furthermore, a check constraint for the domain doesn't show up in
the information_schema.check_constraints table at all.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

A test Database was created by pgAdmin III Version 1.0.1 (Oct 14 2003)
for Windows with:

CREATE DATABASE test
  WITH ENCODING = 'UNICODE';

The following was executed with psql V. 7.4 in a Cygwin Bash shell:

CREATE DOMAIN public.dom_10bit
  AS bit(10)
  DEFAULT B'0000000000'
  NOT NULL
   CHECK ((VALUE = B'0000000000') OR (VALUE = B'0000000001'));

Afterwards, the following queries gave the respective results:

SELECT domain_name, data_type, character_maximum_length, character_octet_length,
  domain_default, udt_name, dtd_identifier
FROM information_schema.domains
WHERE domain_name = 'dom_10bit';

 domain_name | data_type | character_maximum_length | character_octet_length |    domain_default    | udt_name |
dtd_identifier

-------------+-----------+--------------------------+------------------------+----------------------+----------+----------------
 dom_10bit   | bit       |                        6 |                        | B'0000000000'::"bit" | bit      | 1
(1 row)

SELECT *
FROM information_schema.check_constraints;

 constraint_catalog | constraint_schema | constraint_name | check_clause
--------------------+-------------------+-----------------+--------------
(0 rows)

SELECT typname, typlen, typtype, typtypmod, typdefaultbin
FROM pg_type
WHERE typname = 'dom_10bit';

  typname  | typlen | typtype | typtypmod |

typdefaultbin

-----------+--------+---------+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 dom_10bit |     -1 | d       |        10 | {FUNCEXPR :funcid 1685 :funcresulttype 1560 :funcretset false :funcformat 2
:args({CONST :consttype 1560 :constlen -1 :constbyval false :constisnull false :constvalue 10 [ 10 0 0 0 10 0 0 0 0 0
]}{CONST :consttype 23 :constlen 4 :constbyval true :constisnull false :constvalue 4 [ 10 0 0 0 ]} {CONST :consttype 16
:constlen1 :constbyval true :constisnull false :constvalue 1 [ 0 0 0 0 ]})} 
(1 row)

SELECT conname, contype, conbin, consrc
FROM pg_type t INNER JOIN pg_constraint c
  ON t.oid = c.contypid
WHERE typname = 'dom_10bit';

 conname | contype |

                          conbin

                                      |                               consrc 

---------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------
 $1      | c       | {BOOLEXPR :boolop or :args ({OPEXPR :opno 1784 :opfuncid 0 :opresulttype 16 :opretset false :args
({COERCETODOMAINVALUE:typeId 1560 :typeMod 10} {CONST :consttype 1560 :constlen -1 :constbyval false :constisnull false
:constvalue10 [ 10 0 0 0 10 0 0 0 0 0 ]})} {OPEXPR :opno 1784 :opfuncid 0 :opresulttype 16 :opretset false :args
({COERCETODOMAINVALUE:typeId 1560 :typeMod 10} {CONST :consttype 1560 :constlen -1 :constbyval false :constisnull false
:constvalue10 [ 10 0 0 0 10 0 0 0 0 64 ]})})} | ((VALUE = B'0000000000'::"bit") OR (VALUE = B'0000000001'::"bit")) 
(1 row)

pgAdmin3 now shows the following script (notice the double 'CHECK'):

CREATE DOMAIN public.dom_10bit
  AS bit(6)
  DEFAULT B'0000000000'::"bit"
  NOT NULL
   CHECK CHECK ((VALUE = B'0000000000'::"bit") OR (VALUE = B'0000000001'::"bit"));

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

well, no, i'm a newbie to PostgreSQL

Sincerely,
Claus Colloseus

Re: Corrupted string length for bit(n) in information schema

From
Peter Eisentraut
Date:
Claus Colloseus wrote:
> After creating a domain of type bit(n), the length n is given back
> with another number from the information schema.

Will be fixed in 7.4.1.