Commit graph

425 commits

Author SHA1 Message Date
Brad Jorsch
d5f52588a2 Move MySQL-specific fakeMaster/fakeSlave stuff to DatabaseMysqlBase
Probably the fakeMaster/fakeSlave stuff was originally intended to be
generic, but the existing code in Database.php is making some very
MySQL-specific assumptions. So let's evict it from Database.php (except
for the minimal support functions) and put it in DatabaseMysqlBase where
it makes more sense.

This also takes care of fixing the breakage described in I5d2a1696 by
reverting Id6268193 and the problematic bit of I364e192e (again).

Change-Id: I3dc6ca216bf2c2f07d3090e86f2539292e1fa86b
2014-01-13 15:00:27 -05:00
Siebrand Mazeland
da32eb2356 Correct return type doc for DatabaseBase::getLBInfo()
This confused PHPStorm's code analyser.

Change-Id: If99abfa6ca9e52a39b6d2621441686ab564781c7
2014-01-11 12:31:28 +01:00
jenkins-bot
4e7ab69708 Merge "Update formatting" 2014-01-10 12:09:48 +00:00
jenkins-bot
af7a22b771 Merge "Ensure variables in database classes are defined, used and correctly cased" 2014-01-10 11:57:32 +00:00
Siebrand Mazeland
c12aafdc92 Remove superfluous spaces and doc tweak
Change-Id: I3755b31a1fc9b9930fc41ef44242d0bd12dc26d8
2014-01-07 11:41:14 +01:00
Siebrand Mazeland
aa4d6e1f2e Update formatting
Change-Id: I27e43c19906edc732b4976b8426ed34bad63622b
2014-01-06 21:04:34 +00:00
Siebrand Mazeland
559cc681d3 Ensure variables in database classes are defined, used and correctly cased
Change-Id: I12065b2c2bae1c000edac3c92d1db0c03fc40f90
2014-01-06 18:46:48 +00:00
Siebrand Mazeland
e22a70a103 Update documentation for database related classes
Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f
2014-01-06 19:45:40 +01:00
umherirrender
8a2e1a4c88 Fix doc for Database::upsert
One @params too much

Change-Id: I8cea6228587574ff90060d46b4430b2348a68973
2014-01-03 21:35:21 +01:00
umherirrender
382651e2f1 Call Database::makeInsertOptions from Database::insertSelect
This allows other database types to modify the options.

Bug: 59233
Change-Id: I45a2c7944057f43453423c8edbe5d173b1fc067d
2014-01-03 18:57:22 +00:00
Kevin Israel
bc06a9b8b7 Abstract out mysql_field_type() call from DatabaseBase
DatabaseMysqlBase::fieldType() is used in the maintenance script
convertLinks.php for upgrading from MediaWiki 1.2 or earlier. This
script was failing when the mysqli extension was enabled.

Follows-up b1cc3511fd, b2d64432ee, and 00299ecb95.

Change-Id: I5d888f4dd344ecba15506023d35f6d2d6e24cfd8
2013-12-15 18:40:50 +00:00
Siebrand Mazeland
d1e42ff982 Update documentation for DatabaseBase::selectRow()
Change-Id: I3b2f1224b1dc41bbd96ef10dbb9a8744511186e3
2013-12-04 17:12:22 +01:00
umherirrender
5ca5672aac Fixed spacing
- Place commas correct
- Moved comments
- Add space after if/foreach/catch
- Reformat some conditions
- Removed trailing spaces/tabs

Change-Id: I40ccda72c418c4a33fcd675773cb08d971510cdb
2013-12-01 20:58:51 +01:00
Aaron Schulz
e3e6008743 Truncate super long SQL in DB error log lines (useful for blobs)
Change-Id: Ibb9b9178de80e691406e5c1a7113f0511055d18d
2013-11-21 16:00:15 -08:00
Siebrand Mazeland
b547395796 Break long lines and formatting updates for includes/db/
Fix all line length related CodeSniffer warnings.

Change-Id: Id0fd8f4c7276185f51489659ee3cd06962fbc16d
2013-11-21 16:43:40 +00:00
Siebrand Mazeland
1e10dcd3aa Update formatting on database-related classes
Change-Id: I91f83e28ae25f80ba9e36c612f1ad050ffa1573c
2013-11-21 16:39:38 +00:00
Aaron Schulz
a97402559b Changed use of tag_summary to use change_tag with GROUP_CONCAT()
* Added buildGroupConcatField() method to the DB classes

bug: 53577
Change-Id: I976f297653880e66af429ba9b622a954fefcc512
2013-11-17 06:37:08 +00:00
MarkAHershberger
c24f8be729 Revert "Remove unsupported and mostly non-functional Mssql support"
This reverts commit 5e1efc3144.

This sort of thing needs to be discussed.  Please do not self-approve changes like this.

