Index: openacs-4/packages/acs-bootstrap-installer/db-init-checks-postgresql.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/db-init-checks-postgresql.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-bootstrap-installer/db-init-checks-postgresql.tcl 29 Jul 2001 23:16:50 -0000 1.2
+++ openacs-4/packages/acs-bootstrap-installer/db-init-checks-postgresql.tcl 14 Dec 2001 03:00:04 -0000 1.3
@@ -9,26 +9,74 @@
upvar $errors my_errors
upvar $error_p my_error_p
+ set my_errors "We found the following problems with your PostgreSQL installation:
\n"
+
foreach pool [nsv_get db_available_pools .] {
if { [catch { set db [ns_db gethandle -timeout 15 $pool]}] || ![string compare $db ""] } {
# This should never happened - we were able to grab a handle previously, why not now?
- append my_errors "(db_bootstrap_checks) Internal error accessing pool \"$pool\".
"
+ append my_errors "- (db_bootstrap_checks) Internal error accessing pool \"$pool\".
"
set my_error_p 1
- } elseif { [catch { ns_db 1row $db "select count(*) from pg_class pg1 left join pg_class pg2 using (relname)" }] } {
- set my_errors "Your installed version of Postgres does not support outer joins. Please install Postgres V7.1 or later."
+ } else {
+ ns_db releasehandle $db
+ }
+ }
+
+ set db [ns_db gethandle [lindex [nsv_get db_available_pools .] 0]]
+
+ # We'll just run the rest of the tests on a single pool ...
+
+ if { [catch { set version [ns_set value [ns_db 1row $db "select version()"] 0] }] } {
+ append my_errors " - (db_bootstrap_checks) Internal error querying for PostgreSQL version.\n"
+ set my_error_p 1
+ set version 0
+ } else {
+ # DRB: We only want the major.minor portion of the version, i.e. 7.1 not 7.1.3
+ regexp {PostgreSQL ([0-9]*\.[0-9]*)} $version all version
+ nsv_set ad_database_version . $version
+ }
+
+ if { $version < 7.1 } {
+ append my_errors "
- Your installed version of Postgres is too old. Please install Postgres V7.1 or later.\n"
+ set my_error_p 1
+ }
+
+ if { [catch { ns_pg_bind 1row $db "select count(*) from pg_class" }] } {
+ append my_errors "
- Your Postgres driver is too old. You need to update.\n"
+ set my_error_p 1
+ }
+
+ if { [catch { ns_db dml $db "create function __test__() returns integer as 'begin end;' language 'plpgsql'" } errmsg] } {
+ append my_errors "
- PL/pgSQL has not been created in your database. Execute the following command while logged in as a PostgreSQL \"superuser\":
createlang plpgsql your_database_name
\n"
+ set my_error_p 1
+ } elseif { [catch { ns_db dml $db "drop function __test__();" } errmsg] } {
+ append my_errors " - An unexpected error was encountered while testing for the of existence PL/pgSQL. Here's the error messsage:
$errmsg
\n"
+ set my_error_p 1
+ }
+
+ # DRB: The PG user has to have "createuser" privs for the PG 7.1 install to work. Not necessary for PG 7.2
+
+ if { $version == 7.1 } {
+ if { [catch { ns_db dml $db "create function __test__() returns integer as 'select 1' language 'sql'" } errmsg] } {
+ append my_errors " - Unexpected error creating SQL function. Check your AOLserver log for details.\n"
set my_error_p 1
- } elseif { [catch { ns_pg_bind 1row $db "select count(*) from pg_class" }] } {
- set my_errors "Your Postgres driver is too old. You need to update."
- set my_error_p 1
- } elseif { [empty_string_p [ns_db 0or1row $db "select 1 where 'a' > 'A'"] ] } {
- set my_errors "You have enabled locale support and did an initdb with the environment variable \"LANG\" set to something other than \"C\". OpenACS won't work unless PostgreSQL's collation order is set to match \"C\"."
+ } else {
+ if { [catch { ns_db dml $db "update pg_proc set proname = '__test__' where proname = '__test__'" } errmsg] } {
+ append my_errors "
- To install the kernel datamodel in PostgreSQL 7.1 database user named in your AOLserver database pools must have the CREATEUSER privilege. You must drop your database and user and recreate the user, answering \"yes\" when asked if the new user should be able to create other users.
After installation is complete we recommend that you remove this privilege using the following command:
alter user your_acs_postgres_user nocreatuser\;
If you upgrade to PostgreSQL 7.2 you can avoid the need to grant this privilege."
set my_error_p 1
+ }
+ if { [catch { ns_db dml $db "drop function __test__();" } errmsg] } {
+ append my_errors "
- An unexpected error was encountered while dropping test function:
$errmsg
\n"
+ set my_error_p 1
+ }
}
- ns_db releasehandle $db
}
- if { ![info exists my_error_p] } {
- # DRB: I don't know how to get this from PG...
- nsv_set ad_database_version . "7.1"
+
+ ns_db releasehandle $db
+
+ if { [info exists my_error_p] } {
+ append my_errors "
"
+ } else {
+ unset my_errors
}
}