786 Commits

Author SHA1 Message Date
Shamim Rezaie
b4d062c6be MDL-58584 core: remove duplications from get_columns functions 2020-02-03 15:07:15 +11:00
Matteo Scaramuccia
a8a4eac163 MDL-67414 database: Fixed PostgreSQL 12.x support 2020-01-26 09:37:17 +01:00
Matteo Scaramuccia
aa0a602b10 MDL-65811 database: Fix subsetting in MSSQL 2019-10-25 23:00:32 +02:00
Andrew Nicols
fe0944987e MDL-66011 test: remove magic @covers lines 2019-10-04 09:40:34 +08:00
sam marshall
46875866c6 MDL-63315 DB: Postgres - Clear cursors in persistent connection
If there is a PHP fatal error and destructors do not run (this can
happen in out-of-memory errors, and maybe if there is an error in a
previous destructor) then Postgres cursors may be left open.

Usually this does not cause a problem because the connection is
closed anyway, but if using persistent connections, a future
request may reuse the connection with a cursor open. It then gets
errors when it tries to create a new cursor with the same name.

This change closes all cursors at the start of a persistent
connection.
2019-09-02 14:08:57 +01:00
Jun Pataleta
669de78352 MDL-66110 dml: Undo table name fix when table name's used as parameter 2019-08-22 16:16:08 +08:00
Ryan Wyllie
f12c591807 MDL-66110 dml: use fix_table_name for all mysql table names
Changed all of the places that were manually prefixing the table
name to instead fix the table name with the fix_table_name
function.
2019-08-22 16:03:33 +08:00
Jun Pataleta
ff6a7345f7 Merge branch 'MDL-66110-master' of https://github.com/ryanwyllie/moodle 2019-08-21 09:57:49 +08:00
Ryan Wyllie
30d2b9cd31 MDL-66110 dml: Fix MySQL v8 compatibility with groups table
MySQL v8 has added "groups" to the reserved word list. That is used
as a table name in Moodle so we have to quote it with backticks in the
SQL so that MySQL knows it's being used as an identifier.
2019-08-13 09:35:19 +08:00
Andrew Nicols
66fa73d84e MDL-66327 pgsql DML: Update get_records_sql to consume less memory
It's more memory efficient to use `pg_fetch_assoc` for each row than to
call `pg_fetch_all` and release memory immediately. This is because we
can treat the assoc fetch like an iterator and it only fetches the
current record into memory one at a time, whilst the all fetch fetches
all records and never unsets them. Attempting to unset them is extremely
time consuming.
2019-08-08 15:48:12 +08:00
Eloy Lafuente (stronk7)
87f196af93 MDL-65204 phpunit: more isEqual() strict string fixes
This is a followup of 85f47ba, where we were relaxing
the (new since phpunit 7.x) strict (===) isEqual()
comparison for strings. Copying the explanations for
easier understanding.

Link: https://github.com/sebastianbergmann/phpunit/issues/3185
Solution here is one of:
  a) Return to the previous situation, making the comparison
     softer. That can achieved by forcing different types, so
     float == string works.
  b) Changing APIs (both forms and database return strings) to
     perform some conversion to floats. That would make float
     comparison (with floats or strings) to work too.
The patch here follows the a) approach. Changing all the internals
for proper float handling sounds excesive when it has been working
perfectly since ever. So we went the easier route, just getting
rid of the new === comparisons when needed by changing expectation
types to float.
2019-04-03 22:08:16 +02:00
Andrew Nicols
71cbc0550f MDL-65168 dml: Move preload SQL functions to self-contained class 2019-03-25 23:05:22 +01:00
Ryan Wyllie
a30570c555 MDL-64820 dml: add object preloading helpers 2019-03-22 09:24:04 +08:00
Tim Hunt
a0536c410a MDL-64981 dml tests: pgsql_native_recordset_testcase port number 2019-03-01 11:12:40 +00:00
Eloy Lafuente (stronk7)
0de29dbf35 MDL-63020 tests: ensure that searching for is null values also works ok 2018-09-24 17:38:10 +02:00
Tim Hunt
eb6c769a8c MDL-63020 dml: improve the unit tests 2018-09-24 11:41:25 +01:00
Tim Hunt
5abc431335 MDL-63020 ddl: fix nullable unique indexes in OCI and MS SQL
This works-around the default non-standard behaviour of these DB engines.
2018-09-20 17:41:22 +01:00
Tim Hunt
54b2b1d27f MDL-63020 xmldb: Improve PHPdoc comments for better IDE autocomplete 2018-09-20 17:41:22 +01:00
Matteo Scaramuccia
82c2d98fa2 MDL-61702 dml: MariaDB 10.3 supports only the Barracuda file format.
More details about this change also in https://tracker.moodle.org/browse/MDL-59099

