Re: Initial review of xslt with no limits patch

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Mike Fowler <mike(at)mlfowler(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Initial review of xslt with no limits patch
Date: 2010-08-06 21:12:53
Message-ID: AANLkTikVYgRWAy-kBAWskq0tjGGONp7Up7OCC+QxqY7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/8/6 David E. Wheeler <david(at)kineticode(dot)com>:
> On Aug 6, 2010, at 1:49 PM, Pavel Stehule wrote:
>
>> yes it is one a possibility and probably best. The nice of this
>> variant can be two forms like current variadic does -  foo(.., a :=
>> 10, b := 10) or foo(.., variadic ARRAY[(a,10),(b,10)])
>
> I started fiddling and got as far as this:
>
>
> CREATE TYPE pair AS ( key text, val text );
>
> CREATE OR REPLACE FUNCTION pair(anyelement, anyelement) RETURNS pair
> LANGUAGE SQL AS $$
>    SELECT ROW($1, $2)::pair;
> $$;
>
> CREATE OR REPLACE FUNCTION pair(text, text) RETURNS pair
> LANGUAGE SQL AS $$
>    SELECT ROW($1, $2)::pair;
> $$;
>
> CREATE OPERATOR ~> (
>        LEFTARG = anyelement,
>        RIGHTARG = anyelement,
>        PROCEDURE = pair
> );
>
> CREATE OPERATOR ~> (
>        LEFTARG = text,
>        RIGHTARG = text,
>        PROCEDURE = pair
> );
>
> CREATE OR REPLACE FUNCTION foo(variadic pair[]) RETURNS SETOF text
> LANGUAGE SQL AS $$
> --    SELECT unnest($1)::text
>    SELECT $1[1].key
>    UNION  SELECT $1[1].val
>    UNION  SELECT $1[2].key
>    UNION  SELECT $1[2].val;
> $$;
>
> SELECT foo('this' ~> 'that', 1 ~> 4);
>
> Not bad, I think. I kind of like it. It reminds me how much I hate the % hstore construction operator, though (the new name for =>).

so there is only small step to proposed feature

SELECT foo(this := 'that', "1" := 4)

there is only one difference (but you cannot implement it now)
* notation for key is same like for sql identifier - why: I would to
clearly identify key and value. When I use a custom operator - like
you did, it depends on implementation what is key, what is value. When
you use a SQL identifier's notation for key, you can't to do a error

Regards

Pavel

>
> Best,
>
> David
>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2010-08-06 21:13:39 Re: MERGE Specification
Previous Message Peter Eisentraut 2010-08-06 21:08:47 Re: patch for contrib/isn