Re: Question about Encoding a Custom Type
От | David E. Wheeler |
---|---|
Тема | Re: Question about Encoding a Custom Type |
Дата | |
Msg-id | 6EF5F3C6-22D2-43C1-AAD2-5AD9B8E5AE59@kineticode.com обсуждение исходный текст |
Ответ на | Re: Question about Encoding a Custom Type (Martijn van Oosterhout <kleptog@svana.org>) |
Ответы |
Re: Question about Encoding a Custom Type
|
Список | pgsql-hackers |
On Jun 16, 2008, at 13:41, Martijn van Oosterhout wrote: > Actually, real dumb question but: arn't you assume that text* values > are NULL terminated, because they're not... >> >> char * cilower(text * arg) { >> // Do I need to free anything here? >> char * str = VARDATA_ANY( arg ); > > str here is not null terminated. You need text_to_cstring or something > similar. Ah! That makes sense. I changed it to this: #define GET_TEXT_STR(textp) DatumGetCString( \ DirectFunctionCall1( textout, PointerGetDatum( textp ) ) \ ) char * cilower(text * arg) { // Do I need to free anything here? char * str = GET_TEXT_STR( arg ); ... And now I don't get that error anymore. W00t! Many thanks. Now I have just one more bizarre error: PostgreSQL thinks that a citext column is not in an aggregate even when it is: try=# CREATE AGGREGATE array_accum (anyelement) ( try(# sfunc = array_append, try(# stype = anyarray, try(# initcond = '{}' try(# ); try=# CREATE TEMP TABLE srt ( name CITEXT ); try=# try=# INSERT INTO srt (name) try-# VALUES ('aardvark'), try-# ('AAA'), try-# ('â'); try=# select array_accum(name) from srt order by name; ERROR: column "srt.name" must appear in the GROUP BY clause or be used in an aggregate function Um, what? Again, I'm sure I'm just missing something really stupid. What might cause this? Many thanks all, David
В списке pgsql-hackers по дате отправления: