Commit graph

231 commits

Author SHA1 Message Date
Reedy
d3d88f8a46 Remove see comment
Change-Id: I58fcd682dba6c778c0975baf67a6b87f36b1aff2
2016-09-23 01:20:50 +01:00
Aaron Schulz
9569674153 Fix doc typo for wasConnectionError()
Change-Id: I70eaeb630e2a4bb8f2940c2dcc938f7305014d48
2016-09-22 15:10:16 -07:00
jenkins-bot
26c0ffd8dd Merge "Break long lines and generalize some comments in /rdbms" 2016-09-22 21:29:44 +00:00
jenkins-bot
e85fe80d59 Merge "Remove old remapping hacks from Database::indexName()" 2016-09-22 21:05:56 +00:00
Aaron Schulz
80bee99157 Break long lines and generalize some comments in /rdbms
Change-Id: Ibf80c67b59df748e98d74eeab492b1f33d198024
2016-09-22 14:02:53 -07:00
Aaron Schulz
c0c9fe8694 Make Database::__clone() a bit more robust using handleSessionLoss()
Change-Id: I6c16abceea612a7b1167b9cca70a174fa6b77020
2016-09-22 20:38:47 +00:00
jenkins-bot
41af1a484d Merge "Use ConvertibleTimestamp::convert() in a few places" 2016-09-22 05:36:32 +00:00
Aaron Schulz
6572d9af53 Actually set errorLogger in Database
Change-Id: Icc2e49bcedf5172c1c1fdf8202acc6c1abdbac5b
2016-09-21 22:22:04 -07:00
Kunal Mehta
728588128b Use ConvertibleTimestamp::convert() in a few places
Change-Id: I9da31cd96fa7afa5cfccbbc204fb446fdb1a3c65
2016-09-21 21:46:24 -07:00
Kunal Mehta
8e9d2e93ca Rename Convert*a*bleTimestamp to Convert*i*bleTimestamp
Per the dictionary.

Change-Id: I3dcef9fb020c8c6764ee073111ed8c032e4c5a63
2016-09-21 21:43:32 -07:00
jenkins-bot
aca7983aeb Merge "Cleanup method visibilites in Database" 2016-09-21 21:48:39 +00:00
Aaron Schulz
bec6151e5f Remove old remapping hacks from Database::indexName()
Change-Id: Icab995aa6a442aab133da723363f794ef9128eb8
2016-09-21 12:52:17 -07:00
Aaron Schulz
1bd86b3490 Cleanup method visibilites in Database
Also removed some unused cruft

Change-Id: I855d0e0d6571ea15c03d2a27bf55ad5e14cd15d4
2016-09-21 12:26:45 -07:00
jenkins-bot
07292095eb Merge "Check Database::mSessionTempTables in Database::tableExists()" 2016-09-21 19:14:19 +00:00
Aaron Schulz
d0e6d92fb0 Check Database::mSessionTempTables in Database::tableExists()
Also make the temp table tracking catch plain "DROP TABLE"
in addition to the stricter "DROP TEMPORARY TABLE" clause.

Bug: T146300
Change-Id: Ia8306ec25e63adcdcf0dcc8f6a700dd01afdc948
2016-09-21 19:02:09 +00:00
Brad Jorsch
f536c780eb Database: Behave correctly when inserting booleans
Pretty much everything seems to assume that PHP booleans should be
converted to 0/1: MySQL does this implicitly thanks to the lack of
strict mode by default, while PostgreSQL and Sqlite (and Mssql) do it
explicitly.

The addition of MySQL strict mode for unit tests in Ib2873913 exposed
the assumption in the case of MySQL by making some extension unit tests
fail. So let's make casting bool to int the default behavior of
Database::addQuotes().

This also cleans up the phpdoc for Database::addQuotes() to properly
reflect all the supported types that can be passed to it.

Change-Id: I13d0e402fa676bc27c345e8ac12f363ebc627f6a
2016-09-21 14:03:29 -04:00
Aaron Schulz
ccbab078f7 Remove Database clone call from DatabaseTests.php
Change-Id: I60a22de9ccc7253abc9bbefe2a4f38675655ee4f
2016-09-20 16:24:16 -07:00
jenkins-bot
8204049f3c Merge "Avoid TransactionProfiler notices for TEMPORARY table writes" 2016-09-20 22:45:17 +00:00
Aaron Schulz
a591ed5793 Improve Database::__destruct() and add a __clone() method too
* Close dangling connections in LoadBalancer/Database destructors.
* When DBs are cloned, create new connection resources for the clone
  so the two do Database objects don't clobber each other.

