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
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
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
- 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
* 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
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>
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
* 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
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
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
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
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
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
* 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
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
* 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
No RELEASE-NOTES entry since this is going to be backported and RELEASE-NOTES-1.19 is out of sync.
Change-Id: I1ec6c824677606ac6f93cc43345942e4de8bd3f4