I'm trying to locally download the results of a query as csv on a postgres instance that I have read-only access to (v8.0.2). I've truly read 10 different ways of going about this and have tried implementing them all (here, here, here, here, and here), but every single time I try to execute the copy command, I get the following error:
ERROR: syntax error at or near "STDOUT"
Here are five of the roughly 20 permutations I have tried. The foo_bar table is a temporary table that was created as the output of a query.
=> \copy "pg_temp_5.foo_bar" TO '/Users/baz/Downloads/foo_bar.csv' DELIMITER ',' CSV
ERROR: syntax error at or near "STDOUT"
LINE 1: COPY "pg_temp_5.foo_bar" TO STDOUT DELIMITER ',' CSV
=> \copy "pg_temp_5.foo_bar" TO '/Users/baz/Downloads/foo_bar.csv' CSV
ERROR: syntax error at or near "STDOUT"
LINE 1: COPY "pg_temp_5.foo_bar" TO STDOUT CSV
=> \copy "pg_temp_5.foo_bar" TO '/Users/baz/Downloads/foo_bar.csv' WITH FORMAT "csv"
ERROR: syntax error at or near "STDOUT"
LINE 1: COPY "pg_temp_5.foo_bar" TO STDOUT WITH FORMAT "csv"
=> \copy pg_temp_5.foo_bar TO '/Users/baz/Downloads/foo_bar.csv' With CSV
ERROR: syntax error at or near "STDOUT"
LINE 1: COPY pg_temp_5.foo_bar TO STDOUT With CSV
=> \copy foo_bar TO foo_bar.csv With CSV
ERROR: syntax error at or near "STDOUT"
LINE 1: COPY foo_bar TO STDOUT With CSV
I figure that it isn't a permissions issue, as if it were, I would be thrown a "permission denied" when I try to run the command. I also know that there have been similar issues with the \copy command as documented by postgres here, but nothing has been noted specifically with regards to my case. Any help would be greatly appreciated!