Bug 13523 - AddBiblio fails on mysql with STRICT_TRANS_TABLES
authorBenjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Thu, 22 Jan 2015 11:21:47 +0000 (12:21 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Wed, 22 Apr 2015 07:11:39 +0000 (09:11 +0200)
This patch removes the NOT NULL restriction on biblioitems.marcxml and
deletedbiblioitems.marcxml due to STRICT_TRANS_TABLES default in
Mysql 5.6.22 and onwards.

Test:

1. check mysql global settings:
   mysql > SELECT @@GLOBAL.sql_mode;
   verify that STRICT_TRANS_TABLES is not set
2. set STRICT_TRANS_TABLES (or upgrade mysql to > 5.6.21)
   mysql > SET @@GLOBAL.sql_mode = 'STRICT_TRANS_TABLES';
3. try to add biblio in Cataloguing module
   verify that it fails with a "software error"
4. apply patch
5. repeat 3 and verify that there is no "software error" any more

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
I confirm with the problem with mariadb and STRICT_TRANS_TABLES enabled.
On adding a biblio (C4::Biblio::AddBiblio), biblioitems is populate in
_koha_add_biblioitem but marxcml is not generated yet. It's in
ModBiblioMarc, few lines later.
The NOT NULL condition is not valid here.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Mason James <mtj@kohaaloha.com>
(cherry picked from commit 4eaa86acffde08b7fcdf16ae8cf8a73c35bf0d10)

Conflicts:
installer/data/mysql/updatedatabase.pl

installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl

index b760454..2516d3e 100644 (file)
@@ -181,7 +181,7 @@ CREATE TABLE `biblioitems` ( -- information related to bibliographic records in
   `cn_sort` varchar(30) default NULL, -- normalized version of the call number used for sorting
   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
   `totalissues` int(10),
-  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
+  `marcxml` longtext, -- full bibliographic MARC record in MARCXML
   PRIMARY KEY  (`biblioitemnumber`),
   KEY `bibinoidx` (`biblioitemnumber`),
   KEY `bibnoidx` (`biblionumber`),
@@ -783,7 +783,7 @@ CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t
   `cn_sort` varchar(30) default NULL, -- normalized version of the call number used for sorting
   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
   `totalissues` int(10),
-  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
+  `marcxml` longtext, -- full bibliographic MARC record in MARCXML
   PRIMARY KEY  (`biblioitemnumber`),
   KEY `bibinoidx` (`biblioitemnumber`),
   KEY `bibnoidx` (`biblionumber`),
index 58b2e58..354395e 100755 (executable)
@@ -8083,6 +8083,20 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.19.00.XXX";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext
+    });
+
+    $dbh->do(q{
+        ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext
+    });
+
+    print "Upgrade to $DBversion done (Bug 13523 - Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)