Commit graph

178 commits

Author SHA1 Message Date
Aaron Schulz
a129edcc5e Made DatabaseSqlite::__construct always caller super
* Also fixed misuse of private mTrxAtomicLevels var

Change-Id: I711508cb3906a5192be1a244a7e511b1720141ca
2015-04-28 08:37:21 -07:00
Aaron Schulz
46cf4f1e30 Clean up $wgSQLiteDataDir handling and removed standalone sqlite class
* The data directory can now be set via the construction params
* A standalone factory method now replaces the subclass
* Also made mDatabaseFile protected

Change-Id: I1791fd4f630e5c121fa7f68f473411a7c12d0c97
2015-03-09 18:35:24 +00:00
Aaron Schulz
22508bec75 Allow configuring the transaction locking mode for SQLite
Bug: T89180
Change-Id: Ib18347299ea78f9b31e56313b2acf749f693cddb
2015-02-26 01:21:20 +00:00
Aaron Schulz
2cfcb390c6 DatabaseBase constructor cleanups
* The array based format is now required
* Pass any additional parameters through factory() to __construct() even
  if the base clase does not recognize them. This makes DB specific
  options simpler.
* Also added missing bits to Sqlite constructors

Bug: T90288
Change-Id: I29b79a3c1bb2b5e51c1c8f5e04cd08c71e0662a3
2015-02-23 13:02:28 -08:00
Timo Tijhof
b5efd9f1fc database: Avoid use of PDO transaction system for SQLite
This is in preparation for changing doBegin() to use BEGIN IMMEDIATE.

PDO::beginTransaction() doesn't support any parameters for mode.
Use direct queries instead so that modes (such as IMMEDIATE) can
be used.

Since PDO's transaction system maintains state internally (similarly
to what MediaWiki Database classes do) we have to abandon use of
PDO commit() and rollback() as well (in favour of direct queries
already provided by DatabaseBase).

Bug: T89180
Change-Id: I2ad2a3c2a6d4737f5ef8822fba7cbcf5e36021f4
2015-02-19 20:03:54 +00:00
Erik Bernhardson
fa286d4eb5 Doc: Document problem sorting inserted data
Adds documentation referencing the root cause of the linked intermittent
failures caused by some versions of sqlite mis-handling this data. Logs
an error indicating that this is a known buggy workaroung along with
the solution.

Bug: 72367
Change-Id: If26346e4d71560d6a8a3f79a52e52ee6e90e0304
2014-11-13 19:28:17 -05:00
Max Semenik
d315c3bdb3 Ignore duplicate key errors in update-keys.sql
Otherwise, reinstalls can fail.

