MediaWiki  master
IDatabase.php
Go to the documentation of this file.
1 <?php
20 namespace Wikimedia\Rdbms;
21 
22 use Exception;
23 use InvalidArgumentException;
24 use stdClass;
25 use Wikimedia\ScopedCallback;
26 
38 interface IDatabase {
40  public const TRIGGER_IDLE = 1;
42  public const TRIGGER_COMMIT = 2;
44  public const TRIGGER_ROLLBACK = 3;
46  public const TRIGGER_CANCEL = 4;
47 
49  public const TRANSACTION_EXPLICIT = '';
51  public const TRANSACTION_INTERNAL = 'implicit';
52 
54  public const ATOMIC_NOT_CANCELABLE = '';
56  public const ATOMIC_CANCELABLE = 'cancelable';
57 
59  public const FLUSHING_ONE = '';
61  public const FLUSHING_ALL_PEERS = 'flush';
63  public const FLUSHING_INTERNAL = 'flush-internal';
64 
66  public const REMEMBER_NOTHING = '';
68  public const REMEMBER_PRIOR = 'remember';
70  public const RESTORE_PRIOR = 'prior';
72  public const RESTORE_INITIAL = 'initial';
73 
75  public const ESTIMATE_TOTAL = 'total';
77  public const ESTIMATE_DB_APPLY = 'apply';
78 
80  public const LIST_COMMA = 0;
82  public const LIST_AND = 1;
84  public const LIST_SET = 2;
86  public const LIST_NAMES = 3;
88  public const LIST_OR = 4;
89 
91  public const DBO_DEBUG = 1;
93  public const DBO_NOBUFFER = 2;
95  public const DBO_IGNORE = 4;
97  public const DBO_TRX = 8;
99  public const DBO_DEFAULT = 16;
101  public const DBO_PERSISTENT = 32;
103  public const DBO_SYSDBA = 64;
105  public const DBO_DDLMODE = 128;
107  public const DBO_SSL = 256;
109  public const DBO_COMPRESS = 512;
110 
112  public const QUERY_NORMAL = 0;
114  public const QUERY_SILENCE_ERRORS = 1; // b/c for 1.32 query() argument; (int)true = 1
119  public const QUERY_PSEUDO_PERMANENT = 2;
121  public const QUERY_REPLICA_ROLE = 4;
123  public const QUERY_IGNORE_DBO_TRX = 8;
125  public const QUERY_NO_RETRY = 16;
127  public const QUERY_CHANGE_NONE = 32;
129  public const QUERY_CHANGE_TRX = 64 | self::QUERY_IGNORE_DBO_TRX;
131  public const QUERY_CHANGE_ROWS = 128;
133  public const QUERY_CHANGE_SCHEMA = 256 | self::QUERY_IGNORE_DBO_TRX;
134 
136  public const UNION_ALL = true;
138  public const UNION_DISTINCT = false;
139 
141  public const LB_TRX_ROUND_ID = 'trxRoundId';
143  public const LB_READ_ONLY_REASON = 'readOnlyReason';
144 
146  public const ROLE_STREAMING_MASTER = 'streaming-master';
148  public const ROLE_STREAMING_REPLICA = 'streaming-replica';
150  public const ROLE_STATIC_CLONE = 'static-clone';
152  public const ROLE_UNKNOWN = 'unknown';
153 
155  public const ALL_ROWS = '*';
156 
164  public function getServerInfo();
165 
177  public function getTopologyBasedServerId();
178 
190  public function getTopologyRole();
191 
203  public function getTopologyRootMaster();
204 
213  public function trxLevel();
214 
226  public function trxTimestamp();
227 
232  public function explicitTrxActive();
233 
240  public function assertNoOpenTransactions();
241 
248  public function tablePrefix( $prefix = null );
249 
256  public function dbSchema( $schema = null );
257 
264  public function getLBInfo( $name = null );
265 
274  public function setLBInfo( $nameOrArray, $value = null );
275 
282  public function implicitOrderby();
283 
289  public function lastQuery();
290 
297  public function lastDoneWrites();
298 
303  public function writesPending();
304 
309  public function preCommitCallbacksPending();
310 
319  public function writesOrCallbacksPending();
320 
330  public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL );
331 
338  public function pendingWriteCallers();
339 
346  public function pendingWriteRowsAffected();
347 
351  public function isOpen();
352 
359  public function setFlag( $flag, $remember = self::REMEMBER_NOTHING );
360 
367  public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING );
368 
375  public function restoreFlags( $state = self::RESTORE_PRIOR );
376 
383  public function getFlag( $flag );
384 
392  public function getDomainID();
393 
399  public function getType();
400 
410  public function fetchObject( $res );
411 
421  public function fetchRow( $res );
422 
431  public function numRows( $res );
432 
440  public function numFields( $res );
441 
450  public function fieldName( $res, $n );
451 
461  public function insertId();
462 
470  public function dataSeek( $res, $row );
471 
478  public function lastErrno();
479 
486  public function lastError();
487 
496  public function affectedRows();
497 
505  public function getSoftwareLink();
506 
512  public function getServerVersion();
513 
526  public function close( $fname = __METHOD__, $owner = null );
527 
555  public function query( $sql, $fname = __METHOD__, $flags = 0 );
556 
565  public function freeResult( $res );
566 
573  public function newSelectQueryBuilder();
574 
591  public function selectField(
592  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
593  );
594 
612  public function selectFieldValues(
613  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
614  );
615 
793  public function select(
794  $table,
795  $vars,
796  $conds = '',
797  $fname = __METHOD__,
798  $options = [],
799  $join_conds = []
800  );
801 
819  public function selectSQLText(
820  $table,
821  $vars,
822  $conds = '',
823  $fname = __METHOD__,
824  $options = [],
825  $join_conds = []
826  );
827 
844  public function selectRow(
845  $table,
846  $vars,
847  $conds,
848  $fname = __METHOD__,
849  $options = [],
850  $join_conds = []
851  );
852 
875  public function estimateRowCount(
876  $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
877  );
878 
897  public function selectRowCount(
898  $tables, $var = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
899  );
900 
913  public function lockForUpdate(
914  $table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
915  );
916 
926  public function fieldExists( $table, $field, $fname = __METHOD__ );
927 
937  public function indexExists( $table, $index, $fname = __METHOD__ );
938 
947  public function tableExists( $table, $fname = __METHOD__ );
948 
968  public function insert( $table, $rows, $fname = __METHOD__, $options = [] );
969 
994  public function update( $table, $set, $conds, $fname = __METHOD__, $options = [] );
995 
1021  public function makeList( array $a, $mode = self::LIST_COMMA );
1022 
1039  public function makeWhereFrom2d( $data, $baseKey, $subKey );
1040 
1050  public function aggregateValue( $valuedata, $valuename = 'value' );
1051 
1056  public function bitNot( $field );
1057 
1063  public function bitAnd( $fieldLeft, $fieldRight );
1064 
1070  public function bitOr( $fieldLeft, $fieldRight );
1071 
1077  public function buildConcat( $stringList );
1078 
1095  public function buildGroupConcatField(
1096  $delim, $table, $field, $conds = '', $join_conds = []
1097  );
1098 
1113  public function buildGreatest( $fields, $values );
1114 
1129  public function buildLeast( $fields, $values );
1130 
1143  public function buildSubString( $input, $startPosition, $length = null );
1144 
1150  public function buildStringCast( $field );
1151 
1157  public function buildIntegerCast( $field );
1158 
1173  public function buildSelectSubquery(
1174  $table,
1175  $vars,
1176  $conds = '',
1177  $fname = __METHOD__,
1178  $options = [],
1179  $join_conds = []
1180  );
1181 
1199  public function limitResult( $sql, $limit, $offset = false );
1200 
1213  public function databasesAreIndependent();
1214 
1226  public function selectDB( $db );
1227 
1240  public function selectDomain( $domain );
1241 
1247  public function getDBname();
1248 
1254  public function getServer();
1255 
1262  public function getServerName();
1263 
1270  public function addQuotes( $s );
1271 
1281  public function addIdentifierQuotes( $s );
1282 
1302  public function buildLike( $param, ...$params );
1303 
1309  public function anyChar();
1310 
1316  public function anyString();
1317 
1334  public function nextSequenceValue( $seqName );
1335 
1363  public function replace( $table, $uniqueKeys, $rows, $fname = __METHOD__ );
1364 
1398  public function upsert(
1399  $table, array $rows, $uniqueKeys, array $set, $fname = __METHOD__
1400  );
1401 
1422  public function deleteJoin(
1423  $delTable,
1424  $joinTable,
1425  $delVar,
1426  $joinVar,
1427  $conds,
1428  $fname = __METHOD__
1429  );
1430 
1443  public function delete( $table, $conds, $fname = __METHOD__ );
1444 
1475  public function insertSelect(
1476  $destTable,
1477  $srcTable,
1478  $varMap,
1479  $conds,
1480  $fname = __METHOD__,
1481  $insertOptions = [],
1482  $selectOptions = [],
1483  $selectJoinConds = []
1484  );
1485 
1491  public function unionSupportsOrderAndLimit();
1492 
1502  public function unionQueries( $sqls, $all );
1503 
1531  $table,
1532  $vars,
1533  array $permute_conds,
1534  $extra_conds = '',
1535  $fname = __METHOD__,
1536  $options = [],
1537  $join_conds = []
1538  );
1539 
1550  public function conditional( $cond, $caseTrueExpression, $caseFalseExpression );
1551 
1560  public function strreplace( $orig, $old, $new );
1561 
1568  public function getServerUptime();
1569 
1577  public function wasDeadlock();
1578 
1586  public function wasLockTimeout();
1587 
1596  public function wasConnectionLoss();
1597 
1603  public function wasReadOnlyError();
1604 
1612  public function wasErrorReissuable();
1613 
1628  public function masterPosWait( DBMasterPos $pos, $timeout );
1629 
1636  public function getReplicaPos();
1637 
1644  public function getMasterPos();
1645 
1650  public function serverIsReadOnly();
1651 
1684  public function onTransactionResolution( callable $callback, $fname = __METHOD__ );
1685 
1720  public function onTransactionCommitOrIdle( callable $callback, $fname = __METHOD__ );
1721 
1730  public function onTransactionIdle( callable $callback, $fname = __METHOD__ );
1731 
1761  public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ );
1762 
1786  public function onAtomicSectionCancel( callable $callback, $fname = __METHOD__ );
1787 
1805  public function setTransactionListener( $name, callable $callback = null );
1806 
1881  public function startAtomic( $fname = __METHOD__, $cancelable = self::ATOMIC_NOT_CANCELABLE );
1882 
1894  public function endAtomic( $fname = __METHOD__ );
1895 
1921  public function cancelAtomic( $fname = __METHOD__, AtomicSectionIdentifier $sectionId = null );
1922 
1995  public function doAtomicSection(
1996  $fname, callable $callback, $cancelable = self::ATOMIC_NOT_CANCELABLE
1997  );
1998 
2018  public function begin( $fname = __METHOD__, $mode = self::TRANSACTION_EXPLICIT );
2019 
2038  public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE );
2039 
2059  public function rollback( $fname = __METHOD__, $flush = self::FLUSHING_ONE );
2060 
2080  public function flushSnapshot( $fname = __METHOD__, $flush = self::FLUSHING_ONE );
2081 
2093  public function timestamp( $ts = 0 );
2094 
2109  public function timestampOrNull( $ts = null );
2110 
2117  public function ping( &$rtt = null );
2118 
2127  public function getLag();
2128 
2143  public function getSessionLagStatus();
2144 
2150  public function maxListLen();
2151 
2162  public function encodeBlob( $b );
2163 
2173  public function decodeBlob( $b );
2174 
2186  public function setSessionOptions( array $options );
2187 
2195  public function setSchemaVars( $vars );
2196 
2206  public function lockIsFree( $lockName, $method );
2207 
2219  public function lock( $lockName, $method, $timeout = 5 );
2220 
2231  public function unlock( $lockName, $method );
2232 
2254  public function getScopedLockAndFlush( $lockKey, $fname, $timeout );
2255 
2262  public function namedLocksEnqueue();
2263 
2271  public function getInfinity();
2272 
2279  public function encodeExpiry( $expiry );
2280 
2288  public function decodeExpiry( $expiry, $format = TS_MW );
2289 
2299  public function setBigSelects( $value = true );
2300 
2305  public function isReadOnly();
2306 
2320  public function setTableAliases( array $aliases );
2321 
2334  public function setIndexAliases( array $aliases );
2335 
2343  public function __toString();
2344 }
2345 
2349 class_alias( IDatabase::class, 'IDatabase' );
DBO_PERSISTENT
const DBO_PERSISTENT
Definition: defines.php:14
LIST_OR
const LIST_OR
Definition: Defines.php:46
Wikimedia\Rdbms\IDatabase\getServerName
getServerName()
Get the readable name for the server.
Wikimedia\Rdbms\IDatabase\isOpen
isOpen()
LIST_NAMES
const LIST_NAMES
Definition: Defines.php:45
Wikimedia\Rdbms\IDatabase\affectedRows
affectedRows()
Get the number of rows affected by the last write query.
Wikimedia\Rdbms\IDatabase\setBigSelects
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
Wikimedia\Rdbms\IDatabase\getServer
getServer()
Get the hostname or IP address of the server.
Wikimedia\Rdbms\IDatabase\getServerVersion
getServerVersion()
A string describing the current software version, like from mysql_get_server_info()
Wikimedia\Rdbms\IDatabase\onAtomicSectionCancel
onAtomicSectionCancel(callable $callback, $fname=__METHOD__)
Run a callback when the atomic section is cancelled.
Wikimedia\Rdbms\IDatabase\maxListLen
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
Wikimedia\Rdbms\IDatabase\getInfinity
getInfinity()
Find out when 'infinity' is.
Wikimedia\Rdbms\IDatabase\insertSelect
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[])
INSERT SELECT wrapper.
Wikimedia\Rdbms\IDatabase\unionQueries
unionQueries( $sqls, $all)
Construct a UNION query.
Wikimedia\Rdbms\IDatabase\pendingWriteQueryDuration
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
Wikimedia\Rdbms\IDatabase\tablePrefix
tablePrefix( $prefix=null)
Get/set the table prefix.
Wikimedia\Rdbms\IDatabase\writesPending
writesPending()
Wikimedia\Rdbms\IDatabase\rollback
rollback( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Rollback a transaction previously started using begin()
Wikimedia\Rdbms\IDatabase\replace
replace( $table, $uniqueKeys, $rows, $fname=__METHOD__)
Insert row(s) into a table, deleting all conflicting rows beforehand.
Wikimedia\Rdbms\IDatabase\numRows
numRows( $res)
Get the number of rows in a query result.
Wikimedia\Rdbms\IDatabase\setLBInfo
setLBInfo( $nameOrArray, $value=null)
Set the entire array or a particular key of the managing load balancer info array.
Wikimedia\Rdbms\IDatabase\cancelAtomic
cancelAtomic( $fname=__METHOD__, AtomicSectionIdentifier $sectionId=null)
Cancel an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\ping
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
Wikimedia\Rdbms\IDatabase\numFields
numFields( $res)
Get the number of fields in a result object.
Wikimedia\Rdbms\IDatabase\bitNot
bitNot( $field)
Wikimedia\Rdbms\IDatabase\getMasterPos
getMasterPos()
Get the position of this master.
Wikimedia\Rdbms\IDatabase\wasErrorReissuable
wasErrorReissuable()
Determines if the last query error was due to something outside of the query itself.
LIST_AND
const LIST_AND
Definition: Defines.php:43
Wikimedia\Rdbms\IDatabase\encodeExpiry
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
Wikimedia\Rdbms\IDatabase\upsert
upsert( $table, array $rows, $uniqueKeys, array $set, $fname=__METHOD__)
Upsert the given row(s) into a table.
Wikimedia\Rdbms\IDatabase\lastError
lastError()
Get a description of the last error.
DBO_DEBUG
const DBO_DEBUG
Definition: defines.php:9
Wikimedia\Rdbms\IDatabase\endAtomic
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\trxLevel
trxLevel()
Gets the current transaction level.
Wikimedia\Rdbms\IDatabase\implicitOrderby
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\IDatabase\getServerInfo
getServerInfo()
Get a human-readable string describing the current software version.
Wikimedia\Rdbms\DBMasterPos
An object representing a master or replica DB position in a replicated setup.
Definition: DBMasterPos.php:14
Wikimedia\Rdbms\IDatabase\trxTimestamp
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
LIST_SET
const LIST_SET
Definition: Defines.php:44
DBO_SSL
const DBO_SSL
Definition: defines.php:17
DBO_IGNORE
const DBO_IGNORE
Definition: defines.php:11
Wikimedia\Rdbms\IDatabase\decodeBlob
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
Wikimedia\Rdbms\IDatabase\getSessionLagStatus
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
Wikimedia\Rdbms\IDatabase\selectField
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
Wikimedia\Rdbms\IDatabase\getLag
getLag()
Get the amount of replication lag for this database server.
Wikimedia\Rdbms\IDatabase\buildGreatest
buildGreatest( $fields, $values)
Build a GREATEST function statement comparing columns/values.
Wikimedia\Rdbms\IDatabase\onTransactionCommitOrIdle
onTransactionCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback when the current transaction commits or now if there is none.
Wikimedia\Rdbms\IDatabase\isReadOnly
isReadOnly()
$res
$res
Definition: testCompression.php:57
LIST_COMMA
const LIST_COMMA
Definition: Defines.php:42
DBO_TRX
const DBO_TRX
Definition: defines.php:12
Wikimedia\Rdbms\IDatabase\dbSchema
dbSchema( $schema=null)
Get/set the db schema.
Wikimedia\Rdbms\IDatabase\tableExists
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
Wikimedia\Rdbms\IDatabase\conditional
conditional( $cond, $caseTrueExpression, $caseFalseExpression)
Returns an SQL expression for a simple conditional.
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IDatabase\fieldName
fieldName( $res, $n)
Get a field name in a result object.
Wikimedia\Rdbms\IDatabase\lastDoneWrites
lastDoneWrites()
Get the last time the connection may have been used for a write query.
DBO_NOBUFFER
const DBO_NOBUFFER
Definition: defines.php:10
Wikimedia\Rdbms\IDatabase\update
update( $table, $set, $conds, $fname=__METHOD__, $options=[])
Update all rows in a table that match a given condition.
Wikimedia\Rdbms\IDatabase\fetchObject
fetchObject( $res)
Fetch the next row from the given result object, in object form.
Wikimedia\Rdbms\IDatabase\getServerUptime
getServerUptime()
Determines how long the server has been up.
Wikimedia\Rdbms\IDatabase\lock
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
Wikimedia\Rdbms\IDatabase\buildSelectSubquery
buildSelectSubquery( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery.
Wikimedia\Rdbms\IDatabase\unionSupportsOrderAndLimit
unionSupportsOrderAndLimit()
Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION.
Wikimedia\Rdbms\IDatabase\getSoftwareLink
getSoftwareLink()
Returns a wikitext style link to the DB's website (e.g.
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
Wikimedia\Rdbms\IDatabase\freeResult
freeResult( $res)
Free a result object returned by query() or select()
Wikimedia\Rdbms\IDatabase\encodeBlob
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
Wikimedia\Rdbms\IDatabase\deleteJoin
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Wikimedia\Rdbms\IDatabase\__toString
__toString()
Get a debugging string that mentions the database type, the ID of this instance, and the ID of any un...
Wikimedia\Rdbms\IDatabase\getTopologyRole
getTopologyRole()
Get the replication topology role of this server.
Wikimedia\Rdbms\IDatabase\lockForUpdate
lockForUpdate( $table, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Lock all rows meeting the given conditions/options FOR UPDATE.
Wikimedia\Rdbms\IDatabase\databasesAreIndependent
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
Wikimedia\Rdbms\IDatabase\close
close( $fname=__METHOD__, $owner=null)
Close the database connection.
Wikimedia\Rdbms\IDatabase\limitResult
limitResult( $sql, $limit, $offset=false)
Construct a LIMIT query with optional offset.
Wikimedia\Rdbms\IDatabase\wasDeadlock
wasDeadlock()
Determines if the last failure was due to a deadlock.
Wikimedia\Rdbms\IDatabase\anyChar
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
Wikimedia\Rdbms\IDatabase\preCommitCallbacksPending
preCommitCallbacksPending()
Wikimedia\Rdbms\IDatabase\query
query( $sql, $fname=__METHOD__, $flags=0)
Run an SQL query and return the result.
Wikimedia\Rdbms\IDatabase\decodeExpiry
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
Wikimedia\Rdbms\IDatabase\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Wikimedia\Rdbms\IDatabase\wasLockTimeout
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
Wikimedia\Rdbms\IDatabase\buildLeast
buildLeast( $fields, $values)
Build a LEAST function statement comparing columns/values.
Wikimedia\Rdbms\IDatabase\assertNoOpenTransactions
assertNoOpenTransactions()
Assert that all explicit transactions or atomic sections have been closed.
Wikimedia\Rdbms\IDatabase\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Wikimedia\Rdbms\IDatabase\buildSubString
buildSubString( $input, $startPosition, $length=null)
Build a SUBSTRING function.
DBO_COMPRESS
const DBO_COMPRESS
Definition: defines.php:18
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:206
Wikimedia\Rdbms\IDatabase\unlock
unlock( $lockName, $method)
Release a lock.
Wikimedia\Rdbms\IDatabase\lastQuery
lastQuery()
Get the last query that sent on account of IDatabase::query()
Wikimedia\Rdbms\IDatabase\selectRow
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Wrapper to IDatabase::select() that only fetches one row (via LIMIT)
DBO_DDLMODE
const DBO_DDLMODE
Definition: defines.php:16
Wikimedia\Rdbms\IDatabase\getScopedLockAndFlush
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
Wikimedia\Rdbms\IDatabase\selectRowCount
selectRowCount( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
Wikimedia\Rdbms\IDatabase\explicitTrxActive
explicitTrxActive()
Wikimedia\Rdbms\IDatabase\buildStringCast
buildStringCast( $field)
Wikimedia\Rdbms\IDatabase\getDomainID
getDomainID()
Return the currently selected domain ID.
Wikimedia\Rdbms\IDatabase\buildConcat
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
Wikimedia\Rdbms\IDatabase\wasConnectionLoss
wasConnectionLoss()
Determines if the last query error was due to a dropped connection.
Wikimedia\Rdbms\IDatabase\setTransactionListener
setTransactionListener( $name, callable $callback=null)
Run a callback after each time any transaction commits or rolls back.
Wikimedia\Rdbms\AtomicSectionIdentifier
Class used for token representing identifiers for atomic sections from IDatabase instances.
Definition: AtomicSectionIdentifier.php:26
Wikimedia\Rdbms\IDatabase\getDBname
getDBname()
Get the current database name; null if there isn't one.
Wikimedia\Rdbms\IDatabase\wasReadOnlyError
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
Wikimedia\Rdbms\IDatabase\strreplace
strreplace( $orig, $old, $new)
Returns a SQL expression for simple string replacement (e.g.
Wikimedia\Rdbms\IDatabase\bitOr
bitOr( $fieldLeft, $fieldRight)
Wikimedia\Rdbms\IDatabase\pendingWriteCallers
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
Wikimedia\Rdbms\IDatabase\fetchRow
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
DBO_SYSDBA
const DBO_SYSDBA
Definition: defines.php:15
Wikimedia\Rdbms\IDatabase\anyString
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
Wikimedia\Rdbms\IDatabase\getReplicaPos
getReplicaPos()
Get the replication position of this replica DB.
Wikimedia\Rdbms\IDatabase\getFlag
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
Wikimedia\Rdbms\IDatabase\masterPosWait
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
Wikimedia\Rdbms\IDatabase\insert
insert( $table, $rows, $fname=__METHOD__, $options=[])
Insert the given row(s) into a table.
Wikimedia\Rdbms\IDatabase\onTransactionIdle
onTransactionIdle(callable $callback, $fname=__METHOD__)
Alias for onTransactionCommitOrIdle() for backwards-compatibility.
Wikimedia\Rdbms\IDatabase\bitAnd
bitAnd( $fieldLeft, $fieldRight)
Wikimedia\Rdbms\IDatabase\lockIsFree
lockIsFree( $lockName, $method)
Check to see if a named lock is not locked by any thread (non-blocking)
Wikimedia\Rdbms\IDatabase\selectDB
selectDB( $db)
Change the current database.
Wikimedia\Rdbms\IDatabase\doAtomicSection
doAtomicSection( $fname, callable $callback, $cancelable=self::ATOMIC_NOT_CANCELABLE)
Perform an atomic section of reversable SQL statements from a callback.
Wikimedia\Rdbms\IDatabase\lastErrno
lastErrno()
Get the last error number.
Wikimedia\Rdbms\IDatabase\fieldExists
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
Wikimedia\Rdbms\IDatabase\aggregateValue
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
Wikimedia\Rdbms\IDatabase\selectSQLText
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Take the same arguments as IDatabase::select() and return the SQL it would use.
Wikimedia\Rdbms\IDatabase\setSchemaVars
setSchemaVars( $vars)
Set schema variables to be used when streaming commands from SQL files or stdin.
Wikimedia\Rdbms\IDatabase\addQuotes
addQuotes( $s)
Escape and quote a raw value string for use in a SQL query.
Wikimedia\Rdbms\IDatabase\unionConditionPermutations
unionConditionPermutations( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Construct a UNION query for permutations of conditions.
Wikimedia\Rdbms\IDatabase\selectDomain
selectDomain( $domain)
Set the current domain (database, schema, and table prefix)
Wikimedia\Rdbms\IDatabase\onTransactionPreCommitOrIdle
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
Wikimedia\Rdbms\IDatabase\makeWhereFrom2d
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
Wikimedia\Rdbms\IDatabase\selectFieldValues
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
Wikimedia\Rdbms\IDatabase\getType
getType()
Get the RDBMS type of the server (e.g.
Wikimedia\Rdbms\IDatabase\getTopologyRootMaster
getTopologyRootMaster()
Get the readable name of the sole root master server for the replication topology.
Wikimedia\Rdbms\IDatabase\select
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
Wikimedia\Rdbms\IDatabase\getLBInfo
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Wikimedia\Rdbms\IDatabase\newSelectQueryBuilder
newSelectQueryBuilder()
Create an empty SelectQueryBuilder which can be used to run queries against this connection.
Wikimedia\Rdbms\IDatabase\timestampOrNull
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
Wikimedia\Rdbms\IDatabase\buildGroupConcatField
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
Wikimedia\Rdbms\IDatabase\serverIsReadOnly
serverIsReadOnly()
Wikimedia\Rdbms\IDatabase\estimateRowCount
estimateRowCount( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Estimate the number of rows in dataset.
Wikimedia\Rdbms\IDatabase\dataSeek
dataSeek( $res, $row)
Change the position of the cursor in a result object.
Wikimedia\Rdbms\IDatabase\getTopologyBasedServerId
getTopologyBasedServerId()
Get a non-recycled ID that uniquely identifies this server within the replication topology.
Wikimedia\Rdbms\IDatabase\buildIntegerCast
buildIntegerCast( $field)
Wikimedia\Rdbms\IDatabase\insertId
insertId()
Get the inserted value of an auto-increment row.
Wikimedia\Rdbms\IDatabase\onTransactionResolution
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback when the current transaction commits or rolls back.
Wikimedia\Rdbms\IDatabase\addIdentifierQuotes
addIdentifierQuotes( $s)
Escape a SQL identifier (e.g.
Wikimedia\Rdbms\IDatabase\setSessionOptions
setSessionOptions(array $options)
Override database's default behavior.
Wikimedia\Rdbms\IDatabase\buildLike
buildLike( $param,... $params)
LIKE statement wrapper.
DBO_DEFAULT
const DBO_DEFAULT
Definition: defines.php:13
Wikimedia\Rdbms\IDatabase\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Wikimedia\Rdbms\IDatabase\nextSequenceValue
nextSequenceValue( $seqName)
Deprecated method, calls should be removed.
Wikimedia\Rdbms\IDatabase\makeList
makeList(array $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
Wikimedia\Rdbms\IDatabase\restoreFlags
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
Wikimedia\Rdbms\IDatabase\begin
begin( $fname=__METHOD__, $mode=self::TRANSACTION_EXPLICIT)
Begin a transaction.
Wikimedia\Rdbms\IDatabase\commit
commit( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Commits a transaction previously started using begin()
Wikimedia\Rdbms\IDatabase\indexExists
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists.
Wikimedia\Rdbms\IDatabase\flushSnapshot
flushSnapshot( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Commit any transaction but error out if writes or callbacks are pending.
Wikimedia\Rdbms\IDatabase\clearFlag
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
Wikimedia\Rdbms\IDatabase\pendingWriteRowsAffected
pendingWriteRowsAffected()
Get the number of affected rows from pending write queries.
Wikimedia\Rdbms\IDatabase\namedLocksEnqueue
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
$type
$type
Definition: testCompression.php:52
Wikimedia\Rdbms\IDatabase\startAtomic
startAtomic( $fname=__METHOD__, $cancelable=self::ATOMIC_NOT_CANCELABLE)
Begin an atomic section of SQL statements.
Wikimedia\Rdbms\IDatabase\writesOrCallbacksPending
writesOrCallbacksPending()
Whether there is a transaction open with either possible write queries or unresolved pre-commit/commi...