--- dba.module.orig 2008-04-19 12:44:02.000000000 +0800 +++ dba.module 2008-04-19 13:16:34.000000000 +0800 @@ -310,6 +310,23 @@ ), ); } + + if (!_is_mysql()) { + $form['pgsql_options'] = array( + '#type' => 'fieldset', + '#title' => t('PostgreSQL options'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + $form['pgsql_options']['pgsql_schema'] = array( + '#type' => 'textfield', + '#title' => t('PostgreSQL Schema'), + '#default_value' => variable_get('pgsql_schema', 'public'), + '#size' => 30, + '#maxlength' => 255, + '#description' => t('Comma seperated list of schemas'), + ); + } // Add a validation callback to make sure the backup path is writable. $setting_valid = array('dba_settings_validate' => array()); $form['#validate'] = isset($form['#validate']) ? array_merge($form['#validate'], $setting_valid) : $setting_valid; @@ -457,11 +474,16 @@ // It'd be great to use the pager and tablesort, but doesn't appear possible. $header = array('', t('Tables'), t('Rows')); - $tables = dba_get_tables(); - foreach ($tables as $table) { - $count = dba_get_row_count($table); - $checkbox = drupal_render($form['tables'][$table]); - $rows[] = array($checkbox, l($table, "admin/build/database/table/$table/view"), $count); + $schemas = _pgsql_schemas(); + $result = db_query("SELECT n.nspname || '.' || relname as tbname, reltuples as rowcount FROM pg_class r JOIN pg_namespace n ON (relnamespace = n.oid) WHERE relkind = 'r' AND n.nspname IN ($schemas)"); + //foreach ($tables as $table) { + // $count = dba_get_row_count($table); + // $checkbox = drupal_render($form['tables'][$table]); + // $rows[] = array($checkbox, l($table, "admin/build/database/table/$table/view"), $count); + //} + while ($table = db_fetch_object($result)) { + $checkbox = drupal_render($form['tables'][$table->tbname]); + $rows[] = array($checkbox, l($table->tbname, "admin/build/database/table/$table->tbname/view"), $table->rowcount); } $output .= dba_select_all_js(); $output .= theme('table', $header, $rows); @@ -1289,7 +1311,8 @@ $result = db_query('show tables'); } else { - $result = db_query('SELECT DISTINCT tabname as Table FROM {drupal_system_catalog}'); + $schemas = _pgsql_schemas(); + $result = db_query("SELECT DISTINCT tabschema || '.' || tabname as Table FROM {drupal_system_catalog} WHERE tabschema IN ($schemas)"); } while ($tables = db_fetch_object($result)) { @@ -1603,3 +1626,12 @@ ); return $op ? $ops[$op] : $ops; } + +function _pgsql_schemas() { + $schemas = explode(',', variable_get('pgsql_schema', 'public')); + $placeholder = array(); + foreach ($schemas as $schema) { + $placeholder[] = "'$schema'"; + } + return implode(',', $placeholder); +}