Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread Martijn van Oosterhout
On Sun, Jun 15, 2008 at 10:07:43PM -0700, David E. Wheeler wrote: Howdy, Possibly showing my ignorance here, but as I'm working on updating citext to be locale-aware and to work on 8.3, I've run into this peculiarity: The only odd thing I see is the use of PG_ARGS to pass the arguments

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
On Jun 16, 2008, at 02:52, Martijn van Oosterhout wrote: The only odd thing I see is the use of PG_ARGS to pass the arguments to citextcmp. But I can't see why it would break either. Can you attach a debugger and see where it goes wrong? Yes, I can do that, although I'm pretty new to C (let

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
On Jun 16, 2008, at 09:24, David E. Wheeler wrote: On Jun 16, 2008, at 02:52, Martijn van Oosterhout wrote: The only odd thing I see is the use of PG_ARGS to pass the arguments to citextcmp. But I can't see why it would break either. Can you attach a debugger and see where it goes wrong?

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread Tom Lane
David E. Wheeler [EMAIL PROTECTED] writes: What's even weirder is that it can not work and then suddenly work: Smells like uninitialized-memory problems to me. Perhaps you are miscalculating the length of the input data? Are you testing in an --enable-cassert build? The memory clobber stuff

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
On Jun 16, 2008, at 13:06, Tom Lane wrote: David E. Wheeler [EMAIL PROTECTED] writes: What's even weirder is that it can not work and then suddenly work: Smells like uninitialized-memory problems to me. Perhaps you are miscalculating the length of the input data? Entirely possible. Here

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread Martijn van Oosterhout
On Mon, Jun 16, 2008 at 01:29:33PM -0500, David E. Wheeler wrote: Smells like uninitialized-memory problems to me. Perhaps you are miscalculating the length of the input data? Entirely possible. Here are the two functions in which I calculate size: Actually, real dumb question but: arn't

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
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

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread Tom Lane
David E. Wheeler [EMAIL PROTECTED] writes: Now I have just one more bizarre error: PostgreSQL thinks that a citext column is not in an aggregate even when it is: 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

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
On Jun 16, 2008, at 14:38, Tom Lane wrote: It's complaining about the use in ORDER BY. Okay, so stupid question: How can I get an array of the values in a given order? I guess this works: select array_accum(b) from ( select name from srt order by name ) AS A(b); Thanks, David --

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David Fetter
On Mon, Jun 16, 2008 at 02:45:57PM -0500, David Wheeler wrote: On Jun 16, 2008, at 14:38, Tom Lane wrote: It's complaining about the use in ORDER BY. Okay, so stupid question: How can I get an array of the values in a given order? I guess this works: select array_accum(b) from ( select

Re: [HACKERS] Question about Encoding a Custom Type

2008-06-16 Thread David E. Wheeler
On Jun 16, 2008, at 16:48, David Fetter wrote: select array_accum(b) from ( select name from srt order by name ) AS A(b); SELECT ARRAY(SELECT name FROM srt ORDER BY name); -- also works. Wow, somehow I'd missed that syntax over the years. Thanks David! Best, David -- Sent via