Commit graph

132 commits

Author SHA1 Message Date
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
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
76246b9bf5 More return documentation 2012-02-09 21:33:27 +00:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Sam Reed
e1d83d5721 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:54 +00:00
Sam Reed
138ddc452f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 17:42:35 +00:00
Chad Horohoe
70430650e9 Followup r96369: update child classes and a few callers 2011-09-06 20:51:10 +00:00
Max Semenik
5e5b01dc07 rv r89483 per CR 2011-09-03 20:14:17 +00:00
Chad Horohoe
f54857941f Sqlite fails to open a connection when $user is given.
Reported by lokkju in #wikimedia-tech
2011-08-01 22:57:34 +00:00
Tim Starling
0e73205470 General database-related code cleanup:
* Merged the 4 simulated implementations of Database*::replace(). I took diffs, they were nearly identical. I made one based on the IBM DB2 version, since it used insert() which looked like a nice touch.
* Provided the non-simulated implementation of Database*::replace() via a protected member function, and made DatabaseMysql::replace() and DatabaseSqlite::replace() into a wrapper for it. 
* Moved the MySQL-specific functionality from masterPosWait(), getSlavePos() and getMasterPos() from DatabaseBase to DatabaseMysql. 
* Renamed getStatus() to getMysqlStatus() and moved it to DatabaseMysql. Removed "unimplemented" errors from two other subclasses. Really there's no way another DBMS could or should implement this function. 
* Split the LoadMonitor class into a no-op class and a MySQL-specific class, to avoid fatal errors due to the getMysqlStatus() call if other DBMSs tried to use LoadBalancer with multiple servers. Of course there are lots of other reasons it won't work, I'm just fixing the architecture issue here.

And while I have a replicated test setup handy:
* On MySQL 4.1.9 and later, use SHOW SLAVE STATUS to get the lag instead of SHOW PROCESSLIST. This has the advantage of reading zero when there are no events for a while.
2011-06-23 03:14:11 +00:00
Tim Starling
5fcd668a02 Followup r90429:
* Reverted the public -> protected changes from r90429, except for doQuery() after a review of usage:
** resultObject() is used by lots of things in core and extensions. 
** makeSelectOptions() is used by SMW, and if that's going to be public, the other two probably should be too, for consistency. 
** doQuery() was used by several things, but mostly by mistake. It's been marked private since r21359 which is before almost all of them. I updated the callers to use query().

