Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2008-03-24 Thread Bruce Momjian
Added to TODO: * Allow xml arrays to be cast to other data types http://archives.postgresql.org/pgsql-hackers/2007-09/msg00981.php http://archives.postgresql.org/pgsql-hackers/2007-10/msg00231.php http://archives.postgresql.org/pgsql-hackers/2007-11/msg00471.php

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-12 Thread Pavel Stehule
> > > > You're right, that's my mistake, sorry. So, having casting rules seems > > to be the only option.. > > > > > We can already cast as text[], and so we can do this: > > andrew=# select > xpath('//foo/text()','12')::text[]::int[]; > xpath > --- > {1,2} > (1 row) > > > So why do we desper

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-12 Thread Andrew Dunstan
Nikolay Samokhvalov wrote: On Nov 12, 2007 12:59 AM, Tom Lane <[EMAIL PROTECTED]> wrote: I'm not clear on what you're proposing. There is no such thing as an opclass with no operators (or at least, not a useful one), so this seems mutually contradictory. regards, t

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-11 Thread Nikolay Samokhvalov
On Nov 12, 2007 12:59 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > I'm not clear on what you're proposing. There is no such thing as an > opclass with no operators (or at least, not a useful one), so this seems > mutually contradictory. > > regards, tom lane > You're right, t

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-11 Thread Tom Lane
"Nikolay Samokhvalov" <[EMAIL PROTECTED]> writes: > Alternative (and maybe better) approach would be: > - create comparison functions that work in the same way as string > comparison functions do (currently, it's straight forward since XML is > stored as string); > - do NOT create comparison oper

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-11 Thread Pavel Stehule
On 11/11/2007, Nikolay Samokhvalov <[EMAIL PROTECTED]> wrote: > > > On Sep 25, 2007 10:57 AM, Pavel Stehule <[EMAIL PROTECTED]> wrote: > > Hello > > > > Current result from xpath function isn't indexable. It cannot be > > problem with possibility cast it to some base types. > > > > CREATE OR REPLAC

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-11 Thread Nikolay Samokhvalov
On Sep 25, 2007 10:57 AM, Pavel Stehule <[EMAIL PROTECTED]> wrote: > Hello > > Current result from xpath function isn't indexable. It cannot be > problem with possibility cast it to some base types. > > CREATE OR REPLACE FUNCTION xml_list_to_int(xml[]) > RETURNS int[] AS $$ > SELECT ARRAY(SELECT t

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-11-03 Thread Bruce Momjian
This has been saved for the 8.4 release: http://momjian.postgresql.org/cgi-bin/pgpatches_hold --- Andrew Dunstan wrote: > > > Peter Eisentraut wrote: > > Am Freitag, 28. September 2007 schrieb Nikolay Samokhvalov:

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-10-08 Thread Andrew Dunstan
Peter Eisentraut wrote: Am Freitag, 28. September 2007 schrieb Nikolay Samokhvalov: what should be returned for XML like "PostgreSQL is a powerful, open source relational database system" if user requests for text under "em" node? In XML world, the correct answer is "PostgreSQL is a powerf

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-10-08 Thread Peter Eisentraut
Am Freitag, 28. September 2007 schrieb Nikolay Samokhvalov: > what should be returned for XML like "PostgreSQL > is a powerful, open source relational database system" if user > requests for text under "em" node? In XML world, the correct answer is > "PostgreSQL  is a powerful, open source relation

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-28 Thread Pavel Stehule
2007/9/28, Nikolay Samokhvalov <[EMAIL PROTECTED]>: > On 9/28/07, Pavel Stehule <[EMAIL PROTECTED]> wrote: > > > We would create wrappers returning int[], bool[], string[], but there > > > are several issues with such functions: > > > - if the type of the data located on nodes that match XPath >

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-28 Thread Nikolay Samokhvalov
On 9/28/07, Pavel Stehule <[EMAIL PROTECTED]> wrote: > > We would create wrappers returning int[], bool[], string[], but there > > are several issues with such functions: > > - if the type of the data located on nodes that match XPath > > expression differs from what is expected, what should we d

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-28 Thread Pavel Stehule
> We would create wrappers returning int[], bool[], string[], but there > are several issues with such functions: > - if the type of the data located on nodes that match XPath > expression differs from what is expected, what should we do? raise exception > - in XML world, if you request for a

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-28 Thread Nikolay Samokhvalov
The problem with contrib/xml2's xpath_* functions (that return scalars) was that they are very specific. If XPath expression evaluation returns array of values (set of XML pieces), but the function returns only the first, significant information is lost, while there is no any gain in speed at all.

Re: [HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-25 Thread Peter Eisentraut
Am Dienstag, 25. September 2007 schrieb Pavel Stehule: > Current result from xpath function isn't indexable. It cannot be > problem with possibility cast it to some base types. Nikolay might be able to remind us what happened to the proposed functions xpath_bool, xpath_text, etc. -- Peter Eisen

[HACKERS] proposal casting from XML[] to int[], numeric[], text[]

2007-09-25 Thread Pavel Stehule
Hello Current result from xpath function isn't indexable. It cannot be problem with possibility cast it to some base types. CREATE OR REPLACE FUNCTION xml_list_to_int(xml[]) RETURNS int[] AS $$ SELECT ARRAY(SELECT to_number(($1[i])::text,'99.99')::int FROM generate_series(1, a