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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Binary data type with other output method



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group