Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 366509

Summary: dev-db/libdbi-drivers-0.8.3: uses incorrect query for listing tables on PostgreSQL database
Product: Gentoo Linux Reporter: Sergey Otinov <sotinov>
Component: Current packagesAssignee: Robin Johnson <robbat2>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Changed query

Description Sergey Otinov 2011-05-08 22:48:42 UTC
Function dbd_list_tables uses incorrect query to seach for tables. To retrieve relation owner OID it uses following subquery 'SELECT datdba FROM pg_database WHERE datname = ?' which is return only one (DBA) user however database may containt hudreds of users.

One way to solve ther problem use following subquery. It returns OID of the currently connected user
'SELECT usesysid FROM pg_user WHERE usename = user'
where 'user' built-in function wich returns currently connected user.

Another option use information schema for searching tables
ex. select * from information_schema.tables where table_name like <tabpattern>

This problem affects app-office/gnucash-2.4.5 when I use PostgreSQL database backend. gnucash refuses work with database on subsequent runs.

Reproducible: Always

Steps to Reproduce:
1. Run gnucash
2. Save work to PG database and close application
3. Run it again and open previously saved work
Actual Results:  
gnucash complains and refuses saving changes

Expected Results:  
normal work
Comment 1 Sergey Otinov 2011-05-08 22:49:42 UTC
Created attachment 272543 [details, diff]
Changed query

a bit changed query that solves the problem
Comment 2 Pacho Ramos gentoo-dev 2014-01-11 21:30:07 UTC
All this problems should be solved in 0.9