Change-Id: Ie4f7f73152a055f9a8d69970c22795433f564b26
2014-09-08 13:29:31 -07: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
physikerwelt
5048f30f69 Fix: numFields wrong for sqlite
Currently the first row of the result
is used to return the number of fields.
This fix corrects that calculation, which has returned
twice the number of fields before. The reason for that
was that the resulting data array has the following form:
array() {
 [0] => value_0
 ["field_name0"] =>value_0
 [1] => value_1
 ["field_name1"] =>value_1
...
Furthermore the constant 0 (int) is returned if the result
set is empty. This issue should be corrected in the future,
since the number or fields should be answered in a metadata context
independent of the data stored in the relation.

Bug: 65578
Change-Id: I399c7c857dcbd774cc4eb6102bbfe8a8764b07c9
2014-05-21 13:09:13 +00: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
aude
e611604d10 Fix IGNORE option for sqlite update
this fixes the issue of the normalized sqlite
IGNORE option being discarded and ignored in
DatabaseBase::makeUpdateOptions.

Change-Id: I01579dee0f939a56c086d13683a60f4400014f62
2014-03-12 17:37:17 +01:00
Skizzerz
f7174057a4 Add preliminary MS SQL support
This likely has outstanding bugs but basic wiki operations work just fine in it.

Change-Id: I25df82065a307b9abc30c694f8c8afff0996d7c1
2014-02-15 10:40:19 -08:00
Aaron Schulz
786db87907 Added some lock()/unlock() support for SQLite using lock file emulation
Change-Id: Ifd70d06055c74715c52758615c3081dde409c9a6
2014-01-31 15:32:52 -08:00
Aaron Schulz
caab04363f Fixed getDBname() for DatabaseSQLite
Change-Id: Ie1a575bb96141b59880358d066e710b2f868f880
2014-01-31 15:03:34 -08: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
1b0a0021ca Make tableNamesWithUseIndexOrJOIN() and makeUpdateOptions() protected
Per parents.

Change-Id: I4419e19abac84f8f4e397c4ebc9d1cf2e1f6a945
2014-01-06 18:47:42 +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
Siebrand Mazeland
3c736f711a Declare visibility for class properties in DatabaseSqlite
$mName appears to be unused.

Change-Id: Id9ef59cf070e379413d16a8d4456fd93df296442
2013-12-27 09:23:29 +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
Aaron Schulz
58a0e0c06d Cleaned up DatabaseBase constructor to use an array
Change-Id: I094185585dc844ca4d2d8b629107b2ab8f9bef39
2013-11-06 12:17:15 -08:00
jenkins-bot
a443be2747 Merge "Add DROP INDEX support to DatabaseSqlite::replaceVars method" 2013-11-05 14:18:01 +00: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
Dereckson
60596ab27e Add DROP INDEX support to DatabaseSqlite::replaceVars method
DROP INDEX is database-wide (and not table-specific) in SQLite,
so we need to add a rule in our MySQL to SQLite schema convert.

"DROP INDEX foo ON bar" becomes "DROP INDEX foo".

Change-Id: Ie10784d166ed5a7f6ea52cf4f3a812fb7878a744
2013-10-15 22:32:28 +02:00
Jackmcbarn
1eca78131b Store boolean values as integers with SQLite
Since SQLite doesn't have a boolean type, and doesn't enforce types, make
sure booleans get stored as integers, to prevent undesirable behavior,
such as false values being stored as empty strings.

Change-Id: I2a96065826412fa25f98ec298d806e73ebe155ba
2013-09-17 20:03:22 -04:00
jenkins-bot
ca15b909fb Merge "Made DatabaseBase::getSoftwareLink() dynamic." 2013-05-15 14:37:58 +00:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Aaron Schulz
be7b10166a Made DatabaseBase::getSoftwareLink() dynamic.
* All callers are calling it this way and it breaks
  hhvm when declared statically and called dynamically.

Change-Id: I894e615fd828615384aa8457a16a759c8aa416ef
2013-05-14 21:18:57 -07:00
Chad Horohoe
b27cfbd9e8 Use __METHOD__ for default $fname params to database functions
Change-Id: I86cbdeabee9709cde15a6b7bd47a53229c2e3f92
2013-05-07 06:18:57 +00:00
umherirrender
dbd0b590e9 else if -> elseif
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20
2013-04-17 16:52:47 +02:00
Liam Edwards-Playne
2750f8382f Filtered "LOCK IN SHARE MODE" from SQLite
"LOCK IN SHARE MODE" is a MySQL extension not supported
by SQLite.

Bug: 45650
Change-Id: I74af28e3f7bb0c37ea1cc9cd087a688ba7621e57
2013-03-13 20:25:59 +10:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Alexandre Emsenhuber
4746329a73 Fix documentation of DatabaseBase::fetchObject() and DatabaseBase::fetchRow()
- DatabaseBase::fetchRows() returns the row as an array, not an object
- Both methods return false if there are no more rows in the result

Change-Id: I328d61b237bb82479d3fcb4c54ee9fd96dc4598f
2013-02-18 15:39:29 +01:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
btongminh
3300e5870c Force case-sensitivity on the LIKE operator, to ensure similar behaviour
between MySQL and SQLite

Change-Id: Idf2d90fe3df07364657abb6070f6eac59add1306
2012-12-24 21:10:22 +01:00
daniel
9205808960 Fix handling of strings containing \0 in SQLite.
This change provides a workaround and test case for a problem
in the sqlite library:

SQLite truncates strings at ASCII value 00 aka \0. Strings
containing \0 need to be represented in hexadecimal form.

Reported to PHP as bug 63419
 https://bugs.php.net/bug.php?id=63419

Change-Id: I2bbc445ffebd41e181edfc3201e6e5514de06142
2012-11-02 14:23:55 +01:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00: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
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
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
Alexandre Emsenhuber
78a56a67ba Added missing GPLv2 headers in includes/db.
Change-Id: Ib8fe301c6db77603e411113cea5a39c25c664961
2012-04-26 10:47:10 +02:00
Christian Aistleitner
02c05b9d0e Correcting type of DatabaseSqlite::insertId()
Change-Id: I37ebe291cf8c4fd66a1ee236fcfa063016efbc8d
2012-04-06 21:02:27 +02:00
Max Semenik
a8f718267e Follow-up r112565: fix code duplication 2012-02-28 14:42:08 +00:00
Alexandre Emsenhuber
d97561461c Pass __METHOD__ to DatabaseBase::begin(), DatabaseBase::commit() and DatabaseBase::rollback() 2012-02-25 13:23:43 +00:00