Index: trunk/phase3/includes/DatabasePostgres.php |
— | — | @@ -7,9 +7,6 @@ |
8 | 8 | * than MySQL ones, some of them should be moved to parent |
9 | 9 | * Database class. |
10 | 10 | * |
11 | | - * STATUS: Working PG implementation of MediaWiki |
12 | | - * TODO: Installer support |
13 | | - * |
14 | 11 | * @package MediaWiki |
15 | 12 | */ |
16 | 13 | |
— | — | @@ -18,10 +15,6 @@ |
19 | 16 | */ |
20 | 17 | require_once( 'Database.php' ); |
21 | 18 | |
22 | | -/** |
23 | | - * |
24 | | - * @package MediaWiki |
25 | | - */ |
26 | 19 | class DatabasePostgres extends Database { |
27 | 20 | var $mInsertId = NULL; |
28 | 21 | var $mLastResult = NULL; |
— | — | @@ -191,6 +184,7 @@ |
192 | 185 | } |
193 | 186 | |
194 | 187 | function fieldInfo( $table, $field ) { |
| 188 | + return false; |
195 | 189 | throw new DBUnexpectedError($this, 'Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre' ); |
196 | 190 | /* |
197 | 191 | $res = $this->query( "SELECT * FROM '$table' LIMIT 1" ); |
— | — | @@ -439,6 +433,41 @@ |
440 | 434 | $searchpath=$this->makeList($schemas,LIST_NAMES); |
441 | 435 | $this->query("SET search_path = $searchpath"); |
442 | 436 | } |
| 437 | + |
| 438 | + /** |
| 439 | + * Query whether a given table exists |
| 440 | + */ |
| 441 | + function tableExists( $table, $fname = 'DatabasePostgres:tableExists' ) { |
| 442 | + global $wgDBschema; |
| 443 | + $stable = preg_replace("/'/", "''", $table); |
| 444 | + $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " |
| 445 | + . "WHERE c.relnamespace = n.oid AND c.relname = '$stable AND n.nspname = '$wgDBschema'"; |
| 446 | + $res = $this->query( $SQL, $fname ); |
| 447 | + if ($res) { |
| 448 | + $this->freeResult( $res ); |
| 449 | + return true; |
| 450 | + } |
| 451 | + return false; |
| 452 | + } |
| 453 | + |
| 454 | + /** |
| 455 | + * Query whether a given column exists |
| 456 | + */ |
| 457 | + function fieldExists( $table, $field, $fname = 'DatabasePostgres::fieldExists' ) { |
| 458 | + global $wgDBschema; |
| 459 | + $stable = preg_replace("/'/", "''", $table); |
| 460 | + $scol = preg_replace("/'/", "''", $field); |
| 461 | + $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_catalog.pg_attribute a " |
| 462 | + . "WHERE c.relnamespace = n.oid AND c.relname = '$stable' AND n.nspname = '$wgDBschema' " |
| 463 | + . "AND a.attrelid = c.oid AND a.attname = '$safecol'"; |
| 464 | + $res = $this->query( $SQL, $fname ); |
| 465 | + if ($res) { |
| 466 | + $this->freeResult( $res ); |
| 467 | + return true; |
| 468 | + } |
| 469 | + return false; |
| 470 | + } |
| 471 | + |
443 | 472 | } |
444 | 473 | |
445 | 474 | ?> |