title: PHP Postgres bug adding index after table creation using values
body: <p>Inside a php file I use the bellow code that creates a string to pass to a postgres server.</p>
  <pre><code>$vv=...
  
  $cc.=&quot;drop table if exists aa cascade;&quot;;
  
  $cc.=&quot;create table a(mark,xx,yy) as VALUES $vv ;&quot;;
  
  $cc.=&quot;alter table aa add primary key(mark);&quot;;
  
  $db-&gt;query($cc) or die(&quot;&lt;br&gt;$db-&gt;lasterror&lt;br&gt;&quot;);
  </code></pre>
  <p>BUT I get error: ERROR: 42P16: multiple primary keys for table &quot;aa&quot; are not allowed LOCATION: index_check_primary_key, index.c:206</p>
  <p>If I execute the query by &quot;hand&quot; copying the generated string inside pgadmin it works.
  If I execute the query in two parts,calling $db-&gt;query() twice first dropping and creating the table and after calling the primary key creating it works.
  Obviously the data added is huge.
  It seems to me that the call prosecutes concurrently to delete the table, create and add values and to create an index generating the above problem.</p>
  <p>Any similar experience; may I put a &quot;semaphore&quot; by hand, in the postgres code to allow for the completion of previous steps before prosecuting to index creation ;</p>