Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_15:22:34-0400 Gregory Stark <[EMAIL PROTECTED]>: > "Ron Peterson" <[EMAIL PROTECTED]> writes: > > > My first thought was to just do something like: > > > > CREATE TYPE __full_key AS ( n bytea, e bytea, d bytea ); > > > > CREATE OR REPLACE FUNCTION > > generate_rsa_key( ) > > RETURNS >

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Gregory Stark
"Ron Peterson" <[EMAIL PROTECTED]> writes: > My first thought was to just do something like: > > CREATE TYPE __full_key AS ( n bytea, e bytea, d bytea ); > > CREATE OR REPLACE FUNCTION > generate_rsa_key( ) > RETURNS > __full_key Oh, incidentally you probably don't want to name your type star

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Gregory Stark
"Ron Peterson" <[EMAIL PROTECTED]> writes: > Am I making this way too complicated? Do I only have to return a C > string representation of three bytea values as a tuple? No, if you want to define a composite type and return it then you're on the right track to be using heap_form_tuple. And usin

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_14:15:06-0400 yrp001: > select * from generate_rsa_key(); Am I making this way too complicated? Do I only have to return a C string representation of three bytea values as a tuple? (I still think a bona-fide user-defined type in C is probably better.) -- Ron Peterson https://www.ye

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_13:44:33-0400 Gregory Stark <[EMAIL PROTECTED]>: > "Ron Peterson" <[EMAIL PROTECTED]> writes: > > > I think I can get where I want to go without completely figuring that out > > right now though... > > What are you trying to do? I've implemented the RSA PKCS #1 v2.1 public key cryptog

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Gregory Stark
"Ron Peterson" <[EMAIL PROTECTED]> writes: > I think I can get where I want to go without completely figuring that out > right now though... What are you trying to do? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com ---(end of broadcast)--

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_11:12:05-0400 Gregory Stark <[EMAIL PROTECTED]>: > "Ron Peterson" <[EMAIL PROTECTED]> writes: > > > 2007-10-13_08:50:56-0400 Ron Peterson <[EMAIL PROTECTED]>: > >> 2007-10-13_01:22:06-0400 Gregory Stark <[EMAIL PROTECTED]>: > > > >> > And normally you would define your own datatype and

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Gregory Stark
"Ron Peterson" <[EMAIL PROTECTED]> writes: > 2007-10-13_08:50:56-0400 Ron Peterson <[EMAIL PROTECTED]>: >> 2007-10-13_01:22:06-0400 Gregory Stark <[EMAIL PROTECTED]>: > >> > And normally you would define your own datatype and not use bytea. >> >> Actually, I already have my data in a structure mu

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_08:50:56-0400 Ron Peterson <[EMAIL PROTECTED]>: > 2007-10-13_01:22:06-0400 Gregory Stark <[EMAIL PROTECTED]>: > > And normally you would define your own datatype and not use bytea. > > Actually, I already have my data in a structure much like varlena. Pght, I misunderstood what you we

Re: [GENERAL] convert binary string to datum

2007-10-13 Thread Ron Peterson
2007-10-13_01:22:06-0400 Gregory Stark <[EMAIL PROTECTED]>: > "Ron Peterson" <[EMAIL PROTECTED]> writes: > > > Is this a legitimate/blessed way to go about it? > > > > aval = (bytea *)palloc( len + VARHDRSZ ); > > VARATT_SIZEP(aval) = len + VARHDRSZ; > > memcpy( VARDATA(aval), myrawdata, len ); >

Re: [GENERAL] convert binary string to datum

2007-10-12 Thread Gregory Stark
"Ron Peterson" <[EMAIL PROTECTED]> writes: > Is this a legitimate/blessed way to go about it? > > aval = (bytea *)palloc( len + VARHDRSZ ); > VARATT_SIZEP(aval) = len + VARHDRSZ; > memcpy( VARDATA(aval), myrawdata, len ); > values[0] = PointerGetDatum(aval); > ...etc > tuple = heap_formtuple( tupd

Re: [GENERAL] convert binary string to datum

2007-10-12 Thread Ron Peterson
2007-10-12_22:22:32-0400 Ron Peterson <[EMAIL PROTECTED]>: > How does one convert an octet string (e.g. something like a varlena > structure) to a Datum? I want to create datums for use w/ > heap_form_tuple in a function returning a tuple containing bytea > representations of very large integers.

[GENERAL] convert binary string to datum

2007-10-12 Thread Ron Peterson
How does one convert an octet string (e.g. something like a varlena structure) to a Datum? I want to create datums for use w/ heap_form_tuple in a function returning a tuple containing bytea representations of very large integers. TIA -- Ron Peterson https://www.yellowbank.com/ ---