Change-Id: I3adb57cbb1fdc2a17e6d95389d0562ef22701576
2016-09-20 22:04:11 +00:00
jenkins-bot
a108728ced Merge "Set an initial dummy domain in Database::__construct()" 2016-09-20 19:23:12 +00:00
Aaron Schulz
83549a2e71 Clean up redundant defaults in Database::__construct()
* This are already (or now) managed by Database::factory().
* Also remove unused "foreign" parameter.

Change-Id: I9161b9f158b656fd10b1506ecb82bf42ab94ea43
2016-09-20 18:36:38 +00:00
Aaron Schulz
aa9ef623ec Set an initial dummy domain in Database::__construct()
This avoids errors when LoadBalancer calls getWikiId() in
reallyOpenConnection() after a failed connection.

Change-Id: Idc3d93ae39be09f2da277df57cdc5a564cb3408d
2016-09-20 18:05:25 +00:00
Aaron Schulz
8c261ee924 Database class parameter and documentation cleanups
* Document various parameter arrays.
* Fix $user = false loophole in Database::__construct().
* Set the Postgres port *before* calling super, as it is
  needed by open().
* Remove 'chronProt' parameter as it is lazy-loaded.

Change-Id: Icc1037efa1eee7ae6fdd2919f60001e6e29ae55c
2016-09-19 23:23:30 -07:00
Aaron Schulz
0dd19856b0 Avoid TransactionProfiler notices for TEMPORARY table writes
* Make Database detect and track temporary tables for the session.
  Creating, dropping, and updating them do not count as "write" queries.
  Even a read-only mysql slave can have these operations performed on it
  and it can be useful for complex read queries that need temporary results.
* Rename handleTransactionLoss() to handleSessionLoss() and cover named locks too.

Bug: T145947
Change-Id: I826439e9e9f550f32a9c46b3dd60e8e8015aa274
2016-09-19 16:49:56 -07:00
Aaron Schulz
ff38b54d61 Move LIST_ constaints to IDatabase class constants
Leave aliases in Defines.php for backwards compatibility.

Change-Id: I88b45e0943cbfe97d863c2e0a4911fc0f81e5bb5
2016-09-19 07:59:21 +00:00
Aaron Schulz
81e8d7af41 Avoid MWDebug usage in DatabaseBase
This class is in /libs and cannot depend on all of MediaWiki.
Replace the call with a simple debug() call instead.

Also, make the legacy logger route/format errors from the two
new DB log types (DBConnection, DBQuery) to the old wfLogDBError
locations, including MWDebug::debugMsg().

Change-Id: I64895d3f5b9a000d8186ab6a6ffb4b76a7e9ff40
2016-09-17 18:49:30 -07:00
Aaron Schulz
8d82ff1069 Clean up $wgDBmwschema handling and only apply it to mssql
Follow-up to 61762bf3f8f904bcc5a0f90985e7f787756032a7

Change-Id: Ib8dc247ba17d7cbf4cf0f46dbe82983a715f2c8d
2016-09-17 16:49:25 -07:00
jenkins-bot
1afef61fb0 Merge "Inject Profiler into Database objects" 2016-09-17 22:57:15 +00:00
Aaron Schulz
5c681e438f Inject Profiler into Database objects
* This removes the Profiler::instance() dependency from
  a class in /libs.
* Also removed unused setTransactionProfiler() method

Change-Id: Iec735a130914090dc51aed30a283565a66aabee6
2016-09-17 22:32:57 +00:00
Aaron Schulz
847b91bf1f Make database classes handle hyphens in $wgDBname
* Add DatabaseDomain class to handle passing domains around.
It also can be cast to and from strings, which are of the same
format as wfWikiId() except with hyphens escaped.
* Make IDatabase::getDomainID() use these IDs so they can be
passed into LoadBalancer::getConnection() and friends without
breaking on sites with a hyphen in the DB name.
* Add more LBFactory unit tests for domains.

Bug: T145840
Change-Id: Icfed62b251af8cef706a899197c3ccdb730ef4d1
2016-09-17 15:29:21 -07:00
Aaron Schulz
403a1ea178 Move all of the reasonable DatabaseBase methods to Database class
The Database class was previously just a short-hand for "Database::",
and such calls should still work. The class now resides in /libs/rdbms.

The subclasses now extend DatabaseBase to avoid breaking type hints
that use that (hints use either IDatabase or DatabaseBase).

Also, use CASCADE with DROP TABLE for MySQL as with other DBs.
Keep SQLite excempt due to lack of support.

Added getDomainID() methods to avoid mentioning the word "wiki".

Change-Id: Ibd05d786cb26c21dcc9cb9601f6b2b52056af9ae
2016-09-17 03:38:05 +00:00