Moodle
  1. Moodle
  2. MDL-33434

MSSQL driver (freetds) hiding errors on insert violating unique constraints

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.9, 2.1.6, 2.2.3, 2.3
    • Fix Version/s: 2.1.7, 2.2.4
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Testing Instructions:
      Hide

      NOTE: This needs to be tested in all branches!

      For 21_STABLE and 22_STABLE:

      • Run the "Functional DB tests" for all (FIVE) databases.
      • Verify that there isn't any failure in the "test_insert_record" case. Ignore others.

      For master:

      • Prepare your site to run phpunittests.
      • Run the dml tests for all (FIVE) databases:
        cd lib/dml
        phpunit dml_testcase tests/dml_test.php
        
      • Verify that there isn't any failure in the "test_insert_record" case. Ignore others.

      Note: This has been tested already for:

      • mysql
      • postgresql
      • oracle
      • mssql (using freetds 0.82)

      It would be great to have it tested under:

      • mssql (using freetds 0.91)
      • sqlsrv

      Ciao

      Show
      NOTE: This needs to be tested in all branches! For 21_STABLE and 22_STABLE: Run the "Functional DB tests" for all (FIVE) databases. Verify that there isn't any failure in the "test_insert_record" case. Ignore others. For master: Prepare your site to run phpunittests. Run the dml tests for all (FIVE) databases: cd lib/dml phpunit dml_testcase tests/dml_test.php Verify that there isn't any failure in the "test_insert_record" case. Ignore others. Note: This has been tested already for: mysql postgresql oracle mssql (using freetds 0.82) It would be great to have it tested under: mssql (using freetds 0.91) sqlsrv Ciao
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      41324

      Description

      Testing MDL-33326 some problems were detected under MSSQL.

      After investigating possible causes (SQL*Server versions, FreeTDS libraries...) debugging revealed that the problem was caused by one combination of the behavior of mssql_query() when running batches and the insertion of records returning ids.

      So this issue is about:

      • Change the current batch used for inserting records returning ids (SCOPE_IDENTITY), to newer and recommended OUTPUT clause and specialized handling of returned values.
      • Cover the 2 insertion cases (with and without returning ids).
      • Verify tests pass under the 5 drivers.

      Ciao

        Issue Links

          Activity

          Hide
          Eloy Lafuente (stronk7) added a comment -

          Sending to integration...ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Sending to integration...ciao
          Hide
          Dan Poltawski added a comment -

          Integrated this now, Thanks Eloy

          Show
          Dan Poltawski added a comment - Integrated this now, Thanks Eloy
          Hide
          Dan Poltawski added a comment -

          Tested sqlsrv and freedts 0.91 on master and all good.

          Show
          Dan Poltawski added a comment - Tested sqlsrv and freedts 0.91 on master and all good.
          Hide
          Dan Poltawski added a comment -

          Test 22/21 with sqlsrv driver and passed (although grr I did have some other environemnt related problems relating to my install)

          Show
          Dan Poltawski added a comment - Test 22/21 with sqlsrv driver and passed (although grr I did have some other environemnt related problems relating to my install)
          Hide
          Dan Poltawski added a comment -

          Testing on freedts 0.91 21_STABLE and 22_STABLE and all good.

          I have also randomly tested mysql and pgsql, but not on all branches as it looks like you've done that. But I can run them if required.

          Show
          Dan Poltawski added a comment - Testing on freedts 0.91 21_STABLE and 22_STABLE and all good. I have also randomly tested mysql and pgsql, but not on all branches as it looks like you've done that. But I can run them if required.
          Hide
          Dan Poltawski added a comment -

          Congratulations!

          Your work has made into the latest Moodle release!

          You are only authorised to celebrate after testing 15 Moodle 2.3 QA tests, thanks!

          Show
          Dan Poltawski added a comment - Congratulations! Your work has made into the latest Moodle release! You are only authorised to celebrate after testing 15 Moodle 2.3 QA tests, thanks!

            People

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

              Dates

              • Created:
                Updated:
                Resolved: