MediaWiki  1.34.0
DBConnRef.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
5 use InvalidArgumentException;
6 
29 class DBConnRef implements IDatabase {
31  private $lb;
33  private $conn;
35  private $params;
37  private $role;
38 
39  const FLD_INDEX = 0;
40  const FLD_GROUP = 1;
41  const FLD_DOMAIN = 2;
42  const FLD_FLAGS = 3;
43 
50  public function __construct( ILoadBalancer $lb, $conn, $role ) {
51  $this->lb = $lb;
52  $this->role = $role;
53  if ( $conn instanceof IDatabase && !( $conn instanceof DBConnRef ) ) {
54  $this->conn = $conn; // live handle
55  } elseif ( is_array( $conn ) && count( $conn ) >= 4 && $conn[self::FLD_DOMAIN] !== false ) {
56  $this->params = $conn;
57  } else {
58  throw new InvalidArgumentException( "Missing lazy connection arguments." );
59  }
60  }
61 
62  function __call( $name, array $arguments ) {
63  if ( $this->conn === null ) {
64  list( $index, $groups, $wiki, $flags ) = $this->params;
65  $this->conn = $this->lb->getConnection( $index, $groups, $wiki, $flags );
66  }
67 
68  return $this->conn->$name( ...$arguments );
69  }
70 
75  public function getReferenceRole() {
76  return $this->role;
77  }
78 
79  public function getServerInfo() {
80  return $this->__call( __FUNCTION__, func_get_args() );
81  }
82 
88  public function bufferResults( $buffer = null ) {
89  return $this->__call( __FUNCTION__, func_get_args() );
90  }
91 
92  public function trxLevel() {
93  return $this->__call( __FUNCTION__, func_get_args() );
94  }
95 
96  public function trxTimestamp() {
97  return $this->__call( __FUNCTION__, func_get_args() );
98  }
99 
100  public function explicitTrxActive() {
101  return $this->__call( __FUNCTION__, func_get_args() );
102  }
103 
104  public function assertNoOpenTransactions() {
105  return $this->__call( __FUNCTION__, func_get_args() );
106  }
107 
108  public function tablePrefix( $prefix = null ) {
109  if ( $this->conn === null && $prefix === null ) {
110  $domain = DatabaseDomain::newFromId( $this->params[self::FLD_DOMAIN] );
111  // Avoid triggering a database connection
112  return $domain->getTablePrefix();
113  } elseif ( $this->conn !== null && $prefix === null ) {
114  // This will just return the prefix
115  return $this->__call( __FUNCTION__, func_get_args() );
116  }
117  // Disallow things that might confuse the LoadBalancer tracking
118  throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
119  }
120 
121  public function dbSchema( $schema = null ) {
122  if ( $this->conn === null && $schema === null ) {
123  $domain = DatabaseDomain::newFromId( $this->params[self::FLD_DOMAIN] );
124  // Avoid triggering a database connection
125  return $domain->getSchema();
126  } elseif ( $this->conn !== null && $schema === null ) {
127  // This will just return the schema
128  return $this->__call( __FUNCTION__, func_get_args() );
129  }
130  // Disallow things that might confuse the LoadBalancer tracking
131  throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
132  }
133 
134  public function getLBInfo( $name = null ) {
135  return $this->__call( __FUNCTION__, func_get_args() );
136  }
137 
138  public function setLBInfo( $nameOrArray, $value = null ) {
139  // Disallow things that might confuse the LoadBalancer tracking
140  throw new DBUnexpectedError( $this, "Changing LB info is disallowed to enable reuse." );
141  }
142 
143  public function setLazyMasterHandle( IDatabase $conn ) {
144  // Disallow things that might confuse the LoadBalancer tracking
145  throw new DBUnexpectedError( $this, "Database injection is disallowed to enable reuse." );
146  }
147 
148  public function implicitOrderby() {
149  return $this->__call( __FUNCTION__, func_get_args() );
150  }
151 
152  public function lastQuery() {
153  return $this->__call( __FUNCTION__, func_get_args() );
154  }
155 
156  public function lastDoneWrites() {
157  return $this->__call( __FUNCTION__, func_get_args() );
158  }
159 
160  public function writesPending() {
161  return $this->__call( __FUNCTION__, func_get_args() );
162  }
163 
164  public function preCommitCallbacksPending() {
165  return $this->__call( __FUNCTION__, func_get_args() );
166  }
167 
168  public function writesOrCallbacksPending() {
169  return $this->__call( __FUNCTION__, func_get_args() );
170  }
171 
172  public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL ) {
173  return $this->__call( __FUNCTION__, func_get_args() );
174  }
175 
176  public function pendingWriteCallers() {
177  return $this->__call( __FUNCTION__, func_get_args() );
178  }
179 
180  public function pendingWriteRowsAffected() {
181  return $this->__call( __FUNCTION__, func_get_args() );
182  }
183 
184  public function isOpen() {
185  return $this->__call( __FUNCTION__, func_get_args() );
186  }
187 
188  public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
189  return $this->__call( __FUNCTION__, func_get_args() );
190  }
191 
192  public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
193  return $this->__call( __FUNCTION__, func_get_args() );
194  }
195 
196  public function restoreFlags( $state = self::RESTORE_PRIOR ) {
197  return $this->__call( __FUNCTION__, func_get_args() );
198  }
199 
200  public function getFlag( $flag ) {
201  return $this->__call( __FUNCTION__, func_get_args() );
202  }
203 
204  public function getProperty( $name ) {
205  return $this->__call( __FUNCTION__, func_get_args() );
206  }
207 
208  public function getDomainID() {
209  if ( $this->conn === null ) {
210  $domain = $this->params[self::FLD_DOMAIN];
211  // Avoid triggering a database connection
212  return $domain instanceof DatabaseDomain ? $domain->getId() : $domain;
213  }
214 
215  return $this->__call( __FUNCTION__, func_get_args() );
216  }
217 
218  public function getType() {
219  if ( $this->conn === null ) {
220  // Avoid triggering a database connection
221  if ( $this->params[self::FLD_INDEX] === ILoadBalancer::DB_MASTER ) {
222  $index = $this->lb->getWriterIndex();
223  } else {
224  $index = $this->params[self::FLD_INDEX];
225  }
226  if ( $index >= 0 ) {
227  // In theory, if $index is DB_REPLICA, the type could vary
228  return $this->lb->getServerType( $index );
229  }
230  }
231 
232  return $this->__call( __FUNCTION__, func_get_args() );
233  }
234 
235  public function fetchObject( $res ) {
236  return $this->__call( __FUNCTION__, func_get_args() );
237  }
238 
239  public function fetchRow( $res ) {
240  return $this->__call( __FUNCTION__, func_get_args() );
241  }
242 
243  public function numRows( $res ) {
244  return $this->__call( __FUNCTION__, func_get_args() );
245  }
246 
247  public function numFields( $res ) {
248  return $this->__call( __FUNCTION__, func_get_args() );
249  }
250 
251  public function fieldName( $res, $n ) {
252  return $this->__call( __FUNCTION__, func_get_args() );
253  }
254 
255  public function insertId() {
256  return $this->__call( __FUNCTION__, func_get_args() );
257  }
258 
259  public function dataSeek( $res, $row ) {
260  return $this->__call( __FUNCTION__, func_get_args() );
261  }
262 
263  public function lastErrno() {
264  return $this->__call( __FUNCTION__, func_get_args() );
265  }
266 
267  public function lastError() {
268  return $this->__call( __FUNCTION__, func_get_args() );
269  }
270 
271  public function affectedRows() {
272  return $this->__call( __FUNCTION__, func_get_args() );
273  }
274 
275  public function getSoftwareLink() {
276  return $this->__call( __FUNCTION__, func_get_args() );
277  }
278 
279  public function getServerVersion() {
280  return $this->__call( __FUNCTION__, func_get_args() );
281  }
282 
283  public function close( $fname = __METHOD__, $owner = null ) {
284  throw new DBUnexpectedError( $this->conn, 'Cannot close shared connection.' );
285  }
286 
287  public function query( $sql, $fname = __METHOD__, $flags = 0 ) {
288  if ( $this->role !== ILoadBalancer::DB_MASTER ) {
289  $flags |= IDatabase::QUERY_REPLICA_ROLE;
290  }
291 
292  return $this->__call( __FUNCTION__, [ $sql, $fname, $flags ] );
293  }
294 
295  public function freeResult( $res ) {
296  return $this->__call( __FUNCTION__, func_get_args() );
297  }
298 
299  public function selectField(
300  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
301  ) {
302  return $this->__call( __FUNCTION__, func_get_args() );
303  }
304 
305  public function selectFieldValues(
306  $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
307  ) {
308  return $this->__call( __FUNCTION__, func_get_args() );
309  }
310 
311  public function select(
312  $table, $vars, $conds = '', $fname = __METHOD__,
313  $options = [], $join_conds = []
314  ) {
315  return $this->__call( __FUNCTION__, func_get_args() );
316  }
317 
318  public function selectSQLText(
319  $table, $vars, $conds = '', $fname = __METHOD__,
320  $options = [], $join_conds = []
321  ) {
322  return $this->__call( __FUNCTION__, func_get_args() );
323  }
324 
325  public function limitResult( $sql, $limit, $offset = false ) {
326  return $this->__call( __FUNCTION__, func_get_args() );
327  }
328 
329  public function selectRow(
330  $table, $vars, $conds, $fname = __METHOD__,
331  $options = [], $join_conds = []
332  ) {
333  return $this->__call( __FUNCTION__, func_get_args() );
334  }
335 
336  public function estimateRowCount(
337  $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
338  ) {
339  return $this->__call( __FUNCTION__, func_get_args() );
340  }
341 
342  public function selectRowCount(
343  $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
344  ) {
345  return $this->__call( __FUNCTION__, func_get_args() );
346  }
347 
348  public function lockForUpdate(
349  $table, $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
350  ) {
351  $this->assertRoleAllowsWrites();
352 
353  return $this->__call( __FUNCTION__, func_get_args() );
354  }
355 
356  public function fieldExists( $table, $field, $fname = __METHOD__ ) {
357  return $this->__call( __FUNCTION__, func_get_args() );
358  }
359 
360  public function indexExists( $table, $index, $fname = __METHOD__ ) {
361  return $this->__call( __FUNCTION__, func_get_args() );
362  }
363 
364  public function tableExists( $table, $fname = __METHOD__ ) {
365  return $this->__call( __FUNCTION__, func_get_args() );
366  }
367 
368  public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
369  $this->assertRoleAllowsWrites();
370 
371  return $this->__call( __FUNCTION__, func_get_args() );
372  }
373 
374  public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {
375  $this->assertRoleAllowsWrites();
376 
377  return $this->__call( __FUNCTION__, func_get_args() );
378  }
379 
380  public function makeList( $a, $mode = self::LIST_COMMA ) {
381  return $this->__call( __FUNCTION__, func_get_args() );
382  }
383 
384  public function makeWhereFrom2d( $data, $baseKey, $subKey ) {
385  return $this->__call( __FUNCTION__, func_get_args() );
386  }
387 
388  public function aggregateValue( $valuedata, $valuename = 'value' ) {
389  return $this->__call( __FUNCTION__, func_get_args() );
390  }
391 
392  public function bitNot( $field ) {
393  return $this->__call( __FUNCTION__, func_get_args() );
394  }
395 
396  public function bitAnd( $fieldLeft, $fieldRight ) {
397  return $this->__call( __FUNCTION__, func_get_args() );
398  }
399 
400  public function bitOr( $fieldLeft, $fieldRight ) {
401  return $this->__call( __FUNCTION__, func_get_args() );
402  }
403 
404  public function buildConcat( $stringList ) {
405  return $this->__call( __FUNCTION__, func_get_args() );
406  }
407 
408  public function buildGroupConcatField(
409  $delim, $table, $field, $conds = '', $join_conds = []
410  ) {
411  return $this->__call( __FUNCTION__, func_get_args() );
412  }
413 
414  public function buildSubstring( $input, $startPosition, $length = null ) {
415  return $this->__call( __FUNCTION__, func_get_args() );
416  }
417 
418  public function buildStringCast( $field ) {
419  return $this->__call( __FUNCTION__, func_get_args() );
420  }
421 
422  public function buildIntegerCast( $field ) {
423  return $this->__call( __FUNCTION__, func_get_args() );
424  }
425 
426  public function buildSelectSubquery(
427  $table, $vars, $conds = '', $fname = __METHOD__,
428  $options = [], $join_conds = []
429  ) {
430  return $this->__call( __FUNCTION__, func_get_args() );
431  }
432 
433  public function databasesAreIndependent() {
434  return $this->__call( __FUNCTION__, func_get_args() );
435  }
436 
437  public function selectDB( $db ) {
438  // Disallow things that might confuse the LoadBalancer tracking
439  throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
440  }
441 
442  public function selectDomain( $domain ) {
443  // Disallow things that might confuse the LoadBalancer tracking
444  throw new DBUnexpectedError( $this, "Database selection is disallowed to enable reuse." );
445  }
446 
447  public function getDBname() {
448  if ( $this->conn === null ) {
449  $domain = DatabaseDomain::newFromId( $this->params[self::FLD_DOMAIN] );
450  // Avoid triggering a database connection
451  return $domain->getDatabase();
452  }
453 
454  return $this->__call( __FUNCTION__, func_get_args() );
455  }
456 
457  public function getServer() {
458  return $this->__call( __FUNCTION__, func_get_args() );
459  }
460 
461  public function addQuotes( $s ) {
462  return $this->__call( __FUNCTION__, func_get_args() );
463  }
464 
465  public function addIdentifierQuotes( $s ) {
466  return $this->__call( __FUNCTION__, func_get_args() );
467  }
468 
469  public function buildLike( $param ) {
470  return $this->__call( __FUNCTION__, func_get_args() );
471  }
472 
473  public function anyChar() {
474  return $this->__call( __FUNCTION__, func_get_args() );
475  }
476 
477  public function anyString() {
478  return $this->__call( __FUNCTION__, func_get_args() );
479  }
480 
481  public function nextSequenceValue( $seqName ) {
482  $this->assertRoleAllowsWrites();
483 
484  return $this->__call( __FUNCTION__, func_get_args() );
485  }
486 
487  public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) {
488  $this->assertRoleAllowsWrites();
489 
490  return $this->__call( __FUNCTION__, func_get_args() );
491  }
492 
493  public function upsert(
494  $table, array $rows, $uniqueIndexes, array $set, $fname = __METHOD__
495  ) {
496  $this->assertRoleAllowsWrites();
497 
498  return $this->__call( __FUNCTION__, func_get_args() );
499  }
500 
501  public function deleteJoin(
502  $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = __METHOD__
503  ) {
504  $this->assertRoleAllowsWrites();
505 
506  return $this->__call( __FUNCTION__, func_get_args() );
507  }
508 
509  public function delete( $table, $conds, $fname = __METHOD__ ) {
510  $this->assertRoleAllowsWrites();
511 
512  return $this->__call( __FUNCTION__, func_get_args() );
513  }
514 
515  public function insertSelect(
516  $destTable, $srcTable, $varMap, $conds,
517  $fname = __METHOD__, $insertOptions = [], $selectOptions = [], $selectJoinConds = []
518  ) {
519  $this->assertRoleAllowsWrites();
520 
521  return $this->__call( __FUNCTION__, func_get_args() );
522  }
523 
524  public function unionSupportsOrderAndLimit() {
525  return $this->__call( __FUNCTION__, func_get_args() );
526  }
527 
528  public function unionQueries( $sqls, $all ) {
529  return $this->__call( __FUNCTION__, func_get_args() );
530  }
531 
532  public function unionConditionPermutations(
533  $table, $vars, array $permute_conds, $extra_conds = '', $fname = __METHOD__,
534  $options = [], $join_conds = []
535  ) {
536  return $this->__call( __FUNCTION__, func_get_args() );
537  }
538 
539  public function conditional( $cond, $trueVal, $falseVal ) {
540  return $this->__call( __FUNCTION__, func_get_args() );
541  }
542 
543  public function strreplace( $orig, $old, $new ) {
544  return $this->__call( __FUNCTION__, func_get_args() );
545  }
546 
547  public function getServerUptime() {
548  return $this->__call( __FUNCTION__, func_get_args() );
549  }
550 
551  public function wasDeadlock() {
552  return $this->__call( __FUNCTION__, func_get_args() );
553  }
554 
555  public function wasLockTimeout() {
556  return $this->__call( __FUNCTION__, func_get_args() );
557  }
558 
559  public function wasConnectionLoss() {
560  return $this->__call( __FUNCTION__, func_get_args() );
561  }
562 
563  public function wasReadOnlyError() {
564  return $this->__call( __FUNCTION__, func_get_args() );
565  }
566 
567  public function wasErrorReissuable() {
568  return $this->__call( __FUNCTION__, func_get_args() );
569  }
570 
571  public function masterPosWait( DBMasterPos $pos, $timeout ) {
572  return $this->__call( __FUNCTION__, func_get_args() );
573  }
574 
575  public function getReplicaPos() {
576  return $this->__call( __FUNCTION__, func_get_args() );
577  }
578 
579  public function getMasterPos() {
580  return $this->__call( __FUNCTION__, func_get_args() );
581  }
582 
583  public function serverIsReadOnly() {
584  return $this->__call( __FUNCTION__, func_get_args() );
585  }
586 
587  public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
588  // DB_REPLICA role: caller might want to refresh cache after a REPEATABLE-READ snapshot
589  return $this->__call( __FUNCTION__, func_get_args() );
590  }
591 
592  public function onTransactionCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
593  // DB_REPLICA role: caller might want to refresh cache after a REPEATABLE-READ snapshot
594  return $this->__call( __FUNCTION__, func_get_args() );
595  }
596 
597  public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
598  return $this->onTransactionCommitOrIdle( $callback, $fname );
599  }
600 
601  public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
602  // DB_REPLICA role: caller might want to refresh cache after a cache mutex is released
603  return $this->__call( __FUNCTION__, func_get_args() );
604  }
605 
606  public function onAtomicSectionCancel( callable $callback, $fname = __METHOD__ ) {
607  return $this->__call( __FUNCTION__, func_get_args() );
608  }
609 
610  public function setTransactionListener( $name, callable $callback = null ) {
611  return $this->__call( __FUNCTION__, func_get_args() );
612  }
613 
614  public function startAtomic(
615  $fname = __METHOD__, $cancelable = IDatabase::ATOMIC_NOT_CANCELABLE
616  ) {
617  // Don't call assertRoleAllowsWrites(); caller might want a REPEATABLE-READ snapshot
618  return $this->__call( __FUNCTION__, func_get_args() );
619  }
620 
621  public function endAtomic( $fname = __METHOD__ ) {
622  // Don't call assertRoleAllowsWrites(); caller might want a REPEATABLE-READ snapshot
623  return $this->__call( __FUNCTION__, func_get_args() );
624  }
625 
626  public function cancelAtomic( $fname = __METHOD__, AtomicSectionIdentifier $sectionId = null ) {
627  // Don't call assertRoleAllowsWrites(); caller might want a REPEATABLE-READ snapshot
628  return $this->__call( __FUNCTION__, func_get_args() );
629  }
630 
631  public function doAtomicSection(
632  $fname, callable $callback, $cancelable = self::ATOMIC_NOT_CANCELABLE
633  ) {
634  // Don't call assertRoleAllowsWrites(); caller might want a REPEATABLE-READ snapshot
635  return $this->__call( __FUNCTION__, func_get_args() );
636  }
637 
638  public function begin( $fname = __METHOD__, $mode = IDatabase::TRANSACTION_EXPLICIT ) {
639  return $this->__call( __FUNCTION__, func_get_args() );
640  }
641 
642  public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
643  return $this->__call( __FUNCTION__, func_get_args() );
644  }
645 
646  public function rollback( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
647  return $this->__call( __FUNCTION__, func_get_args() );
648  }
649 
650  public function flushSnapshot( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
651  return $this->__call( __FUNCTION__, func_get_args() );
652  }
653 
654  public function timestamp( $ts = 0 ) {
655  return $this->__call( __FUNCTION__, func_get_args() );
656  }
657 
658  public function timestampOrNull( $ts = null ) {
659  return $this->__call( __FUNCTION__, func_get_args() );
660  }
661 
662  public function ping( &$rtt = null ) {
663  return func_num_args()
664  ? $this->__call( __FUNCTION__, [ &$rtt ] )
665  : $this->__call( __FUNCTION__, [] ); // method cares about null vs missing
666  }
667 
668  public function getLag() {
669  return $this->__call( __FUNCTION__, func_get_args() );
670  }
671 
672  public function getSessionLagStatus() {
673  return $this->__call( __FUNCTION__, func_get_args() );
674  }
675 
676  public function maxListLen() {
677  return $this->__call( __FUNCTION__, func_get_args() );
678  }
679 
680  public function encodeBlob( $b ) {
681  return $this->__call( __FUNCTION__, func_get_args() );
682  }
683 
684  public function decodeBlob( $b ) {
685  return $this->__call( __FUNCTION__, func_get_args() );
686  }
687 
688  public function setSessionOptions( array $options ) {
689  return $this->__call( __FUNCTION__, func_get_args() );
690  }
691 
692  public function setSchemaVars( $vars ) {
693  return $this->__call( __FUNCTION__, func_get_args() );
694  }
695 
696  public function lockIsFree( $lockName, $method ) {
697  $this->assertRoleAllowsWrites();
698 
699  return $this->__call( __FUNCTION__, func_get_args() );
700  }
701 
702  public function lock( $lockName, $method, $timeout = 5 ) {
703  $this->assertRoleAllowsWrites();
704 
705  return $this->__call( __FUNCTION__, func_get_args() );
706  }
707 
708  public function unlock( $lockName, $method ) {
709  $this->assertRoleAllowsWrites();
710 
711  return $this->__call( __FUNCTION__, func_get_args() );
712  }
713 
714  public function getScopedLockAndFlush( $lockKey, $fname, $timeout ) {
715  $this->assertRoleAllowsWrites();
716 
717  return $this->__call( __FUNCTION__, func_get_args() );
718  }
719 
720  public function namedLocksEnqueue() {
721  return $this->__call( __FUNCTION__, func_get_args() );
722  }
723 
724  public function getInfinity() {
725  return $this->__call( __FUNCTION__, func_get_args() );
726  }
727 
728  public function encodeExpiry( $expiry ) {
729  return $this->__call( __FUNCTION__, func_get_args() );
730  }
731 
732  public function decodeExpiry( $expiry, $format = TS_MW ) {
733  return $this->__call( __FUNCTION__, func_get_args() );
734  }
735 
736  public function setBigSelects( $value = true ) {
737  return $this->__call( __FUNCTION__, func_get_args() );
738  }
739 
740  public function isReadOnly() {
741  return $this->__call( __FUNCTION__, func_get_args() );
742  }
743 
744  public function setTableAliases( array $aliases ) {
745  return $this->__call( __FUNCTION__, func_get_args() );
746  }
747 
748  public function setIndexAliases( array $aliases ) {
749  return $this->__call( __FUNCTION__, func_get_args() );
750  }
751 
752  public function __toString() {
753  if ( $this->conn === null ) {
754  // spl_object_id is PHP >= 7.2
755  $id = function_exists( 'spl_object_id' )
756  ? spl_object_id( $this )
757  : spl_object_hash( $this );
758 
759  return $this->getType() . ' object #' . $id;
760  }
761 
762  return $this->__call( __FUNCTION__, func_get_args() );
763  }
764 
778  protected function assertRoleAllowsWrites() {
779  // DB_MASTER is "prima facie" writable
780  if ( $this->role !== ILoadBalancer::DB_MASTER ) {
781  throw new DBReadOnlyRoleError( $this->conn, "Cannot write with role DB_REPLICA" );
782  }
783  }
784 
788  function __destruct() {
789  if ( $this->conn ) {
790  $this->lb->reuseConnection( $this->conn );
791  }
792  }
793 }
794 
799 class_alias( DBConnRef::class, 'DBConnRef' );
Wikimedia\Rdbms\DBConnRef\isOpen
isOpen()
Definition: DBConnRef.php:184
Wikimedia\Rdbms\DBConnRef\explicitTrxActive
explicitTrxActive()
Definition: DBConnRef.php:100
Wikimedia\Rdbms\DBConnRef\affectedRows
affectedRows()
Get the number of rows affected by the last write query.
Definition: DBConnRef.php:271
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:49
Wikimedia\Rdbms\DBConnRef\strreplace
strreplace( $orig, $old, $new)
Returns a SQL expression for simple string replacement (e.g.
Definition: DBConnRef.php:543
Wikimedia\Rdbms\DBConnRef\FLD_FLAGS
const FLD_FLAGS
Definition: DBConnRef.php:42
Wikimedia\Rdbms\DBConnRef\getType
getType()
Get the type of the DBMS (e.g.
Definition: DBConnRef.php:218
Wikimedia\Rdbms\DatabaseDomain\getId
getId()
Definition: DatabaseDomain.php:196
Wikimedia\Rdbms\DatabaseDomain\newFromId
static newFromId( $domain)
Definition: DatabaseDomain.php:77
Wikimedia\Rdbms\DBConnRef\buildGroupConcatField
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
Definition: DBConnRef.php:408
Wikimedia\Rdbms\DBConnRef\query
query( $sql, $fname=__METHOD__, $flags=0)
Run an SQL query and return the result.
Definition: DBConnRef.php:287
Wikimedia\Rdbms\DBConnRef\nextSequenceValue
nextSequenceValue( $seqName)
Deprecated method, calls should be removed.
Definition: DBConnRef.php:481
Wikimedia\Rdbms\DBConnRef\assertNoOpenTransactions
assertNoOpenTransactions()
Assert that all explicit transactions or atomic sections have been closed.
Definition: DBConnRef.php:104
Wikimedia\Rdbms\DBConnRef\decodeExpiry
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
Definition: DBConnRef.php:732
Wikimedia\Rdbms\DBConnRef\setSessionOptions
setSessionOptions(array $options)
Override database's default behavior.
Definition: DBConnRef.php:688
Wikimedia\Rdbms\DBConnRef\selectDomain
selectDomain( $domain)
Set the current domain (database, schema, and table prefix)
Definition: DBConnRef.php:442
Wikimedia\Rdbms\DBConnRef\makeList
makeList( $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
Definition: DBConnRef.php:380
Wikimedia\Rdbms\DBConnRef\serverIsReadOnly
serverIsReadOnly()
Definition: DBConnRef.php:583
Wikimedia\Rdbms\DBConnRef\tableExists
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
Definition: DBConnRef.php:364
Wikimedia\Rdbms\DBConnRef\anyString
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
Definition: DBConnRef.php:477
Wikimedia\Rdbms\DBConnRef\selectRowCount
selectRowCount( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
Definition: DBConnRef.php:342
Wikimedia\Rdbms\DBConnRef\conditional
conditional( $cond, $trueVal, $falseVal)
Returns an SQL expression for a simple conditional.
Definition: DBConnRef.php:539
Wikimedia\Rdbms\DBReadOnlyRoleError
Exception class for attempted DB write access to a DBConnRef with the DB_REPLICA role.
Definition: DBReadOnlyRoleError.php:29
Wikimedia\Rdbms\DBConnRef\timestampOrNull
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
Definition: DBConnRef.php:658
Wikimedia\Rdbms\DBConnRef\dataSeek
dataSeek( $res, $row)
Change the position of the cursor in a result object.
Definition: DBConnRef.php:259
Wikimedia\Rdbms\DBConnRef\getDomainID
getDomainID()
Return the currently selected domain ID.
Definition: DBConnRef.php:208
Wikimedia\Rdbms\DBConnRef\$lb
ILoadBalancer $lb
Definition: DBConnRef.php:31
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\DBConnRef\$params
array null $params
N-tuple of (server index, group, DatabaseDomain|string)
Definition: DBConnRef.php:35
Wikimedia\Rdbms\DBConnRef\unionSupportsOrderAndLimit
unionSupportsOrderAndLimit()
Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION.
Definition: DBConnRef.php:524
Wikimedia\Rdbms\DBMasterPos
An object representing a master or replica DB position in a replicated setup.
Definition: DBMasterPos.php:12
Wikimedia\Rdbms\DBConnRef\buildStringCast
buildStringCast( $field)
Definition: DBConnRef.php:418
Wikimedia\Rdbms\DBConnRef\getLag
getLag()
Get the amount of replication lag for this database server.
Definition: DBConnRef.php:668
Wikimedia\Rdbms\DBConnRef\bufferResults
bufferResults( $buffer=null)
Definition: DBConnRef.php:88
Wikimedia\Rdbms\DBConnRef\pendingWriteCallers
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
Definition: DBConnRef.php:176
Wikimedia\Rdbms\DBConnRef\buildSelectSubquery
buildSelectSubquery( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Equivalent to IDatabase::selectSQLText() except wraps the result in Subqyery.
Definition: DBConnRef.php:426
Wikimedia\Rdbms\DBConnRef\rollback
rollback( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Rollback a transaction previously started using begin()
Definition: DBConnRef.php:646
$s
$s
Definition: mergeMessageFileList.php:185
Wikimedia\Rdbms\DBConnRef\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Definition: DBConnRef.php:188
Wikimedia\Rdbms\DBConnRef\maxListLen
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
Definition: DBConnRef.php:676
Wikimedia\Rdbms\DBConnRef\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
Definition: DBConnRef.php:368
Wikimedia\Rdbms\DBConnRef\getSessionLagStatus
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
Definition: DBConnRef.php:672
Wikimedia\Rdbms\DBConnRef\implicitOrderby
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Definition: DBConnRef.php:148
$res
$res
Definition: testCompression.php:52
Wikimedia\Rdbms\DBConnRef\lastError
lastError()
Get a description of the last error.
Definition: DBConnRef.php:267
Wikimedia\Rdbms\DBConnRef\getFlag
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
Definition: DBConnRef.php:200
Wikimedia\Rdbms\DBConnRef\wasLockTimeout
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
Definition: DBConnRef.php:555
Wikimedia\Rdbms\DBConnRef\doAtomicSection
doAtomicSection( $fname, callable $callback, $cancelable=self::ATOMIC_NOT_CANCELABLE)
Perform an atomic section of reversable SQL statements from a callback.
Definition: DBConnRef.php:631
Wikimedia\Rdbms\DBConnRef\upsert
upsert( $table, array $rows, $uniqueIndexes, array $set, $fname=__METHOD__)
INSERT ON DUPLICATE KEY UPDATE wrapper, upserts an array into a table.
Definition: DBConnRef.php:493
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\DBConnRef\getLBInfo
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Definition: DBConnRef.php:134
Wikimedia\Rdbms\DBConnRef\replace
replace( $table, $uniqueIndexes, $rows, $fname=__METHOD__)
REPLACE query wrapper.
Definition: DBConnRef.php:487
Wikimedia\Rdbms\DBConnRef\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Definition: DBConnRef.php:744
Wikimedia\Rdbms\DBConnRef\getProperty
getProperty( $name)
Definition: DBConnRef.php:204
Wikimedia\Rdbms\DBConnRef\preCommitCallbacksPending
preCommitCallbacksPending()
Definition: DBConnRef.php:164
Wikimedia\Rdbms\DBConnRef\getInfinity
getInfinity()
Find out when 'infinity' is.
Definition: DBConnRef.php:724
Wikimedia\Rdbms\DBConnRef\pendingWriteQueryDuration
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
Definition: DBConnRef.php:172
Wikimedia\Rdbms\DBConnRef\addIdentifierQuotes
addIdentifierQuotes( $s)
Escape a SQL identifier (e.g.
Definition: DBConnRef.php:465
Wikimedia\Rdbms\DBConnRef\select
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
Definition: DBConnRef.php:311
Wikimedia\Rdbms\DBConnRef\insertSelect
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[])
INSERT SELECT wrapper.
Definition: DBConnRef.php:515
Wikimedia\Rdbms\DBConnRef\buildIntegerCast
buildIntegerCast( $field)
Definition: DBConnRef.php:422
Wikimedia\Rdbms\DBConnRef\$conn
Database null $conn
Live connection handle.
Definition: DBConnRef.php:33
Wikimedia\Rdbms\DBConnRef\selectRow
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Wrapper to IDatabase::select() that only fetches one row (via LIMIT)
Definition: DBConnRef.php:329
Wikimedia\Rdbms\DBConnRef\onAtomicSectionCancel
onAtomicSectionCancel(callable $callback, $fname=__METHOD__)
Run a callback when the atomic section is cancelled.
Definition: DBConnRef.php:606
Wikimedia\Rdbms\DBConnRef\getScopedLockAndFlush
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
Definition: DBConnRef.php:714
Wikimedia\Rdbms\DBConnRef\getServerInfo
getServerInfo()
Get a human-readable string describing the current software version.
Definition: DBConnRef.php:79
Wikimedia\Rdbms\DBConnRef\indexExists
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists.
Definition: DBConnRef.php:360
Wikimedia\Rdbms\DBConnRef\encodeExpiry
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
Definition: DBConnRef.php:728
Wikimedia\Rdbms\DBConnRef\wasDeadlock
wasDeadlock()
Determines if the last failure was due to a deadlock.
Definition: DBConnRef.php:551
Wikimedia\Rdbms\DBConnRef\selectSQLText
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Take the same arguments as IDatabase::select() and return the SQL it would use.
Definition: DBConnRef.php:318
Wikimedia\Rdbms\DBConnRef\writesOrCallbacksPending
writesOrCallbacksPending()
Whether there is a transaction open with either possible write queries or unresolved pre-commit/commi...
Definition: DBConnRef.php:168
Wikimedia\Rdbms\DBConnRef\__destruct
__destruct()
Clean up the connection when out of scope.
Definition: DBConnRef.php:788
Wikimedia\Rdbms\DBConnRef\fetchObject
fetchObject( $res)
Fetch the next row from the given result object, in object form.
Definition: DBConnRef.php:235
Wikimedia\Rdbms\DBConnRef\selectFieldValues
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
Definition: DBConnRef.php:305
Wikimedia\Rdbms\DBConnRef\anyChar
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
Definition: DBConnRef.php:473
Wikimedia\Rdbms\DBConnRef\startAtomic
startAtomic( $fname=__METHOD__, $cancelable=IDatabase::ATOMIC_NOT_CANCELABLE)
Begin an atomic section of SQL statements.
Definition: DBConnRef.php:614
Wikimedia\Rdbms\DBConnRef\endAtomic
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
Definition: DBConnRef.php:621
Wikimedia\Rdbms\DBConnRef\unlock
unlock( $lockName, $method)
Release a lock.
Definition: DBConnRef.php:708
Wikimedia\Rdbms\DBConnRef\setSchemaVars
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
Definition: DBConnRef.php:692
Wikimedia\Rdbms\DBConnRef\tablePrefix
tablePrefix( $prefix=null)
Get/set the table prefix.
Definition: DBConnRef.php:108
Wikimedia\Rdbms\DBConnRef\buildSubstring
buildSubstring( $input, $startPosition, $length=null)
Definition: DBConnRef.php:414
Wikimedia\Rdbms\DBConnRef\writesPending
writesPending()
Definition: DBConnRef.php:160
Wikimedia\Rdbms\DBConnRef\getServer
getServer()
Get the server hostname or IP address.
Definition: DBConnRef.php:457
Wikimedia\Rdbms\DBConnRef\buildLike
buildLike( $param)
LIKE statement wrapper.
Definition: DBConnRef.php:469
Wikimedia\Rdbms\DBConnRef\lock
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
Definition: DBConnRef.php:702
Wikimedia\Rdbms\DBConnRef\estimateRowCount
estimateRowCount( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Estimate the number of rows in dataset.
Definition: DBConnRef.php:336
Wikimedia\Rdbms\DBConnRef\setLBInfo
setLBInfo( $nameOrArray, $value=null)
Set the entire array or a particular key of the managing load balancer info array.
Definition: DBConnRef.php:138
DB_MASTER
const DB_MASTER
Definition: defines.php:26
Wikimedia\Rdbms\DBConnRef\fieldExists
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
Definition: DBConnRef.php:356
Wikimedia\Rdbms\DBConnRef\selectDB
selectDB( $db)
Change the current database.
Definition: DBConnRef.php:437
Wikimedia\Rdbms\DBConnRef\commit
commit( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Commits a transaction previously started using begin()
Definition: DBConnRef.php:642
Wikimedia\Rdbms\DBConnRef\setLazyMasterHandle
setLazyMasterHandle(IDatabase $conn)
Set a lazy-connecting DB handle to the master DB (for replication status purposes)
Definition: DBConnRef.php:143
Wikimedia\Rdbms\DBConnRef\limitResult
limitResult( $sql, $limit, $offset=false)
Construct a LIMIT query with optional offset.
Definition: DBConnRef.php:325
Wikimedia\Rdbms\DBConnRef\fieldName
fieldName( $res, $n)
Get a field name in a result object.
Definition: DBConnRef.php:251
Wikimedia\Rdbms\DBConnRef\bitNot
bitNot( $field)
Definition: DBConnRef.php:392
LIST_COMMA
const LIST_COMMA
Definition: Defines.php:38
Wikimedia\Rdbms\DBConnRef\onTransactionCommitOrIdle
onTransactionCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
Definition: DBConnRef.php:592
Wikimedia\Rdbms\DBConnRef\restoreFlags
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
Definition: DBConnRef.php:196
Wikimedia\Rdbms\DBConnRef\lastQuery
lastQuery()
Get the last query that sent on account of IDatabase::query()
Definition: DBConnRef.php:152
Wikimedia\Rdbms\DBConnRef\getServerUptime
getServerUptime()
Determines how long the server has been up.
Definition: DBConnRef.php:547
Wikimedia\Rdbms\DBConnRef\getDBname
getDBname()
Get the current DB name.
Definition: DBConnRef.php:447
Wikimedia\Rdbms\DBConnRef\pendingWriteRowsAffected
pendingWriteRowsAffected()
Get the number of affected rows from pending write queries.
Definition: DBConnRef.php:180
Wikimedia\Rdbms\DBConnRef\decodeBlob
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
Definition: DBConnRef.php:684
Wikimedia\Rdbms\DBConnRef\lastDoneWrites
lastDoneWrites()
Get the last time the connection may have been used for a write query.
Definition: DBConnRef.php:156
Wikimedia\Rdbms\DBConnRef\FLD_GROUP
const FLD_GROUP
Definition: DBConnRef.php:40
Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites
assertRoleAllowsWrites()
Error out if the role is not DB_MASTER.
Definition: DBConnRef.php:778
Wikimedia\Rdbms\DBConnRef\trxTimestamp
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
Definition: DBConnRef.php:96
Wikimedia\Rdbms\DBConnRef\unionConditionPermutations
unionConditionPermutations( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Construct a UNION query for permutations of conditions.
Definition: DBConnRef.php:532
Wikimedia\Rdbms\DBConnRef\trxLevel
trxLevel()
Gets the current transaction level.
Definition: DBConnRef.php:92
Wikimedia\Rdbms\DBConnRef\getSoftwareLink
getSoftwareLink()
Returns a wikitext style link to the DB's website (e.g.
Definition: DBConnRef.php:275
Wikimedia\Rdbms\DBConnRef\FLD_INDEX
const FLD_INDEX
Definition: DBConnRef.php:39
Wikimedia\Rdbms\DBConnRef\addQuotes
addQuotes( $s)
Escape and quote a raw value string for use in a SQL query.
Definition: DBConnRef.php:461
Wikimedia\Rdbms\AtomicSectionIdentifier
Class used for token representing identifiers for atomic sections from IDatabase instances.
Definition: AtomicSectionIdentifier.php:26
Wikimedia\Rdbms\DBConnRef\$role
int $role
One of DB_MASTER/DB_REPLICA.
Definition: DBConnRef.php:37
Wikimedia\Rdbms\DBConnRef\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for ins...
Definition: DBConnRef.php:654
Wikimedia\Rdbms\DBConnRef\wasReadOnlyError
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
Definition: DBConnRef.php:563
Wikimedia\Rdbms\DBConnRef\encodeBlob
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
Definition: DBConnRef.php:680
Wikimedia\Rdbms\DBConnRef\onTransactionResolution
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
Definition: DBConnRef.php:587
Wikimedia\Rdbms\DBConnRef\freeResult
freeResult( $res)
Free a result object returned by query() or select()
Definition: DBConnRef.php:295
Wikimedia\Rdbms\DBConnRef\buildConcat
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
Definition: DBConnRef.php:404
Wikimedia\Rdbms\DBConnRef\selectField
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
Definition: DBConnRef.php:299
Wikimedia\Rdbms\DBConnRef\makeWhereFrom2d
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
Definition: DBConnRef.php:384
Wikimedia\Rdbms\DBConnRef\setTransactionListener
setTransactionListener( $name, callable $callback=null)
Run a callback after each time any transaction commits or rolls back.
Definition: DBConnRef.php:610
Wikimedia\Rdbms\DBConnRef\lockForUpdate
lockForUpdate( $table, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Lock all rows meeting the given conditions/options FOR UPDATE.
Definition: DBConnRef.php:348
Wikimedia\Rdbms\DBConnRef\bitOr
bitOr( $fieldLeft, $fieldRight)
Definition: DBConnRef.php:400
Wikimedia\Rdbms\DBConnRef\setBigSelects
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
Definition: DBConnRef.php:736
Wikimedia\Rdbms\DBUnexpectedError
Definition: DBUnexpectedError.php:27
Wikimedia\Rdbms\DBConnRef\numRows
numRows( $res)
Get the number of rows in a query result.
Definition: DBConnRef.php:243
Wikimedia\Rdbms\DBConnRef\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Definition: DBConnRef.php:374
Wikimedia\Rdbms\DBConnRef\dbSchema
dbSchema( $schema=null)
Get/set the db schema.
Definition: DBConnRef.php:121
Wikimedia\Rdbms\DBConnRef
Helper class used for automatically marking an IDatabase connection as reusable (once it no longer ma...
Definition: DBConnRef.php:29
Wikimedia\Rdbms\DBConnRef\getReplicaPos
getReplicaPos()
Get the replication position of this replica DB.
Definition: DBConnRef.php:575
Wikimedia\Rdbms\DBConnRef\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Definition: DBConnRef.php:748
Wikimedia\Rdbms\DBConnRef\ping
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
Definition: DBConnRef.php:662
Wikimedia\Rdbms\DBConnRef\masterPosWait
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
Definition: DBConnRef.php:571
Wikimedia\Rdbms\DBConnRef\getReferenceRole
getReferenceRole()
Definition: DBConnRef.php:75
Wikimedia\Rdbms\DBConnRef\deleteJoin
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Definition: DBConnRef.php:501
Wikimedia\Rdbms\DBConnRef\unionQueries
unionQueries( $sqls, $all)
Construct a UNION query.
Definition: DBConnRef.php:528
Wikimedia\Rdbms\DBConnRef\onTransactionPreCommitOrIdle
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
Definition: DBConnRef.php:601
Wikimedia\Rdbms\DBConnRef\insertId
insertId()
Get the inserted value of an auto-increment row.
Definition: DBConnRef.php:255
Wikimedia\Rdbms\DBConnRef\isReadOnly
isReadOnly()
Definition: DBConnRef.php:740
Wikimedia\Rdbms\DBConnRef\getMasterPos
getMasterPos()
Get the position of this master.
Definition: DBConnRef.php:579
Wikimedia\Rdbms\DBConnRef\databasesAreIndependent
databasesAreIndependent()
Returns true if DBs are assumed to be on potentially different servers.
Definition: DBConnRef.php:433
Wikimedia\Rdbms\DBConnRef\wasConnectionLoss
wasConnectionLoss()
Determines if the last query error was due to a dropped connection.
Definition: DBConnRef.php:559
Wikimedia\Rdbms\DBConnRef\FLD_DOMAIN
const FLD_DOMAIN
Definition: DBConnRef.php:41
Wikimedia\Rdbms\DBConnRef\numFields
numFields( $res)
Get the number of fields in a result object.
Definition: DBConnRef.php:247
Wikimedia\Rdbms\DBConnRef\__construct
__construct(ILoadBalancer $lb, $conn, $role)
Definition: DBConnRef.php:50
Wikimedia\Rdbms\DatabaseDomain
Class to handle database/schema/prefix specifications for IDatabase.
Definition: DatabaseDomain.php:40
Wikimedia\Rdbms\DBConnRef\flushSnapshot
flushSnapshot( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
Commit any transaction but error out if writes or callbacks are pending.
Definition: DBConnRef.php:650
Wikimedia\Rdbms\DBConnRef\clearFlag
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
Definition: DBConnRef.php:192
Wikimedia\Rdbms\DBConnRef\lockIsFree
lockIsFree( $lockName, $method)
Check to see if a named lock is not locked by any thread (non-blocking)
Definition: DBConnRef.php:696
Wikimedia\Rdbms\DBConnRef\close
close( $fname=__METHOD__, $owner=null)
Close the database connection.
Definition: DBConnRef.php:283
Wikimedia\Rdbms\DBConnRef\onTransactionIdle
onTransactionIdle(callable $callback, $fname=__METHOD__)
Alias for onTransactionCommitOrIdle() for backwards-compatibility.
Definition: DBConnRef.php:597
Wikimedia\Rdbms\DBConnRef\fetchRow
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
Definition: DBConnRef.php:239
Wikimedia\Rdbms\DBConnRef\lastErrno
lastErrno()
Get the last error number.
Definition: DBConnRef.php:263
Wikimedia\Rdbms\DBConnRef\namedLocksEnqueue
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
Definition: DBConnRef.php:720
Wikimedia\Rdbms\DBConnRef\__toString
__toString()
Get a debugging string that mentions the database type, the ID of this instance, and the ID of any un...
Definition: DBConnRef.php:752
Wikimedia\Rdbms\DBConnRef\getServerVersion
getServerVersion()
A string describing the current software version, like from mysql_get_server_info()
Definition: DBConnRef.php:279
Wikimedia\Rdbms\DBConnRef\begin
begin( $fname=__METHOD__, $mode=IDatabase::TRANSACTION_EXPLICIT)
Begin a transaction.
Definition: DBConnRef.php:638
Wikimedia\Rdbms\DBConnRef\wasErrorReissuable
wasErrorReissuable()
Determines if the last query error was due to something outside of the query itself.
Definition: DBConnRef.php:567
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
Wikimedia\Rdbms\DBConnRef\bitAnd
bitAnd( $fieldLeft, $fieldRight)
Definition: DBConnRef.php:396
Wikimedia\Rdbms\DBConnRef\__call
__call( $name, array $arguments)
Definition: DBConnRef.php:62
Wikimedia\Rdbms\DBConnRef\aggregateValue
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
Definition: DBConnRef.php:388
$type
$type
Definition: testCompression.php:48
Wikimedia\Rdbms\DBConnRef\cancelAtomic
cancelAtomic( $fname=__METHOD__, AtomicSectionIdentifier $sectionId=null)
Cancel an atomic section of SQL statements.
Definition: DBConnRef.php:626