MediaWiki master
|
Inherits Wikimedia\Rdbms\Platform\SQLPlatform.
Public Member Functions | |||||||
buildConcat ( $stringList) | |||||||
Build a concatenation list to feed into a SQL query.
| |||||||
buildGroupConcatField ( $delim, $tables, $field, $conds='', $join_conds=[]) | |||||||
Build a GROUP_CONCAT or equivalent statement for a query. | |||||||
buildStringCast ( $field) | |||||||
getCoreSchema () | |||||||
getDatabaseAndTableIdentifier (string $table) | |||||||
Get the database identifer and prefixed table name identifier for a table. | |||||||
implicitOrderby () | |||||||
Returns true if this database does an implicit order by when the column has an index For example: SELECT page_title FROM page LIMIT 1. | |||||||
isTransactableQuery (Query $sql) | |||||||
Determine whether a SQL statement is sensitive to isolation level. | |||||||
limitResult ( $sql, $limit, $offset=false) | |||||||
Construct a LIMIT query with optional offset. | |||||||
lockIsFreeSQLText ( $lockName) | |||||||
lockSQLText ( $lockName, $timeout) | |||||||
makeInsertLists (array $rows, $aliasPrefix='', array $typeByColumn=[]) | |||||||
Make SQL lists of columns, row tuples, and column aliases for INSERT/VALUES expressions. | |||||||
selectSQLText ( $tables, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |||||||
Take the same arguments as IDatabase::select() and return the SQL it would use. | |||||||
setCoreSchema (string $coreSchema) | |||||||
timestamp ( $ts=0) | |||||||
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for inserting into timestamp fields in this DBMS. | |||||||
unlockSQLText ( $lockName) | |||||||
Public Member Functions inherited from Wikimedia\Rdbms\Platform\SQLPlatform | |||||||
__construct (DbQuoter $quoter, ?LoggerInterface $logger=null, ?DatabaseDomain $currentDomain=null, $errorLogger=null) | |||||||
addIdentifierQuotes ( $s) | |||||||
Escape a SQL identifier (e.g. | |||||||
anyChar () | |||||||
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query. | |||||||
anyString () | |||||||
Returns a token for buildLike() that denotes a '' to be used in a LIKE query. | |||||||
assertValidUpsertSetArray (array $set, array $uniqueKey, array $rows) | |||||||
bitAnd ( $fieldLeft, $fieldRight) | |||||||
bitNot ( $field) | |||||||
bitOr ( $fieldLeft, $fieldRight) | |||||||
buildComparison (string $op, array $conds) | |||||||
Build a condition comparing multiple values, for use with indexes that cover multiple fields, common when e.g. | |||||||
buildExcludedValue ( $column) | |||||||
Build a reference to a column value from the conflicting proposed upsert() row. | |||||||
buildGreatest ( $fields, $values) | |||||||
Build a GREATEST function statement comparing columns/values.Integer and float values in $values will not be quotedIf $fields is an array, then each value with a string key is treated as an expression (which must be manually quoted); such string keys do not appear in the SQL and are only descriptive aliases.
| |||||||
buildIntegerCast ( $field) | |||||||
buildLeast ( $fields, $values) | |||||||
Build a LEAST function statement comparing columns/values.Integer and float values in $values will not be quotedIf $fields is an array, then each value with a string key is treated as an expression (which must be manually quoted); such string keys do not appear in the SQL and are only descriptive aliases.
| |||||||
buildLike ( $param,... $params) | |||||||
LIKE statement wrapper. | |||||||
buildSelectSubquery ( $tables, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |||||||
Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery. | |||||||
buildSubstring ( $input, $startPosition, $length=null) | |||||||
conditional ( $cond, $caseTrueExpression, $caseFalseExpression) | |||||||
Returns an SQL expression for a simple conditional. | |||||||
decodeExpiry ( $expiry, $format=TS_MW) | |||||||
Decode an expiry time into a DBMS independent format. | |||||||
deleteJoinSqlText ( $delTable, $joinTable, $delVar, $joinVar, $conds) | |||||||
deleteSqlText ( $table, $conds) | |||||||
dispatchingInsertSqlText ( $table, $rows, $options) | |||||||
dropTableSqlText ( $table) | |||||||
encodeExpiry ( $expiry) | |||||||
Encode an expiry time into the DBMS dependent format. | |||||||
escapeLikeInternal ( $s, $escapeChar='`') | |||||||
extractSingleFieldFromList ( $var) | |||||||
extractTableNameComponents (string $name) | |||||||
Extract the dot-separated components of a table name, preserving identifier quotation. | |||||||
factorConds ( $condsArray) | |||||||
Given an array of condition arrays representing an OR list of AND lists, for example: | |||||||
fieldNameWithAlias ( $name, $alias=false) | |||||||
Get an aliased field name e.g. | |||||||
getCurrentDomain () | |||||||
getInfinity () | |||||||
Find out when 'infinity' is. | |||||||
getQueryVerb ( $sql) | |||||||
getTableAliases () | |||||||
ignoreIndexClause ( $index) | |||||||
IGNORE INDEX clause. | |||||||
indexName ( $index) | |||||||
Allows for index remapping in queries where this is not consistent across DBMS. | |||||||
insertNonConflictingSqlText ( $table, array $rows) | |||||||
insertSelectNativeSqlText ( $destTable, $srcTable, array $varMap, $conds, $fname, array $insertOptions, array $selectOptions, $selectJoinConds) | |||||||
insertSqlText ( $table, array $rows) | |||||||
isFlagInOptions ( $option, array $options) | |||||||
isQuotedIdentifier ( $name) | |||||||
Returns if the given identifier looks quoted or not according to the database convention for quoting identifiers. | |||||||
makeKeyCollisionCondition (array $rows, array $uniqueKey) | |||||||
Build an SQL condition to find rows with matching key values to those in $rows. | |||||||
makeList (array $a, $mode=self::LIST_COMMA) | |||||||
Makes an encoded list of strings from an array. | |||||||
makeWhereFrom2d ( $data, $baseKey, $subKey) | |||||||
Build a "OR" condition with pairs from a two-dimensional array. | |||||||
normalizeConditions ( $conds, $fname) | |||||||
normalizeOptions ( $options) | |||||||
normalizeUpsertParams ( $uniqueKeys, &$rows) | |||||||
Validate and normalize parameters to upsert() or replace() | |||||||
qualifiedTableComponents ( $name) | |||||||
Get the table components needed for a query given the currently selected database/schema. | |||||||
releaseSavepointSqlText ( $identifier) | |||||||
replaceVars ( $ins) | |||||||
Database-independent variable replacement. | |||||||
rollbackSqlText () | |||||||
rollbackToSavepointSqlText ( $identifier) | |||||||
savepointSqlText ( $identifier) | |||||||
setCurrentDomain (DatabaseDomain $currentDomain) | |||||||
setIndexAliases (array $aliases) | |||||||
Convert certain index names to alternative names before querying the DB. | |||||||
setPrefix ( $prefix) | |||||||
setSchemaVars ( $vars) | |||||||
Set schema variables to be used when streaming commands from SQL files or stdin. | |||||||
setTableAliases (array $aliases) | |||||||
Make certain table names use their own database, schema, and table prefix when passed into SQL queries pre-escaped and without a qualified database name. | |||||||
strreplace ( $orig, $old, $new) | |||||||
Returns a SQL expression for simple string replacement (e.g. | |||||||
tableName (string $name, $format='quoted') | |||||||
Format a table name ready for use in constructing an SQL query. | |||||||
tableNamesN (... $tables) | |||||||
Fetch a number of table names into a zero-indexed numerical array. | |||||||
timestampOrNull ( $ts=null) | |||||||
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for inserting into timestamp fields in this DBMS. | |||||||
unionQueries ( $sqls, $all, $options=[]) | |||||||
Construct a UNION query. | |||||||
unionSupportsOrderAndLimit () | |||||||
Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION.
| |||||||
updateSqlText ( $table, $set, $conds, $options) | |||||||
useIndexClause ( $index) | |||||||
USE INDEX clause. | |||||||
Public Member Functions inherited from Wikimedia\Rdbms\Platform\ISQLPlatform | |||||||
buildSubString ( $input, $startPosition, $length=null) | |||||||
Build a SUBSTRING function. | |||||||
Protected Member Functions | |
makeInsertNonConflictingVerbAndOptions () | |
makeSelectOptions (array $options) | |
Returns an optional USE INDEX clause to go after the table, and a string to go at the end of the query. | |
makeUpdateOptionsArray ( $options) | |
Make UPDATE options array for Database::makeUpdateOptions. | |
relationSchemaQualifier () | |
Protected Member Functions inherited from Wikimedia\Rdbms\Platform\SQLPlatform | |
assertBuildSubstringParams ( $startPosition, $length) | |
Check type and bounds for parameters to self::buildSubstring() | |
assertValidUpsertRowArray (array $rows, array $uniqueKey) | |
buildSuperlative ( $sqlfunc, $fields, $values) | |
Build a superlative function statement comparing columns/values. | |
fieldNamesWithAlias ( $fields) | |
Gets an array of aliased field names. | |
getDefaultSchemaVars () | |
Get schema variables to use if none have been set via setSchemaVars(). | |
getIdentifierQuoteChar () | |
Get the character used for identifier quoting. | |
getSchemaVars () | |
Get schema variables. | |
makeGroupByWithHaving ( $options) | |
Returns an optional GROUP BY with an optional HAVING. | |
makeOrderBy ( $options) | |
Returns an optional ORDER BY. | |
makeUpdateOptions ( $options) | |
Make UPDATE options for the Database::update function. | |
normalizeJoinType (string $joinType) | |
Validate and normalize a join type. | |
normalizeRowArray (array $rowOrRows) | |
tableNamesWithIndexClauseOrJOIN ( $tables, $use_index=[], $ignore_index=[], $join_conds=[]) | |
Get the aliased table name clause for a FROM clause which might have a JOIN and/or USE INDEX or IGNORE INDEX clause. | |
tableNameWithAlias ( $table, $alias=false) | |
Get an aliased table name. | |
Additional Inherited Members | |
Public Attributes inherited from Wikimedia\Rdbms\Platform\ISQLPlatform | |
const | ALL_ROWS = '*' |
Unconditional update/delete of whole table. | |
const | CALLER_SUBQUERY = 'subquery' |
Special value for ->caller() / $fname parameter used when providing a caller is not expected, because we're formatting a subquery that won't be executed directly. | |
const | CALLER_UNKNOWN = 'unknown' |
Special value for ->caller() / $fname parameter used when a caller is not provided. | |
const | LIST_AND = 1 |
Combine list with AND clauses. | |
const | LIST_COMMA = 0 |
Combine list with comma delimiters. | |
const | LIST_NAMES = 3 |
Treat as field name and do not apply value escaping. | |
const | LIST_OR = 4 |
Combine list with OR clauses. | |
const | LIST_SET = 2 |
Convert map into a SET clause. | |
const | QUERY_CHANGE_LOCKS = 512 |
Query is a command for advisory locks. | |
const | QUERY_CHANGE_NONE = 32 |
Query is a read-only Data Query Language query. | |
const | QUERY_CHANGE_ROWS = 128 |
Query is a Data Manipulation Language command (INSERT, DELETE, LOCK, ...) | |
const | QUERY_CHANGE_SCHEMA = 256 |
Query is a Data Definition Language command. | |
const | QUERY_CHANGE_TRX = 64 |
Query is a Transaction Control Language command (BEGIN, USE, SET, ...) | |
const | QUERY_IGNORE_DBO_TRX = 8 |
Ignore the current presence of any DBO_TRX flag. | |
const | QUERY_NO_RETRY = 16 |
Do not try to retry the query if the connection was lost. | |
const | QUERY_NORMAL = 0 |
Idiom for "no special flags". | |
const | QUERY_PSEUDO_PERMANENT = 2 |
Track a TEMPORARY table CREATE as if it was for a permanent table (for testing) | |
const | QUERY_REPLICA_ROLE = 4 |
Enforce that a query does not make effective writes. | |
const | QUERY_SILENCE_ERRORS = 1 |
Ignore query errors and return false when they happen. | |
Protected Attributes inherited from Wikimedia\Rdbms\Platform\SQLPlatform | |
DatabaseDomain null | $currentDomain |
callable | $errorLogger |
Error logging callback. | |
string[] | $indexAliases = [] |
Current map of (index alias => index) | |
LoggerInterface | $logger |
DbQuoter | $quoter |
array null | $schemaVars |
Current variables use for schema element placeholders. | |
array[] | $tableAliases = [] |
Current map of (table => (dbname, schema, prefix) map) | |
Wikimedia\Rdbms\Platform\PostgresPlatform::buildConcat | ( | $stringList | ) |
Build a concatenation list to feed into a SQL query.
string[] | $stringList | Raw SQL expression list; caller is responsible for escaping |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 38 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::buildGroupConcatField | ( | $delim, | |
$tables, | |||
$field, | |||
$conds = '', | |||
$join_conds = [] ) |
Build a GROUP_CONCAT or equivalent statement for a query.
This is useful for combining a field for several rows into a single string. NULL values will not appear in the output, duplicated values will appear, and the resulting delimiter-separated values have no defined sort order. Code using the results may need to use the PHP unique() or sort() methods.
string | $delim | Glue to bind the results together |
string | array | $tables | Table reference(s), using the unqualified name of tables or of the form "information_schema.<identifier>". { |
string | $field | Field name |
string|IExpression|array<string,?scalar|non-empty-array<int,?scalar>|RawSQLValue>|array<int,string|IExpression> | $conds Conditions | |
string | array | $join_conds | Join conditions |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 174 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::buildStringCast | ( | $field | ) |
string | $field | Field or column to cast |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 48 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::getCoreSchema | ( | ) |
Definition at line 56 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::getDatabaseAndTableIdentifier | ( | string | $table | ) |
Get the database identifer and prefixed table name identifier for a table.
The table name is assumed to be relative to the current DB domain
This method is useful for TEMPORARY table tracking. In MySQL, temp tables with identical names can co-exist on different databases, which can be done via CREATE and USE. Note that SQLite/PostgreSQL do not allow changing the database within a session. This method omits the schema identifier for several reasons:
string | $table | Table name |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 151 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::implicitOrderby | ( | ) |
Returns true if this database does an implicit order by when the column has an index For example: SELECT page_title FROM page LIMIT 1.
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 52 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::isTransactableQuery | ( | Query | $sql | ) |
Determine whether a SQL statement is sensitive to isolation level.
A SQL statement is considered transactable if its result could vary depending on the transaction isolation level. Operational commands such as 'SET' and 'SHOW' are not considered to be transactable.
Main purpose: Used by query() to decide whether to begin a transaction before the current query (in DBO_TRX mode, on by default).
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 239 of file PostgresPlatform.php.
References Wikimedia\Rdbms\Query\getSQL().
Wikimedia\Rdbms\Platform\PostgresPlatform::limitResult | ( | $sql, | |
$limit, | |||
$offset = false ) |
Construct a LIMIT query with optional offset.
The SQL should be adjusted so that only the first $limit rows are returned. If $offset is provided as well, then the first $offset rows should be discarded, and the next $limit rows should be returned. If the result of the query is not ordered, then the rows to be returned are theoretically arbitrary.
$sql is expected to be a SELECT, if that makes a difference.
string | $sql | SQL query we will append the limit too |
int | $limit | The SQL limit |
int | false | $offset | The SQL offset (default false) |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 34 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::lockIsFreeSQLText | ( | $lockName | ) |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 253 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::lockSQLText | ( | $lockName, | |
$timeout ) |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 244 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::makeInsertLists | ( | array | $rows, |
$aliasPrefix = '', | |||
array | $typeByColumn = [] ) |
Make SQL lists of columns, row tuples, and column aliases for INSERT/VALUES expressions.
The tuple column order is that of the columns of the first provided row. The provided rows must have exactly the same keys and ordering thereof.
array[] | $rows | Non-empty list of (column => value) maps |
string | $aliasPrefix | Optional prefix to prepend to the magic alias names |
string[] | $typeByColumn | Optional map of (column => data type) |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 182 of file PostgresPlatform.php.
|
protected |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 227 of file PostgresPlatform.php.
|
protected |
Returns an optional USE INDEX clause to go after the table, and a string to go at the end of the query.
array | $options | Associative array of options to be turned into an SQL query, valid keys are listed in the function. |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 122 of file PostgresPlatform.php.
|
protected |
Make UPDATE options array for Database::makeUpdateOptions.
array | $options |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 231 of file PostgresPlatform.php.
|
protected |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 165 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::selectSQLText | ( | $tables, | |
$vars, | |||
$conds = '', | |||
$fname = __METHOD__, | |||
$options = [], | |||
$join_conds = [] ) |
Take the same arguments as IDatabase::select() and return the SQL it would use.
This can be useful for making UNION queries, where the SQL text of each query is needed. In general, however, callers outside of Database classes should just use select().
string | array | $tables | Table reference(s), using the unqualified name of tables or of the form "information_schema.<identifier>". |
string | array | $vars | Field names |
string|IExpression|array<string,?scalar|non-empty-array<int,?scalar>|RawSQLValue>|array<int,string|IExpression> | $conds Conditions | |
string | $fname | Caller function name |
string | array | $options | Query options |
string | array | $join_conds | Join conditions |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 64 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::setCoreSchema | ( | string | $coreSchema | ) |
Definition at line 60 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::timestamp | ( | $ts = 0 | ) |
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp
to the format used for inserting into timestamp fields in this DBMS.
The result is unquoted, and needs to be passed through addQuotes() before it can be included in raw SQL.
string | int | $ts |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 42 of file PostgresPlatform.php.
Wikimedia\Rdbms\Platform\PostgresPlatform::unlockSQLText | ( | $lockName | ) |
Reimplemented from Wikimedia\Rdbms\Platform\SQLPlatform.
Definition at line 260 of file PostgresPlatform.php.