From: | Andreas 'ads' Scherbaum <adsmail(at)wars-nicht(dot)de> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Binary data type with other output method |
Date: | 2007-12-25 10:33:03 |
Message-ID: | 20071225113303.07760755@iridium.wars-nicht.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello all,
i'm in the need to create a boolean datatype which returns an integer
instead of the usual 't'/'f'. Before anyone starts to point me at
casts: it's a lot overhead to cast some hundred occurances beside the
source of trouble, if you forget one.
And so i asked myself, if there is an easier way than my current
approach. Right now i'm creating input/output functions, the datatype
and a lot of casts and operators (350 lines SQL) just to get another
output:
CREATE FUNCTION boolean2_in(cstring)
RETURNS boolean2
AS 'boolin'
LANGUAGE internal STRICT;
CREATE FUNCTION boolean2_out(boolean2)
RETURNS cstring
AS 'int2out'
LANGUAGE internal STRICT;
CREATE FUNCTION boolean2_recv(internal)
RETURNS boolean2
AS 'boolrecv'
LANGUAGE internal STRICT;
CREATE FUNCTION boolean2_send(boolean2)
RETURNS bytea
AS 'boolsend'
LANGUAGE internal STRICT;
CREATE TYPE boolean2 (
input = boolean2_in,
output = boolean2_out,
receive = boolean2_recv,
send = boolean2_send,
internallength = 1,
alignment = char,
storage = plain,
passedbyvalue
);
CREATE CAST (boolean2 AS boolean)
WITHOUT FUNCTION
AS ASSIGNMENT;
CREATE CAST (boolean AS boolean2)
WITHOUT FUNCTION
AS ASSIGNMENT;
... and so on.
Can i have this in an easier way?
Kind regards
--
Andreas 'ads' Scherbaum
German PostgreSQL User Group
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2007-12-25 16:10:25 | Re: Binary data type with other output method |
Previous Message | Bruce Momjian | 2007-12-25 06:16:10 | Re: Spoofing as the postmaster |