[open-ils-commits] [GIT] Evergreen ILS branch rel_2_1 updated. 715a367a2f9db3c9dc8ffbe612c0b36511d5b23d

Evergreen Git git at git.evergreen-ils.org
Sat Sep 10 12:54:42 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_1 has been updated
       via  715a367a2f9db3c9dc8ffbe612c0b36511d5b23d (commit)
       via  0b762516b831bbb82557aee37cefdd42a7eb1888 (commit)
       via  21c2f1f64f54e9b65e57fedbabfa031f6a27ff9b (commit)
       via  faa3f12eda9e407d6649e95973dcd519a84a306d (commit)
      from  6491a6f758cf95451689289d7aa53e9888eeda66 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 715a367a2f9db3c9dc8ffbe612c0b36511d5b23d
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Fri Sep 9 10:25:10 2011 -0400

    When checking postgresql version use postgres db
    
    Otherwise we may get an error instead of a version number.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/support-scripts/eg_db_config.pl b/Open-ILS/src/support-scripts/eg_db_config.pl
index ef49e98..93c53fa 100755
--- a/Open-ILS/src/support-scripts/eg_db_config.pl
+++ b/Open-ILS/src/support-scripts/eg_db_config.pl
@@ -136,7 +136,7 @@ sub create_database {
 	$ENV{'PGPASSWORD'} = $settings->{pw};
 	$ENV{'PGPORT'} = $settings->{port};
 	$ENV{'PGHOST'} = $settings->{host};
-	my @temp = `psql -qtc 'show server_version;' | xargs | cut -c1,3`;
+	my @temp = `psql -d postgres -qtc 'show server_version;' | xargs | cut -c1,3`;
 	chomp $temp[0];
 	my $pgversion = $temp[0];
 	my $cmd;

commit 0b762516b831bbb82557aee37cefdd42a7eb1888
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Thu Sep 8 18:09:49 2011 -0400

    Take a stab at 9.1 support
    
    Second create database SQL to deal with
    CREATE EXTENSION
    instead of contrib files.
    
    Check create DB steps for errors. If any found, die.
    This should cover "could not load file" from pre-9.1 as well.
    
    Also copied the 9.0 fts-config as 9.1 to avoid that warning during
    database load.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql b/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql
new file mode 100644
index 0000000..7ddce06
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2004-2008  Georgia Public Library Service
+ * Copyright (C) 2008  Equinox Software, Inc., Laurentian University
+ * Mike Rylander <miker at esilibrary.com>
+ * Dan Scott <dscott at laurentian.ca>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+BEGIN;
+
+SET search_path = public, pg_catalog;
+
+CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$
+BEGIN
+	NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, NEW.value);
+	RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+DROP TEXT SEARCH DICTIONARY IF EXISTS english_nostop CASCADE;
+
+CREATE TEXT SEARCH DICTIONARY english_nostop (TEMPLATE=pg_catalog.snowball, language='english');
+COMMENT ON TEXT SEARCH DICTIONARY english_nostop IS 'English snowball stemmer with no stopwords for ASCII words only.';
+
+CREATE TEXT SEARCH CONFIGURATION title ( COPY = pg_catalog.english );
+ALTER TEXT SEARCH CONFIGURATION title ALTER MAPPING FOR word, hword, hword_part WITH pg_catalog.simple;
+ALTER TEXT SEARCH CONFIGURATION title ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH english_nostop;
+CREATE TEXT SEARCH CONFIGURATION author ( COPY = title );
+CREATE TEXT SEARCH CONFIGURATION subject ( COPY = title );
+CREATE TEXT SEARCH CONFIGURATION keyword ( COPY = title );
+CREATE TEXT SEARCH CONFIGURATION identifier ( COPY = title );
+CREATE TEXT SEARCH CONFIGURATION series ( COPY = title );
+CREATE TEXT SEARCH CONFIGURATION "default" ( COPY = title );
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/create_database_9_1.sql b/Open-ILS/src/sql/Pg/create_database_9_1.sql
new file mode 100644
index 0000000..97739f9
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/create_database_9_1.sql
@@ -0,0 +1,23 @@
+-- This file is intended to be called by eg_db_config.pl
+
+-- If manually calling:
+-- Connect to the postgres database initially
+-- Specify the database to create as -vdb_name=DATABASE
+-- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR
+-- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it
+
+-- NOTE: This file does not do transactions
+-- This is intentional. Please do not wrap in BEGIN/COMMIT.
+DROP DATABASE IF EXISTS :db_name;
+
+CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C';
+
+\connect :db_name
+
+CREATE LANGUAGE plperl;
+CREATE LANGUAGE plperlu;
+
+CREATE EXTENSION tablefunc;
+CREATE EXTENSION tsearch2;
+CREATE EXTENSION xml2;
+CREATE EXTENSION hstore;
diff --git a/Open-ILS/src/support-scripts/eg_db_config.pl b/Open-ILS/src/support-scripts/eg_db_config.pl
index 894f716..ef49e98 100755
--- a/Open-ILS/src/support-scripts/eg_db_config.pl
+++ b/Open-ILS/src/support-scripts/eg_db_config.pl
@@ -33,6 +33,7 @@ my $prefix = '';
 my $sysconfdir = '';
 my $pg_contribdir = '';
 my $create_db_sql = '';
