Problem with BYTEA, CAST, and pg_dump - Mailing list pgsql-general

From D. Dante Lorenso
Subject Problem with BYTEA, CAST, and pg_dump
Date
Msg-id 471CE5CF.8080309@vocalspace.com
Whole thread Raw
List pgsql-general
All,

I'm trying to use the crypt and decrypt functions from contrib and have
installed them into my database.  The definition for crypt seems to
require that I use BYTEA datatype to input the data I need to encrypt.
All of my data is either TEXT or VARCHAR, though and not BYTEA.

I was trying to run a query like this from a trigger:

     SELECT encrypt(NEW.card_number::bytea, 'password', 'bf')
     INTO NEW.card_number_enc;

Problem is that a cast from VARCHAR to BYTEA didn't exist.  I saw an
email thread that suggested I create the cast myself so I did:

     CREATE CAST (VARCHAR TO BYTEA) WITHOUT FUNCTION;

And that worked.  Now I can run the encrypt function above without a
problem.

However, when I use pg_dump and restore the dumped database, the CREAT
CAST is lost.  Is this a bug with pg_dump or should I be doing something
different?

-- Dante



pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Inheritance foreign key unexpected behaviour
Next
From: Magnus Hagander
Date:
Subject: Re: [HACKERS] 8.2.3: Server crashes on Windows using Eclipse/Junit