Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-44377

dmlreadexception when installing on MSSQL without table prefix

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.4, 2.6.1, 2.7
    • Fix Version/s: 2.5.5, 2.6.2
    • Component/s: Installation
    • Labels:
    • Testing Instructions:
      Hide

      1) Use a default config.php file, using the sqlsrv driver, and set $CFG->prefix to '' (empty string).

      2) Try to access to any Moodle page with the settings above, an immediate error should be shown: "Error: database table prefix cannot be empty (mssql)" not allowing the application to go anywhere beyond that.

      3) Set a non empty $CFG->prefix value and visit the site again. Now it will work with normality (installation will be triggered if the site is new or normal pages will work if the site already existed).

      4) Run unit tests for sqlsrv, no problems should appear related with this issue.

      Show
      1) Use a default config.php file, using the sqlsrv driver, and set $CFG->prefix to '' (empty string). 2) Try to access to any Moodle page with the settings above, an immediate error should be shown: "Error: database table prefix cannot be empty (mssql)" not allowing the application to go anywhere beyond that. 3) Set a non empty $CFG->prefix value and visit the site again. Now it will work with normality (installation will be triggered if the site is new or normal pages will work if the site already existed). 4) Run unit tests for sqlsrv, no problems should appear related with this issue.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull 2.6 Branch:
    • Pull Master Branch:

      Description

      The following exception occurs when using the web installer, configured with MSSQL without a table prefix. I believe the issue is because "User" is a reserved word in MSSQL and must be escaped (if that is the proper way to say it) using square brackets: [User].

      Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near the keyword 'user'.<br>
       
      SELECT TOP 1 'x' FROM user 
      [array (
      )] 
      Error code: dmlreadexception
      

      I was able to work around this by: dumping the database, updating the config.php file to include a table prefix, and re-installing.

        Gliffy Diagrams

          Activity

          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Aha, it seems that the sqlsrv driver is missing a check that all the other drivers perform on connect (about to require prefix not to be empty). That should lead to an earlier error on connection.

          Coming with a patch soon...

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Aha, it seems that the sqlsrv driver is missing a check that all the other drivers perform on connect (about to require prefix not to be empty). That should lead to an earlier error on connection. Coming with a patch soon...
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Sent to peer review. The patch puts sqlsrv on par with the rest of drivers.

          Thanks for the report!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Sent to peer review. The patch puts sqlsrv on par with the rest of drivers. Thanks for the report!
          Show
          cibot CiBoT added a comment - Results for MDL-44377 Remote repository: https://github.com/stronk7/moodle.git Remote branch MDL-44377 _25 to be integrated into upstream MOODLE_25_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1781 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1781/artifact/work/smurf.html Remote branch MDL-44377 _26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1782 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1782/artifact/work/smurf.html Remote branch MDL-44377 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1783 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1783/artifact/work/smurf.html
          Hide
          skodak Petr Skoda added a comment -

          thanks a lot, submitting for integration

          Show
          skodak Petr Skoda added a comment - thanks a lot, submitting for integration
          Hide
          cibot CiBoT added a comment -

          Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

          Show
          cibot CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
          Hide
          poltawski Dan Poltawski added a comment -

          Thanks Eloy.

          Integrated to master, 26 and 25.

          Show
          poltawski Dan Poltawski added a comment - Thanks Eloy. Integrated to master, 26 and 25.
          Hide
          poltawski Dan Poltawski added a comment -

          ps. this has a gold standard example of a useful commit message IMO.

          Show
          poltawski Dan Poltawski added a comment - ps. this has a gold standard example of a useful commit message IMO.
          Hide
          salvetore Michael de Raadt added a comment -

          Test result: Success!

          Tested in 2.5, 2.6 and master.

          Show
          salvetore Michael de Raadt added a comment - Test result: Success! Tested in 2.5, 2.6 and master.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          For fun: http://www.youtube.com/watch?v=IGENkpaPkgw

          Many thanks for your hard work, this is now part of Moodle!

          Ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - For fun: http://www.youtube.com/watch?v=IGENkpaPkgw Many thanks for your hard work, this is now part of Moodle! Ciao

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Mar/14