Change-Id: I9eb9ea315d90584b7fe95db43a6759884f9506b5
2013-11-16 02:06:01 +00:00
Chad Horohoe
5e1efc3144 Remove unsupported and mostly non-functional Mssql support
Change-Id: Id0a688865a5b7b6bb363f7b118fad4f455d2b3b6
2013-11-15 10:59:37 -08:00
jenkins-bot
baab646245 Merge "Cleanups to DB transaction handling" 2013-11-13 23:13:30 +00:00
Bartosz Dziewoński
fe4f65689d DatabaseBase: Fix version number in deprecation notice
Followup to I09418558.

Change-Id: Iebdaf5a6678c4c2611d91b5c2678e89d36bccb20
2013-11-11 22:18:04 +01:00
jenkins-bot
164f334e53 Merge "Cleaned up DatabaseBase constructor to use an array" 2013-11-07 19:36:22 +00:00
AlephNull
e9d53667f4 MySQL method to find out view + fix fatal in tests
We were missing a method to list out views defined in a database. This
patch adds in MysqlBase::isView() and MysqlBse::listViews().

Since listViews() cache its result in DatabaseBase::$allViews, we also
introduce a final DatabaseBase::clearViewsCache() to let us clear the
per process cache.

Finally, fixed fatal error when duplicating VIEWs in MySQL.

bug: 43571
Change-Id: I8650baa4b721fe69ea3e1d557dd76745c0c7754e
2013-11-07 09:43:59 +00:00
Aaron Schulz
58a0e0c06d Cleaned up DatabaseBase constructor to use an array
Change-Id: I094185585dc844ca4d2d8b629107b2ab8f9bef39
2013-11-06 12:17:15 -08:00
Aaron Schulz
54664be154 Cleanups to DB transaction handling
* Only do requeries after automatic reconnection if there is no trx open instead.
  of doing possible half-broken changes and not fully updating trx state variables
* Also made trxLevel() no longer take an argument.
* Avoid clearing trx fields in some redundant places to make the code simpler
  Only mTrxLevel needs to be well tracked in various places. For the other fields,
  code just checks mTrxLevel before using those fields.
  They do need to be cleared in begin() though.
* Moved endAtomic() up next to startAtomic().
* Improved mTrxLevel docs

Change-Id: I12adfb4fcb28a4832facd63baee2283ead500bd2
2013-11-06 11:29:35 -08:00
jenkins-bot
66f3cc0c2d Merge "Added DatabaseBase::startAtomic and endAtomic" 2013-11-04 18:34:29 +00:00
Tyler Anthony Romeo
120161f2b3 Added DatabaseBase::startAtomic and endAtomic
Added new functions to ensure certain groups of statements
are atomic without having to go through the trouble of
starting a new transaction if one has already been opened.

Change-Id: I5328fb337e5544bf28ea282860ef8f81e19ac43c
2013-11-01 17:36:18 +00:00
Reedy
6afa1f337c Fix double space in trigger_error() call
Change-Id: I31b0aab630bf4083f4fa15d3fbce8a0d0759c94e
2013-10-29 01:24:26 +00:00
Aaron Schulz
5b876967a7 Fixed use of wrong callback array element
bug: 56124
Change-Id: Ia9f058f42616f5c7c5936733747d0c3a8d56dc19
2013-10-24 23:12:04 -07:00
jenkins-bot
91f5f17708 Merge "Added a few more trx sanity checks to DatabaseBase" 2013-10-21 20:28:44 +00:00
Aaron Schulz
ca8810e29d Added a few more trx sanity checks to DatabaseBase
* Also track the caller that added the callbacks

Change-Id: Idc4d9e4a89fcee28bd4b18ad6d8c6b09b9fe7e75
2013-10-21 10:15:47 -07:00
Tim Starling
01bc04f178 Fix SQLite exception when $wgDBuser is set
Fixed from several different directions:
* The error reporting was screwed up, so I wrapped the PDOException
  in a DBUnexpectedError.
* Make $db->open() trigger a close/open sequence if called a second
  time, like MySQL, instead of breaking mTrxLevel.
* Don't call $this->open() twice from the constructor, even if $user is
  set.

The bug dates to r84485. The nasty hack allowing you to construct a
do-nothing database object with "new Database()" dates back to 2004 and
has probably outlived its usefulness -- noted this. It was formerly used
by LoadBalancer::reportConnectionError().

Bug: 49254
Change-Id: I571f9209bec8e8ed5058b6327e1738eb4315d5a0
2013-10-17 22:36:47 +00:00
Tim Starling
98aca05888 Fix mysqli support
Exception was thrown if $dbType=mysql, regardless of whether a driver
was available. Also, the installer support was broken if the mysql
driver was missing.

