Bugzilla – Attachment 24212 Details for
Bug 11389
re-enable PostgreSQL as a database scheme that Koha can connect to
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11389: reenable Pg as a DB scheme that Koha can connect to
PASSED-QA-Bug-11389-reenable-Pg-as-a-DB-scheme-tha.patch (text/plain), 5.45 KB, created by
Katrin Fischer
on 2014-01-12 15:21:01 UTC
(
hide
)
Description:
[PASSED QA] Bug 11389: reenable Pg as a DB scheme that Koha can connect to
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-01-12 15:21:01 UTC
Size:
5.45 KB
patch
obsolete
>From 1371509c9c53b26ec9f7108aa3e32b7e73534b33 Mon Sep 17 00:00:00 2001 >From: Galen Charlton <gmc@esilibrary.com> >Date: Thu, 12 Dec 2013 23:55:14 +0000 >Subject: [PATCH] [PASSED QA] Bug 11389: reenable Pg as a DB scheme that Koha > can connect to > >This patch restores the ability to request a DBI database handle >or a DBIx::Class schema object connected to a PostgreSQL database. > >To address the concerns raised in bug 7188, only "mysql" and "Pg" >are recognized as valid DB schemes. If anything else is passed >to C4::Context::db_scheme2dbi or set as the db_scheme in the Koha >configuration file, the DBD driver to load is assumed to be "mysql". > >Note that this patch drops any pretense of Oracle support. > >To test: > >[1] Apply patch, and verify that the database-dependent tests > pass when run against a MySQL Koha database. >[2] To test against PostgreSQL, create a Pg database and > edit koha-conf.xml to set db_scheme to Pg (and adjust > the other DB connection parameters appropriately). The > following tests should pass, at minimum: > > t/Context.t > t/db_dependent/Koha_Database.t > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Works as described, some additional notes: > >- Installed Postgres following > http://wiki.ubuntuusers.de/PostgreSQL >- Created a database user koha >- Created a database koha >- Changed the koha-conf.xml file > <db_scheme>Pg</db_scheme> > <database>koha</database> > <hostname>localhost</hostname> > <port>5432</port> > <user>koha</user> > <pass>xxxx</pass> >- Installed libdbd-pg-perl >- Ran the web installer until step 3 everything looked ok > Step 3 complains: > Password for user koha: psql: fe_sendauth: no password supplied >- Both t/Context.t and t/db_dependent/Koha_Database.t pass >--- > C4/Context.pm | 33 ++++++++++++++------------------- > Koha/Database.pm | 8 +------- > etc/koha-conf.xml | 1 + > t/Context.t | 7 ++++++- > 4 files changed, 22 insertions(+), 27 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index cee4a0f..3914420 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -293,20 +293,20 @@ sub memcached { > } > } > >-# db_scheme2dbi >-# Translates the full text name of a database into de appropiate dbi name >-# >+=head2 db_schema2dbi >+ >+ my $dbd_driver_name = C4::Context::db_schema2dbi($scheme); >+ >+This routines translates a database type to part of the name >+of the appropriate DBD driver to use when establishing a new >+database connection. It recognizes 'mysql' and 'Pg'; if any >+other scheme is supplied it defaults to 'mysql'. >+ >+=cut >+ > sub db_scheme2dbi { >- my $name = shift; >- # for instance, we support only mysql, so don't care checking >- return "mysql"; >- for ($name) { >-# FIXME - Should have other databases. >- if (/mysql/) { return("mysql"); } >- if (/Postgres|Pg|PostgresSQL/) { return("Pg"); } >- if (/oracle/) { return("Oracle"); } >- } >- return; # Just in case >+ my $scheme = shift // ''; >+ return $scheme eq 'Pg' ? $scheme : 'mysql'; > } > > sub import { >@@ -794,12 +794,7 @@ sub _new_dbh > > ## $context > ## correct name for db_schme >- my $db_driver; >- if ($context->config("db_scheme")){ >- $db_driver=db_scheme2dbi($context->config("db_scheme")); >- }else{ >- $db_driver="mysql"; >- } >+ my $db_driver = db_scheme2dbi($context->config("db_scheme")); > > my $db_name = $context->config("database"); > my $db_host = $context->config("hostname"); >diff --git a/Koha/Database.pm b/Koha/Database.pm >index 4c6cae6..12758bf 100644 >--- a/Koha/Database.pm >+++ b/Koha/Database.pm >@@ -45,14 +45,8 @@ __PACKAGE__->mk_accessors(qw( )); > # database connection from the data given in the current context, and > # returns it. > sub _new_schema { >- my $db_driver; > my $context = C4::Context->new(); >- if ( $context->config("db_scheme") ) { >- $db_driver = $context->db_scheme2dbi( $context->config("db_scheme") ); >- } >- else { >- $db_driver = "mysql"; >- } >+ my $db_driver = C4::Context::db_scheme2dbi($context->config("db_scheme")); > > my $db_name = $context->config("database"); > my $db_host = $context->config("hostname"); >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index d42f041..1da5378 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -264,6 +264,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > > <!-- ADDITIONAL KOHA CONFIGURATION DIRECTIVE --> > <!-- db_scheme should follow the DBD driver name --> >+<!-- the DBD drivers supported by Koha are mysql and Pg --> > <!-- port info: mysql:3306 Pg:5432 (5433 on Debian) --> > <config> > <db_scheme>__DB_TYPE__</db_scheme> >diff --git a/t/Context.t b/t/Context.t >index 9c561cb..446e254 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > use DBI; >-use Test::More tests => 6; >+use Test::More tests => 10; > use Test::MockModule; > > BEGIN { >@@ -30,3 +30,8 @@ $userenv->{flags} = 421; > $is_super_librarian = eval{ C4::Context::IsSuperLibrarian() }; > is ( $@, q||, "IsSuperLibrarian does not log an error if userenv is defined" ); > is ( $is_super_librarian, 1, "With flag=1, it is a super librarian" ); >+ >+is(C4::Context::db_scheme2dbi('mysql'), 'mysql', 'ask for mysql, get mysql'); >+is(C4::Context::db_scheme2dbi('Pg'), 'Pg', 'ask for Pg, get Pg'); >+is(C4::Context::db_scheme2dbi('xxx'), 'mysql', 'ask for unsupported DBMS, get mysql'); >+is(C4::Context::db_scheme2dbi(), 'mysql', 'ask for nothing, get mysql'); >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11389
:
23497
|
23885
| 24212