X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabasePostgres.php;h=a5dc1713dcf25eb855ac5f3b47af965635f2b369;hb=1a62e51a00321eb6674e27cdff57c683703a5579;hp=5f04e39718ef9a9c780acdcdf1e997145924b20f;hpb=d24cb5054ca51282c82db63cc78fc99d2e23dbbf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabasePostgres.php b/includes/libs/rdbms/database/DatabasePostgres.php index 5f04e39718..a5dc1713dc 100644 --- a/includes/libs/rdbms/database/DatabasePostgres.php +++ b/includes/libs/rdbms/database/DatabasePostgres.php @@ -116,7 +116,7 @@ class DatabasePostgres extends Database { $connectVars['port'] = (int)$this->port; } if ( $this->flags & self::DBO_SSL ) { - $connectVars['sslmode'] = 1; + $connectVars['sslmode'] = 'require'; } $this->connectString = $this->makeConnectionString( $connectVars ); @@ -216,6 +216,10 @@ class DatabasePostgres extends Database { !preg_match( '/^SELECT\s+pg_(try_|)advisory_\w+\(/', $sql ); } + /** + * @param string $sql + * @return bool|mixed|resource + */ public function doQuery( $sql ) { $conn = $this->getBindingHandle(); @@ -653,6 +657,18 @@ __INDEXATTR__; return true; } + protected function makeUpdateOptionsArray( $options ) { + if ( !is_array( $options ) ) { + $options = [ $options ]; + } + + // PostgreSQL doesn't support anything like "ignore" for + // UPDATE. + $options = array_diff( $options, [ 'IGNORE' ] ); + + return parent::makeUpdateOptionsArray( $options ); + } + /** * INSERT SELECT wrapper * $varMap must be an associative array of the form [ 'dest1' => 'source1', ... ] @@ -803,8 +819,12 @@ __INDEXATTR__; $temporary = $temporary ? 'TEMPORARY' : ''; - $ret = $this->query( "CREATE $temporary TABLE $newNameE " . - "(LIKE $oldNameE INCLUDING DEFAULTS INCLUDING INDEXES)", $fname ); + $ret = $this->query( + "CREATE $temporary TABLE $newNameE " . + "(LIKE $oldNameE INCLUDING DEFAULTS INCLUDING INDEXES)", + $fname, + $this::QUERY_PSEUDO_PERMANENT + ); if ( !$ret ) { return $ret; } @@ -816,7 +836,7 @@ __INDEXATTR__; . ' WHERE relkind = \'r\'' . ' AND nspname = ' . $this->addQuotes( $this->getCoreSchema() ) . ' AND relname = ' . $this->addQuotes( $oldName ) - . ' AND adsrc LIKE \'nextval(%\'', + . ' AND pg_get_expr(adbin, adrelid) LIKE \'nextval(%\'', $fname ); $row = $this->fetchObject( $res ); @@ -826,7 +846,10 @@ __INDEXATTR__; $fieldE = $this->addIdentifierQuotes( $field ); $newSeqE = $this->addIdentifierQuotes( $newSeq ); $newSeqQ = $this->addQuotes( $newSeq ); - $this->query( "CREATE $temporary SEQUENCE $newSeqE OWNED BY $newNameE.$fieldE", $fname ); + $this->query( + "CREATE $temporary SEQUENCE $newSeqE OWNED BY $newNameE.$fieldE", + $fname + ); $this->query( "ALTER TABLE $newNameE ALTER COLUMN $fieldE SET DEFAULT nextval({$newSeqQ}::regclass)", $fname @@ -851,10 +874,10 @@ __INDEXATTR__; } $oid = $this->fetchObject( $res )->oid; - $res = $this->query( 'SELECT adsrc FROM pg_attribute a' + $res = $this->query( 'SELECT pg_get_expr(adbin, adrelid) AS adsrc FROM pg_attribute a' . ' JOIN pg_attrdef d ON (a.attrelid=d.adrelid and a.attnum=d.adnum)' . " WHERE a.attrelid = $oid" - . ' AND adsrc LIKE \'nextval(%\'', + . ' AND pg_get_expr(adbin, adrelid) LIKE \'nextval(%\'', $fname ); $row = $this->fetchObject( $res ); @@ -1330,10 +1353,6 @@ SQL; return [ $startOpts, $useIndex, $preLimitTail, $postLimitTail, $ignoreIndex ]; } - public function getServer() { - return $this->server; - } - public function buildConcat( $stringList ) { return implode( ' || ', $stringList ); }