--- a/adminer/drivers/pgsql.inc.php
+++ b/adminer/drivers/pgsql.inc.php
@@ -402,21 +402,31 @@
 	function alter_indexes($table, $alter) {
 		$create = array();
 		$drop = array();
+		$queries = array();
 		foreach ($alter as $val) {
 			if ($val[0] != "INDEX") {
 				$create[] = ($val[2] == "DROP"
 					? "\nDROP CONSTRAINT " . idf_escape($val[1])
-					: "\nADD $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . $val[2]
+					: "\nADD" . ($val[1] != "" ? " CONSTRAINT " . idf_escape($val[1]) : "") . " $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . $val[2]
 				);
 			} elseif ($val[2] == "DROP") {
 				$drop[] = idf_escape($val[1]);
-			} elseif (!queries("CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . " $val[2]")) {
+			} else {
+				$queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . " $val[2]";
+			}
+		}
+		if ($create) {
+			array_unshift($queries, "ALTER TABLE " . table($table) . implode(",", $create));
+		}
+		if ($drop) {
+			array_unshift($queries, "DROP INDEX " . implode(", ", $drop));
+		}
+		foreach ($queries as $query) {
+			if (!queries($query)) {
 				return false;
 			}
 		}
-		return ((!$create || queries("ALTER TABLE " . table($table) . implode(",", $create)))
-			&& (!$drop || queries("DROP INDEX " . implode(", ", $drop)))
-		);
+		return true;
 	}
 	
 	function truncate_tables($tables) {