Mahara17.04.2 fails to install when deployed against MariaDB v10.2.4 or higher

Bug #1706263 reported by Raoul DORISSEN
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Cecilia Vela Gurovic
17.04
Fix Released
High
Cecilia Vela Gurovic
17.10
Fix Released
High
Cecilia Vela Gurovic

Bug Description

During the installation process the installation is halted due to an error. As a result further deploy+ent of the Mahara server is not possible.

Used configuration Ubuntu 16.4LTS, Moodle 3.3.1, Mahara 17.04.2, MariaDB 10.2.6

Consulting the apache error log files gives back following information

[Mon Jul 24 10:06:57.616387 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [INF] 2a (admin/upgrade.php:49) Starting Mahara installation..., referer: http://mahara.syntra-cloud.be/admin/index.php
[Mon Jul 24 10:07:11.571057 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'rows BIGINT(10) NOT NULL DEFAULT 1,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571082 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) iscustom TINYINT(1) NOT NULL DEFAULT 0,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571094 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) ' at line 3] in EXECUTE("CREATE TABLE view_layout (, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571096 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) id BIGINT(10) NOT NULL auto_increment,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571097 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) rows BIGINT(10) NOT NULL DEFAULT 1,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571099 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) iscustom TINYINT(1) NOT NULL DEFAULT 0,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571101 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) layoutmenuorder BIGINT(10) NOT NULL DEFAULT 0,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571102 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) CONSTRAINT PRIMARY KEY (id), referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571104 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) )ENGINE=innodb")Command was: CREATE TABLE view_layout (, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571106 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) id BIGINT(10) NOT NULL auto_increment,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571108 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) rows BIGINT(10) NOT NULL DEFAULT 1,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571109 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) iscustom TINYINT(1) NOT NULL DEFAULT 0,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571111 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) layoutmenuorder BIGINT(10) NOT NULL DEFAULT 0,, referer: http://mahara.syntra-cloud.be/admin/upgrade.php
[Mon Jul 24 10:07:11.571112 2017] [:error] [pid 38507] [client 81.165.22.67:55069] [DBG] 98 (lib/dml.php:157) CONSTRAINT PRIMARY KEY (id), referer: http://mahara.syntra-cloud.be/admin/upgrade.php
Looking into file htdocs/lib/db/install.xml (line726) – table view_layout

A Quick analysis of the problem indicated the following
The column rows in the table view_layout is causing a problem (as of MariaDB 10.2.4 rows is now a reserved keyword (https://mariadb.com/kb/en/mariadb/reserved-words/)

        <TABLE NAME="view_layout">
            <FIELDS>
                <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
                <FIELD NAME="rows" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="1"/>
                <FIELD NAME="iscustom" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
                <FIELD NAME="layoutmenuorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0"/>
            </FIELDS>
            <KEYS>
                <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
            </KEYS>
        </TABLE>

To hotfix the issue I´ve updated the column rows to numrows in the following files after which the installation continues as expected and Mahara functioned properly.

htdocs/lib/db/install.xml (line726) rename ´rows´ column to ´numrows´
htdocs/lib/db/upgrade.php (line2407) rename ´rows´ column to ´numrows´
htdocs/lib/db/upgrade.php (line2441) rename ´rows´ column to ´numrows´
htdocs/lib/upgrade.php (line1233) rename ´rows´ column to ´numrows´
htdocs/lib/upgrade.php (line1292) rename ´rows´ column to ´numrows´
htdocs/lib/view.php (line1185) rename ´rows´ column to numrows´
htdocs/lib/view.php (line2935) rename ´rows´ column to ´numrows´

Revision history for this message
Raoul DORISSEN (radorify) wrote :
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Cecilia, can you please take a look at the reported error and the patch?

Changed in mahara:
assignee: nobody → Cecilia Vela Gurovic (ceciliavg)
Revision history for this message
Cecilia Vela Gurovic (ceciliavg) wrote :

From https://mariadb.com:
reserved words ROWS Added in MariaDB 10.2.4 (Release date: 17 Feb 2017)

The patch is ok but it needs to consider upgrades. if an instance of mahara is using MariaDB and they upgrade it to 10.2.4 or higher then there will be issues. We need to change the name of the column for all versions of Mahara for new installs and for already existing DBs.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/7912

Revision history for this message
Cecilia Vela Gurovic (ceciliavg) wrote :

I updated the patch to include latest new keywords for versions

PostgresSQL 10
MySQL 8.0.3
MariaDB 10.2.7

Changed in mahara:
status: New → In Progress
Revision history for this message
Cecilia Vela Gurovic (ceciliavg) wrote :

Hi Raoul,

We made this patch for this issue https://reviews.mahara.org/#/c/7912 expanding on what you have provided, can you please give it a go?

Thank you,
Cecilia

Changed in mahara:
importance: Undecided → High
milestone: none → 17.10.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/7912
Committed: https://git.mahara.org/mahara/mahara/commit/ff8106115709d6f1dedcef40aff594852c675fe2
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit ff8106115709d6f1dedcef40aff594852c675fe2
Author: Raoul Dorissen <email address hidden>
Date: Wed Aug 2 09:49:23 2017 +1200

Bug 1706263: Updating db keywords to be escaped

Added new keywords to be quoted when creating db queries

Change-Id: I699bbbf949ab6014da515bfa9d45bd4f2310f309
behatnotneeded

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "17.04_STABLE" branch: https://reviews.mahara.org/8019

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/8019
Committed: https://git.mahara.org/mahara/mahara/commit/1ed58578e6cc1f402f6ac1ed93776ff50359dbb7
Submitter: Robert Lyon (<email address hidden>)
Branch: 17.04_STABLE

commit 1ed58578e6cc1f402f6ac1ed93776ff50359dbb7
Author: Raoul Dorissen <email address hidden>
Date: Wed Aug 2 09:49:23 2017 +1200

Bug 1706263: Updating db keywords to be escaped

Added new keywords to be quoted when creating db queries

Change-Id: I699bbbf949ab6014da515bfa9d45bd4f2310f309
behatnotneeded
(cherry picked from commit ff8106115709d6f1dedcef40aff594852c675fe2)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.