Commit graph

767 commits

Author SHA1 Message Date
Aaron Schulz
de0e9f09c5 Fixed mismatched profile calls in LoadBalancer.
Change-Id: I1ac81347b8af9b30dc03df94a76483a4ae4a6503
2012-09-29 11:52:48 -07:00
daniel
5bfd85cf26 Warn about all nested transactions when testing.
This change causes implicit commits caused by consecutive calls to
Database::begin() without intermediate calls to Database::commit() to
be more easily tracable. The changes introduced are:

* $this->doCommit( $fname ) is now called unconcitionally if there is
  an open transaction. Previously, it was not called if there were no
  write operations performed in that transaction.

* A warning about implicite commits (nested transactions) is now issued
  if write operations were performed OR ther DBO_TRX flag is NOT set. This
  causes any unmatched calls to begin() to trigger an error in CLI mode,
  notably also within unit tests.

* Implicit commits of non-write transactions in DBO_TRX mode can now be
  logged by enabling $wgDebugDBTRansactions.

Besides this, this change improves the documentation of the transaction
control functions.

The rationale is that implicite commits should be more easily tracable
in production and development.

Change-Id: I1e746322c36a7c53b545bfe78e252a13cce44ea1
2012-09-26 12:38:44 +02:00
Aaron Schulz
597167dc48 Limit bad transactions warnings to those involving possible writes.
Change-Id: I3f1dd5fd34c5554619936471a2c9687a8f501006
2012-09-22 01:14:35 -07:00
Aaron
522820ccaa Don't send COMMIT if not in a transaction.
Change-Id: Ifffbf703b15cd875feda1514d3c0d488b8665b66
2012-09-21 15:27:10 -07:00
Aaron Schulz
e0b9180525 Merge "Trigger warning for bad use of transactions." 2012-09-20 04:06:20 +00:00
daniel
877c8afc3e Trigger warning for bad use of transactions.
Mediawiki currently does not support nested transactions, which means that
starting a transaction while another is in progress will silently commit
the previous transaction, causing lots of potential inconsistency.

This change introduces checks that will log a warning whenever begin() is
used while a transaction is already in progress, and whenever commit() or
rollback() are used without a transaction being in progress.

NOTE: this exposes several places in the code where transactions have inadvertedly
be nested, or unmatched calls to begin() resp commit() are used. With
$wgDevelopmentWarnings enabled or I36583fb0 merged, this may cause tests to fail.
The following changes fix the issues in question: I80faf2ed, Ia225251e, Iff394f97,
and I20d90fed.

Change-Id: I8c0426e12b78edbd758b1f087c35dabd64498624
2012-09-19 21:00:05 -07:00
Alexandre Emsenhuber
7525820cb7 Remove some debug output when opening a new database connection
Simplified the messages to avoid duplicates.

Change-Id: Ibcccc98bc18bdd0e0b876d9ad97f281c643eeabf
2012-09-18 14:01:02 +00:00
Tyler Anthony Romeo
b69cc58b7f (bug 39287) Fixed error checking in DatabaseMysql::fetchObject.
According to the libmysql API documentation, mysql_fetch_row,
upon which the PHP functions mysql_fetch_object, etc. are
based on, does not reset the error number or message upon
success. So calling mysql_errno() after a successful fetch
may return the error of the previous function call.

This commit changes DatabaseMysql::fetchObject and similar
functions to only check for specific error numbers that are
explicitly documented to be expected from mysql_fetch_*.

Change-Id: Iacb78828885a8a0d4e499a681d938a6adf651582
2012-09-04 11:41:58 -07:00
Alexandre Emsenhuber
72a72e26dc Fixes for DatabaseMysql::open()
- Group global declarations at the top
- Early abort on error, instead of going through
  the whole code
- Group double call to wfDebug()
- Whitespaces fixes

Change-Id: I9e28395a2698216e14458d1a74ef0a89e7ee48d6
2012-09-01 17:13:35 +02:00
umherirrender
59e0647457 Allow array condition for HAVING in database interface
Current no use in core.

