Commit graph

233 commits

Author SHA1 Message Date
jenkins-bot
8eac2feedb Merge "Use pg_result_error, not pg_last_error, as the latter gives false negatives." 2016-04-08 23:56:05 +00:00
Max Semenik
943563062f Kill mbstring fallbacks
In the age when we require PHP 5.5, pretending that mbstring emulation
is not slow and silly is silly.

Bug: T129435
Change-Id: Ic8235c9da9a926df63ec7388900c44eab454eebe
2016-04-06 22:14:48 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Greg Sabino Mullane
290829ae0d Use pg_result_error, not pg_last_error, as the latter gives false negatives.
Specifically in the savepoint part of the code, where a failed query inside the
savepoint gives a non-false reply to pg_last_error by the time we call it,
which then leads to us doing 'RELEASE' instead of 'ROLLBACK TO', and causes
all sorts of mayhem.

The whole system needs a little cleanup, but this is an important bandaid.

Change-Id: I0223a3599816db5650f45863400e6194468d4361
2016-02-10 23:10:19 -05:00
Aaron Schulz
79d12a284b Do not auto-reconnect to DBs if named locks where lost
Otherwise, transactions might be committed without cooperative
locks that were supposed to be present. This is similar to the
logic of not auto-reconnecting if a transaction was started to
avoid committing incomplete changes.

Change-Id: Ia7bc6b188bb5ee53a5bf7c5a30718bc7c4dd0ba9
2016-01-30 09:17:17 -08:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
umherirrender
6ff5461ce9 Add curly braces to while
Follows Iaa1a479b5eefcae0fc8f82b1d20e9575d609c0e9

Change-Id: I7f2b9b12e3282f5b8ba54a315fa12f1a97985572
2015-10-14 11:42:00 +02:00
yoonghm
a6ed742237 Clear previously left-over PQresult before calling pg_get_result()
Bug: T52091
Change-Id: Iaa1a479b5eefcae0fc8f82b1d20e9575d609c0e9
2015-10-10 12:03:59 -04:00
jenkins-bot
c5ac11e2eb Merge "Start rename of DatabaseBase => Database" 2015-10-05 23:45:36 +00:00
Aaron Schulz
a88df43d3f Database debug log cleanup (remove wgDebugDumpSqlLength/wgDebugDBTransactions)
* Simplify the debug log call and use queries group
* Remove $wgDebugDumpSqlLength, as profiler output
  already has shortened query strings (one can use
  profiling without DBO_DEBUG)
* Removed $wgDebugDBTransactions as BEGIN/COMMIT already show
* Removed PostgresTransactionState as it was only used for
  $wgDebugDBTransactions handling
* This cuts down on lots of global variable usage

Change-Id: I185adb1694441d074dea965960429b4910727620
2015-10-05 12:47:09 -07:00
Aaron Schulz
1b67a929ab Start rename of DatabaseBase => Database
This gives static method callers the option
to use methods like Database::factory() instead
of having to use the uglier DatabaseBase::factory().

Change-Id: I61800626b71ad2803a897df060059dbaf8778679
2015-10-04 12:36:56 -07:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Aaron Schulz
fe11696aa4 Avoid postgres IDE error with doQuery() visibility
Change-Id: I25061a5d72eaa5a455c65baf3023431b2d1628d6
2015-07-02 19:29:56 +00:00
Vivek Ghaisas
fd9178e4c3 Fix braces code style
Bug: T102805
Change-Id: I7ce4c71dd605f9be79a630602391271bb269b962
2015-06-17 16:28:51 +03:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Aaron Schulz
419221e4a7 Fixed bug where catching DB errors left ignoreErrors() on
* Also fixed an actual rollback loop possible in postgres

Change-Id: I41508127f74e1bbee4c020546fed85ab53318ab7
2015-04-07 18:12:06 +00:00
jenkins-bot
bd5fd843d6 Merge "Always decode Blob objects from Database::addQuotes" 2015-02-25 21:17:06 +00:00
Kevin Israel
5f3957498b Database: Cast to int in estimateRowCount(), selectRowCount()
Doc comments state that these methods return ints. In order to ensure
that, values must be cast to int before they are returned.

With respect to selectRowCount(), follows-up 65f81d2843.

Change-Id: I108221ce4ad1b5b103b015fe875de54e04781741
2015-02-06 05:03:45 -05:00
Erik Bernhardson
7fd481c770 Always decode Blob objects from Database::addQuotes
The current API for Database::encodeBlob/Database::addQuotes requires
the code that is outputting binary data to have a database handle, so
that it may call Database::encodeBlob to get either a plain string or
a Blob object back. All database implementations other than MySQL
return a Blob object from Database::encodeBlob.

