Commit graph

158 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
saper
557a05f384 bug 36087: PostgresUpdater fails on 8.3.14
PostgresUpdater fails on PostgreSQL 8.3.14:

> Changing 'image.img_metadata' default value
> A database query syntax error has occurred.
> The last attempted database query was:
> "ALTER TABLE image ALTER img_metadata SET DEFAULT '\x'::bytea"
> from within function "".
> Database returned error "22P02: ERROR:  invalid input syntax for type
> bytea"

Patchset 2:

> Database returned error "42883: ERROR:  function
> generate_subscripts(int2vector, integer) does not exist
> LINE 7:     (SELECT generate_subscripts(isub.indkey, 1) AS g
>                     ^
> HINT:  No function matches the given name and argument types. You
> might need to add explicit type casts.
> "

Change-Id: I6e1811ded0eedad9c0eb0df715698c45aaf8e3f0
2012-04-19 14:53:08 +02:00
saper
91eb34756e Fix broken merge by 0a792a1dcb
Changeset 1 of https://gerrit.wikimedia.org/r/#change,3365:
763b57f9f2af131a2d8e65f520a23c00109be0e1

got mis-merged in changeset 2:
f752cf8042

And introduced into master wth
0a792a1dcb

Also, marking all new functions as @since 1.19
since we want to have them there later.

Patchset 2: whitespace fixes
Patchset 3: Fix <?php
Patchset 4: rebase to current master

Change-Id: Ic7d940dfec8890de20197128505962375fac4f06
2012-04-13 20:55:14 +02:00
Mark A. Hershberger
1fd03b05f0 misleading comment: s/append/prepend/
Change-Id: I0855dd8c90270c902e78de36ecab711cb2b561ac
2012-04-12 10:59:09 +02:00
saper
632fdd3759 bug35572 Blocks appear to succeed w/DB error
Bug 35572 - Blocks appear to succeed even if query fails due to wrong DB
structure

When emulating INSERT IGNORE ignore only SQL Error Code 23505
- unique key violation

http://www.postgresql.org/docs/9.1/interactive/errcodes-appendix.html

All other error codes (missing column, syntex error, whatever)
should unconditionally abort the transaction and show internal
error to the user.

Patchset 2: Fixed whitespace.
Patchset 3: More whitespace. And ()'s.
Patchset 4: Yet more whitespace.
Patchset 5: rebase & fix conflict in release-notes

Change-Id: Ic32bff9fff46bce124273156d224fa01b8adc008
2012-04-10 12:59:24 -07:00
saper
f752cf8042 Fix PostgreSQL updater to produce 1.19 schema
* PostgresField now reports column default value
* DatabasePostgres::indexAttributes reports index
  details
* Perform schema update in one transaction

With this change we can sucessfully update
MediaWiki 1.7.3 schema to trunk^Wmaster

Patch set 2: Rebased against master. PLEASE check carefully
to make sure I got those conflicted files right.

Conflicts:

	includes/db/DatabasePostgres.php
	includes/installer/PostgresUpdater.php

Change-Id: Iebb6855e8f6f44470bbb1dc5ab9ac1abb513adfe
2012-04-10 12:59:21 -04:00
Demon
6392dda47b Merge "Remove unused $wgDebugDBTransactions" 2012-04-02 15:43:21 +00:00
Platonides
98787e87bb Remove unused $wgDebugDBTransactions
Change-Id: I74f93f83e5955b6953b11a13ed4312a536498b8d
2012-04-02 14:17:07 +02:00
saper
fa6ab16686 (bug 33689) Fix incomplete query on constraints
Upgrade to 1.19 on Postgres fails due to incomplete query when trying to
defer foreign key for externallinks

* FieldInfo::conname() should return NULL not "" when constraint
  is not present
* Re-create missing constraint on schema update

Change-Id: I7ca351e07d228afdf4a5c3bef365f42a27c9ac45
2012-03-28 23:23:13 +02:00
Marcin Cieślak
556c5cf464 Rename "user" and "text" when upgrading on PostgreSQL
Follow-up to r15791.

You can lie to me, but not to your installer.

Make DatabasePostgres::tableExists to check for real table names, not
faked ones.

DatabasePostgres is currently lying to the rest of the MediaWiki that
"mwuser" table is actually called "user" and that "pagecontents" is
called "text". While MediaWiki does not care, the installer (and updater
do).

This allows us to overcome first hurdle in getting MediaWiki 1.7.3 to
update to trunk on PostgreSQL and uncover further bugs.

For this commit to actually do something, we rename those tables when
upgrading to match what we have in maintenance/postgres/tables.sql

And by the way, tell installer not to check for "user" table, since most
PostgreSQL users will have "mwuser" instead. Picking "archive" instead.

Patchset2: wrapped commit message at 72 chars

Change-Id: Ic874e92bb1adda3430d3292423d4f3617c25456c
2012-03-24 09:10:59 +01:00
Roan Kattouw
0fca9a7991 Revert r107309, r113601, r113704, r113742, r113792, r113838, r113859, r113893, r113894, r113952, r114047, r114252, r114256, r114257. This reverts the remaining 'new' revisions in core.
All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
2012-03-21 00:16:50 +00:00
Marcin Cieślak
8e2da3a4a6 Follow-up to r15791: Rename "user" and "text" when upgrading on PostgreSQL
You can lie to me, but not to your installer.

Make DatabasePostgres::tableExists to check
for real table names, not faked ones.

DatabasePostgres is currently lying to the rest
of the MediaWiki that "mwuser" table is actually
called "user" and that "pagecontents" is called
"text". While MediaWiki does not care, the
installer (and updater do).

This allows us to overcome first hurdle
in getting MediaWiki 1.7.3 to update to trunk
on PostgreSQL and uncover further bugs.

For this commit to actually do something,
we rename those tables when upgrading to match
what we have in maintenance/postgres/tables.sql

And by the way, tell installer not to check
for "user" table, since most PostgreSQL users
will have "mwuser" instead. Picking "archive"
instead.
2012-03-14 20:20:53 +00:00
Marcin Cieślak
490644674a Fix PostgreSQL updater broken by r113487 2012-03-09 22:29:22 +00:00
Sam Reed
eee30c7fd0 Fix syntax error and indenting from r113487 2012-03-09 19:05:29 +00:00
Sam Reed
f33011e5a7 Fix up some documentation weirdness from r113487 2012-03-09 18:55:12 +00:00
Sam Reed
d1588bbf02 Fix broken unit tests post r113487
[exec] PHP Fatal error:  Call to a member function getCoreSchema() on a non-object in /var/lib/jenkins/jobs/MediaWiki-postgres-phpunit/workspace/mw-core/includes/db/DatabasePostgres.php on line 216
2012-03-09 18:52:31 +00:00
Marcin Cieślak
cfb8e9a251 Handle PostgreSQL transaction errors and improve schema detection
* 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
2012-03-09 17:24:57 +00:00
Marcin Cieślak
94633ff448 PostgreSQL: Improve SQL error handling
After a query error, PostgreSQL transaction is aborted
until it's terminated or the query is closed. 

All further queries result in:

  ERROR: current transaction is aborted, commands ignored 
  until end of transaction block

Those subsequent errors are ignored by double fault handling in
DatabaseBase::reportQueryError but they cause all localization
of error messages to fail (unable to issue queries to message
tables) and errors lke


This resulted in a broken MediaWiki screen with

  <databaseerror>
  <dberrortext>

instead of localized error message.

We need to fully reset database connection because after
pg_connection_reset() various session parameters need to
be set again (like "search_path"), otherwise tables will not be
found.

   ERROR: relation "msg_resource" does not exist
   ERROR:  relation "l10n_cache" does not exist
2012-03-08 21:44:03 +00:00
Max Semenik
a8f718267e Follow-up r112565: fix code duplication 2012-02-28 14:42:08 +00:00
Chad Horohoe
2177a4d8b4 (bug 34762) Calling close() on a DatabaseBase object now clears the connection. Based on patch by Christian.
By the way, the duplication here is stupid.
2012-02-28 02:18:18 +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
c47f83a4d4 More __METHOD__ in our madness 2012-02-24 18:45:24 +00:00
Sam Reed
76246b9bf5 More return documentation 2012-02-09 21:33:27 +00:00
Aaron Schulz
e8cee706fe Reverted r106025 and friends (r106370, r106373, r108060, r108337, r106419). This can go in 1.20 if a Postgres person has time to look at it. 2012-02-03 23:37:30 +00:00
OverlordQ
074a7001c6 Followup to r108744 2012-01-12 23:22:09 +00:00
Max Semenik
6d87a6ea8f Revert r108603, which was itself a revert of r107376, r107994. Before considering something unneeded, please ask first ;) 2012-01-11 20:19:55 +00:00
Antoine Musso
f5f1b6d0bb Reverts MySQL stored procedure support
This is reverting the work done by MaxSem to support stored procedures
and stored function in MySQL. The reasons are:
 - it is not needed yet
 - tests are not functionals
 - alter the stable include/db/Database.php and drop support for ';;'

