MediaWiki  REL1_23
DatabasePostgres Class Reference
Inheritance diagram for DatabasePostgres:
Collaboration diagram for DatabasePostgres:

List of all members.

Public Member Functions

 addQuotes ($s)
 affectedRows ()
 Get the number of rows affected by the last write query.
 aggregateValue ($valuedata, $valuename= 'value')
 Return aggregated value function call.
 buildConcat ($stringList)
 Build a concatenation list to feed into a SQL query.
 buildGroupConcatField ($delimiter, $table, $field, $conds= '', $options=array(), $join_conds=array())
 cascadingDeletes ()
 Returns true if this database supports (and uses) cascading deletes.
 cleanupTriggers ()
 Returns true if this database supports (and uses) triggers (e.g.
 constraintExists ($table, $constraint)
 currentSequenceValue ($seqName)
 Return the current value of a sequence.
 dataSeek ($res, $row)
 decodeBlob ($b)
 Some DBMSs return a special placeholder object representing blob fields in result objects.
 determineCoreSchema ($desiredSchema)
 Determine default schema for MediaWiki core Adjust this session schema search path if desired schema exists and is not alread there.
 doQuery ($sql)
 The DBMS-dependent part of query()
 duplicateTableStructure ($oldName, $newName, $temporary=false, $fname=__METHOD__)
 Creates a new table with structure copied from existing table Note that unlike most database abstraction functions, this function does not automatically append database prefix, because it works at a lower abstraction level.
 encodeBlob ($b)
 estimateRowCount ($table, $vars= '*', $conds= '', $fname=__METHOD__, $options=array())
 Estimate rows in dataset Returns estimated count, based on EXPLAIN output This is not necessarily an accurate estimate, so use sparingly Returns -1 if count cannot be found Takes same arguments as Database::select()
 fetchObject ($res)
 fetchRow ($res)
 Fetch the next row from the given result object, in associative array form.
 fieldInfo ($table, $field)
 mysql_fetch_field() wrapper Returns false if the field doesn't exist
 fieldName ($res, $n)
 Get a field name in a result object.
 fieldType ($res, $index)
 pg_field_type() wrapper
 freeResult ($res)
 functionalIndexes ()
 Returns true if this database can use functional indexes.
 getCoreSchema ()
 Return schema name fore core MediaWiki tables.
 getCurrentSchema ()
 Return current schema (executes SELECT current_schema()) Needs transaction.
 getDBname ()
 Get the current DB name.
 getSchemas ()
 Return list of schemas which are accessible without schema name This is list does not contain magic keywords like "$user" Needs transaction.
 getSearchEngine ()
 Get search engine class.
 getSearchPath ()
 Return search patch for schemas This is different from getSchemas() since it contain magic keywords (like "$user").
 getServer ()
 Get the server hostname or IP address.
 getServerVersion ()
 getSoftwareLink ()
 getType ()
 Get the type of the DBMS, as it appears in $wgDBtype.
 hasConstraint ($name)
 implicitGroupby ()
 Returns true if this database does an implicit sort when doing GROUP BY.
 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.
 indexAttributes ($index, $schema=false)
 Returns is of attributes used in index.
 indexInfo ($table, $index, $fname=__METHOD__)
 Returns information about an index If errors are explicitly ignored, returns NULL on failure.
 indexUnique ($table, $index, $fname=__METHOD__)
 insert ($table, $args, $fname=__METHOD__, $options=array())
 INSERT wrapper, inserts an array into a table.
 insertId ()
 Return the result of the last call to nextSequenceValue(); This must be called after nextSequenceValue().
 insertSelect ($destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=array(), $selectOptions=array())
 INSERT SELECT wrapper $varMap must be an associative array of the form array( 'dest1' => 'source1', ...) Source items may be literals rather then field names, but strings should be quoted with Database::addQuotes() $conds may be "*" to copy the whole table srcTable may be an array of tables.
 lastErrno ()
 Get the last error number.
 lastError ()
 Get a description of the last error.
 limitResult ($sql, $limit, $offset=false)
 Construct a LIMIT query with optional offset.
 listTables ($prefix=null, $fname=__METHOD__)
 List all tables on the database.
 lock ($lockName, $method, $timeout=5)
 See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS.
 lockIsFree ($lockName, $method)
 Check to see if a named lock is available.
 makeConnectionString ($vars)
 makeSelectOptions ($options)
 Various select options.
 nextSequenceValue ($seqName)
 Return the next in a sequence, save the value for retrieval via insertId()
 numFields ($res)
 Get the number of fields in a result object.
 numRows ($res)
 Get the number of rows in a result object.
 open ($server, $user, $password, $dbName)
 Usually aborts on failure.
 pg_array_parse ($text, &$output, $limit=false, $offset=1)
 queryIgnore ($sql, $fname=__METHOD__)
 realTableName ($name, $format= 'quoted')
 realTimestamps ()
 Returns true if this database uses timestamps rather than integers.
 relationExists ($table, $types, $schema=false)
 Query whether a given relation exists (in the given schema, or the default mw one if not given)
 reportQueryError ($error, $errno, $sql, $fname, $tempIgnore=false)
 Report a query error.
 roleExists ($roleName)
 Returns true if a given role (i.e.
 ruleExists ($table, $rule)
 schemaExists ($schema)
 Query whether a given schema exists.
 searchableIPs ()
 Returns true if this database can do a native search on IP columns e.g.
 selectDB ($db)
 Postgres doesn't support selectDB in the same way MySQL does.
 selectSQLText ($table, $vars, $conds= '', $fname=__METHOD__, $options=array(), $join_conds=array())
 Change the FOR UPDATE option as necessary based on the join conditions.
 sequenceExists ($sequence, $schema=false)
 setSearchPath ($search_path)
 Update search_path, values should already be sanitized Values may contain magic keywords like "$user".
 streamStatementEnd (&$sql, &$newLine)
 Called by sourceStream() to check if we've reached a statement end.
 strencode ($s)
 Wrapper for addslashes()
 strictIPs ()
 Returns true if this database is strict about what can be put into an IP field.
 tableExists ($table, $fname=__METHOD__, $schema=false)
 For backward compatibility, this function checks both tables and views.
 tableName ($name, $format= 'quoted')
 Format a table name ready for use in constructing an SQL query.
 textFieldSize ($table, $field)
 Returns the size of a text field, or -1 for "unlimited".
 timestamp ($ts=0)
 Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting into timestamp fields in this DBMS.
 triggerExists ($table, $trigger)
 unlock ($lockName, $method)
 See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKSFROM PG DOCS: http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS.
 wasDeadlock ()
 Determines if the last failure was due to a deadlock STUB.

Protected Member Functions

 closeConnection ()
 Closes a database connection, if it is open Returns success, true if already closed.
 dumpError ()
 replaceVars ($ins)
 Postgres specific version of replaceVars.

Protected Attributes

int $mAffectedRows = null
 The number of rows affected as an integer *.
resource $mLastResult = null
 *

Private Member Functions

 bigintFromLockName ($lockName)

Private Attributes

string $connectString
 Connect string to open a PostgreSQL connection *.
string $mCoreSchema
 *
int $mInsertId = null
 *
PostgresTransactionState $mTransactionState
 *
float string $numericVersion = null
 *

Detailed Description

Definition at line 290 of file DatabasePostgres.php.


Member Function Documentation

Parameters:
null | bool | Blob$s
Returns:
int|string

Reimplemented from DatabaseBase.

Definition at line 1501 of file DatabasePostgres.php.

Referenced by lockIsFree(), and streamStatementEnd().

Get the number of rows affected by the last write query.

See also:
http://www.php.net/mysql_affected_rows
Returns:
int

Implements DatabaseType.

Definition at line 667 of file DatabasePostgres.php.

DatabasePostgres::aggregateValue ( valuedata,
valuename = 'value' 
)

Return aggregated value function call.

Reimplemented from DatabaseBase.

Definition at line 1194 of file DatabasePostgres.php.

DatabasePostgres::bigintFromLockName ( lockName) [private]
Parameters:
string$lockName
Returns:
string Integer

Definition at line 1674 of file DatabasePostgres.php.

Referenced by lockIsFree().

DatabasePostgres::buildConcat ( stringList)

Build a concatenation list to feed into a SQL query.

Parameters:
array$stringListList of raw SQL expressions; caller is responsible for any quoting
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 1584 of file DatabasePostgres.php.

DatabasePostgres::buildGroupConcatField ( delimiter,
table,
field,
conds = '',
options = array(),
join_conds = array() 
)

Definition at line 1588 of file DatabasePostgres.php.

Returns true if this database supports (and uses) cascading deletes.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 309 of file DatabasePostgres.php.

Returns true if this database supports (and uses) triggers (e.g.

on the page table)

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 313 of file DatabasePostgres.php.

Closes a database connection, if it is open Returns success, true if already closed.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 470 of file DatabasePostgres.php.

DatabasePostgres::constraintExists ( table,
constraint 
)

Definition at line 1419 of file DatabasePostgres.php.

Return the current value of a sequence.

Assumes it has been nextval'ed in this session.

Parameters:
string$seqName
Returns:
int

Definition at line 1083 of file DatabasePostgres.php.

DatabasePostgres::dataSeek ( res,
row 
)
Parameters:
mixed$res
int$row
Returns:
bool

Implements DatabaseType.

Definition at line 639 of file DatabasePostgres.php.

Some DBMSs return a special placeholder object representing blob fields in result objects.

Pass the object through this function to return the original string.

Parameters:
string$b
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 1485 of file DatabasePostgres.php.

Determine default schema for MediaWiki core Adjust this session schema search path if desired schema exists and is not alread there.

We need to have name of the core schema stored to be able to query database metadata.

This will be also called by the installer after the schema is created

Since:
1.19
Parameters:
string$desiredSchema

Definition at line 1282 of file DatabasePostgres.php.

Referenced by open().

The DBMS-dependent part of query()

Parameters:
string$sqlSQL query.
Returns:
ResultWrapper|bool Result object to feed to fetchObject, fetchRow, ...; or false on failure

Reimplemented from DatabaseBase.

Definition at line 474 of file DatabasePostgres.php.

Referenced by open().

DatabasePostgres::dumpError ( ) [protected]

Definition at line 492 of file DatabasePostgres.php.

DatabasePostgres::duplicateTableStructure ( oldName,
newName,
temporary = false,
fname = __METHOD__ 
)

Creates a new table with structure copied from existing table Note that unlike most database abstraction functions, this function does not automatically append database prefix, because it works at a lower abstraction level.

The table names passed to this function shall not be quoted (this function calls addIdentifierQuotes when needed).

Parameters:
string$oldNameName of table whose structure should be copied
string$newNameName of table to be created
bool$temporaryWhether the new table should be temporary
string$fnameCalling function name
Exceptions:
MWException
Returns:
bool True if operation was successful

Reimplemented from DatabaseBase.

Definition at line 1118 of file DatabasePostgres.php.

Parameters:
string$b
Returns:
Blob

Reimplemented from DatabaseBase.

Definition at line 1481 of file DatabasePostgres.php.

DatabasePostgres::estimateRowCount ( table,
vars = '*',
conds = '',
fname = __METHOD__,
options = array() 
)

Estimate rows in dataset Returns estimated count, based on EXPLAIN output This is not necessarily an accurate estimate, so use sparingly Returns -1 if count cannot be found Takes same arguments as Database::select()

Parameters:
string$table
string$vars
string$conds
string$fname
array$options
Returns:
int

Reimplemented from DatabaseBase.

Definition at line 693 of file DatabasePostgres.php.

Parameters:
ResultWrapper | stdClass$res
Returns:
stdClass
Exceptions:
DBUnexpectedError

Implements DatabaseType.

Definition at line 553 of file DatabasePostgres.php.

Referenced by lockIsFree().

Fetch the next row from the given result object, in associative array form.

Fields are retrieved with $row['fieldname']. If no more rows are available, false is returned.

Parameters:
ResultWrapper$resResult object as returned from DatabaseBase::query(), etc.
Returns:
array|bool
Exceptions:
DBUnexpectedErrorThrown if the database returns an error

Implements DatabaseType.

Definition at line 574 of file DatabasePostgres.php.

Referenced by getSearchPath(), and textFieldSize().

DatabasePostgres::fieldInfo ( table,
field 
)

mysql_fetch_field() wrapper Returns false if the field doesn't exist

Parameters:
string$tableTable name
string$fieldField name
Returns:
Field

Implements DatabaseType.

Definition at line 1459 of file DatabasePostgres.php.

DatabasePostgres::fieldName ( res,
n 
)

Get a field name in a result object.

See also:
http://www.php.net/mysql_field_name
Parameters:
mixed$resA SQL result
int$n
Returns:
string

Implements DatabaseType.

Definition at line 616 of file DatabasePostgres.php.

DatabasePostgres::fieldType ( res,
index 
)

pg_field_type() wrapper

Parameters:
ResultWrapper | resource$resResultWrapper or PostgreSQL query result resource
int$indexField number, starting from 0
Returns:
string

Definition at line 1469 of file DatabasePostgres.php.

References PostgresField\fromText().

Parameters:
stdClass | ResultWrapper$res
Exceptions:
DBUnexpectedError

Reimplemented from DatabaseBase.

Definition at line 536 of file DatabasePostgres.php.

Returns true if this database can use functional indexes.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 337 of file DatabasePostgres.php.

Return schema name fore core MediaWiki tables.

Since:
1.19
Returns:
string core schema name

Definition at line 1316 of file DatabasePostgres.php.

Return current schema (executes SELECT current_schema()) Needs transaction.

Since:
1.19
Returns:
string Default schema for the current session

Definition at line 1212 of file DatabasePostgres.php.

Get the current DB name.

Reimplemented from DatabaseBase.

Definition at line 1576 of file DatabasePostgres.php.

Return list of schemas which are accessible without schema name This is list does not contain magic keywords like "$user" Needs transaction.

See also:
getSearchPath()
setSearchPath()
Since:
1.19
Returns:
array list of actual schemas for the current sesson

Definition at line 1229 of file DatabasePostgres.php.

Get search engine class.

All subclasses of this need to implement this if they wish to use searching.

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 1596 of file DatabasePostgres.php.

Return search patch for schemas This is different from getSchemas() since it contain magic keywords (like "$user").

Needs transaction

Since:
1.19
Returns:
array How to search for table names schemas for the current user

Definition at line 1248 of file DatabasePostgres.php.

References $res, fetchRow(), and DatabaseBase\query().

Get the server hostname or IP address.

Reimplemented from DatabaseBase.

Definition at line 1580 of file DatabasePostgres.php.

Returns:
string Version information from the database

Implements DatabaseType.

Definition at line 1323 of file DatabasePostgres.php.

Referenced by open().

Returns:
string Wikitext of a link to the server software's web site

Implements DatabaseType.

Definition at line 1201 of file DatabasePostgres.php.

Get the type of the DBMS, as it appears in $wgDBtype.

Returns:
string

Implements DatabaseType.

Definition at line 305 of file DatabasePostgres.php.

Definition at line 341 of file DatabasePostgres.php.

Returns true if this database does an implicit sort when doing GROUP BY.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 325 of file DatabasePostgres.php.

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.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 329 of file DatabasePostgres.php.

DatabasePostgres::indexAttributes ( index,
schema = false 
)

Returns is of attributes used in index.

Since:
1.19
Parameters:
string$index
bool | string$schema
Returns:
array

Definition at line 742 of file DatabasePostgres.php.

DatabasePostgres::indexInfo ( table,
index,
fname = __METHOD__ 
)

Returns information about an index If errors are explicitly ignored, returns NULL on failure.

Parameters:
string$table
string$index
string$fname
Returns:
bool|null

Implements DatabaseType.

Definition at line 719 of file DatabasePostgres.php.

References $fname, $res, as, and DatabaseBase\query().

DatabasePostgres::indexUnique ( table,
index,
fname = __METHOD__ 
)

Definition at line 799 of file DatabasePostgres.php.

DatabasePostgres::insert ( table,
args,
fname = __METHOD__,
options = array() 
)

INSERT wrapper, inserts an array into a table.

$args may be a single associative array, or an array of these with numeric keys, for multi-row insert (Postgres version 8.2 and above only).

Parameters:
string$tableName of the table to insert to.
array$argsItems to insert into the table.
string$fnameName of the function, for profiling
array | string$optionsString or array. Valid options: IGNORE
Returns:
bool Success of insert operation. IGNORE always returns true.

Reimplemented from DatabaseBase.

Definition at line 857 of file DatabasePostgres.php.

Return the result of the last call to nextSequenceValue(); This must be called after nextSequenceValue().

Returns:
int|null

Implements DatabaseType.

Definition at line 630 of file DatabasePostgres.php.

DatabasePostgres::insertSelect ( destTable,
srcTable,
varMap,
conds,
fname = __METHOD__,
insertOptions = array(),
selectOptions = array() 
)

INSERT SELECT wrapper $varMap must be an associative array of the form array( 'dest1' => 'source1', ...) Source items may be literals rather then field names, but strings should be quoted with Database::addQuotes() $conds may be "*" to copy the whole table srcTable may be an array of tables.

Todo:
FIXME: Implement this a little better (seperate select/insert)?
Parameters:
string$destTable
array | string$srcTable
array$varMap
array$conds
string$fname
array$insertOptions
array$selectOptions
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 983 of file DatabasePostgres.php.

Get the last error number.

See also:
http://www.php.net/mysql_errno
Returns:
int

Implements DatabaseType.

Definition at line 659 of file DatabasePostgres.php.

Get a description of the last error.

See also:
http://www.php.net/mysql_error
Returns:
string

Implements DatabaseType.

Definition at line 647 of file DatabasePostgres.php.

Referenced by open().

DatabasePostgres::limitResult ( sql,
limit,
offset = false 
)

Construct a LIMIT query with optional offset.

This is used for query pages. 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.

The version provided by default works in MySQL and SQLite. It will very likely need to be overridden for most other DBMSes.

Parameters:
string$sqlSQL query we will append the limit too
int$limitThe SQL limit
int | bool$offsetThe SQL offset (default false)
Exceptions:
DBUnexpectedError
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 1110 of file DatabasePostgres.php.

DatabasePostgres::listTables ( prefix = null,
fname = __METHOD__ 
)

List all tables on the database.

Parameters:
string$prefixOnly show tables with this prefix, e.g. mw_
string$fnameCalling function name
Exceptions:
MWException

Reimplemented from DatabaseBase.

Definition at line 1126 of file DatabasePostgres.php.

DatabasePostgres::lock ( lockName,
method,
timeout = 5 
)

See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS.

Parameters:
string$lockName
string$method
int$timeout
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 1638 of file DatabasePostgres.php.

DatabasePostgres::lockIsFree ( lockName,
method 
)

Check to see if a named lock is available.

This is non-blocking. See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS

Parameters:
string$lockNameName of lock to poll
string$methodName of method calling us
Returns:
bool
Since:
1.20

Reimplemented from DatabaseBase.

Definition at line 1622 of file DatabasePostgres.php.

References $key, $result, addQuotes(), bigintFromLockName(), fetchObject(), and DatabaseBase\query().

Definition at line 456 of file DatabasePostgres.php.

Referenced by open().

Various select options.

Parameters:
array$optionsan associative array of options to be turned into an SQL query, valid keys are listed in the function.
Returns:
array

Reimplemented from DatabaseBase.

Definition at line 1542 of file DatabasePostgres.php.

Return the next in a sequence, save the value for retrieval via insertId()

Parameters:
string$seqName
Returns:
int|null

Reimplemented from DatabaseBase.

Definition at line 1068 of file DatabasePostgres.php.

References $name, and tableName().

Get the number of fields in a result object.

See also:
http://www.php.net/mysql_num_fields
Parameters:
mixed$resA SQL result
Returns:
int

Implements DatabaseType.

Definition at line 608 of file DatabasePostgres.php.

Get the number of rows in a result object.

Parameters:
mixed$resA SQL result
Returns:
int

Implements DatabaseType.

Definition at line 591 of file DatabasePostgres.php.

DatabasePostgres::open ( server,
user,
password,
dbName 
)

Usually aborts on failure.

Parameters:
string$server
string$user
string$password
string$dbName
Exceptions:
DBConnectionError|Exception
Returns:
DatabaseBase|null

Implements DatabaseType.

Definition at line 360 of file DatabasePostgres.php.

References $password, $user, $wgCommandLineMode, array(), DatabaseBase\close(), determineCoreSchema(), doQuery(), e, getServerVersion(), global, DatabaseBase\installErrorHandler(), is, lastError(), makeConnectionString(), DatabaseBase\query(), DatabaseBase\restoreErrorHandler(), and wfDebug().

DatabasePostgres::pg_array_parse ( text,
&$  output,
limit = false,
offset = 1 
)

Definition at line 1164 of file DatabasePostgres.php.

References $limit, $output, and array().

DatabasePostgres::queryIgnore ( sql,
fname = __METHOD__ 
)

Definition at line 528 of file DatabasePostgres.php.

DatabasePostgres::realTableName ( name,
format = 'quoted' 
)

Definition at line 1058 of file DatabasePostgres.php.

Returns true if this database uses timestamps rather than integers.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 321 of file DatabasePostgres.php.

DatabasePostgres::relationExists ( table,
types,
schema = false 
)

Query whether a given relation exists (in the given schema, or the default mw one if not given)

Parameters:
string$table
array | string$types
bool | string$schema
Returns:
bool

Definition at line 1349 of file DatabasePostgres.php.

DatabasePostgres::replaceVars ( ins) [protected]

Postgres specific version of replaceVars.

Calls the parent version in Database.php

Parameters:
string$insSQL string, read from a stream (usually tables.sql)
Returns:
string SQL string

Reimplemented from DatabaseBase.

Definition at line 1520 of file DatabasePostgres.php.

DatabasePostgres::reportQueryError ( error,
errno,
sql,
fname,
tempIgnore = false 
)

Report a query error.

Log the error, and if neither the object ignore flag nor the $tempIgnore flag is set, throw a DBQueryError.

Parameters:
string$error
int$errno
string$sql
string$fname
bool$tempIgnore
Exceptions:
DBQueryError

Reimplemented from DatabaseBase.

Definition at line 513 of file DatabasePostgres.php.

Returns true if a given role (i.e.

user) exists, false otherwise.

Parameters:
string$roleName
Returns:
bool

Definition at line 1452 of file DatabasePostgres.php.

DatabasePostgres::ruleExists ( table,
rule 
)

Definition at line 1407 of file DatabasePostgres.php.

Query whether a given schema exists.

Returns true if it does, false if it doesn't.

Parameters:
string$schema
Returns:
bool

Definition at line 1440 of file DatabasePostgres.php.

Returns true if this database can do a native search on IP columns e.g.

this works as expected: .. WHERE rc_ip = '127.42.12.102/32';

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 333 of file DatabasePostgres.php.

Postgres doesn't support selectDB in the same way MySQL does.

So if the DB name doesn't match the open connection, open a new one

Parameters:
string$db
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 448 of file DatabasePostgres.php.

DatabasePostgres::selectSQLText ( table,
vars,
conds = '',
fname = __METHOD__,
options = array(),
join_conds = array() 
)

Change the FOR UPDATE option as necessary based on the join conditions.

Then pass to the parent function to get the actual SQL text.

In Postgres when using FOR UPDATE, only the main table and tables that are inner joined can be locked. That means tables in an outer join cannot be FOR UPDATE locked. Trying to do so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly.

MySQL uses "ORDER BY NULL" as an optimization hint, but that syntax is illegal in PostgreSQL.

Reimplemented from DatabaseBase.

Definition at line 822 of file DatabasePostgres.php.

Referenced by streamStatementEnd().

DatabasePostgres::sequenceExists ( sequence,
schema = false 
)

Definition at line 1380 of file DatabasePostgres.php.

DatabasePostgres::setSearchPath ( search_path)

Update search_path, values should already be sanitized Values may contain magic keywords like "$user".

Since:
1.19
Parameters:
$search_patharray list of schemas to be searched by default

Definition at line 1264 of file DatabasePostgres.php.

DatabasePostgres::streamStatementEnd ( &$  sql,
&$  newLine 
)

Called by sourceStream() to check if we've reached a statement end.

Parameters:
string$sqlSQL assembled so far
string$newLineNew line about to be added to $sql
Returns:
bool Whether $newLine contains end of the statement

Reimplemented from DatabaseBase.

Definition at line 1600 of file DatabasePostgres.php.

References $conds, DatabaseBase\$delimiter, addQuotes(), array(), and selectSQLText().

Wrapper for addslashes()

Parameters:
string$sString to be slashed.
Returns:
string Slashed string.

Implements DatabaseType.

Definition at line 1493 of file DatabasePostgres.php.

Returns true if this database is strict about what can be put into an IP field.

Specifically, it uses a NULL value instead of an empty string.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 317 of file DatabasePostgres.php.

DatabasePostgres::tableExists ( table,
fname = __METHOD__,
schema = false 
)

For backward compatibility, this function checks both tables and views.

Parameters:
string$table
string$fname
bool | string$schema
Returns:
bool

Definition at line 1376 of file DatabasePostgres.php.

DatabasePostgres::tableName ( name,
format = 'quoted' 
)

Format a table name ready for use in constructing an SQL query.

This does two important things: it quotes the table names to clean them up, and it adds a table prefix if only given a table name with no quotes.

All functions of this object which require a table name call this function themselves. Pass the canonical name to such functions. This is only needed when calling query() directly.

Parameters:
string$nameDatabase table name
string$formatOne of: quoted - Automatically pass the table name through addIdentifierQuotes() so that it can be used in a query. raw - Do not add identifier quotes to the table name
Returns:
string Full database name

Reimplemented from DatabaseBase.

Definition at line 1045 of file DatabasePostgres.php.

Referenced by nextSequenceValue().

DatabasePostgres::textFieldSize ( table,
field 
)

Returns the size of a text field, or -1 for "unlimited".

Parameters:
string$table
string$field
Returns:
int

Reimplemented from DatabaseBase.

Definition at line 1093 of file DatabasePostgres.php.

References $res, fetchRow(), and DatabaseBase\query().

Convert a timestamp in one of the formats accepted by wfTimestamp() 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.

Parameters:
string | int$ts
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 1142 of file DatabasePostgres.php.

DatabasePostgres::triggerExists ( table,
trigger 
)

Definition at line 1384 of file DatabasePostgres.php.

Determines if the last failure was due to a deadlock STUB.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 1114 of file DatabasePostgres.php.


Member Data Documentation

string DatabasePostgres::$connectString [private]

Connect string to open a PostgreSQL connection *.

Definition at line 299 of file DatabasePostgres.php.

int DatabasePostgres::$mAffectedRows = null [protected]

The number of rows affected as an integer *.

Definition at line 293 of file DatabasePostgres.php.

string DatabasePostgres::$mCoreSchema [private]

*

Definition at line 303 of file DatabasePostgres.php.

int DatabasePostgres::$mInsertId = null [private]

*

Definition at line 295 of file DatabasePostgres.php.

resource DatabasePostgres::$mLastResult = null [protected]

*

Definition at line 291 of file DatabasePostgres.php.

PostgresTransactionState DatabasePostgres::$mTransactionState [private]

*

Definition at line 301 of file DatabasePostgres.php.

float string DatabasePostgres::$numericVersion = null [private]

*

Definition at line 297 of file DatabasePostgres.php.


The documentation for this class was generated from the following file: