Commit graph

31 commits

Author SHA1 Message Date
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Aaron Schulz
1a1c43bdff Database: clean up lockTables() and add postgres support
A new method is now available to check whether session scope
locks are supported, which callers typically want when using lock().
Its usage can avoid deadlock prone and expensive row-level locks for
some maintenance tasks.

For Postgres, table locks are tied to the transaction. Trigger
startAtomic() in lockTables() and endAtomic() in unlockTables() to
assure that a transaction is present.

Also remove LOW_PRIORITY feature, which is ignored by mysql.

Change-Id: I499061bcc2763afb1ff4a43319064eed4ba3a8fe
2017-04-07 16:28:36 -07:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
Kunal Mehta
a57b64436c Use wikimedia/timestamp
Bug: T100924
Depends-On: I0a067367cda6885fa45631ed7c18799d653dc9bf
Change-Id: I69ba64e364df8af089c1c918cdf32f99454e693a
2017-02-28 21:15:38 -08:00
jenkins-bot
b444c2a3df Merge "includes/libs: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:50:31 +00:00
Bartosz Dziewoński
0da3d2ff2b Database: Remove weird commented-out block
Commented out in 033b6b9646 (r20329).
After ten years, I think it's safe to bet this won't ever be getting
un-commented.

Change-Id: Ibb1f3e2969b2d81f6f2a17fff57e9b05cc17d58b
2017-02-25 22:55:45 +01:00
James D. Forrester
b715f432f4 includes/libs: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Skipping jsminplus.php as those bug numbers aren't Wikimedia's, nor obviously
someone else's.

Change-Id: I9a2210e17852ee56f11282b980ac66d8c7a95671
2017-02-21 18:13:08 +00:00
Aaron Schulz
8a5d8c0c71 Move Field classes to Rdbms namespace
Update core callers and leave a class alias to \Field.

Change-Id: I4908282301d5de2a20baafe510557bd2c3867de5
2017-02-16 01:14:37 +00:00
Aaron Schulz
019fa7cb9c Move Blob class to Rdbms namespaces
Leave \Blob as an alias. Callers can now use the Rdbms\Blob class
for "extends"/"new" and the Rdbms\IBlob interface for type hints.

Change-Id: I983b76f181ac60c1eb92c350cd27ad77ec90a192
2017-02-13 21:07:00 +00:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
Kevin Israel
cc495efff4 Database: Avoid internal use of ignoreErrors()
* Use $tempIgnore in DatabaseBase::tableExists() instead of ignoreErrors().
* DatabasePostgres::reportQueryError(), since 419221e4a7, calls
  ignoreErrors() before and after rollback(). This is probably not effective
  as a recursion guard (reportQueryError() would be called regardless), and
  for suppressing any log entry or exception, it is redundant (doRollback()
  already sets $tempIgnore when calling query()).
* ignoreErrors(), now unused, can be removed in a separate change set.

Change-Id: Iee768abf996ece213146ab8f64a15a2b407a2e5e
2016-12-27 05:20:30 -05:00
Aaron Schulz
f5dbb60c6e Depedency inject remappedTableName() map via MWLBFactory
Change-Id: I71d3481fc624f665bac81725026647bbb84ae608
2016-11-09 21:35:57 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Paladox
995d44ccde Make determineCoreSchema a public function again in DatabasePostgres
It was changed to a private function today, but it is called in
PostgresInstaller so it is causing this error

PHP Fatal error:  Call to private method
DatabasePostgres::determineCoreSchema() from context 'PostgresInstaller'
in /home/travis/build/paladox/mw/includes/installer/PostgresInstaller.php
on line 515

Caused by I2a067ca89a03f9ebf3f70a4f36ddae92e5b1e468

Change-Id: Ifac5a5c7dfeceeb8c7827d6d70e757633df77ca5
2016-10-29 22:13:14 +00:00
Aaron Schulz
3cc48cb058 Various small cleanups to DatabasePostgres
* Add missing method visibilites
* Removed redundant doc blocks
* Use empty string for mSchema for consistency with
  the base class

Change-Id: I2a067ca89a03f9ebf3f70a4f36ddae92e5b1e468
2016-10-28 22:14:26 -07:00
jenkins-bot
31a3a94d20 Merge "Postgres updater fixes to make update.php able to run" 2016-10-29 01:31:01 +00:00
Aaron Schulz
eef8fc45f3 Postgres updater fixes to make update.php able to run
* Remove redundant schema prefix from relname=x query. The
  schema filtering is already done via the JOIN. The relname
  portion is just the table name not <schema>.<table name>.
* Avoid explicit table schema qualification and rely on the
  search path, as MW 1.27 did. Previously it only used the
  global $wgDBschema var to pass to determineCoreSchema()
  instead of keeping it in mSchema.
* Clean up some code duplication in Database::tableName() and
  make the code comments clearer.
* Make DatabasePostgres::tableName() use parent::tableName()
  instead of a method that just wraps this method. The intent
  seems clearer this way.
* Remove unused return value in
  PostgresUpdater::rebuildTextSearch().

Bug: T148628
Change-Id: Id11d9576b7c2fdad22ff7f90727c12997217a632
2016-10-28 17:13:56 -07:00
Aaron Schulz
3e4b7663ec Add short-circuit to DatabasePostgres::schemaExists()
Change-Id: I5221f7d937be1e87689df5a21fd64e244dbd4c2a
2016-10-26 16:07:12 -07:00
Aaron Schulz
d1215eb7a5 Small DB classes IDEA warning fixes and cleanups
Change-Id: I65b5f452a364b329bb671540f4115dbc4f40eebd
2016-10-23 22:03:37 -07:00
Aaron Schulz
fda4d46fc4 Clean up postgres connection handling
* Remove non-connection magic case when no DB $user
  is given. This was removed from the base class.
* Use PGSQL_CONNECT_FORCE_NEW to let LoadBalancer
  handle connection reuse. This makes it work like
  the mysql classes.
* Make postgres connection error messages actually
  be useful by using the PHP error when possible.
  This makes it clear if the problem is authentication
  or something else and so on.

Change-Id: I3fd76c1e2db8d6008074f5347b201554579b549a
2016-10-19 01:08:49 +00:00
Aaron Schulz
66b0ad56df Postgres installation fixes
* Make isTransactableQuery() exclude CREATE/ALTER.
  Starting transactions for schema changes like this can cause
  errors as it is not supported for MySQL and some Postgres
  operations. Note that temporary tables are session-level,
  so they are not effected by this change.
* Clean up the transaction logic in determineCoreSchema()
  so a transaction is not left dangling.
* Fix broken getSchemaPath() call in PostgresInstaller.
* Avoid warnings in DatabasePostgres::closeConnection() if
  mConn is already unset.
* Commit master changes in doMaintenance.php before running
  deferred updates, just as MediaWiki.php does.
* Change E_WARNING to E_USER_WARNING to avoid notices in the
  default /rdbms error handlers.
* Also avoid trying to rollback in MWExceptionHandler if the
  LBFactory service is disabled, which just results in an error.

Bug: T147599
Change-Id: I64ccab7f9b74f60309ba0c9a8ce68337c42ffb0f
2016-10-17 15:06:38 -07:00
Kunal Mehta
090d0267da Use wikimedia/wait-condition-loop
Since the WaitConditionLoop class was first introduced in 1.28 (current
master), no back-compat alias is added.

Bug: T146256
Depends-On: Ia84774d83da79fea1e167fe065c69549981f753b
Change-Id: Ibd4f15c87105b8caccbd1f661b74b6efa012b77f
2016-10-01 00:25:43 -07:00
Aaron Schulz
0bdab07814 Move DatabaseBase to a class alias for type-hints
Change-Id: Ib6bbbd751358cbc2f2d2767c80721d3d8f142c0d
2016-09-29 06:09:03 +00:00
Aaron Schulz
63ce63820e Add DBO_* class constants and defines.php alias the class constants
Change-Id: If13b23ef849d4cf4c711b0ec2bf2e8a795f90738
2016-09-23 19:58:44 +00:00
Aaron Schulz
00d677347e Generalize core schema docs in DatabasePostgres
Change-Id: I52e64867c1533c50406623d5bc121c1e4da2459a
2016-09-22 21:41:19 +00:00
Kunal Mehta
8e9d2e93ca Rename Convert*a*bleTimestamp to Convert*i*bleTimestamp
Per the dictionary.

Change-Id: I3dcef9fb020c8c6764ee073111ed8c032e4c5a63
2016-09-21 21:43:32 -07:00
Brad Jorsch
f536c780eb Database: Behave correctly when inserting booleans
Pretty much everything seems to assume that PHP booleans should be
converted to 0/1: MySQL does this implicitly thanks to the lack of
strict mode by default, while PostgreSQL and Sqlite (and Mssql) do it
explicitly.

The addition of MySQL strict mode for unit tests in Ib2873913 exposed
the assumption in the case of MySQL by making some extension unit tests
fail. So let's make casting bool to int the default behavior of
Database::addQuotes().

This also cleans up the phpdoc for Database::addQuotes() to properly
reflect all the supported types that can be passed to it.

Change-Id: I13d0e402fa676bc27c345e8ac12f363ebc627f6a
2016-09-21 14:03:29 -04:00
Aaron Schulz
8c261ee924 Database class parameter and documentation cleanups
* Document various parameter arrays.
* Fix $user = false loophole in Database::__construct().
* Set the Postgres port *before* calling super, as it is
  needed by open().
* Remove 'chronProt' parameter as it is lazy-loaded.

Change-Id: Icc1037efa1eee7ae6fdd2919f60001e6e29ae55c
2016-09-19 23:23:30 -07:00
Aaron Schulz
adfd1b93d9 Move DatabasePostgres to /libs/rdbms
Fixed all IDEA warnings in the postgres classes too.

Change-Id: I06b4c5b2c581fb65552d980cc106aa10fed40285
2016-09-19 14:55:31 -07:00
Renamed from includes/db/DatabasePostgres.php (Browse further)