Ref.: https://mariadb.com/kb/en/library/mariadb-1031-release-notes/#other-variables
2018-05-31 22:55:00 +02:00
David Monllao
17ed12eb17 Merge branch 'm35_MDL-59596_DDL_Issues_With_MariaDB_10p2_SQLMode' of https://github.com/scara/moodle 2018-05-28 08:15:09 +02:00
Jake Dallimore
48c3e99599 MDL-59581 database: remove mssql specific code from lib/dml 2018-04-09 01:58:26 +02:00
Matteo Scaramuccia
f6b16e95a8 MDL-59596 ddl: Added has_breaking_change_sqlmode() 2018-03-26 23:12:36 +02:00
David Monllao
c2e970779d MDL-53226 search_simpledb: Refine the patch
- Clumsy fallback only when there is no full-text search support
- Mimic solr tests
- pgsql tokenization using simple configuration
- workaround for mysql '*' search issue
- total results proper calculation
- SQL server FTS support
- Standarize dml full-text search checkings
- Upgrade note about the new dml method
- Set search_simpledb as default engine if no solr config
2018-03-20 18:49:38 +01:00
Matteo Scaramuccia
bccbd3b4eb MDL-61626 core_dml: pgsql and schema qualification. 2018-03-11 22:56:36 +01:00
Eloy Lafuente (stronk7)
5405354d88 MDL-61240 dml: php72 compatibility, avoid counting on non-countables
This was not detected earlier because we have been unable to
run sqlsrv + php72 till now (not available).
2018-01-19 00:59:16 +01:00
Jake Dallimore
fa2a9cc933 MDL-23887 database: fix use of deprecated system tables for mssql
Catalog views are available which we should use instead.
2018-01-02 17:19:17 +08:00
Damyon Wiese
8cae085071 Merge branch 'MDL-60976-master' of https://github.com/matt-catalyst/moodle 2017-12-12 09:56:20 +08:00
Neill Magill
61fad215f1 MDL-60041 dml: MOODLELIB sql file must have Unix line endings
If the file does not have Unix line endings then the regular expression
in oci_native_moodle_database::attempt_oci_package_install() does
not split it correctly.

This leads to an invalid package being created in Oracle.

The .gitattribute file changes for oci_native_moodle_package.sql
force it to have Unix style line endings when the branch is checked
out and the file does not already exist.

The file has been modified so that the Unix style line endings are
applied even if the file already exists, for example when pulling in
this change to an existing branch.
2017-12-11 08:40:58 +00:00
Matt Clarkson
1c06098b6b MDL-60976 dml: Optimise replace_all_text()
Avoid updating fields that do not match the search string.
2017-12-08 12:35:56 +13:00
sam marshall
ed00d67c99 MDL-60174 core_dml: get_recordset on Postgres eats all the RAM
On Postgres, get_recordset_sql loads all the results into memory
(within the Postgres library, which doesn't count towards the PHP
memory limit, but does count towards making your server run out of
memory) as soon as the query completes.

This commit changes the code to use cursors, which in Postgres
allow the results to be returned in smaller chunks (by default
100,000 rows).
2017-11-27 11:10:29 +00:00
Matteo Scaramuccia
740a9315c3 MDL-59099 dml: MySQL8 supports only the Barracuda file format.
The following InnoDB file format configuration parameters were deprecated
in MySQL 5.7.7 and are now removed:
- innodb_file_format
- innodb_file_format_check
- innodb_file_format_max
- innodb_large_prefix

