I have just messed up by writing a complicated query where it turned out that the first column was not unique (again!).
I notice that pgsql_native_moodle_database.php does not have the nice debugging code I wrote that tells you immediately if you make this mistake. Please can you add it (around like 650 - maybe other methods need it to).
And in adodb_moodle_database.php (around like 470) the code is no longer effective, since we are doing $records = $rs->GetAssoc(true) - which, in isolation, seems like a good idea - but makes it impossible to detect this common programming error.