While I'm all for COPY from views, I think I'd rather have the
syntactic
warts than code warts. ISTM that
CREATE TEMP VIEW some_name AS SELECT * FROM table WHERE ...;
COPY some_name TO stdout;
is much uglier than
COPY SELECT * FROM table WHERE ... TO stdout;
Or, you could just allow subqueries in COPY to disambiguate the syntax:
COPY (SELECT * FROM table WHERE i=1) TO stdout;
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-
AgentM
[EMAIL PROTECTED]
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend