Add support for PostgreSQL schemas
k4ml - April 19, 2008 - 05:07
| Project: | Database Administration |
| Version: | 5.x-1.x-dev |
| Component: | PostgreSQL Support |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
PostgreSQL allow us to seperate tables in multiple namespace known as schemas. The default schema search path is public so query such as:-
SELECT * FROM table_name;
Will actually looked into public schemas. The equivalent query would be:-
SELECT * FROM public.table_name;
So, what I did was to add a textfield into system settings form:-
<?php
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'),
);
}
?>Then I change the query in function dba_get_tables() and theme_dba_database_overview_form(). I had to query the rowcount directly since seperate call through dba_get_row_count($table) would halt the system. This is just a rough idea. I'm sure there's a better way to do this.
| Attachment | Size |
|---|---|
| pgsql_schema.patch | 2.81 KB |

#1
Here's a better patch that used {drupal_system_catalog} view like the original in dba_get_tables(). I add a new column tabschema to the view.