From e905db13057c84403d33b7007b4a13e9ffbf2ed0 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 14 Oct 2008 08:49:44 -0400
Subject: [PATCH] Set postgres-specific schema options + fix indentation

---
 program/include/rcube_mdb2.php |    6 +++---
 bin/dumpschema.php             |   22 ++++++++++++++++------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/bin/dumpschema.php b/bin/dumpschema.php
index da82f73..cbadb00 100644
--- a/bin/dumpschema.php
+++ b/bin/dumpschema.php
@@ -1,5 +1,6 @@
 <?php
 /*
+ #!/usr/bin/php
 
  +-----------------------------------------------------------------------+
  | bin/dumpschema.php                                                    |
@@ -45,14 +46,21 @@
 	'quote_identifier' => true,
 	'force_defaults' => false,
 	'portability' => false,
-	'disable_smart_seqname' => true,
-	'seqname_format' => '%s'
 );
 
-$schema =& MDB2_Schema::factory($config->get('db_dsnw'), $options);
+$dsnw = $config->get('db_dsnw');
+$dsn_array = MDB2::parseDSN($dsnw);
+
+// set options for postgres databases
+if ($dsn_array['phptype'] == 'pgsql') {
+	$options['disable_smart_seqname'] = true;
+	$options['seqname_format'] = '%s';
+}
+
+$schema =& MDB2_Schema::factory($dsnw, $options);
 $schema->db->supported['transactions'] = false;
 
-			
+
 // send as text/xml when opened in browser
 if ($_SERVER['REMOTE_ADDR'])
 	header('Content-Type: text/xml');
@@ -68,6 +76,8 @@
 	);
 	
 	$definition = $schema->getDefinitionFromDatabase();
+	$definition['charset'] = 'utf8';
+
 	if (PEAR::isError($definition)) {
 		$error = $definition->getMessage() . ' ' . $definition->getUserInfo();
 	}
@@ -81,7 +91,7 @@
 
 $schema->disconnect();
 
-//if ($error)
-//	fputs(STDERR, $error);
+if ($error && !$_SERVER['REMOTE_ADDR'])
+	fputs(STDERR, $error);
 
 ?>
diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php
index eb6cec9..b5767e3 100644
--- a/program/include/rcube_mdb2.php
+++ b/program/include/rcube_mdb2.php
@@ -86,9 +86,9 @@
         'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);
 
     if ($this->db_provider == 'pgsql') {
-	$db_options['disable_smart_seqname'] = true;
-	$db_options['seqname_format'] = '%s';
-      }
+      $db_options['disable_smart_seqname'] = true;
+      $db_options['seqname_format'] = '%s';
+    }
 
     $dbh = MDB2::connect($dsn, $db_options);
 

--
Gitblit v1.9.1