Change-Id: I29df3fc9b3bf5743c1365f757e0cf899d5b96ae9
2013-10-17 03:11:53 +00:00
Tim Starling
00299ecb95 Resubmit "Add support for mysqli extension"
This reverts commit 1d7e12179d.

Change-Id: Id1a3fc34e94006b880f58de83e5e7c70b21d26ed
2013-10-17 01:35:28 +00:00
Tim Starling
1d7e12179d Revert "Add support for mysqli extension"
Throws exception unconditionally, installer support is totally broken.

This reverts commit b2d64432ee.

Change-Id: I2edb78440806754c42d48c5da2ff74b4cb40fa2d
2013-10-16 23:49:24 +00:00
Jakub Vrana
b2d64432ee Add support for mysqli extension
DatabaseBase::factory()'s parameter array now takes an optional
'driver' variable to allow specifying a specific driver for the
database class if we support more than one.

This is so we can gracefully support mysql/mysqli as the former is
deprecated, but the concept could be extended to other databases
as well.

Bug: 45288
Co-Author: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I6733fe21c4aa7443e409c5dfa7c789552b2b62b7
2013-10-16 23:17:57 +00:00
jeroendedauw
c3c023bc28 Remove comment which is plainly wrong
Change-Id: I89bb9243a19e0355260e4e1c217e3868014c4886
2013-10-15 20:31:34 +02:00
Aaron Schulz
cef0b81cdc Added comment about not using ignoreErrors()
* Using this makes it easy to forget to restore the old value, which then
  complicates anything that inserts to the DB.
* Also removed mention of the flag from some places.

Change-Id: I838183222518e0d008dee47ec8df6b3f3dc578e9
2013-10-01 13:08:43 -07:00
jenkins-bot
f4fc43d42c Merge "Avoid profiler spam for numeric IN() clauses for each possible number of items" 2013-08-23 23:09:47 +00:00
Aaron Schulz
8b47c6b901 Further fix to profiling order for DBPerformance log
* Make sure transactionWritingIn() gets called before the profileIn()
  so the first write query shows up

Change-Id: Ife504651f6fe33f1360e817bcb05afc02f4075a5
2013-08-22 14:45:11 -07:00
Aaron Schulz
9d5fe1eb2d Avoid profiler spam for numeric IN() clauses for each possible number of items
* This currently can be seen in several category queries with IN() clauses on graphite

Change-Id: I04e7745c7d4f11f5f2905c7f86f1558a9fdb0b5c
2013-08-22 11:44:24 -07:00
Aaron Schulz
b70967e3e6 Tweaked location of profiling in query() to split out the implicit BEGIN
* This also should make the DBPerformance log look clearer.

Change-Id: I98764647bbb19a5f130bd3d87488f32cb2825ea8
2013-08-20 09:49:47 -07:00
jenkins-bot
d871b25e1a Merge "Avoid "Transaction already in progress" errors in SiteStatsUpdate::doUpdate" 2013-08-15 17:56:35 +00:00
jenkins-bot
ebbea3c974 Merge "Never prefix table names with $wgSharedDB when used in foreign DB" 2013-08-09 00:19:48 +00:00
Aaron Schulz
45daade27c Avoid "Transaction already in progress" errors in SiteStatsUpdate::doUpdate
* Also fixed TRX callback code to match documentation (wrong since 3b7c4f6)

Change-Id: I8c4ea7412e9f96912939c441c68090eacc42b3d4
2013-07-20 12:09:12 -07:00
Aaron Schulz
797d5f19c4 profiler: log slow methods that worsen DB locks in transactions
Change-Id: I1aa13c29837fa655c13ef324d02cd1be1739edea
2013-07-19 03:46:55 +00:00
Aaron Schulz
1fbb0404f5 Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef
* Use this in LogEntry to avoid needless type errors

Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7
2013-07-18 03:43:20 +00:00
jenkins-bot
0898fa993c Merge "database: Simplify selectSQLText() and fix USE INDEX bug" 2013-06-26 04:27:35 +00:00
Alexandre Emsenhuber
b18770232c (bug 50078) Allow a string other than '*' as condition for DatabaseBase::delete()
Currently, either '*' is given as condition meaning "everything" or an array must
be passed since DatabaseBase::makeList() requires an array. Now the parameter is
consistent with one of other similar methods, since a string will be handled
correctly.

Bug: 50078
Change-Id: Id5a8220d21245669f1091a3b5ed1def65b22d375
2013-06-25 16:15:45 +02:00
Aaron Schulz
0b3daef807 database: Simplify selectSQLText() and fix USE INDEX bug
* Previously, using a USE INDEX array with one table string resulted
  in the FORCE INDEX statement not appearing in the SQL.
* Renamed two variables in tableNamesWithUseIndexOrJOIN().

Change-Id: Id084db7df3b07d125ea73faca7e4506a58be5f35
2013-06-21 05:31:50 +00:00