124 Commits

Author SHA1 Message Date
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
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
Marina Glancy
109fbd5a15 MDL-46269 dml: Add casesensitive argument to sql_regex() 2017-10-16 16:53:46 +08:00
Matteo Scaramuccia
ea34d02d55 MDL-59635 tool_replace: Escape the column name. 2017-09-04 11:46:55 +02:00
John Okely
9726144ef3 MDL-57698 sqlsrv: Unit test NOLOCK 2017-07-21 14:41:55 +08:00
Adrian Greeve
8c1288dbdb MDL-48228 database: Unit test addition and update. 2017-03-01 09:03:12 +08:00
Eloy Lafuente (stronk7)
8dcc999d96 Merge branch 'wip-MDL-55827-master' of git://github.com/marinaglancy/moodle 2016-09-20 01:02:06 +02:00
Eloy Lafuente (stronk7)
03d27c303d MDL-29332 tests: Cover the new sql_equal() function
- For CS, CI and AS
- Not for AI (it's not cross-db)
- equal (=) and not equal (<>)
- delete old test_sql_binary_equal() now with cross-db solution.
2016-09-15 16:33:08 +02:00
Marina Glancy
308ce5b46f MDL-55827 tests: @ does not suppress wrong number of arguments in php7.1 2016-09-06 15:37:30 +08:00
Russell Smith
1b0b082a08 MDL-54947 database: Update PostgreSQL binary handling.
PostgreSQL 9.1 allows hex formating for binary which is handled better
by pg_query_params().

Getting bytea isn't required on connection, it can be used as pg_field_type()
when binary needs to be checked.
2016-06-30 12:58:53 +10:00
Eloy Lafuente (stronk7)
4ae653024d MDL-53944 dml: make char2real() for mysql to support decimals
- With the patch, 6 positions of scale accuracy are guaranteed
  per individual casted value.
- Backed with unit tests, both for varchar and clob.
- Added 2 missing tests about uses of the method with params
  and values.

Note: 6 was picked because looking to all databases implementation
postgres was found to be casting to real, aka, 6.
2016-05-06 09:27:32 +08:00
David Monllao
ef474575e1 Merge branch 'MDL-51374-master-new' of git://github.com/lameze/moodle
Conflicts:
	lib/db/caches.php
2016-03-16 10:13:14 +08:00
Simey Lameze
87a3e50192 MDL-51374 core_dml: change database layer to pass table name as parameter 2016-03-15 14:43:45 +08:00
Eric Merrill
208a79c920 MDL-53430 dml: Fix recordset_walk for additional parameters 2016-03-10 16:32:02 -05:00
Mark Nielsen
d494306de7 MDL-52060 phpunit: Prevent querying database metadata 2015-12-22 13:40:38 +08:00
Charles Fulton
3d47155643 MDL-51052 dml: support for sql_like() under utf8_bin 2015-09-18 09:56:43 +08:00
Eloy Lafuente (stronk7)
789d40a803 Merge branch 'MDL-49293-master' of git://github.com/andrewnicols/moodle 2015-08-11 22:58:09 +02:00
Eloy Lafuente (stronk7)
15c0a85071 MDL-50771 oracle: Bind long (>4000byte) text as CLOB
While we already were detecting @ normalise_value()
both BLOBs and CLOBs properly on insert and update
statements (by introspectind the column specs), when
a long TEXT is being passed as part of an arbitrary
SQL, or within the conditions... it was being bound
as VARCHAR, leading to problems if used in combination
with DBMS_LOB functions.

This patch just ensures that any TEXT > 4000 bytes not
detected by normalise_value() will be, always, bound as CLOB,
unconditionally.

Covered with tests both covering its use with DBMS_LOB (the
reported bug) and also in general raw statements.
2015-08-03 10:50:56 +02:00
Mark Nelson
17a3781259 MDL-49551 core_dml: deprecated set_logging() 2015-04-13 19:30:08 -07:00
David Monllao
ad23227bd6 MDL-48595 core_dml: Adding a recordset walker 2015-03-09 08:25:14 +08:00
Andrew Nicols
29e2563a6d MDL-49293 db: Test sql_concat_join with more conditions 2015-03-06 11:36:31 +08:00
Eloy Lafuente (stronk7)
5d98ba68f5 MDL-35155 database: better sql_substr() impl. for mssql/sqlsrv + unit tests
MSSQL's substring() implementation is somehow silly/strict and unable to
perform implicit casts to integer both for the start and length parameters.

This hits Moodle badly because of another problems (MDL-23997) we decided
to cast to string all bound placeholders long ago.

So this commit just enforces the cast of the start and length parameters to
integer. And includes unit tests for using placeholders on all positions in
the sql_substr() method.
2015-01-15 08:32:38 +00:00
Dan Poltawski
9581dff081 MDL-35155 dml: add unit test which exposes substr problem
Previously, when using parameters, substring broke on mssql.
2014-12-31 15:17:16 +00:00
Damyon Wiese
0cc1ee1f30 MDL-46171 dml: DML unit test for tricky SQL in assign upgrade
This tests a workaround for set_field_select where the set table and from table are the same.
2014-09-30 23:35:37 +08:00
Marina Glancy
3b4db5bdf5 MDL-44725 dml: added sql_intersect() 2014-09-03 13:33:58 +08:00
Petr Škoda
ce1f5ed57a MDL-44624 fix false failures in DML tests 2014-03-14 14:14:10 +08:00
Tim Hunt
9eec598ca9 MDL-44251 fix typo in DML unit tests. 2014-03-02 09:41:17 +01:00
David Monllao
3af7eea68d MDL-43882 dml: New test for perf_get_xxxx() methods 2014-02-21 13:21:13 +08:00
Petr Škoda
cc5dba8e54 MDL-34055 add bulk DB->insert_records() method
This patch was inspired by patch by Simon Coggins from Totara.
2014-01-28 10:41:43 +08:00
Dan Poltawski
c582565a06 MDL-43395 dml: warn about invalid limit params
Help developers to find bugs by throwing a DEBUG_DEVELOPER message
rather than ignoring this case completely.
2014-01-13 08:42:07 +08:00
Sam Hemelryk
37f59a68bd Merge branch 'MDL-41359-master' of https://github.com/mr-russ/moodle 2013-12-18 10:08:33 +13:00
Russell Smith
9c7dfbe6ed MDL-41359 database: no table columns is a dml_excpeiton
When insert_record is called and it doesn't find any columns
to insert data into, that is a dml_exception as you need at least
one column in the database to insert into it.  This can happen
when you have created a zero column database table, or the table
does not exist.
2013-12-07 08:56:24 +11:00
Petr Škoda
6c3ae510f1 MDL-31625 fix multiple global search-replace issues
Includes following fixes:
* support for MS SQL Server
* optional trimming of of oversized VARCHAR fields
* conversion to forms library
* full localisation
* other cleanup
2013-12-06 09:51:49 +08:00
Dan Poltawski
356d33a866 MDL-42775 dml: remove invalid unit test assertion 2013-11-08 12:25:49 +08:00
Petr Škoda
9d6d32b6f0 MDL-41022 cleanup core_dml_testcase 2013-08-24 16:18:02 +02:00
Dan Poltawski
6f44a73369 Merge branch 'w33_MDL-39474_m26_debugdeveloper' of https://github.com/skodak/moodle
Conflicts:
	lib/upgrade.txt
2013-08-20 11:42:03 +08:00
Simon Coggins
be4bf53d6d MDL-39572: Fix existing tests and add more to demonstrate issue with sql_order_by_text() 2013-08-16 11:26:54 +12:00
Petr Škoda
96f81ea385 MDL-39474 introduce $CFG->debugdeveloper and cleanup $CFG init 2013-08-12 13:01:47 +02:00
Petr Škoda
8252b7c291 MDL-40901 standardise core test case class and file names
This finally allows us to type only the class name when executing individual core test cases.
2013-08-04 22:10:31 +02:00
Petr Škoda
d11b8d0c63 MDL-40808 remove unused DML strings 2013-07-25 12:02:29 +02:00
Eloy Lafuente (stronk7)
9b2ebc4587 MDL-27071 Add big IN() unit tests
Let's verify how all databases perform with a big
number of parameters (10000) using IN() SQL clauses.
Both using QM and NAMED parameters.

Ideally only Oracle fails, and only it will need fixing.
2013-04-29 01:11:10 +02:00
Petr Škoda
031a6de97a MDL-39038 nasty workaround for Oracle NULL concats 2013-04-08 23:23:08 +02:00
Petr Škoda
e788339786 MDL-37742 add debugging message when $DB->sql_empty() used 2013-03-26 22:12:17 +01:00
Petr Škoda
77a5c09354 MDL-37742 simplify dirty one-space oracle hack 2013-03-24 13:43:18 +01:00
Eloy Lafuente (stronk7)
5ab0371d74 Merge branch 'MDL-37854_master' of https://github.com/markn86/moodle 2013-02-05 11:10:48 +01:00
Mark Nelson
17222a4a25 MDL-37854 phpunit: replaced occurrence of non-existent function assertFail 2013-02-05 18:03:25 +08:00
Petr Škoda
dd8a39a881 MDL-37734 add one more recordset isolation test 2013-01-29 10:10:40 +01:00
Petr Škoda
b39eac3eca MDL-36983 fix incorrect test method name
Credit goes to David Scotson, thanks.
2012-12-06 15:32:15 +01:00
Petr Škoda
bc5a5527e5 MDL-35691 add unit tests for the fixed integer column length info 2012-10-06 10:07:48 +02:00
Eloy Lafuente (stronk7)
8e4f6bb1d4 MDL-34657 test: verify CASE statements in ORDER BY clauses. 2012-09-27 12:41:41 +01:00