File format configuration parameters were necessary for creating tables
compatible with earlier versions of InnoDB in MySQL 5.1.
Now that MySQL 5.1 has reached the end of its product lifecycle,
the parameters are no longer required.

The FILE_FORMAT column was removed from the INNODB_SYS_TABLES and
INNODB_SYS_TABLESPACES Information Schema tables.

Ref: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-0.html
2017-10-27 17:38:36 +02:00
Matteo Scaramuccia
500d8650d2 MDL-59100 dml: Lower the case of INFORMATION_SCHEMA.* fields. 2017-10-21 14:30:38 +02:00
David Monllao
b1a9a6a19a Merge branch 'wip-MDL-60281-master' of git://github.com/marinaglancy/moodle 2017-10-17 09:45:44 +02:00
Marina Glancy
109fbd5a15 MDL-46269 dml: Add casesensitive argument to sql_regex() 2017-10-16 16:53:46 +08:00
Marina Glancy
484b43f456 MDL-60281 general: create_function is deprecated in PHP7.2 2017-10-16 09:37:19 +08:00
Matteo Scaramuccia
ea34d02d55 MDL-59635 tool_replace: Escape the column name. 2017-09-04 11:46:55 +02:00
Andrew Nicols
ee640d3f2d Merge branch 'm34_MDL-59583_Fix_MariaDB_10d2d7_Breaking_Change' of https://github.com/scara/moodle 2017-08-03 12:29:56 +08:00
Matteo Scaramuccia
2ec50fe3fd MDL-59583 dml: fixed NULL values w/ MariaDB 10.2.7+ 2017-08-03 00:13:03 +02:00
Andrew Nicols
2653e0c8e1 Merge branch 'm34_MDL-59583_Fix_MariaDB_10d2d7_Breaking_Change' of https://github.com/scara/moodle 2017-07-31 11:37:45 +08:00
Dan Poltawski
afa752eb12 Merge branch 'MDL-57698-master' of https://github.com/xow/moodle 2017-07-25 11:48:09 +01:00
Matteo Scaramuccia
0510d5c757 MDL-59583 dml: fixed breaking change added w/ MariaDB 10.2.7+ 2017-07-25 12:36:23 +02:00
Matteo Scaramuccia
dae6c5dc31 MDL-59583 dml: improve perfs by unsetting the key. 2017-07-25 09:06:18 +02:00
David Monllao
b4e55d3a37 Merge branch 'MDL-59509-master' of git://github.com/andrewnicols/moodle 2017-07-24 13:03:10 +02:00
Dan Poltawski
9c0cdc069b Merge branch 'MDL-59572-master' of git://github.com/andrewnicols/moodle 2017-07-24 09:54:39 +01:00
John Okely
9726144ef3 MDL-57698 sqlsrv: Unit test NOLOCK 2017-07-21 14:41:55 +08:00
John Okely
b540fd1a80 MDL-57698 sqlsrv: Query temp tables with no lock 2017-07-21 14:41:54 +08:00
Andrew Nicols
e879619477 MDL-59509 dml: sqlsrv should respect port setting
Details of how to connect to a specific port are available at
https://docs.microsoft.com/en-us/sql/connect/php/how-to-connect-on-a-specified-port
2017-07-21 13:23:17 +08:00
Adrian Greeve
3a8c989137 MDL-59561 database: Update to creating new indexes in mysql.
When updating the mysql system to utf8mb4 not all tables are
converted to the row format of compressed or dynamic. If a new
index is created there is a possibility that the table could be
using compact or redundant and then an error will be shown saying
that the index size is too large. This fix handles this exception
and converts the table over to compressed.
2017-07-21 09:27:08 +08:00
Andrew Nicols
9790a9b583 MDL-59572 dml: Call error_log for AJAX/WS calls 2017-07-19 12:49:15 +08:00
Marina Glancy
f2b5ed40f9 MDL-58689 dml: prevent logging during setup 2017-04-27 10:07:01 +08:00