Re: ORDER BY with EXCEPT?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ORDER BY with EXCEPT?
Date: 2009-02-20 01:30:35
Message-ID: 1235093435.31454.69.camel@dell.linuxdev.us.dell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2009-02-19 at 17:13 -0800, David E. Wheeler wrote:
> CREATE OR REPLACE FUNCTION mytest(NAME, NAME[]) RETURNS setof text AS
> $$
> SELECT quote_ident($2[i])
> FROM generate_series(1, array_upper($2, 1)) AS s(i)
> EXCEPT
> SELECT quote_ident(p.proname)
> FROM pg_catalog.pg_proc p
> JOIN pg_catalog.pg_namespace n
> ON p.pronamespace = n.oid
> AND quote_ident(n.nspname) = quote_ident($1)
> ORDER BY s.i
> $$ LANGUAGE SQL;
>

You can make it work by naming the first quote_ident like
"quote_ident($2[i]) AS foo" and then doing ORDER BY foo.

It seems a little strange to me, too, but I assume that it's SQL
standard behavior.

Regards,
Jeff Davis

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacky Leng 2009-02-20 01:31:30 Re: Doubts about EvalPlanQual
Previous Message David E. Wheeler 2009-02-20 01:13:31 ORDER BY with EXCEPT?