From a7f67e01de1626b8cba850c325ccf12806d312c0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 4 Aug 2006 06:58:44 +0000 Subject: - Patch #76681 by sammys: PostgreSQL support for install system. Woot! :) --- includes/install.pgsql.inc | 134 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 includes/install.pgsql.inc (limited to 'includes') diff --git a/includes/install.pgsql.inc b/includes/install.pgsql.inc new file mode 100644 index 000000000..cc9da3998 --- /dev/null +++ b/includes/install.pgsql.inc @@ -0,0 +1,134 @@ +
  • Are you sure you have the correct username and password?
  • Are you sure that you have typed the correct database hostname?
  • Are you sure that the database server is running?
  • Are you sure you typed the correct database name?
  • For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => 'Connection failed. See log file for failure reason')), 'error'); + return FALSE; + } + + $success = array('CONNECT'); + + // Test CREATE. + $query = 'CREATE TABLE drupal_install_test (id integer NOT NULL)'; + $result = pg_query($connection, $query); + if ($error = pg_result_error($result)) { + drupal_set_message(st('We were unable to create a test table on your PostgreSQL database server with the command %query. PostgreSQL reports the following message: %error.For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%query' => $query, '%error' => $error)), 'error'); + return FALSE; + } + $err = FALSE; + $success[] = 'SELECT'; + $success[] = 'CREATE'; + + // Test INSERT. + $query = 'INSERT INTO drupal_install_test (id) VALUES (1)'; + $result = pg_query($connection, $query); + if ($error = pg_result_error($result)) { + drupal_set_message(st('We were unable to insert a value into a test table on your PostgreSQL database server. We tried inserting a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'INSERT'; + } + + // Test UPDATE. + $query = 'UPDATE drupal_install_test SET id = 2'; + $result = pg_query($connection, $query); + if ($error = pg_result_error($result)) { + drupal_set_message(st('We were unable to update a value in a test table on your PostgreSQL database server. We tried updating a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'UPDATE'; + } + + // Test LOCK. + $query = 'BEGIN; LOCK drupal_install_test IN SHARE ROW EXCLUSIVE MODE'; + $result = pg_query($connection, $query); + if ($error = pg_result_error($result)) { + drupal_set_message(st('We were unable to lock a test table on your PostgreSQL database server. We tried locking a table with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'LOCK'; + } + + // Test UNLOCK, which is done automatically upon transaction end in PostgreSQL + $query = 'COMMIT'; + $result = pg_query($connection, $query); + if ($error = pg_result_error()) { + drupal_set_message(st('We were unable to unlock a test table on your PostgreSQL database server. We tried unlocking a table with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'UNLOCK'; + } + + // Test DELETE. + $query = 'DELETE FROM drupal_install_test'; + $result = pg_query($connection, $query); + if ($error = pg_result_error()) { + drupal_set_message(st('We were unable to delete a value from a test table on your PostgreSQL database server. We tried deleting a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'DELETE'; + } + + // Test DROP. + $query = 'DROP TABLE drupal_install_test'; + $result = pg_query($connection, $query); + if ($error = pg_result_error()) { + drupal_set_message(st('We were unable to drop a test table from your PostgreSQL database server. We tried dropping a table with the command %query and PostgreSQL reported the following error %error.', array('%query' => $query, '%error' => $error)), 'error'); + $err = TRUE; + } + else { + $success[] = 'DROP'; + } + + if ($err) { + return FALSE; + } + + pg_close($connection); + return TRUE; +} + +?> -- cgit v1.2.3