[SQL] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-13 Thread Moran.Michael
Hello all, I have a table with a VARCHAR column that I need to convert to a BYTEA. How do I cast VARCHAR to BYTEA? The following doesn't seem to work as it yields the 'cannot cast varchar to bytea' error message: varchar_data::bytea On the same topic, how do I do the reverse, that is,

[SQL] PGCrypto with Integers and DATE types -- how to?

2005-03-16 Thread Moran.Michael
Hello, How do you encrypt() & decrypt() data of types INT4 or DATE? The PGCrypto methods encrypt() and decrypt() each take BYTEA as input: i.e., encrypt( data::bytea, key::bytea, type::text) decrypt( data::bytea, key::bytea, type::text) So how do you convert INT4 and DATE data into BYTE

[SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Moran.Michael
Hello there, What's the preferred and most efficient way to obtain PGCrypto encrypted data from a plpgsql function? 1. Imagine the following simple table: CREATE TABLE crypto ( pid SERIAL PRIMARY KEY, title VARCHAR(50), crypted_content BYTEA ); 2. Now insert the following 3 rows

Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Moran.Michael
n's RETURN declaration is logical... but now I know that if want a VARCHAR, I gotta manipulate it as a TEXT within my function when using PGCrypto. Any idea why? Thank again, Jim! _ From: Jim Buttafuoco [mailto:[EMAIL PROTECTED] Sent: Thu 3/24/2005 9:14 AM To: Moran.Mic

Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Moran.Michael
in advance. -Michael Moran _ From: Jim Buttafuoco [mailto:[EMAIL PROTECTED] Sent: Thu 3/24/2005 9:58 AM To: Moran.Michael; Subject: Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ?? I would change the return type to TEXT, I believe your original example had it as a varchar and

Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Moran.Michael
content, decode(''password''::text, ''escape''::text), ''aes''::text), ''escape''::text ) = _crypt_data; RETURN ( ret ); END; ' LANGUAGE 'plpgsql'; Thanks, all. This postgresql forum rocks!

[SQL] Calling functions from Delete View (+ contrib/pgcrypto) = madness ??

2005-03-24 Thread Moran.Michael
Hello there, I have a View with a Delete rule and I would like the Delete rule to call a function (and pass-in a few of the the underlying View's/Table's column values). How do you do this? When I do it, I keep getting the following error: ERROR: function expression in FROM may not refer to ot

Re: [SQL] Calling functions from Delete View (+ contrib/pgcrypto)

2005-03-25 Thread Moran.Michael
ding answers to questions like mine below. Much better than the Hackers or Admin forums it seems. Thanks all! -Michael Moran _ From: Jim Buttafuoco [mailto:[EMAIL PROTECTED] Sent: Thu 3/24/2005 7:44 PM To: Moran.Michael; pgsql-sql@postgresql.org Subject: Re: [SQL] Calling functions f

[SQL] Securing VIEWS that use contrib/pgcrypto -- how?

2005-03-25 Thread Moran.Michael
Hello there, How do you secure a VIEW so that only certain users may use it? Let's say you have a table that has a BYTEA column that holds (pgcrypto) encrypted data; and you have a VIEW on the aforementioned table that returns the decrypted contents of the BYTEA column. How do you secure this V

[SQL] PGCrypto: Realworld scenario and advice needed

2005-04-11 Thread Moran.Michael
Hello all, I'm looking for advice on real-world PGCrypto usage. I understand how to programmatically encrypt/decrypt data with PGCrypto -- no problem. My question is: What is the best way to update massive amounts of *existing* encrypted data with a new encryption passphrase, assuming you k

Re: [SQL] PGCrypto: Realworld scenario and advice needed

2005-04-14 Thread Moran.Michael
Thank you, Joe. Your solution provided below works great. Much better/simpler than my original approach. You rock! -Michael _ From: Joe Conway [mailto:[EMAIL PROTECTED] Sent: Mon 4/11/2005 3:26 PM To: Moran.Michael Cc: PostgreSQL Subject: Re: [SQL] PGCrypto: Realworld scenario and