Change-Id: I8ed86c8238146285dd1caed4d8586c877cbecf44
2012-08-31 20:12:19 +02:00
Aaron
3f277e8744 Added post-commit callback support to DB classes.
* This can allow for autocommit job queue insertion without
  breaking existing transactions (which currently happens since
  job queue insert does begin/commit).

Change-Id: I021d4a73635168c05bbc1068912c2c6dbdf9cdc4
2012-08-29 13:01:38 -07:00
Aaron Schulz
d1a806b91b Merge "Allow array condition for Database::conditional" 2012-08-28 00:01:05 +00:00
saper
5fe67c61a7 (bug 39635) PostgreSQL has no LOCK IN SHARE MODE
includes/Category.php tells us to use "SELECT ...
LOCK IN SHARE MODE" before "UPDATE".

This is MySQL-only construct:

http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html

Change-Id: I80709da9e15c891f1605900e7c527d5042a88f73
2012-08-27 18:58:54 +02:00
umherirrender
7a5f4b431d Allow array condition for Database::conditional
Change the one use of that method to use the new syntax.
Add some tests.

Change-Id: I9ad4e5b5e97d1d13cfd858105167ca5d20ffaf83
2012-08-25 20:24:59 +02:00
Aaron Schulz
74a782a082 Merge "(bug 32774) Added config options and flags for SSL and compression in DB." 2012-08-19 02:49:05 +00:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
Tyler Anthony Romeo
494b8b51b1 (bug 32774) Added config options and flags for SSL and compression in DB.
Added configuration options ($wgDBssl, $wgDBcompress) and related
connection flags (DBO_SSL, DBO_COMPRESS) to allow SSL/TLS and
compression on database connections. The flags are only observed if
the functionality is supported for that type of database (e.g.,
SQLite will ignore both flags as neither are supported).

Currently, only MySQL and PgSQL have support for at least one of
these flags in their PHP extensions. MySQL supports both flags and
PgSQL supports the SSL flag only.

Change-Id: I7b4d3ba82ccab0eed4a19e3b4e7bc0b4eb881262
Signed-off-by: Tyler Anthony Romeo <tylerromeo@gmail.com>
2012-08-16 10:48:07 -04:00
umherirrender
aff21af9ae Allow aliased field names with separated syntax
This introduce the syntax from aliased table names for aliased field
names into the abstract database layer:

array( 'alias' => 'field' ) gives 'field AS alias'

This patch also includes changes to query pages, api and some more
places to show, how the new syntax looks in "production".

This allow us to remove the "AS" for Non-PostgreSQL databases, if we
want that.

Change-Id: I5f0de1c2f29092c173aec3de93ffdef436799e8d
2012-08-15 15:16:09 +02:00
Demon
72e00dfb19 Merge "(bug 38406) Properly quote table names in DatabaseBase::tableName()" 2012-08-14 17:42:20 +00:00
Aaron Schulz
eb16f5898d [Database] Various DB cleanups.
* Removed unused and obsolete set() and safeQuery() functions.
* Removed unused deprecated constructor functions.
* Removed unused limitResultForUpdate() cruft function.
* Removed unused standardSelectDistinct(), it's better to just follow the standard for all queries.
* Removed other cruft functions unused by core/extensions.
* Made some internal functions protected.

