[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/db/ -> DatabasePostgres.php (summary)

(no description)

File Size: 1694 lines (44 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 classes

PostgresField:: (10 methods):
  fromText()
  name()
  tableName()
  type()
  isNullable()
  maxLength()
  is_deferrable()
  is_deferred()
  conname()
  defaultValue()

PostgresTransactionState:: (5 methods):
  __construct()
  update()
  check()
  describe_changed()
  log_changed()

SavepointPostgres:: (8 methods):
  __construct()
  __destruct()
  commit()
  query()
  savepoint()
  release()
  rollback()
  __toString()

DatabasePostgres:: (82 methods):
  getType()
  cascadingDeletes()
  cleanupTriggers()
  strictIPs()
  realTimestamps()
  implicitGroupby()
  implicitOrderby()
  searchableIPs()
  functionalIndexes()
  hasConstraint()
  open()
  selectDB()
  makeConnectionString()
  closeConnection()
  doQuery()
  dumpError()
  reportQueryError()
  queryIgnore()
  freeResult()
  fetchObject()
  fetchRow()
  numRows()
  numFields()
  fieldName()
  insertId()
  dataSeek()
  lastError()
  lastErrno()
  affectedRows()
  estimateRowCount()
  indexInfo()
  indexAttributes()
  indexUnique()
  selectSQLText()
  insert()
  insertSelect()
  tableName()
  realTableName()
  nextSequenceValue()
  currentSequenceValue()
  textFieldSize()
  limitResult()
  wasDeadlock()
  duplicateTableStructure()
  listTables()
  timestamp()
  pg_array_parse()
  aggregateValue()
  getSoftwareLink()
  getCurrentSchema()
  getSchemas()
  getSearchPath()
  setSearchPath()
  determineCoreSchema()
  getCoreSchema()
  getServerVersion()
  relationExists()
  tableExists()
  sequenceExists()
  triggerExists()
  ruleExists()
  constraintExists()
  schemaExists()
  roleExists()
  fieldInfo()
  fieldType()
  encodeBlob()
  decodeBlob()
  strencode()
  addQuotes()
  replaceVars()
  makeSelectOptions()
  getDBname()
  getServer()
  buildConcat()
  buildGroupConcatField()
  getSearchEngine()
  streamStatementEnd()
  lockIsFree()
  lock()
  unlock()
  bigintFromLockName()


Class: PostgresField  - X-Ref

This is the Postgres database abstraction layer.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
http://www.gnu.org/copyleft/gpl.html

fromText( $db, $table, $field )   X-Ref

param: DatabaseBase $db
param: string $table
param: string $field
return: null|PostgresField

name()   X-Ref
No description

tableName()   X-Ref
No description

type()   X-Ref
No description

isNullable()   X-Ref
No description

maxLength()   X-Ref
No description

is_deferrable()   X-Ref
No description

is_deferred()   X-Ref
No description

conname()   X-Ref
No description

defaultValue()   X-Ref

return: bool|mixed

Class: PostgresTransactionState  - X-Ref

Used to debug transaction processing
Only used if $wgDebugDBTransactions is true

__construct( $conn )   X-Ref
No description

update()   X-Ref
No description

check()   X-Ref
No description

describe_changed( $status, $desc_table )   X-Ref
No description

log_changed( $old, $new, $watched )   X-Ref
No description

Class: SavepointPostgres  - X-Ref

Manage savepoints within a transaction

__construct( $dbw, $id )   X-Ref

param: DatabaseBase $dbw
param: int $id

__destruct()   X-Ref
No description

commit()   X-Ref
No description

query( $keyword, $msg_ok, $msg_failed )   X-Ref
No description

savepoint()   X-Ref
No description

release()   X-Ref
No description

rollback()   X-Ref
No description

__toString()   X-Ref
No description

Class: DatabasePostgres  - X-Ref


getType()   X-Ref
No description

cascadingDeletes()   X-Ref
No description

cleanupTriggers()   X-Ref
No description

strictIPs()   X-Ref
No description

realTimestamps()   X-Ref
No description

implicitGroupby()   X-Ref
No description

implicitOrderby()   X-Ref
No description

searchableIPs()   X-Ref
No description

functionalIndexes()   X-Ref
No description

hasConstraint( $name )   X-Ref
No description

open( $server, $user, $password, $dbName )   X-Ref
Usually aborts on failure

param: string $server
param: string $user
param: string $password
param: string $dbName
return: DatabaseBase|null

selectDB( $db )   X-Ref
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

param: string $db
return: bool

makeConnectionString( $vars )   X-Ref
No description

closeConnection()   X-Ref
Closes a database connection, if it is open
Returns success, true if already closed

return: bool

doQuery( $sql )   X-Ref
No description

dumpError()   X-Ref
No description

reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false )   X-Ref
No description

queryIgnore( $sql, $fname = __METHOD__ )   X-Ref
No description

freeResult( $res )   X-Ref

param: stdClass|ResultWrapper $res

fetchObject( $res )   X-Ref

param: ResultWrapper|stdClass $res
return: stdClass

fetchRow( $res )   X-Ref
No description

numRows( $res )   X-Ref
No description

numFields( $res )   X-Ref
No description

fieldName( $res, $n )   X-Ref
No description

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

return: int|null

dataSeek( $res, $row )   X-Ref

param: mixed $res
param: int $row
return: bool

lastError()   X-Ref
No description

lastErrno()   X-Ref
No description

affectedRows()   X-Ref
No description

estimateRowCount( $table, $vars = '*', $conds = '',$fname = __METHOD__, $options = array()   X-Ref
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()

param: string $table
param: string $vars
param: string $conds
param: string $fname
param: array $options
return: int

indexInfo( $table, $index, $fname = __METHOD__ )   X-Ref
Returns information about an index
If errors are explicitly ignored, returns NULL on failure

param: string $table
param: string $index
param: string $fname
return: bool|null

indexAttributes( $index, $schema = false )   X-Ref
Returns is of attributes used in index

param: string $index
param: bool|string $schema
return: array

indexUnique( $table, $index, $fname = __METHOD__ )   X-Ref
No description

selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__,$options = array()   X-Ref
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.

insert( $table, $args, $fname = __METHOD__, $options = array()   X-Ref
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).

param: string $table Name of the table to insert to.
param: array $args Items to insert into the table.
param: string $fname Name of the function, for profiling
param: array|string $options String or array. Valid options: IGNORE
return: bool Success of insert operation. IGNORE always returns true.

insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__,$insertOptions = array()   X-Ref
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.

param: string $destTable
param: array|string $srcTable
param: array $varMap
param: array $conds
param: string $fname
param: array $insertOptions
param: array $selectOptions
return: bool

tableName( $name, $format = 'quoted' )   X-Ref
No description

realTableName( $name, $format = 'quoted' )   X-Ref
No description

nextSequenceValue( $seqName )   X-Ref
Return the next in a sequence, save the value for retrieval via insertId()

param: string $seqName
return: int|null

currentSequenceValue( $seqName )   X-Ref
Return the current value of a sequence. Assumes it has been nextval'ed in this session.

param: string $seqName
return: int

textFieldSize( $table, $field )   X-Ref
No description

limitResult( $sql, $limit, $offset = false )   X-Ref
No description

wasDeadlock()   X-Ref
No description

duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ )   X-Ref
No description

listTables( $prefix = null, $fname = __METHOD__ )   X-Ref
No description

timestamp( $ts = 0 )   X-Ref
No description

pg_array_parse( $text, &$output, $limit = false, $offset = 1 )   X-Ref
Posted by cc[plus]php[at]c2se[dot]com on 25-Mar-2009 09:12
to http://www.php.net/manual/en/ref.pgsql.php

Parsing a postgres array can be a tricky problem, he's my
take on this, it handles multi-dimensional arrays plus
escaping using a nasty regexp to determine the limits of each
data-item.

This should really be handled by PHP PostgreSQL module

param: string $text Postgreql array returned in a text form like {a,b}
param: string $output
param: int $limit
param: int $offset
return: string

aggregateValue( $valuedata, $valuename = 'value' )   X-Ref
Return aggregated value function call

param: array $valuedata
param: string $valuename
return: array

getSoftwareLink()   X-Ref

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

getCurrentSchema()   X-Ref
Return current schema (executes SELECT current_schema())
Needs transaction

return: string Default schema for the current session

getSchemas()   X-Ref
Return list of schemas which are accessible without schema name
This is list does not contain magic keywords like "$user"
Needs transaction

return: array List of actual schemas for the current sesson

getSearchPath()   X-Ref
Return search patch for schemas
This is different from getSchemas() since it contain magic keywords
(like "$user").
Needs transaction

return: array How to search for table names schemas for the current user

setSearchPath( $search_path )   X-Ref
Update search_path, values should already be sanitized
Values may contain magic keywords like "$user"

param: array $search_path List of schemas to be searched by default

determineCoreSchema( $desiredSchema )   X-Ref
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

param: string $desiredSchema

getCoreSchema()   X-Ref
Return schema name fore core MediaWiki tables

return: string Core schema name

getServerVersion()   X-Ref

return: string Version information from the database

relationExists( $table, $types, $schema = false )   X-Ref
Query whether a given relation exists (in the given schema, or the
default mw one if not given)

param: string $table
param: array|string $types
param: bool|string $schema
return: bool

tableExists( $table, $fname = __METHOD__, $schema = false )   X-Ref
For backward compatibility, this function checks both tables and
views.

param: string $table
param: string $fname
param: bool|string $schema
return: bool

sequenceExists( $sequence, $schema = false )   X-Ref
No description

triggerExists( $table, $trigger )   X-Ref
No description

ruleExists( $table, $rule )   X-Ref
No description

constraintExists( $table, $constraint )   X-Ref
No description

schemaExists( $schema )   X-Ref
Query whether a given schema exists. Returns true if it does, false if it doesn't.

param: string $schema
return: bool

roleExists( $roleName )   X-Ref
Returns true if a given role (i.e. user) exists, false otherwise.

param: string $roleName
return: bool

fieldInfo( $table, $field )   X-Ref
No description

fieldType( $res, $index )   X-Ref
pg_field_type() wrapper

param: ResultWrapper|resource $res ResultWrapper or PostgreSQL query result resource
param: int $index Field number, starting from 0
return: string

encodeBlob( $b )   X-Ref

param: string $b
return: Blob

decodeBlob( $b )   X-Ref
No description

strencode( $s )   X-Ref
No description

addQuotes( $s )   X-Ref

param: null|bool|Blob $s
return: int|string

replaceVars( $ins )   X-Ref
Postgres specific version of replaceVars.
Calls the parent version in Database.php

param: string $ins SQL string, read from a stream (usually tables.sql)
return: string SQL string

makeSelectOptions( $options )   X-Ref
Various select options

param: array $options An associative array of options to be turned into
return: array

getDBname()   X-Ref
No description

getServer()   X-Ref
No description

buildConcat( $stringList )   X-Ref
No description

buildGroupConcatField($delimiter, $table, $field, $conds = '', $options = array()   X-Ref
No description

getSearchEngine()   X-Ref
No description

streamStatementEnd( &$sql, &$newLine )   X-Ref
No description

lockIsFree( $lockName, $method )   X-Ref
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

param: string $lockName Name of lock to poll
param: string $method Name of method calling us
return: bool

lock( $lockName, $method, $timeout = 5 )   X-Ref
See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS

param: string $lockName
param: string $method
param: int $timeout
return: bool

unlock( $lockName, $method )   X-Ref
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

param: string $lockName
param: string $method
return: bool

bigintFromLockName( $lockName )   X-Ref

param: string $lockName
return: string Integer



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1