This is a rather inconvenient API, it tightly couples the creation of
binary data with the Database object unnecessarily.  If all database
objects accept a Blob via Database::addQuotes then code can simply
wrap its arguments in Blob and know that any database it ends up at
will be properly handled.

This patch changes the default implementation of Database::addQuotes
to recognize a Blob object was passed in, and use Blob::fetch to turn
it back into a string.  Database implementations other than MySQL all
handle this Blob object already.  The postgresql implementation had
to be adjusted slightly. Now when it sees a Blob object that it did
not create it will encode that appropriately.

Bug: 72367
Change-Id: I12fb4bd339be19137fffba2e47a70741382f6a8c
2015-02-02 17:43:12 +00:00
jenkins-bot
9386540362 Merge "Add some @see to doc blocks" 2014-08-25 09:51:15 +00:00
umherirrender
51adb81e6e Add some @see to doc blocks
This avoids repeating the @params for the functions

Change-Id: Ie1f4488a0a7aa30ab128b9ea7ff6f3af12a88884
2014-08-24 11:19:32 +02:00
umherirrender
7c6a25856c Add missing @return to function docs
Change-Id: I45b9d02f94ecc58372268ec5e6a0b572a0b7e2a9
2014-08-23 23:14:57 +02:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
umherirrender
079d9ae83c Use /** for doc comments
/* is only a comment, which is not used when build the documentation

Change-Id: Id5f917928e3a253a90fd17b0d7aad7340f9393f5
2014-08-13 19:31:13 +00:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
umherirrender
2b021dc48a Fixed spacing
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif

Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
2014-07-19 23:12:10 +02:00
Jeff Janes
ae811ddb6c PostgreSQL: Fix ORDER BY NULL
MySQL automatically orders by the GROUP BY columns if no ORDER BY
is specified.  You can countermand this by specifying
ORDER BY NULL, which can give speed improvements in some cases,
for example if the GROUP BY was implemented by hashing then a
sort is unneeded and wastes time.

PostgreSQL does not tolerate the ORDER BY NULL syntax,
and does not need an analgous hint because it never does
gratuitious sorting of the nature just discussed.

This patch makes PostgreSQL ignore the ORDER BY NULL clause.

It might be a better approach to find a way to add this clause
specifically to MySQL, rather than to drop it specifically from
other database engines.

SQLite seems to tolerate the MySQL syntax.  Oracle and MSSQL
were not evaluated.

Bug: 65794
Change-Id: Ia9666136edd25e1e0d0728a8b28a92e44d00abc6
2014-07-08 13:09:25 -07:00
Jeff
72ecbfc127 PostgreSQL: Only rollback when in a transaction
SQL errors would issue a rollback, even when it was
not actually in a transactions.  Doing so would cause
another error to be reported.  This could obscure the
original error, particularly during unit tests.

Fix this by not rolling back when not in a transaction.

Bug: 58095
Change-Id: Ib5220e37dd6c364feee6b7f8e7ecbdae2a2e0ba1
2014-05-29 23:51:57 -07:00
Jeff
52fd3a0e83 PostgreSQL: Support table prefixes
PostgreSQL is usually not used with table name prefixes,
and some of the PostgreSQL-specific code took the
shortcut of not dealing with prefixes.  However, the PHPUnit
tests do force a prefix to be used, exposing this limitation.

Make PostgreSQL code add the prefix to table names being used
in FOR UPDATE OF clause.

This fixes 13 of the 17 PostgreSQL unit tests errors against
git HEAD:

EditPageTest::testAutoMerge with data set #1 ('Elmo', 'one
EditPageTest::testAutoMerge with data set #2 ('Elmo', 'Intro
EditPageTest::testAutoMerge with data set #3 ('Adam', 'one
EditPageTest::testAutoMerge with data set #4 ('Adam', 'one
EditPageTest::testAutoMerge with data set #5 ('Adam', 'Intro
EditPageTest::testAutoMerge with data set #6 ('Berta', 'one
EditPageTest::testAutoMerge with data set #7 ('Berta', 'one
EditPageTest::testAutoMerge with data set #8 ('Berta', 'Intro
WikiPageTest::testDoEdit
WikiPageTest::testDoEditContent
WikiPageTest::testDoRollback
WikiPageTest::testDoRollbackFailureSameContent
WikiPageTest::testExists

The change also applies to 1.22.6 and fixes several unit tests
errors there.

Change-Id: I054690f49e250cadd2dc2a6d9e20dea879d896b6
2014-05-29 15:11:33 -07:00
umherirrender
26f6c1797b Use strict array_search in DatabasePostgres.php
array_search( 'FOR UPDATE', array( 'OFFSET' => 0 ) ) gives 'OFFSET'
array_search( 'FOR UPDATE', array( 'OFFSET' => 0 ), true ) gives false

This avoids FOR UPDATE on QueryPage query like Special:BrokenRedirect.

Bug: 62104
Change-Id: Iaa6db6b3ce5eaf940e7a8afe459955f19ad0e01f
2014-04-27 09:24:25 +02:00
umherirrender
f5f1e38b9a Fixed some @params documentation (includes/[db|installer])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I3595e9aac69ac42fbb74b0783fae0ad9bcc831aa
2014-04-19 13:55:27 +02:00
umherirrender
7c314de876 Rename some local vars to start with a lowercase letter
Change-Id: I6e5975ed7351c1439eda19afaba5120c6afa50f1
2014-03-15 21:03:05 +00:00
Siebrand Mazeland
0cef781886 Fix CodeSniffer errors and warnings
Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28
2014-02-05 11:20:17 +01:00
umherirrender
8f8540a6d9 Avoid variable naming conflicts in DatabasePostgres::selectSQLText
Spotted by gebhkla on bug 60531

Bug: 60531
Change-Id: Iaf100ea0db05b142549bd98da108e48eae8b9101
2014-01-28 17:52:57 +01:00
lethosor
afb297d175 Fix rebuildall.php fatal error with PostgreSQL
The fix for 47055 introduced a fatal error when running rebuildall.php. This
is a workaround suggested by gebhkla on Bugzilla (idle for 10+ days). It just
checks to make sure $options is actually an array before calling array_search
on it.

Bug: 60094
Change-Id: Ib54420b5a749c60b82a4757a9f5fa511f48fdb72
2014-01-26 12:42:07 -05:00
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
jenkins-bot
da39646ddc Merge "Changed FOR UPDATE handling in Postgresql" 2014-01-13 03:15:46 +00:00
jenkins-bot
5330243416 Merge "WebInstaller: Don't call getSoftwareLink()" 2014-01-11 21:55:50 +00:00
Kevin Israel
0eab1ace67 WebInstaller: Don't call getSoftwareLink()
This gets the web installer working without the mysql or mysqli
PHP extension, which is not needed for other database systems.

* Avoid "lego" construction: put link text directly in the messages,
  which because the messages are parsed as wikitext, is easy to do.
* Put URLs in separate, ignored messages to avoid duplication in
  Database*::getSoftwareLink().
* Because I had to touch a MySQL-related i18n message, I figured
  this would be a good time to address bug 28281 (regarding MySQL
  forks and Special:Version).
* Other miscellaneous message changes, such as recommending the
  mysqli PHP extension over the old, deprecated mysql extension.

Bug: 28281
Bug: 58167
Change-Id: I6dbc9d32c8c2d8f233a67d574229b80444885aea
2014-01-10 03:38:44 -05:00
Siebrand Mazeland
687319540e Return correct values and types
Change-Id: Ia069856160aae1ab937daee2da0d6800fe89698f
2014-01-06 18:47:58 +00:00
Siebrand Mazeland
45e2a556da Rename $desired_schema to $desiredSchema
Change-Id: I0f421964e94c95ead931bf8c9faa1667dc2f7e06
2014-01-06 18:47:25 +00:00
Siebrand Mazeland
e22a70a103 Update documentation for database related classes
Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f
2014-01-06 19:45:40 +01:00
jenkins-bot
92a68b0b9d Merge "Declare visibility for class properties in DatabasePostgres.php" 2014-01-03 16:31:02 +00:00
Siebrand Mazeland
d47145d894 Remove unused local variables
Change-Id: I9e5667d3b27c7685004e2f3215ea51176988d3b2
2013-12-27 13:37:14 +01:00
Siebrand Mazeland
346bf949db Declare visibility for class properties in DatabasePostgres.php
* Add used by not declared class properties.
* Rename private $numeric_version to $numericVersion.
* Update some documentation.

Change-Id: I233001e732724146fcee04f0e358a9563c9e9fd4
2013-12-27 09:24:06 +00:00
Tyler Anthony Romeo
63d32eeb6f Changed FOR UPDATE handling in Postgresql
Postgresql cannot handle FOR UPDATE with outer joins, but it allows
specifying which tables can be locked. This changes DatabasePostgresql
to render proper FOR UPDATE statements that only include the main
table and any tables in inner joins.

Bug: 47055
Change-Id: I1ac587ac39f448b9e7f4befb44826b43044ad6f0
2013-12-01 01:10:44 +00: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
daniel
40f6d8546c Make sure we always restore the error handler.
Change-Id: I27f5d11ea27f783eda71c2bfdba7e70695f5d53c
2013-11-15 16:57:34 +00:00