Unnecessary casts in pg_cast

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Unnecessary casts in pg_cast
Date: 2007-11-13 14:07:14
Message-ID: 87bq9yjl2l.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


postgres=# select *,(select typname from pg_type where oid = castsource) as source,(select typname from pg_type where oid = casttarget) as target from pg_cast where castsource = 25 or casttarget = 25;
castsource | casttarget | castfunc | castcontext | source | target
------------+------------+----------+-------------+---------+----------
25 | 2205 | 1079 | i | text | regclass
25 | 1042 | 0 | i | text | bpchar
25 | 1043 | 0 | i | text | varchar
1042 | 25 | 401 | i | bpchar | text
1043 | 25 | 0 | i | varchar | text
18 | 25 | 946 | i | char | text
19 | 25 | 406 | i | name | text
25 | 18 | 944 | a | text | char
25 | 19 | 407 | i | text | name
650 | 25 | 730 | a | cidr | text
869 | 25 | 730 | a | inet | text
16 | 25 | 2971 | a | bool | text
142 | 25 | 2922 | a | xml | text
25 | 142 | 2896 | e | text | xml
(14 rows)

Why do we need assignment casts from cidr, inet, bool, and xml to text? These
all seem redundant since there's effectively an assignment cast from every
data type to text anyways:

postgres=# delete from pg_cast where casttarget = 25;
DELETE 8

postgres=# insert into t values ('1.0.0.0'::cidr);
INSERT 0 1

postgres=# select * from t;
t
------------
1.0.0.0/32
(1 row)

postgres=# \d t
Table "public.t"
Column | Type | Modifiers
--------+------+-----------
t | text |

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's Slony Replication support!

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message rjalster 2007-11-13 14:34:44 New to PostgreSQL
Previous Message Gregory Stark 2007-11-13 13:12:23 Re: Simplifying Text Search