So please create a branch to work on it and merge it back in trunk
once we have branched 1.19 :-)

I have opened bug 33654 to track this enhancement request.

Reverts r107376, r107994.
2012-01-11 09:46:21 +00:00
Platonides
9d46726f73 No need of $wgDBmwschema after r108060 2012-01-07 23:29:48 +00:00
Mark A. Hershberger
227dd89ec8 re r106025 — apply follow up from Luca Fulchir 2012-01-04 18:01:10 +00:00
Max Semenik
6b7317c91f Added support for stored procedures/functions to MySQL:
* Refactored DatabaseBase::sourceStream(), made it possible for descendant classes to alter its behaviour w/o having to redo it completely like Oracle does.
* MySQL class now supports specifying DELIMITER.
* Thrown away the mess of catering for double semicolon. If it's a problem, fix your .sql files!
* Haven't actually touched Oracle.
* Tests!
2011-12-27 12:29:36 +00:00
Niklas Laxström
d88e18abc8 Foooollowup r106373 - update comment 2011-12-16 08:56:57 +00:00
Platonides
e8031547af Simplify a bit the code of r106025 2011-12-15 21:21:30 +00:00
Platonides
2840d9809b Use the canonical name of the setting 2011-12-15 21:12:27 +00:00
Mark A. Hershberger
a8a0258cf2 Bug 16794 - $wgSharedDB PostgreSQL support
Updated fix from Luca Fulchir
2011-12-13 15:06:30 +00:00
Sam Reed
9814e6b075 Add $fname to tableExists
Pass $fname/__METHOD__ in in upstream callers
2011-11-10 20:39:23 +00:00
Sam Reed
9d41b95053 Kill various unused variables
Comment some out also

