2 rcs_id('$Id: PearDB_pgsql.php,v 1.1 2001-09-18 19:16:23 dairiki Exp $');
4 require_once('lib/ErrorManager.php');
5 require_once('lib/WikiDB/backend/PearDB.php');
7 class WikiDB_backend_pgsql
8 extends WikiDB_backend_PearDB
10 function WikiDB_backend_pgsql($dbparams) {
11 // The pgsql handler of (at least my version of) the PEAR::DB
12 // library generates three warnings when a database is opened:
14 // Undefined index: options
15 // Undefined index: tty
16 // Undefined index: port
18 // This stuff is all just to catch and ignore these warnings,
19 // so that they don't get reported to the user. (They are
20 // not consequential.)
23 $ErrorManager->pushErrorHandler(array($this,'_pgsql_open_error'));
24 $this->WikiDB_backend_PearDB($dbparams);
25 $ErrorManager->popErrorHandler();
28 function _pgsql_open_error($error) {
29 if (preg_match('/^Undefined\s+index:\s+(options|tty|port)/',
31 return true; // Ignore error
40 foreach ($this->_table_names as $table) {
41 $dbh->query("VACUUM ANALYZE $table");
46 * Lock all tables we might use.
48 function _lock_tables($write_lock = true) {
51 $dbh->query("BEGIN WORK");
52 foreach ($this->_table_names as $table) {
53 // FIXME: can we use less restrictive locking.
54 // (postgres supports transactions, after all.)
55 $dbh->query("LOCK TABLE $table");
62 function _unlock_tables() {
64 $dbh->query("COMMIT WORK");
68 // (c-file-style: "gnu")
73 // c-hanging-comment-ender-p: nil
74 // indent-tabs-mode: nil