Merge "Force User::__toString() return value to be string"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / IDatabase.php
index 29a32f5..c80fdec 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @defgroup Database Database
  *
  * @file
  * @ingroup Database
  */
+use Wikimedia\ScopedCallback;
 
 /**
- * Basic database interface for live and lazy-loaded DB handles
+ * Basic database interface for live and lazy-loaded relation database handles
  *
  * @note: IDatabase and DBConnRef should be updated to reflect any changes
  * @ingroup Database
@@ -74,6 +74,27 @@ interface IDatabase {
        /** @var int Combine list with OR clauses */
        const LIST_OR = 4;
 
+       /** @var int Enable debug logging */
+       const DBO_DEBUG = 1;
+       /** @var int Disable query buffering (only one result set can be iterated at a time) */
+       const DBO_NOBUFFER = 2;
+       /** @var int Ignore query errors (internal use only!) */
+       const DBO_IGNORE = 4;
+       /** @var int Autoatically start transaction on first query (work with ILoadBalancer rounds) */
+       const DBO_TRX = 8;
+       /** @var int Use DBO_TRX in non-CLI mode */
+       const DBO_DEFAULT = 16;
+       /** @var int Use DB persistent connections if possible */
+       const DBO_PERSISTENT = 32;
+       /** @var int DBA session mode; mostly for Oracle */
+       const DBO_SYSDBA = 64;
+       /** @var int Schema file mode; mostly for Oracle */
+       const DBO_DDLMODE = 128;
+       /** @var int Enable SSL/TLS in connection protocol */
+       const DBO_SSL = 256;
+       /** @var int Enable compression in connection protocol */
+       const DBO_COMPRESS = 512;
+
        /**
         * A string describing the current software version, and possibly
         * other details in a user-friendly way. Will be listed on Special:Version, etc.
@@ -84,15 +105,14 @@ interface IDatabase {
        public function getServerInfo();
 
        /**
-        * Turns buffering of SQL result sets on (true) or off (false). Default is
-        * "on".
+        * Turns buffering of SQL result sets on (true) or off (false). Default is "on".
         *
         * Unbuffered queries are very troublesome in MySQL:
         *
         *   - If another query is executed while the first query is being read
         *     out, the first query is killed. This means you can't call normal
-        *     MediaWiki functions while you are reading an unbuffered query result
-        *     from a normal wfGetDB() connection.
+        *     Database functions while you are reading an unbuffered query result
+        *     from a normal Database connection.
         *
         *   - Unbuffered queries cause the MySQL server to use large amounts of
         *     memory and to hold broad locks which block other queries.
@@ -302,14 +322,6 @@ interface IDatabase {
         */
        public function getFlag( $flag );
 
-       /**
-        * General read-only accessor
-        *
-        * @param string $name
-        * @return string
-        */
-       public function getProperty( $name );
-
        /**
         * @return string
         */
@@ -594,7 +606,7 @@ interface IDatabase {
         * for use in field names (e.g. a.user_name).
         *
         * All of the table names given here are automatically run through
-        * DatabaseBase::tableName(), which causes the table prefix (if any) to be
+        * Database::tableName(), which causes the table prefix (if any) to be
         * added, and various other table name mappings to be performed.
         *
         * Do not use untrusted user input as a table name. Alias names should
@@ -657,7 +669,7 @@ interface IDatabase {
         *
         *   - OFFSET: Skip this many rows at the start of the result set. OFFSET
         *     with LIMIT can theoretically be used for paging through a result set,
-        *     but this is discouraged in MediaWiki for performance reasons.
+        *     but this is discouraged for performance reasons.
         *
         *   - LIMIT: Integer: return at most this many rows. The rows are sorted
         *     and then the first rows are taken until the limit is reached. LIMIT
@@ -876,7 +888,7 @@ interface IDatabase {
         *     IDatabase::affectedRows().
         *
         * @param string $table Table name. This will be passed through
-        *   DatabaseBase::tableName().
+        *   Database::tableName().
         * @param array $a Array of rows to insert
         * @param string $fname Calling function name (use __METHOD__) for logs/profiling
         * @param array $options Array of options
@@ -889,7 +901,7 @@ interface IDatabase {
         * UPDATE wrapper. Takes a condition array and a SET array.
         *
         * @param string $table Name of the table to UPDATE. This will be passed through
-        *   DatabaseBase::tableName().
+        *   Database::tableName().
         * @param array $values An array of values to SET. For each array element,
         *   the key gives the field name, and the value gives the data to set
         *   that field to. The data will be quoted by IDatabase::addQuotes().
@@ -944,6 +956,16 @@ interface IDatabase {
         */
        public function makeWhereFrom2d( $data, $baseKey, $subKey );
 
+       /**
+        * Return aggregated value alias
+        *
+        * @param array $valuedata
+        * @param string $valuename
+        *
+        * @return string
+        */
+       public function aggregateValue( $valuedata, $valuename = 'value' );
+
        /**
         * @param string $field
         * @return string
@@ -992,6 +1014,13 @@ interface IDatabase {
                $delim, $table, $field, $conds = '', $join_conds = []
        );
 
+       /**
+        * @param string $field Field or column to cast
+        * @return string
+        * @since 1.28
+        */
+       public function buildStringCast( $field );
+
        /**
         * Change the current database
         *
@@ -1113,7 +1142,7 @@ interface IDatabase {
         *
         * @since 1.22
         *
-        * @param string $table Table name. This will be passed through DatabaseBase::tableName().
+        * @param string $table Table name. This will be passed through Database::tableName().
         * @param array $rows A single row or list of rows to insert
         * @param array $uniqueIndexes List of single field names or field name tuples
         * @param array $set An array of values to SET. For each array element, the
@@ -1286,7 +1315,7 @@ interface IDatabase {
         *
         * @return DBMasterPos|bool False if this is not a replica DB.
         */
-       public function getSlavePos();
+       public function getReplicaPos();
 
        /**
         * Get the position of this master
@@ -1387,10 +1416,7 @@ interface IDatabase {
         * The goal of this function is to create an atomic section of SQL queries
         * without having to start a new transaction if it already exists.
         *
-        * Atomic sections are more strict than transactions. With transactions,
-        * attempting to begin a new transaction when one is already running results
-        * in MediaWiki issuing a brief warning and doing an implicit commit. All
-        * atomic levels *must* be explicitly closed using IDatabase::endAtomic(),
+        * All atomic levels *must* be explicitly closed using IDatabase::endAtomic(),
         * and any database transactions cannot be began or committed until all atomic
         * levels are closed. There is no such thing as implicitly opening or closing
         * an atomic section.
@@ -1430,8 +1456,8 @@ interface IDatabase {
         *
         * This can be an alternative to explicit startAtomic()/endAtomic() calls.
         *
-        * @see DatabaseBase::startAtomic
-        * @see DatabaseBase::endAtomic
+        * @see Database::startAtomic
+        * @see Database::endAtomic
         *
         * @param string $fname Caller name (usually __METHOD__)
         * @param callable $callback Callback that issues DB updates