diff options
| author | Damien Regad <dregad@mantisbt.org> | 2023-03-20 18:11:42 +0100 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2023-03-20 18:11:42 +0100 |
| commit | 07ade94036c18c7c93dfe742abbeac99a6f2f09f (patch) | |
| tree | d1cb7472f3662b1cd643342f44137102c841b9a5 /drivers | |
| parent | 7e51937c9b5a42b22cfbcea0d7235e432ebf5bcf (diff) | |
| download | adodb-07ade94036c18c7c93dfe742abbeac99a6f2f09f.tar.gz adodb-07ade94036c18c7c93dfe742abbeac99a6f2f09f.tar.bz2 adodb-07ade94036c18c7c93dfe742abbeac99a6f2f09f.zip | |
Fix PHP warning in ADODB_postgres64::MetaIndexes()
When calling the function on a table having an index on an expression
column, a PHP warning is thrown:
Undefined array key 0 in ./drivers/adodb-postgres64.inc.php on line 666
Fixes #940
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/adodb-postgres64.inc.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php index 185c675f..fa8e5fba 100644 --- a/drivers/adodb-postgres64.inc.php +++ b/drivers/adodb-postgres64.inc.php @@ -659,14 +659,16 @@ class ADODB_postgres64 extends ADOConnection{ return $false; } + // Get column names indexed by attnum so we can lookup the index key $col_names = $this->MetaColumnNames($table,true,true); - // 3rd param is use attnum, - // see https://sourceforge.net/p/adodb/bugs/45/ $indexes = array(); while ($row = $rs->FetchRow()) { $columns = array(); foreach (explode(' ', $row[2]) as $col) { - $columns[] = $col_names[$col]; + // When index attribute (pg_index.indkey) is an expression, $col == 0 + // @see https://www.postgresql.org/docs/current/catalog-pg-index.html + // so there is no matching column name - set it to null (see #940). + $columns[] = $col_names[$col] ?? null; } $indexes[$row[0]] = array( |