Add some bits of documentation
2011-10-29 01:17:26 +00:00
OverlordQ
8296d0736b Basic support for Postgres phpunit testing, currently throws 5 errors, 1 inc, 5 skipped 2011-10-24 19:28:31 +00:00
Mark A. Hershberger
71d5b68221 revert r99562 and set standard_conforming_strings “on” by default 2011-10-18 21:09:52 +00:00
Mark A. Hershberger
6b9085255c Avoid warnings from PG about improper escaping.
See http://www.postgresql.org/docs/8.1/static/release-8-1.html
2011-10-11 20:49:28 +00:00
Chad Horohoe
70430650e9 Followup r96369: update child classes and a few callers 2011-09-06 20:51:10 +00:00
Alexandre Emsenhuber
19c5d5e595 * Removed usage of error suppression operator in includes/db
* Changed an usage of $_REQUEST to $wgRequest
2011-07-04 15:00:30 +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
Tim Starling
b37cde66c1 PostgreSQL install fixes:
* Made PG throw a DBQueryError when it gets a query error, instead of DBUnexpectedError. Apparently this mistake goes back to r14625, when exceptions were first introduced. Did it by removing reportQueryError(), the DatabaseBase version works fine.
* Fixed several places where there was an attempt to check for a query error by checking if the result of query() was false. This never worked. Used try/catch instead.
* Made the DBConnectionError messages go on one line so that they don't mess up the formatting in the installer.
* In DatabasePostgres::selectDB(), only disconnect and reconnect if the DB name is actually changing.
* Made DatabasePostgres::schemaExists() less weird and scary.
* Added DatabasePostgres::roleExists() for use by the installer.
* Removed the PostgreSQL-specific hack to make _InstallUser have a default other than "root". Made _InstallUser into a proper DBMS-specific internal variable instead, since every DBMS we support so far needs a different default.
* Removed the $dbName parameters from openConnection/getConnection, and got rid of $this->useAdmin. Implemented a more sophisticated caching scheme instead. Partial revert of r89389 and r81440.
* When connecting as the install user before DB creation, and when testing the web user's credentials, try a few different database names and use whichever one works. 
* Instead of connecting as the web user to create tables, I used SET ROLE. It seems cleaner and more like what the other DBMSes do during installation. "SET ROLE wikiuser" requires the same privileges as "CREATE SCHEMA ... AUTHORIZATION wikiuser", so it's unlikely to break anything.
* In the area of web account creation, fixed various minor logic errors and introduced more informative error messages at the submit stage, pre-install. Show a helpful error message if the web user exists already and the install user can't do the relevant SET ROLE.
* Split schema creation out to a separate install step.
* When creating an account as a non-superuser, add the administrative account to the new account's group. This is necessary to avoid a fatal error during installation (bug 28845).
* Removed code which alters an existing web user to have appropriate search paths and permissions. This may break other apps and is not necessary. As in other DBMSes, If the web user exists, it is the responsibility of the sysadmin to ensure that it has appropriate permissions.
* Rewrote setupPLpgSQL() to use the query builder functions.
2011-06-10 11:32:57 +00:00
Tim Starling
150bfa181e Reverted r89393. A single Database object certainly should not be attempting to manage multiple database connections, that is the job of LBFactory/LoadBalancer. I would like to see $wgSharedDB managed by LBFactory instead, for all DBMSes. Then the cruft in Database::tableName() can be removed.
r89393 caused tableExists() etc. to be completely broken, so PostgreSQL upgrade was broken too, see CR.
2011-06-10 07:36:22 +00:00
Mark A. Hershberger
1fb4ff1dd8 Apply a patch adapted from the one on Bug #16794
This patch should allow you to use the $wgSharedDB [with Postgres]
    normally, as you would with mysql. Basically this patch creates a
    second connection with the shared database and when a query is
    made, we check on which connection we should send it.

Patch from Luca Fulchir
2011-06-03 04:10:33 +00:00
Sam Reed
0d47a2ae90 More parameter documentation!! 2011-05-28 14:52:55 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
OverlordQ
245e6b067a Followup to r85907, correctly quote table names.
Followup to r87129, add handling of arrayed GROUP BY/ORDER BY options to match core class so that this will indeed work.
2011-04-29 22:27:34 +00:00