+my $create_db_sql_9_1 = '';
 my @services;
 
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -135,9 +136,36 @@ sub create_database {
 	$ENV{'PGPASSWORD'} = $settings->{pw};
 	$ENV{'PGPORT'} = $settings->{port};
 	$ENV{'PGHOST'} = $settings->{host};
-	my $cmd = 'psql -vdb_name=' . $settings->{db} . ' -vcontrib_dir=' . $pg_contribdir .
-		' -d postgres -f ' . $create_db_sql;
-	system($cmd);
+	my @temp = `psql -qtc 'show server_version;' | xargs | cut -c1,3`;
+	chomp $temp[0];
+	my $pgversion = $temp[0];
+	my $cmd;
+	# If it looks like it is 9.1 or greater, use create_database_9_1.sql
+	# Otherwise use create_database.sql
+	if($pgversion >= '91') {
+		$cmd = 'psql -vdb_name=' . $settings->{db} . ' -d postgres -f ' . $create_db_sql_9_1;
+	} else {
+		$cmd = 'psql -vdb_name=' . $settings->{db} . ' -vcontrib_dir=' . $pg_contribdir .
+			' -d postgres -f ' . $create_db_sql;
+	}
+	my @output = `$cmd 2>&1`;
+	if(grep(/(ERROR|No such file or directory)/, at output)) {
+		push(@output, "\n------------------------------------------------------------------------------\n",
+			"There was a problem creating the database.\n",
+			"See above for more information.\n");
+		if(grep/unsupported language/, @output) {
+			push(@output, "\nYou may need to install the postgresql plperl package on the database server.\n");
+		}
+		if(grep/No such file or directory/, @output) {
+			if($pgversion >= '91') {
+				push(@output, "\nYou may need to install the postgresql contrib package on the database server.\n"); 
+			} else {
+				push(@output, "\nYou may need to install the postgresql contrib package on this server.\n");
+			}
+		}
+		push(@output, "------------------------------------------------------------------------------\n");
+		die(@output);
+	}
 }
 
 =item create_schema() - Creates the database schema by calling build-db.sh
@@ -194,6 +222,7 @@ GetOptions("create-schema" => \$cschema,
 		"build-db-file=s" => \$build_db_sh,
 		"pg-contrib-dir=s" => \$pg_contribdir,
 		"create-db-sql=s" => \$create_db_sql,
+		"create-db-sql-9-1=s" => \$create_db_sql_9_1,
 		"pg-config=s" => \$pgconfig,
 		"admin-user=s" => \$admin_user,
 		"admin-password=s" => \$admin_pw,
@@ -240,13 +269,16 @@ if (!$create_db_sql) {
 	$create_db_sql = File::Spec->catfile($script_dir, '../sql/Pg/create_database.sql');
 }
 
+if (!$create_db_sql_9_1) {
+	$create_db_sql_9_1 = File::Spec->catfile($script_dir, '../sql/Pg/create_database_9_1.sql');
+}
+
 if (!$offline_file) {
 	$offline_file = File::Spec->catfile($sysconfdir, 'offline-config.pl');
 }
 
 unless (-e $build_db_sh) { die "Error: $build_db_sh does not exist. \n"; }
 unless (-e $config_file) { die "Error: $config_file does not exist. \n"; }
-unless (-d $pg_contribdir || !$cdatabase) { die "Error: $pg_contribdir does not exist. \n"; }
 
 if ($uconfig) { update_config(\@services, \%settings); }
 

commit 21c2f1f64f54e9b65e57fedbabfa031f6a27ff9b
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Fri Aug 26 13:56:21 2011 -0400

    Correct pg_config failure in eg_db_config.pl
    
    Missing a =s in getopts config means it becomes a 0 or 1, when it should
    be a string.
    
    The problem only occurs when you are specifying a particular postgresql
    pg_config file (for example, if you have multiple versions of postgresql
    installed).
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/support-scripts/eg_db_config.pl b/Open-ILS/src/support-scripts/eg_db_config.pl
index 7a3c2a8..894f716 100755
--- a/Open-ILS/src/support-scripts/eg_db_config.pl
+++ b/Open-ILS/src/support-scripts/eg_db_config.pl
@@ -194,7 +194,7 @@ GetOptions("create-schema" => \$cschema,
 		"build-db-file=s" => \$build_db_sh,
 		"pg-contrib-dir=s" => \$pg_contribdir,
 		"create-db-sql=s" => \$create_db_sql,
-		"pg-config" => \$pgconfig,
+		"pg-config=s" => \$pgconfig,
 		"admin-user=s" => \$admin_user,
 		"admin-password=s" => \$admin_pw,
 		"service=s" => \@services,

commit faa3f12eda9e407d6649e95973dcd519a84a306d
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Thu Aug 18 12:06:46 2011 -0400

    Add --create-database option to eg_db_config.pl
    
    Uses create_database.sql and superuser rights to do all
    database creation steps other than making a usable superuser
    account to begin with.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/sql/Pg/create_database.sql b/Open-ILS/src/sql/Pg/create_database.sql
new file mode 100644
index 0000000..b3be0f0
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/create_database.sql
@@ -0,0 +1,30 @@
+-- This file is intended to be called by eg_db_config.pl
+
+-- If manually calling:
+-- Connect to the postgres database initially
+-- Specify the database to create as -vdb_name=DATABASE
+-- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR
+-- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it
+
+-- NOTE: This file does not do transactions
+-- This is intentional. Please do not wrap in BEGIN/COMMIT.
+DROP DATABASE IF EXISTS :db_name;
+
+CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C';
+
+\connect :db_name
+
+CREATE LANGUAGE plperl;
+CREATE LANGUAGE plperlu;
+
+-- This dance is because :variable/blah doesn't seem to work when doing \i
+-- But it does when doing \set
+-- So we \set to a single variable, then use that single variable with \i
+\set load_file :contrib_dir/tablefunc.sql
+\i :load_file
+\set load_file :contrib_dir/tsearch2.sql
+\i :load_file
+\set load_file :contrib_dir/pgxml.sql
+\i :load_file
+\set load_file :contrib_dir/hstore.sql
+\i :load_file
diff --git a/Open-ILS/src/support-scripts/eg_db_config.pl b/Open-ILS/src/support-scripts/eg_db_config.pl
index 498eaf5..7a3c2a8 100755
--- a/Open-ILS/src/support-scripts/eg_db_config.pl
+++ b/Open-ILS/src/support-scripts/eg_db_config.pl
@@ -31,6 +31,8 @@ my $build_db_sh = '';
 my $offline_file = '';
 my $prefix = '';
 my $sysconfdir = '';
+my $pg_contribdir = '';
+my $create_db_sql = '';
 my @services;
 
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -124,6 +126,20 @@ sub get_settings {
 	$settings->{pw} = $settings->{pw} || $opensrf_config->findnodes($pw);
 }
 
+=item create_database() - Creates the database using create_database.sql
+=cut
+sub create_database {
+	my $settings = shift;
+
+	$ENV{'PGUSER'} = $settings->{user};
+	$ENV{'PGPASSWORD'} = $settings->{pw};
+	$ENV{'PGPORT'} = $settings->{port};
+	$ENV{'PGHOST'} = $settings->{host};
+	my $cmd = 'psql -vdb_name=' . $settings->{db} . ' -vcontrib_dir=' . $pg_contribdir .
+		' -d postgres -f ' . $create_db_sql;
+	system($cmd);
+}
+
 =item create_schema() - Creates the database schema by calling build-db.sh
 =cut
 sub create_schema {
@@ -164,15 +180,21 @@ sub set_admin_account {
 }
 
 my $offline;
+my $cdatabase;
 my $cschema;
 my $uconfig;
+my $pgconfig;
 my %settings;
 
 GetOptions("create-schema" => \$cschema, 
+		"create-database" => \$cdatabase,
 		"create-offline" => \$offline,
 		"update-config" => \$uconfig,
 		"config-file=s" => \$config_file,
 		"build-db-file=s" => \$build_db_sh,
+		"pg-contrib-dir=s" => \$pg_contribdir,
+		"create-db-sql=s" => \$create_db_sql,
+		"pg-config" => \$pgconfig,
 		"admin-user=s" => \$admin_user,
 		"admin-password=s" => \$admin_pw,
 		"service=s" => \@services,
@@ -207,25 +229,38 @@ if (!$build_db_sh) {
 	$build_db_sh = File::Spec->catfile($script_dir, '../sql/Pg/build-db.sh');
 }
 
+if (!$pg_contribdir) {
+	$pgconfig = 'pg_config' if(!$pgconfig);
+	my @temp = `$pgconfig --sharedir`;
+	chomp $temp[0];
+	$pg_contribdir = File::Spec->catdir($temp[0], 'contrib');
+}
+
+if (!$create_db_sql) {
+	$create_db_sql = File::Spec->catfile($script_dir, '../sql/Pg/create_database.sql');
+}
+
 if (!$offline_file) {
 	$offline_file = File::Spec->catfile($sysconfdir, 'offline-config.pl');
 }
 
 unless (-e $build_db_sh) { die "Error: $build_db_sh does not exist. \n"; }
 unless (-e $config_file) { die "Error: $config_file does not exist. \n"; }
+unless (-d $pg_contribdir || !$cdatabase) { die "Error: $pg_contribdir does not exist. \n"; }
 
 if ($uconfig) { update_config(\@services, \%settings); }
 
 # Get our settings from the config file
 get_settings(\%settings);
 
+if ($cdatabase) { create_database(\%settings); }
 if ($cschema) { create_schema(\%settings); }
 if ($admin_user && $admin_pw) {
 	set_admin_account($admin_user, $admin_pw, \%settings);
 }
 if ($offline) { create_offline_config($offline_file, \%settings); }
 
-if ((!$cschema && !$uconfig && !$offline && !$admin_pw) || $help) {
+if ((!$cdatabase && !$cschema && !$uconfig && !$offline && !$admin_pw) || $help) {
 	print <<HERE;
 
 SYNOPSIS
@@ -261,6 +296,10 @@ COMMANDS
         Creates the Evergreen database schema according to the settings in
         the file specified by --config-file.  
 
+    --create-database
+        Creates the database itself, provided the user and password options
+        represent a superuser.
+
 SERVICE OPTIONS
     --service
         Specify "all" or one or more of the following services to update:

-----------------------------------------------------------------------

Summary of changes:
 ...-config.sql => 000.english.pg91.fts-config.sql} |    2 +
 Open-ILS/src/sql/Pg/create_database.sql            |   30 ++++++++
 Open-ILS/src/sql/Pg/create_database_9_1.sql        |   23 ++++++
 Open-ILS/src/support-scripts/eg_db_config.pl       |   73 +++++++++++++++++++-
 4 files changed, 127 insertions(+), 1 deletions(-)
 copy Open-ILS/src/sql/Pg/{000.english.pg90.fts-config.sql => 000.english.pg91.fts-config.sql} (97%)
 create mode 100644 Open-ILS/src/sql/Pg/create_database.sql
 create mode 100644 Open-ILS/src/sql/Pg/create_database_9_1.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list