+++ /dev/null
-/*
- * Copyright (C) 2004-2008 Georgia Public Library Service
- * Copyright (C) 2008 Equinox Software, Inc., Laurentian University
- * Mike Rylander <miker@esilibrary.com>
- * Dan Scott <dscott@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;
-
-DO $$
-DECLARE
-lang TEXT;
-BEGIN
-FOR lang IN SELECT substring(pptsd.dictname from '(.*)_stem$') AS lang FROM pg_catalog.pg_ts_dict pptsd JOIN pg_catalog.pg_namespace ppn ON ppn.oid = pptsd.dictnamespace
-WHERE ppn.nspname = 'pg_catalog' AND pptsd.dictname LIKE '%_stem' LOOP
-RAISE NOTICE 'FOUND LANGUAGE %', lang;
-
-EXECUTE 'DROP TEXT SEARCH DICTIONARY IF EXISTS ' || lang || '_nostop CASCADE;
-CREATE TEXT SEARCH DICTIONARY ' || lang || '_nostop (TEMPLATE=pg_catalog.snowball, language=''' || lang || ''');
-COMMENT ON TEXT SEARCH DICTIONARY ' || lang || '_nostop IS ''' ||lang || ' snowball stemmer with no stopwords for ASCII words only.'';
-CREATE TEXT SEARCH CONFIGURATION ' || lang || '_nostop ( COPY = pg_catalog.' || lang || ' );
-ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR word, hword, hword_part WITH pg_catalog.simple;
-ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH ' || lang || '_nostop;';
-
-END LOOP;
-END;
-$$;
-CREATE TEXT SEARCH CONFIGURATION title ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION author ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION subject ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION keyword ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION identifier ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION series ( COPY = english_nostop );
-CREATE TEXT SEARCH CONFIGURATION "default" ( COPY = english_nostop );
-
-
-COMMIT;
+++ /dev/null
-000.english.pg91.fts-config.sql
\ No newline at end of file
+++ /dev/null
-000.english.pg91.fts-config.sql
\ No newline at end of file
+++ /dev/null
-000.english.pg91.fts-config.sql
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2004-2008 Georgia Public Library Service
+ * Copyright (C) 2008 Equinox Software, Inc., Laurentian University
+ * Mike Rylander <miker@esilibrary.com>
+ * Dan Scott <dscott@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;
+
+DO $$
+DECLARE
+lang TEXT;
+BEGIN
+FOR lang IN SELECT substring(pptsd.dictname from '(.*)_stem$') AS lang FROM pg_catalog.pg_ts_dict pptsd JOIN pg_catalog.pg_namespace ppn ON ppn.oid = pptsd.dictnamespace
+WHERE ppn.nspname = 'pg_catalog' AND pptsd.dictname LIKE '%_stem' LOOP
+RAISE NOTICE 'FOUND LANGUAGE %', lang;
+
+EXECUTE 'DROP TEXT SEARCH DICTIONARY IF EXISTS ' || lang || '_nostop CASCADE;
+CREATE TEXT SEARCH DICTIONARY ' || lang || '_nostop (TEMPLATE=pg_catalog.snowball, language=''' || lang || ''');
+COMMENT ON TEXT SEARCH DICTIONARY ' || lang || '_nostop IS ''' ||lang || ' snowball stemmer with no stopwords for ASCII words only.'';
+CREATE TEXT SEARCH CONFIGURATION ' || lang || '_nostop ( COPY = pg_catalog.' || lang || ' );
+ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR word, hword, hword_part WITH pg_catalog.simple;
+ALTER TEXT SEARCH CONFIGURATION ' || lang || '_nostop ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH ' || lang || '_nostop;';
+
+END LOOP;
+END;
+$$;
+CREATE TEXT SEARCH CONFIGURATION title ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION author ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION subject ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION keyword ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION identifier ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION series ( COPY = english_nostop );
+CREATE TEXT SEARCH CONFIGURATION "default" ( COPY = english_nostop );
+
+
+COMMIT;
-000.english.pg91.fts-config.sql
\ No newline at end of file
+000.english.pg94.fts-config.sql
\ No newline at end of file
-000.english.pg91.fts-config.sql
\ No newline at end of file
+000.english.pg94.fts-config.sql
\ No newline at end of file
+++ /dev/null
--- 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/pgxml.sql
-\i :load_file
-\set load_file :contrib_dir/hstore.sql
-\i :load_file
my $offline_file = '';
my $prefix = '';
my $sysconfdir = '';
-my $pg_contribdir = '';
-my $create_db_sql_contribs = '';
my $create_db_sql_extensions = '';
my @services;
$settings->{pw} = $settings->{pw} || $opensrf_config->findnodes($pw);
}
-=item create_database() - Creates the database using create_database_contribs.sql
+=item create_database() - Creates the database using create_database_extensions.sql
=cut
sub create_database {
my $settings = shift;
$ENV{'PGPASSWORD'} = $settings->{pw};
$ENV{'PGPORT'} = $settings->{port};
$ENV{'PGHOST'} = $settings->{host};
- my @temp = `psql -d postgres -qtc 'show server_version;' | xargs | cut -c1,3`;
+ my @temp = `psql -d postgres -qtc 'show server_version;' | xargs | cut -d. -f 1,2 | tr -d '.'`;
chomp $temp[0];
my $pgversion = $temp[0];
my $cmd;
- # If it looks like it is 9.1 or greater, use create_database_extensions.sql
- # Otherwise use create_database_contribs.sql
- if($pgversion >= '91') {
- $cmd = 'psql -vdb_name=' . $settings->{db} . ' -d postgres -f ' . $create_db_sql_extensions;
- } else {
- $cmd = 'psql -vdb_name=' . $settings->{db} . ' -vcontrib_dir=' . $pg_contribdir .
- ' -d postgres -f ' . $create_db_sql_contribs;
+ unless ($pgversion >= '94') {
+ my @message = ();
+ push(@message,
+ "\n------------------------------------------------------------------------------\n",
+ "Cannot create database; version of PostgreSQL appears to be less than the\n",
+ "minimum required of 9.4\n",
+ "------------------------------------------------------------------------------\n",
+ );
+ die(@message);
}
+ $cmd = 'psql -vdb_name=' . $settings->{db} . ' -d postgres -f ' . $create_db_sql_extensions;
my @output = `$cmd 2>&1`;
if(grep(/(ERROR|No such file or directory)/,@output)) {
push(@output, "\n------------------------------------------------------------------------------\n",
"update-config" => \$uconfig,
"config-file=s" => \$config_file,
"build-db-file=s" => \$build_db_sh,
- "pg-contrib-dir=s" => \$pg_contribdir,
- "create-db-sql-contribs=s" => \$create_db_sql_contribs,
"create-db-sql-extensions=s" => \$create_db_sql_extensions,
"pg-config=s" => \$pgconfig,
"admin-user=s" => \$admin_user,
$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_contribs) {
- $create_db_sql_contribs = File::Spec->catfile($script_dir, '../sql/Pg/create_database_contribs.sql');
-}
-
if (!$create_db_sql_extensions) {
$create_db_sql_extensions = File::Spec->catfile($script_dir, '../sql/Pg/create_database_extensions.sql');
}