2007-10-13_15:22:34-0400 Gregory Stark <stark@xxxxxxxxxxxxxxxx>: > "Ron Peterson" <ron.peterson@xxxxxxxxxxxxxx> 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 starting with an _. > Postgres names array types starting with _ so that's likely to confuse > something and if not something then at least someone. Thanks. I got it working, but returning a composite type of text values, rather than bytea. I think that's better for me anyway, because I'd like my type's input and output functions to take hex values instead of the crazy bytea octet representation. I ended up doing CREATE TYPE full_key AS ( n TEXT, e TEXT, d TEXT ); - vals = (char**)palloc( sizeof(char*) * 3 ); // convert key parts to strings len = mpz_sizeinbase( Y_FULL_KEY_MOD(&akey), 16 ) + 1; vals[0] = (char *)palloc( len ); gmp_snprintf( vals[0], len, "%Zx", Y_FULL_KEY_MOD(&akey) ); ...etc if( get_call_result_type( fcinfo, NULL, &td ) != TYPEFUNC_COMPOSITE ) { ereport( ERROR, ( errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg( "function returning record called in context " "that cannot accept type record" ))); PG_RETURN_NULL(); } // Make a persistant copy. td = CreateTupleDescCopy( td ); aim = TupleDescGetAttInMetadata( td ); ht = BuildTupleFromCStrings( aim, vals ); /* make the tuple into a datum */ result = HeapTupleGetDatum( ht ); Someday I'd still like to figure out how to return a composite type containing bytea values... -- Ron Peterson https://www.yellowbank.com/ ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your message can get through to the mailing list cleanly