Re: return varchar from C function
От | Pavel Stehule |
---|---|
Тема | Re: return varchar from C function |
Дата | |
Msg-id | BAY20-F2105C029334674EEB8C8BBF98B0@phx.gbl обсуждение исходный текст |
Ответ на | return varchar from C function ("scotty@linuxtime.it" <scotty@linuxtime.it>) |
Ответы |
Re: return varchar from C function
|
Список | pgsql-hackers |
Hello cstring is clasic c (zero terminated) string and is used only in some PostgreSQL functions. This type isn't compatible with text and you have to explicit cast trick with textin function. root=# select textin(('abc'::cstring)); textin -------- abc (1 row) Standard is using VARLENA types like text, varchar, ... You can find info in PostgreSQL FAQ. These types are similar Pascal string -> first four bytes cary length and next bytes are data without spec. ending symbol. http://www.varlena.com/GeneralBits/68.php using text type in C function is simple: Datum *const_fce(PG_FUNCTION_ARGS) { text *txt = palloc(5 + VARHDRSZ); memcpy(VARDATA(txt), "pavel", 5); VARATT_SIZE(txt) = 5 + VARHDRSZ; PG_RETURN_TEXT_P(txt); } please look to source code my orafce contrib module (you can find it on pgfoundry). Regards Pavel Stehule _________________________________________________________________ Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/
В списке pgsql-hackers по дате отправления: