* Either a short hexidecimal string if a transaction is active or ""
*
* @var string
+ * @see DatabaseBase::mTrxLevel
*/
protected $mTrxShortId = '';
+ /**
+ * The UNIX time that the transaction started. Callers can assume that if
+ * snapshot isolation is used, then the data is *at least* up to date to that
+ * point (possibly more up-to-date since the first SELECT defines the snapshot).
+ *
+ * @var float|null
+ * @see DatabaseBase::mTrxLevel
+ */
+ private $mTrxTimestamp = null;
+
/**
* Remembers the function name given for starting the most recent transaction via begin().
* Used to provide additional context for error reporting.
return $this->mTrxLevel;
}
+ /**
+ * Get the UNIX timestamp of the time that the transaction was established
+ *
+ * This can be used to reason about the staleness of SELECT data
+ * in REPEATABLE-READ transaction isolation level.
+ *
+ * @return float|null Returns null if there is not active transaction
+ * @since 1.25
+ */
+ public function trxTimestamp() {
+ return $this->mTrxLevel ? $this->mTrxTimestamp : null;
+ }
+
/**
* Get/set the number of errors logged. Only useful when errors are ignored
* @param int $count The count to set, or omitted to leave it unchanged.
# Split database and table into proper variables.
# We reverse the explode so that database.table and table both output
# the correct table.
- $dbDetails = explode( '.', $name, 2 );
+ $dbDetails = explode( '.', $name, 3 );
if ( count( $dbDetails ) == 3 ) {
list( $database, $schema, $table ) = $dbDetails;
# We don't want any prefix added in this case
}
$this->doBegin( $fname );
+ $this->mTrxTimestamp = microtime( true );
$this->mTrxFname = $fname;
$this->mTrxDoneWrites = false;
$this->mTrxAutomatic = false;