[HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread David E. Wheeler
Howdy, I was just updating a function in pgTAP that, given a schema name and an array of function names, returns a set of those function names that are not in the named schema. I got it working with a subquery, and David Fetter suggested that I try an EXCEPT query instead. The only

Re: [HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread Jeff Davis
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)

Re: [HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread Andrew Dunstan
David E. Wheeler wrote: Howdy, I was just updating a function in pgTAP that, given a schema name and an array of function names, returns a set of those function names that are not in the named schema. I got it working with a subquery, and David Fetter suggested that I try an EXCEPT query

Re: [HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread David E. Wheeler
On Feb 19, 2009, at 5:45 PM, Andrew Dunstan wrote: A limitation of this feature is that an ORDER BY clause applying to the result of a UNION, INTERSECT, or EXCEPT clause can only specify an output column name or number, not an expression. Why not just say order by 1 ? Well, in this case,

Re: [HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread Andrew Dunstan
David E. Wheeler wrote: On Feb 19, 2009, at 5:45 PM, Andrew Dunstan wrote: A limitation of this feature is that an ORDER BY clause applying to the result of a UNION, INTERSECT, or EXCEPT clause can only specify an output column name or number, not an expression. Why not just say order by

Re: [HACKERS] ORDER BY with EXCEPT?

2009-02-19 Thread Andrew Dunstan
I wrote: select foo from ( SELECT quote_ident($2[i]) as foo, 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