Bugzilla – Attachment 114833 Details for
Bug 27303
Behaviour depends on DB user permissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Attachment to Bug 27303 - Behaviour depends on DB user permissions
Bug-27303-Replace-SELECT-from-informationschema-by.patch (text/plain), 4.23 KB, created by
Jonathan Druart
on 2021-01-05 06:55:22 UTC
(
hide
)
Description:
Attachment to Bug 27303 - Behaviour depends on DB user permissions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-05 06:55:22 UTC
Size:
4.23 KB
patch
obsolete
>From 4bf542687fbccb96b5d83598fd20c368536c2a83 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 5 Jan 2021 07:54:25 +0100 >Subject: [PATCH] Bug 27303: Replace SELECT from information_schema by our > *_exists subs > >--- > installer/data/mysql/updatedatabase.pl | 36 +++++--------------------- > 1 file changed, 7 insertions(+), 29 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 8db165a434..cc33056ee8 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -3507,10 +3507,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > > $DBversion = '3.01.00.118'; > if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >- my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns >- WHERE table_name = 'aqbudgets_planning' >- AND column_name = 'display'"); >- if ($count < 1) { >+ unless ( column_exists('aqbudgets_planning', 'display') ) { > $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1"); > } > print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n"; >@@ -4071,15 +4068,10 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > # this attempts to fix that > $DBversion = '3.03.00.023'; > if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.002")) { >- my $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'billingplace'"); >- $sth->execute; >- $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") if ! $sth->fetchrow_hashref; >- $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliveryplace'"); >- $sth->execute; >- $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") if ! $sth->fetchrow_hashref; >- $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliverycomment'"); >- $sth->execute; >- $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") if ! $sth->fetchrow_hashref; >+ $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") unless column_exists('aqbasketgroups', 'billingplace') >+ $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") unless column_exists('aqbasketgroups', 'deliveryplace'); >+ $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") unless column_exists('aqbasketgroups', 'deliverycomment'); >+ > print "Upgrade to $DBversion done (Reconcile aqbasketgroups)\n"; > SetVersion ($DBversion); > } >@@ -5570,19 +5562,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > $dbh->do('DROP TABLE tmp_reserves'); > $dbh->do('COMMIT'); > >- my $sth = $dbh->prepare(" >- SELECT COUNT( * ) AS count >- FROM information_schema.COLUMNS >- WHERE COLUMN_NAME = 'reserve_id' >- AND ( >- TABLE_NAME LIKE 'reserves' >- OR >- TABLE_NAME LIKE 'old_reserves' >- ) >- "); >- $sth->execute(); >- my $row = $sth->fetchrow_hashref(); >- die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} ); >+ die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless primary_key_exists('reserves', 'reserve_id'); > > print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n"; > SetVersion($DBversion); >@@ -17161,9 +17141,7 @@ if( CheckVersion( $DBversion ) ) { > > $DBversion = '18.12.00.002'; > if( CheckVersion( $DBversion ) ) { >- my $sth = $dbh->prepare(q|SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='accountlines_ibfk_1'|); >- $sth->execute; >- if ($sth->fetchrow_hashref) { >+ if ( foreign_key_exists('accountlines', 'accountlines_ibfk_1') ) { > $dbh->do(q| > ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1; > |); >-- >2.20.1
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 27303
: 114833