Re: Storing images in PG?
От | Joe Conway |
---|---|
Тема | Re: Storing images in PG? |
Дата | |
Msg-id | 027d01c12679$76bf9590$48d210ac@jecw2k1 обсуждение исходный текст |
Ответ на | RE: Storing images in PG? ("Andrew Snow" <andrew@modulus.org>) |
Список | pgsql-general |
> Postgresl, in treating things as strings, handles \000 as NULL as an end > of string. > > select 'abc\000def' as hehehe; > hehehe > -------- > abc > (1 row) > By the way, the '\000' string in the select statement above does get converted to '\0' prior to byteain(), and that is precisely why the value returned is truncated at that point. Take a look at the following snipit of code: <snip> Datum byteain(PG_FUNCTION_ARGS) { char *inputText = PG_GETARG_CSTRING(0); char *tp; char *rp; int byte; bytea *result; for (byte = 0, tp = inputText; *tp != '\0'; byte++) </snip> Notice that byteain() gives up as soon as it hits a '\0' in the input string. So the '\\000' on the client end turns into '\000' by the time it hits byteain(), and byteain converts it to a single character '\0'. Hope this all makes sense. -- Joe
В списке pgsql-general по дате отправления: