title: COPY 0 when copying table with data in PostgreSQL to CSV
body: <p>I have a table under a schema, <code>table_schema</code>, that has data in it:</p>
  
  <pre><code>\c data_store
  select count(*) from table_schema.mytable;
  9898123 rows
  </code></pre>
  
  <p>But when I try to copy this data to a CSV file, I get COPY 0:</p>
  
  <pre><code>copy table_schema.mytable to '/tmp/mytable.csv' with (format csv, header);
  COPY 0
  </code></pre>
  
  <p>but if use a select instead, the file is created correctly:</p>
  
  <pre><code>copy (select * from table_schema.mytable) to '/tmp/mytable.csv' with (format csv, header)
  COPY 9898123
  </code></pre>
  
  <p>Any ideas on what's going on here? PostgreSQL version is 9.6.</p>