title: Postgres pg_dump issue
body: <p>Good Day,</p>
  
  <p>I've been trying to restore a dump file using the psql client and I'm getting this error:</p>
  
  <pre><code>psql.bin:/home/user/Desktop/dump/dumpfile.sql:907:
  ERROR:  more than one function named "pg_catalog.avg"
  CONTEXT:  COPY pg_aggregate, line 1, column aggfnoid: "pg_catalog.avg"
  </code></pre>
  
  <p>I created the dump file from a different Postgres DB (version: 9.4.5) using the command:</p>
  
  <pre><code>pg_dump --username=pgroot ${tables} --no-owner --no-acl --no-security
  --no-tablespaces --no-unlogged-table-data --data-only dbname &gt; dumpfile.sql
  </code></pre>
  
  <p>Where <em>${tables}</em> is a variable in the for:</p>
  
  <pre><code>-T table1 -T table2 -T table3 ...
  </code></pre>
  
  <p>This is because I'm dumping specific tables listed in a new-line delimited file. Hence its not the entire database but specific tables I want to dump.</p>
  
  <p>I tried loading the the dump file int another Postgres DB (9.6) using the following command:</p>
  
  <pre><code>psql -d dbname -U superuser -v "ON_ERROR_STOP=1" -f
  ${DUMP_DIR}dumpfile.sql -1 -a &gt; ${LOG_ERR_DIR}dumpfile.log 
  2&gt;${LOG_ERR_DIR}dumpfile.err
  </code></pre>
  
  <p>This gave the error mentioned above. It seems this error is occurring because the dump file tries to add the function "pg_catalog.avg" to the database and it gives an error because it already exists.</p>
  
  <p>The sql file generated by the pg_dump does not have anywhere in it where it creates the pg_catalog.avg function, so i don't know why this is occurring.</p>
  
  <p>So I tried dropping the database and creating it from template0, and still I got the error. It seems to me that its a bug based on the follwoing post:</p>
  
  <p><a href="https://www.postgresql.org/message-id/4E5665AA.7080900@otg-nc.com" rel="nofollow noreferrer">Re: BUG #6176: pg_dump dumps pg_catalog tables</a> </p>
  
  <p>I'm stuck trying to reslove this issue. If anyone can help me resolve this issue please respond?</p>
  
  <p>Thank you in advance,
  j3rg</p>