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

PostgreSQL 12.x support

XMLWordPrintable

    • PostgreSQL
    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • m39_MDL-67414_Add_PostgreSQL_12x_Support_v2
    • Easy
    • Hide

      (Unit tests should be enough)

      Unit tests

      (easy, requires a docker host and the Moodle HQ docker toolbox)
      Note: CI should cover tests on PG 9..11.

      Copy the patched Moodle code into a directory that will be the target of the unit tests and configure the target:

      # export MOODLE_DOCKER_WWWROOT=/path/to/moodle
      # export MOODLE_DOCKER_PHP_VERSION=7.3
      # export MOODLE_DOCKER_DB=pgsql
      # /bin/cp -f config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php
      

      Then bump PG to 12.x:

      # bin/moodle-docker-compose down -v
      # git diff
      diff --git a/base.yml b/base.yml
      index 2ede0f9..ed960ce 100755
      --- a/base.yml
      +++ b/base.yml
      @@ -15,7 +15,7 @@ services:
             MOODLE_DOCKER_BROWSER: firefox
             MOODLE_DOCKER_WEB_HOST: "${MOODLE_DOCKER_WEB_HOST}"
         db:
      -    image: postgres:11
      +    image: postgres:12
           environment:
             POSTGRES_USER: moodle
             POSTGRES_PASSWORD: "m@0dl3ing"
      

      Finally change to the docker toolbox directory and issue the following commands:

      # bin/moodle-docker-compose up -d
      # bin/moodle-docker-wait-for-db
      # bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php
      # bin/moodle-docker-compose exec webserver vendor/bin/phpunit lib/dml/tests/dml_table_test.php
      # bin/moodle-docker-compose exec webserver vendor/bin/phpunit lib/dml/tests/dml_test.php
      # bin/moodle-docker-compose exec webserver vendor/bin/phpunit auth/db/tests/db_test.php
      

      Tests should be successful on PG 12.x.

      Show
      (Unit tests should be enough) Unit tests (easy, requires a docker host and the Moodle HQ docker toolbox) Note: CI should cover tests on PG 9..11. Copy the patched Moodle code into a directory that will be the target of the unit tests and configure the target: # export MOODLE_DOCKER_WWWROOT=/path/to/moodle # export MOODLE_DOCKER_PHP_VERSION=7.3 # export MOODLE_DOCKER_DB=pgsql # /bin/cp -f config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php Then bump PG to 12.x: # bin/moodle-docker-compose down -v # git diff diff --git a/base.yml b/base.yml index 2ede0f9..ed960ce 100755 --- a/base.yml +++ b/base.yml @@ -15,7 +15,7 @@ services: MOODLE_DOCKER_BROWSER: firefox MOODLE_DOCKER_WEB_HOST: "${MOODLE_DOCKER_WEB_HOST}" db: - image: postgres:11 + image: postgres:12 environment: POSTGRES_USER: moodle POSTGRES_PASSWORD: "m@0dl3ing" Finally change to the docker toolbox directory and issue the following commands: # bin/moodle-docker-compose up -d # bin/moodle-docker-wait-for-db # bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php # bin/moodle-docker-compose exec webserver vendor/bin/phpunit lib/dml/tests/dml_table_test.php # bin/moodle-docker-compose exec webserver vendor/bin/phpunit lib/dml/tests/dml_test.php # bin/moodle-docker-compose exec webserver vendor/bin/phpunit auth/db/tests/db_test.php Tests should be successful on PG 12.x.

      PostgreSQL since version 12.0 has removed the column pg_attrdef.adsrc. See the release notes.

      This column is used in /lib/dml/pgsql_native_moodle_database.php. The installation of Moodle is halted with the message:

      Default exception handler: Error reading from database Debug: ERROR:  column d.adsrc does not exist
      LINE 1: ...e, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, d.adsrc
                                                                      ^
      SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, d.adsrc
                        FROM pg_catalog.pg_class c
                        JOIN pg_catalog.pg_namespace as ns ON ns.oid = c.relnamespace
                        JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
                        JOIN pg_catalog.pg_type t ON t.oid = a.atttypid
                   LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = c.oid AND d.adnum = a.attnum)
                       WHERE relkind = 'r' AND c.relname = 'mdl_config' AND c.reltype > 0 AND a.attnum > 0
                             AND (ns.nspname = current_schema() OR ns.oid = pg_my_temp_schema())
                    ORDER BY a.attnum
      [NULL]
      Error code: dmlreadexception
      * line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
      * line 259 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 425 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 662 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_columns()
      * line 1619 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
      * line 1395 of /lib/moodlelib.php: call to moodle_database->get_field()
      * line 1506 of /lib/upgradelib.php: call to set_config()
      * line 1751 of /lib/upgradelib.php: call to upgrade_started()
      * line 479 of /lib/installlib.php: call to install_core()
      * line 813 of /admin/cli/install.php: call to install_cli_database()
      

            matteo Matteo Scaramuccia
            vmdef Victor Déniz Falcón
            Jun Pataleta Jun Pataleta
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            CiBoT CiBoT
            Votes:
            7 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 40 minutes
                2h 40m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.