title: MySQL reports a primary key but can not drop it from the table
body: <p>I am in the process of updating some tables in my database and I use the following code to check for a primary key and drop it then add a new primary key.</p>
  
  <pre><code>if(strpos($value,'PRIMARY') !== false)
  {
      $dropit = "DROP PRIMARY KEY ,";
      $query = "ALTER TABLE `".$tablename."` ".$dropit." ADD PRIMARY KEY (`".$name."`);" ;
  }
  </code></pre>
  
  <p>When I run I get this error:</p>
  
  <blockquote>
    <p>1091 - Can't DROP 'PRIMARY'; check that column/key exists SQL=ALTER
    TABLE `my_table` DROP PRIMARY KEY , ADD PRIMARY KEY (`id`);</p>
  </blockquote>
  
  <p>After some googling I have seen this issue show up on the MySQL bug reports form like 2006 so I would have figured it would be resolved by now. <a href="http://bugs.mysql.com/bug.php?id=26076" rel="nofollow">MySQL Bugs</a> My version of My SQL is 5.1.44 so not super old... It seems that a column can look like a primary key but not be a primary key... so I am wondering if there is a better way to check before I try and remove to prevent the error.</p>
  
  <p>I have also seen this on some Drupal forums but no clues are given on how to resolve...</p>
  
  <p>If you think more of the surrounding code will help let me know and I will add.</p>