Relied on presence of whitespace. From git-blame looks like $commentedSql has been this way for a long time. Which is odd
since I've seen many commits since then specifically improving
callers of commit() and begin() to pass the __METHOD__, which
doesn't appear to have been logged anywhere up until now.
Change-Id: I48dc8b3f68a6764327b4b1a8f7c06c59a25a31bb
Allows update.php to be run when $wgAllowSchemaUpdates = false.
This is useful for non-WMF environments where strict DB permissions
allow database updates (which update.php performs), but no schema
changes (such as adding or dropping tables or indices which update.php
also performs).
It does this by adding the --schema and --noschema flags. Without
either of these flags, update.php will perform exactly as before.
With --noschema, all changes to the table structure or table additions
are skipped. Only data changes are made.
With --schema is used, no schema changes are made to the database, but
the schema changes are saved to a separate SQL file that can be run.
Change-Id: I96b4cfd4c02e9cbf46cc6a0499b87fb3b89020a0
* (bug 41656) LoadBalancer always commits if there are callbacks pending.
This works by checking a new DatabaseBase::writesOrCallbacksPending() function.
* Made transaction idle callbacks run in autocommit mode. Generally callers already
want autocommit mode or do quick begin()/commit() calls anyway. The docs already
make stat that callbacks should close any connections they start, but this makes
it harder for people to forget about implicit transactions. Since the callbacks
often may happen in commitMasterChanges(), if transactions are left open, they
might not get committed by anything afterwards.
* Added sanity exceptions and warnings if callbacks get lost for some reason.
* Renamed trxIdleCallbacks -> mTrxIdleCallbacks for consistency.
Change-Id: I00e1e0fcdd7deeee1fbac6d0f295160479cb8962
The command delimiter is a protected propery which prevents us form
getting it outside of Database scope. This patch add a public accessor
getDelimiter() so we can access it.
Change-Id: I676d7ed9765444366fdf3dddb07c535807dabf52
Until now, commit() with the "flush" flag would just commit the
transaction, no questions ask. Flushing however should only apply
to automatic transactions.
Change-Id: I621f145902cfdf201206b42c49c160aeeaf0e4ba
In the presence of DBO_TRX, commit() may be used like a "flush".
Added a flag to trigger this mode to commit() and changed DeferredUpdates
to used the flush mode.
Change-Id: I529117618194a2669535f3c5c0fed07588597299
This is a follow-up to Idbe4a903.
LoadBalancer::commitMasterChanges used to cause a warning if an implicite
transaction was in progress. This is now supressed.
Note that warnign when an automatic transaction is committed explicitely,
it does make sense to issue a warning. But that should not be done for summary
commits when closing a connection, etc.
Change-Id: Id68c3607f6b9d930c00422baa6658b0651f2e42e
This tracks which transaction was opened automatically because of the
DBO_TRX flag, and then supresses any warnings about committing these
transactions implicitely, even if write operations were performed by
that transaction. To get warnings about implicitely committed writes
from automatic transactions, enable $wgDebugDBTransactions.
This change is a follow-up to I1e746322 and the older I3f1dd5fd, and
should be considered an alternative to I3eacc5a9. The new warning
behavior is:
* when beginning a transaction, warn if there is a transaction pending
that has also been started explicitely by calling begin().
* when beginning a transaction and $wgDebugDBTransactions is on, log
any implicit commit of an automatic transaction if write operations
where performed within that transaction.
The idea is to provide warnings about nested explicite transactions
while staying quiet about implicite commits to automatic transactions.
Change-Id: Idbe4a9034b13413e351f432408d358a704f6b77d
It's been two weeks and there hasn't been enough
effort in fixing the reported issues to justify
the flooding of logs in twn.
Change-Id: I3eacc5a9220b451bb94c4aa5ae35de4095528542
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
* 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
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
* 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
* 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
$canonicalDBTypes is probably superfluous information, but doesn't harm as a shortcut
Ping r108051
(imported from SVN)
Change-Id: I09ecf56d984405506f654919a822a939e5a9b1ee
* Introduce $wgDebugDBTransactions facility to help
figure out what's going on with transactions.
Currently PostgreSQL only.
PostgresTransactionState can be easily be made more general
to trace all sorts of state machinery.
* Improve r113408: we don't need to full reconnect on error,
rollback is enough.
Rolling back breaks search_path, as PostgreSQL
can manage sessions settings under transaction therefore
we need to improve schema sniffing introduced in r82674
* Introduce few schema handling functions. This could
probably be generalized for other databases like DB2 and Oracle.
* Fix bug 15816 - Add a switch for SETting the search_path
We try to avoid touching search_path at all unless
really necessary. Even in this case we append MediaWiki
core schema to the front of the list.
* No longer add $wgDBmwschema to PostgreSQL role search_path
in the installer. This is no longer necessary as
setting schema on connect should ReallyWorkNow(tm).
* Get rid as much as possible of $wgDBmwschema and
bring us one step closer to fix bug 16794 (wgSharedDB
support).
All references to core MediaWiki schema in PostgreSQL
specific code should now use Database::getCoreSchema()
unless we know what we are doing.
Followup-To: r113408 r82674