Source: php-horde-db Version: 2.4.1-8 Severity: grave Tags: patch Hi,
php-horde-db's primaryKey for PostgreSQL relies on undefined ordering when reading the columns a primary key is defined on. So far it worked, but in PostgreSQL 17, it fails. The attached patch makes it use a proper catalog query. 209s There was 1 failure: 209s 209s 1) Horde_Db_Adapter_Pdo_PgsqlTest::testPrimaryKey 209s Failed asserting that two strings are equal. 209s --- Expected 209s +++ Actual 209s @@ @@ 209s -'foo,bar' 209s +'bar,foo' https://ci.debian.net/packages/p/php-horde-db/testing/armel/51827881/ I intend to NMU this as it's holding up the transition of PostgreSQL 17. Christoph
--- a/Horde_Db-2.4.1/lib/Horde/Db/Adapter/Postgresql/Schema.php +++ b/Horde_Db-2.4.1/lib/Horde/Db/Adapter/Postgresql/Schema.php @@ -271,15 +271,18 @@ class Horde_Db_Adapter_Postgresql_Schema public function primaryKey($tableName, $name = null) { $sql = ' - SELECT column_name - FROM information_schema.constraint_column_usage - WHERE table_name = ? - AND constraint_name = (SELECT constraint_name - FROM information_schema.table_constraints - WHERE table_name = ? - AND constraint_type = ?)'; + SELECT a.attname + FROM + pg_index i, + unnest(indkey) WITH ORDINALITY u (attnum, pos) + JOIN pg_attribute a ON u.attnum = a.attnum + WHERE + i.indisprimary + AND i.indrelid = ?::regclass + AND a.attrelid = i.indrelid + ORDER BY u.pos'; $pk = $this->selectValues($sql, - array($tableName, $tableName, 'PRIMARY KEY'), + array($tableName), $name); return $this->makeIndex($tableName, 'PRIMARY', true, true, $pk);