From 768e8261135d1413b6d4f3900ab41e63ead24eaf Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Mon, 5 Nov 2018 14:37:19 -0500 Subject: [PATCH] Lp 1730726: Basic Patch to build the database with PostgreSQL 10. * Modify the evergreen.org_top() function, with code from Galen Charlton, to be non-set returning. * Modify Open-ILS/src/support-scripts/eg_db_config.in to not strip the period from PostgreSQL version numbers and to use the first two components when checking for supported PostgreSQL versions. * Add link from Open-ILS/src/sql/Pg/000.english.pg94.fts-config.sql to Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql. Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql | 1 + Open-ILS/src/sql/Pg/990.schema.unapi.sql | 5 ++--- .../XXXX.function.non-set-returning-evergreen.org_top.sql | 10 ++++++++++ Open-ILS/src/support-scripts/eg_db_config.in | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 120000 Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.function.non-set-returning-evergreen.org_top.sql diff --git a/Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql b/Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql new file mode 120000 index 0000000000..38504b54c7 --- /dev/null +++ b/Open-ILS/src/sql/Pg/000.english.pg10.fts-config.sql @@ -0,0 +1 @@ +000.english.pg94.fts-config.sql \ No newline at end of file diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql index a40d66f9c5..b761fbbb54 100644 --- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql +++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql @@ -4,10 +4,9 @@ BEGIN; CREATE SCHEMA unapi; CREATE OR REPLACE FUNCTION evergreen.org_top() -RETURNS SETOF actor.org_unit AS $$ +RETURNS actor.org_unit AS $$ SELECT * FROM actor.org_unit WHERE parent_ou IS NULL LIMIT 1; -$$ LANGUAGE SQL STABLE -ROWS 1; +$$ LANGUAGE SQL STABLE; CREATE OR REPLACE FUNCTION evergreen.array_remove_item_by_value(inp ANYARRAY, el ANYELEMENT) RETURNS anyarray AS $$ diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.non-set-returning-evergreen.org_top.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.non-set-returning-evergreen.org_top.sql new file mode 100644 index 0000000000..fd8c882309 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.non-set-returning-evergreen.org_top.sql @@ -0,0 +1,10 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.org_top() +RETURNS actor.org_unit AS $$ + SELECT * FROM actor.org_unit WHERE parent_ou IS NULL LIMIT 1; +$$ LANGUAGE SQL STABLE; + +COMMIT: diff --git a/Open-ILS/src/support-scripts/eg_db_config.in b/Open-ILS/src/support-scripts/eg_db_config.in index dc61d0959c..699dc7e7e0 100755 --- a/Open-ILS/src/support-scripts/eg_db_config.in +++ b/Open-ILS/src/support-scripts/eg_db_config.in @@ -142,11 +142,11 @@ sub create_database { $ENV{'PGPASSWORD'} = $settings->{pw}; $ENV{'PGPORT'} = $settings->{port}; $ENV{'PGHOST'} = $settings->{host}; - my @temp = `psql -d postgres -qtc 'show server_version;' | xargs | cut -d. -f 1,2 | tr -d '.'`; + my @temp = split(/ /, `psql -d postgres -qtc 'show server_version;' | xargs | cut -d. -f 1,2`); chomp $temp[0]; my $pgversion = $temp[0]; my $cmd; - unless ($pgversion >= '94') { + unless ($pgversion >= '9.4') { my @message = (); push(@message, "\n------------------------------------------------------------------------------\n", @@ -166,7 +166,7 @@ sub create_database { 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') { + if($pgversion >= '9.1') { 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"); -- 2.11.0