On 2006-09-18, "Jack Orenstein" <jack.orenstein@xxxxxxxxx> wrote: > On 9/14/06, Andrew - Supernews <andrew+nonews@xxxxxxxxxxxxx> wrote: >> One way: > > Thank you, I hope you can help with some clarifications. > >> >> bytea *my_bytea = (bytea *) palloc(byte_array_len + VARHDRSZ); >> memcpy(VARDATA(my_bytea), byte_array, byte_array_len); >> VARATT_SIZEP(my_bytea) = byte_array_len + VARHDRSZ; >> >> values[0] = DirectFunctionCall1(textin,CStringGetDatum(yourstring)); > > What is textin -- the name of a function? textin is the name of the input function for the "text" type; it takes a C string as input and returns a Datum. Most (but not all) type input functions can be called this way. (The format of the C string that you pass to a type input function is exactly the same as you'd send from a client, without quoting/escaping.) (The ones that can't be called by DirectFunctionCall1 are those that need access to type info, such as array or composite value input, or user-defined types. Those are callable using other fmgr interfaces.) >> values[1] = PointerGetDatum(my_bytea); > > One other thing is still unclear: What about signed/unsigned long? If > I have a C long, then how do I get a Datum that I can assign to > values[i]? What matters isn't so much the C type that you have, as the SQL type that you are supposedly providing. Pg doesn't have an "unsigned" type unless you created your own, so the question is, are you passing an int4 or an int8 to SQL? -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services