* Added "protected" to doQuery() declarations in other database classes.
2011-06-20 12:09:22 +00:00
Platonides
8093e9733c All the databases but MySQL were overriding DatabaseBase::deleteJoin() with the same code.
Move DatabaseBase::deleteJoin() to DatabaseMysql::deleteJoin() and the common code to DatabaseBase::deleteJoin()
Follow up r90356
2011-06-18 20:26:31 +00:00
Matěj Grabovský
07d40e6863 (bug 29476) DatabaseBase::deleteJoin fails for Sqlite
Added deleteJoin() to DatabaseSqlite, C&P from DatabasePostgres
2011-06-18 18:58:26 +00:00
Max Semenik
77f2ca715c SQLite-specific dropTable(): works a bit faster because it doesn't need a separate table existence check and does not rely on subtly broken tableExists() which I will fix a bit later 2011-06-04 22:07:57 +00:00
Sam Reed
2b676156ba And even more documentation 2011-05-28 18:58:51 +00:00
Sam Reed
93b8ff3a10 Some for MaxSem too 2011-05-28 17:52:12 +00:00
Sam Reed
e514478ba5 Fix function level comments that start with /* not /** 2011-05-21 19:35:16 +00:00
Sam Reed
a5db15505b Return comment stuffs 2011-05-11 23:11:41 +00:00
Sam Reed
a194b078ea Kill & from r87290 2011-05-02 21:38:48 +00:00
Sam Reed
a39e48078c Add makeInsertOptions
Allow Sqlite to OR IGNORE on UPDATE or INSERT
2011-05-02 20:14:17 +00:00
Platonides
f524482f2d Change the duplicateTableStructure() to use the original names.
It is now duplicateTableStructure() duty to addIdentifierQuotes() them.
Fixed bug for mysql < 4.1 where the new name would be quoted twice.

Always quote identifier in Oracle, doing otherwise seems a bug (can someone confirm?)
2011-04-12 18:54:51 +00:00
Platonides
a91d6f4cac Abstract tableName() by adding new function isQuotedIdentifier() to databases.
This fixes bug in DatabaseOracle.php tableName() on line 671 and allows it to call 
the parent implementation instead of copying it with different quotes.
Adapt Mssql addIdentifierQuotes(). Replace its addIdentifierQuotes calls with addQuotes
as it's what it really is. The serialize() is probably unneeded, since I don't think it will
ever be called with objects but I kept it anyway.
2011-04-12 16:34:12 +00:00
Max Semenik
c2f49a75f2 Bug 28478: database error in DatabaseSqlite::getFulltextSearchModule().
It was caused by a weird bug in SQLite: virtual table using a non-existent module still gets created somehow, and it is completely undeletable.
2011-04-11 17:16:41 +00:00
Max Semenik
1275cc6df6 SQLite is picky about the position of AUTOINCREMENT in field definition, handle it when converting from MySQL syntax 2011-04-10 08:44:06 +00:00
Chad Horohoe
c3aeca8380 Cleanup r80892, r84485: Check user also in sqlite for consistency. 2011-03-22 15:59:50 +00:00
Max Semenik
10a739f9da Case insensitivity for r82860 2011-02-26 17:04:26 +00:00
Max Semenik
798dafa4dd Follow-up r82856: instead of remembering magic table names, just analyse its structure, added tests. 2011-02-26 16:45:35 +00:00
Bryan Tong Minh
5d2794d89d Add TEMPORARY TABLE support to Sqlite 2011-02-26 14:30:52 +00:00
Chad Horohoe
a5053d4c5a * Cleanup massive duplication across Database constructors. Default implementation fairly sane. Now they all share the same if( $server ) logic to allow constructing the class without forcing open a connection (MySQL has done this since at least r15094)
* Get rid of intermediate installTables() callback
* Actually cache the result of DbInstaller::getConnection() like the documentation says
2011-01-24 18:36:09 +00:00
Chad Horohoe
537bf1ef01 Followup r80864: DatabaseSqlite exploded on installer page because it tried to open an invalid $wgSqliteDataDir.
Even though it doesn't use $server, only call open() if it's set, like in the other constructors.

The amount of code duplication here is stupid.
2011-01-24 17:37:06 +00:00
Niklas Laxström
b6433f144d No space after unary minus 2011-01-11 14:30:03 +00:00
Chad Horohoe
4ece90ed4b Remove ancient and deprecated newFromParams() constructor wrappers from various DatabaseBase implementations. Only callers are AskSql and WikiTrust. Both are calling the (very old) Database class anyway, so are obviously expecting a MySQL connection and can use the fallback (which yells wfDeprecated) in DatabaseBase 2011-01-07 20:25:52 +00:00
X!
dd68f3947a More work on getting SQLite to work with unit tests. DB Prefix changing is now static to allow for external classes to change it. 2010-12-31 20:42:39 +00:00
Roan Kattouw
475c331f60 Remove now-unused SQL timestamp conversion functions added in r77231. They were made obsolete by the querypage-work2 branch merge in r78786 2010-12-31 16:29:44 +00:00
X!
1993c83277 -Destroy the DB automatically when initting the DB
-Add $force option to wfSetVar
-More work on getting SQLite to work
2010-12-30 17:30:35 +00:00
X!
198b54f454 Fix r79109: listTables() does not work without a prefix, and verified that SQLite works now 2010-12-28 18:30:03 +00:00
X!
86df2d2755 It's here! It's finally here! The skies are falling, pigs have sprouted wings, and it's pretty cold in hell!
-Add a working PHPUnit test that instantiates a new DB, adds set data, and deleted when done.
-Add listTables() to the Database classes (only MySql and SQLite use it, and only MySQL is tested)
2010-12-28 17:15:50 +00:00
Daniel Friesen
aae05c49f8 MySQL is the only database which quotes identifiers primarily using backticks. Move the backtick based addIdentifierQuotes implementation from the generic into DatabaseMysql and take the duplicated implementation used by oracle, sqlite, ibm_db2, postgresql, and mssql and remove it from all of them migrating it to the generic Database class as the default. 2010-12-04 15:35:36 +00:00
Daniel Friesen
692ad26f68 Followup to r77713, rename quote_ident to addIdentifierQuotes to follow naming conventions better. While I'm at it adding a missing addIdentifierQuotes implementation for Ibm_db2. 2010-12-04 15:14:08 +00:00
Daniel Friesen
da469e3abe Fix a bug in the installer caused by r77487 creating installer sql statements like "GRANT ALL PRIVILEGES ON 'dbname'.* TO ''tablename''@'%" while improving the database independence of replaceVars.
* Drop unused and likely broken /*$var*/` -> `$var syntax
* Replace {$var} with '{$var}' and `{$var}` handling that uses relevant database independent quoting ({$var} without surrouding quotes are never used)
* Give the generic/mysql class a proper quote_ident implementation
* Fix the unused Oracle and Sqlite quote_ident implementations which are potential sql injections if used
* Split common variable replacemnt code off to a replaceGlobalVars and make the generic and oracle code use it instead of duplicating the same code as each other
2010-12-04 09:27:02 +00:00
Mark A. Hershberger
bdf0b5efc7 revert r77271 since it was an expensive fix to a non-existant problem. 2010-11-26 02:37:28 +00:00
Mark A. Hershberger
028d32b0ff Give SQLite a translation for MySQL's UNIX_TIMESTAMP() functions. Pg will probably need something similar. 2010-11-25 07:39:51 +00:00
Alexandre Emsenhuber
6cb276056b Moved switches in Special:Unusedimages and Special:Ancientpages to extract a unix timestamp from a fielf to DatabaseBase and related classes to avoid code duplication 2010-11-24 15:40:25 +00:00
Max Semenik
4345c2c20e Refactoring of *Field classes:
* Made them all implement one common interface (might add more functions to it later)
* Moved MySQLField to DatabaseMysql.php
* Renamed nullable() to isNullable()
* Removed maxLength() from:
** SQLiteField: makes no sense
** MySQLField: doesn't do what people may think, useless for this class' purpose of assisting querying the DB schema
2010-11-21 19:56:51 +00:00
Max Semenik
46209df2b8 SQLite types can be non-nullable 2010-11-19 20:34:44 +00:00
Chad Horohoe
a5947f6e87 Drop setup_database() here too. Only caller is the old installer 2010-11-10 16:06:42 +00:00
Max Semenik
108f8f8ef4 Follow-up r68127: honor table prefix, perverted though it may seem on SQLite. 2010-11-01 19:51:36 +00:00