Change-Id: I90be88ea740834a417a17d7751f1be7bac4eae4e
2012-08-08 11:00:48 -07:00
jeroendedauw
3ec9d41fb9 Support deleting all rows
Change-Id: I36ee33580261f39cb0ba69473f5afac9a5135853
2012-07-31 20:34:20 +02:00
jeroendedauw
4130c7814d some doc for the ORM system
Change-Id: Icdfe6c754fdeddb42f0df04efcb1e06df8b73173
2012-07-26 10:31:38 +02:00
jeroendedauw
9bd37bae4d Removed now obsolete compat-code
Change-Id: I64dc4beb4f8a084bfc5b7c60cbdaa6b65838b79b
2012-07-22 13:34:50 +02:00
Alexandre Emsenhuber
a6c47b6098 (bug 38406) Properly quote table names in DatabaseBase::tableName()
Currently the logic is the following:
$database = ( $format == 'quoted' || $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
This means that $database will *not* be quoted if $format is set to 'quoted',
which is the opposite of what we want here. Instead I just copied the code
used to quote $table just below and replace the variable.

This causes SQL syntax errors when the shared table name contain hyphens
since it is not quoted.

No RELEASE-NOTES entry since this should be backported to 1.19 once merged.

Patchset #2: added some tests
Patchset #3: fix tests for SQLite

Change-Id: Idda844cb470454a9a22001a31b6692de49892ca2
2012-07-18 14:54:47 +02:00
Aaron Schulz
a021ffc9ce [Database] mark some methods as explicitly public
Change-Id: I95fca6d346ae812c22b88b577477be02b5a0676b
2012-07-17 10:59:19 +02:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
jeroendedauw
0a57c014ba Fixed cp error in method name
Change-Id: Idf5a397773418ee85ea17bcd3e3cbbf16d1a57b5
2012-07-06 13:10:47 +02:00
mlitn
f4b9c8734e Fix FakeResultWrapper::fetchRow, which (contrary to ResultWrapper::fetchRow) didn't always return an array
This was originally part of https://gerrit.wikimedia.org/r/13880

Change-Id: I0b737bafa59c97ff0b658189c53022388bb7a56d
2012-07-03 10:35:19 -07:00
jeroendedauw
5dafc5f14f Improve names of factory methods in ORMTable. Now its clear that they create rows and not tables
Change-Id: Ia83c7c81f4ddd6d3304273094553c31c67fe85c8
2012-06-29 21:05:09 +02:00
Aaron Schulz
604148f1be Revert "Introduce a new hook that allows extensions to add to My Contributions".
In formatRow(): the hook change breaks FlaggedRevs, and also $ret may not
always be defined. The patch could use some extra work.

This reverts commit 0944502d4c

This reverts commit d0131e8a19.

Change-Id: I05d980e19d99e1c461199705b04de9e307daa907
2012-06-27 21:27:32 -07:00
Catrope
a61099ba62 Merge "Introduce a new hook that allows extensions to add to My Contributions" 2012-06-25 18:04:25 +00:00
Aaron Schulz
e7d14c46f1 Merge "Remove adittional type hinting stuff because PHP will die if its there >_>" 2012-06-23 19:39:23 +00:00
mlitn
0944502d4c Introduce a new hook that allows extensions to add to My Contributions
Meanwhile also:
- refactored reallyDoQuery in Pager.php, to make outside intervention possible
- extend reallyDoQuery in SpecialContributions.php, adding in the hook and composing the final results array based on the combined results of all queries added through the hook
- remain backwards compatible on method-level
- fix FakeResultWrapper::fetchRow, which (contrary to ResultWrapper::fetchRow) didn't always return an array

Change-Id: I74c3784d6d93b992d72f2db24cc29f30e458c1e3
2012-06-23 01:37:18 +02:00
Hashar
4a6ce315b8 Merge "Fix INSERT options for PostgreSQL for INSERT+SELECT" 2012-06-22 12:00:34 +00:00
jeroendedauw
071b7d9adf Remove adittional type hinting stuff because PHP will die if its there >_>
I CAN HAZ GENERICS PLZ!

Change-Id: I28e8f024feb346cce1107af3035fc97b870ef6af
2012-06-20 18:13:14 +02:00
saper
c3fe42d1c3 Fix INSERT options for PostgreSQL for INSERT+SELECT
Fix handling of $insertOptions in
DatabasePostgres::insertSelect

Looks like this change:

https://gerrit.wikimedia.org/r/#/c/3962/
(or 646a9490f7)

mishandled badly INSERT IGNORE (instead of
silently broken support for it it introduced
PHP error).

Looks like we have no unit test to cover
the use of Database::insertSelect in the code.

Change-Id: I4f7d8c9bd9e413d8ffa23c1d0c0628a25c28d45c
2012-06-18 20:39:08 +02:00
Reedy
d9f3e8df0f Can't use return value of void functions
Change-Id: Idce6e31f3f0eff0a0045c1cc62def3f5d79b9d48
2012-06-16 14:42:30 +01:00
Aaron Schulz
00ca49cda3 Merge "Added ORMIterator interface which can be used for type hinting (in particular when passing ORMResult objects)" 2012-06-15 19:09:51 +00:00
Siebrand
9e41908dc0 Merge "Added some extra tests for ORMRow class" 2012-06-15 12:59:34 +00:00
saper
646a9490f7 (bug 27283) SqlBagOStuff breaks PostgreSQL txns
* SqlBagOStuff should not turn off automatic transaction
    control just like that. Keep previous
    connection for PostgreSQL and SQLite

* 94633ff448 introduced
    rollback on error to restore sanity
    for the connection. Don't do this
    if you are in the middle of INSERT IGNORE
    and we have a savepoint open.

    Making sure query syntax errors don't
    get silenced by our "wonderful" implementation
    of INSERT IGNORE is bug 35572.

Change-Id: I841b03895e1189c47307fefb1516c4c7c4102e25
2012-06-14 23:33:11 +02:00
jeroendedauw
36a8c9b6ec Added ORMIterator interface which can be used for type hinting (in particular when passing ORMResult objects)
Change-Id: I0d14da35bf35be468a8e2c5530912992577e8dd8
2012-06-12 13:11:56 +02:00
jeroendedauw
7127713c78 Added some extra tests for ORMRow class
Change-Id: I672c88d42168a3daf405e6f0a4f204c15a4489ad
2012-06-07 13:18:49 +02:00
Aaron Schulz
0160b0fb0a Merge "Fix error message for MySQL connection failures" 2012-06-07 06:16:19 +00:00
Timo Tijhof
3b073fa356 (bug 37138) Fix broken Google sitesearch in DatabaseError
Change-Id: I31dc64f83ce8767dcdd84597844b0819840f60e1
2012-06-05 19:47:17 +02:00
Christian Aistleitner
af919fe3e0 Fix error message for MySQL connection failures
Change-Id: I23cbe6a58ab5aed88c656bfa9370568b39ca4e32
2012-05-28 22:06:43 +02:00
jeroendedauw
298c8b4786 Added base class for testing ORMRow deriving classes and added a mock implementation in order to test the abstract parent class itself
Patchset 2: attempt to fix sql error when using sqlite
Patchset 3: for great justice
Patchset 4: sqlite, not postgres... /facepalm
Patchset 5: joy, more sql divergence...
Patchset 7: handle inconsistencies in MWs database abstraction layer

Change-Id: I1948c4ad815008321801c93584eb249c1f597560
2012-05-28 17:35:05 +02:00
jeroendedauw
dc16ea18a7 Adding interfaces for ORM row and table classes so these can be used for type hinting in a way that does not prevent doing stuff such as the decorator pattern. Also made some minor fixes in the docs
Change-Id: I8ee1495a46d676062026d4d6b7acaae7bb227c42
2012-05-25 22:09:32 +02:00
Aaron
ff187ea7cc [SiteStatsUpdate] Reduced contention by using a new lockIsFree() DB function.
* Note: follows up a4b3979160
* Cleanup up transaction statements a bit; transactions don't effect the lock calls
* Also made DatabaseMysql::unlock() actually return a bool

Change-Id: Iade2efa94165b6918eae0863716cc163f36a07b8
2012-05-10 15:48:58 -07:00
Alexandre Emsenhuber
1d3934e1ad (bug 36568) Fixed "Illegal string offset 'LIMIT'" warnings in updater
No RELEASE-NOTES entry since this is going to be backported and RELEASE-NOTES-1.19 is out of sync.

Change-Id: I1ec6c824677606ac6f93cc43345942e4de8bd3f4
2012-05-07 15:52:55 +02:00
umherirrender
f8101287bd Do not treat EXPLAIN as write query
Change-Id: Idb15955b94ee6977f3a4692df44d445d3450b1a5
2012-05-05 11:24:07 +02:00