| @@ 1312-1333 (lines=22) @@ | ||
| 1309 | return $this->relationExists( $sequence, 'S', $schema ); |
|
| 1310 | } |
|
| 1311 | ||
| 1312 | function triggerExists( $table, $trigger ) { |
|
| 1313 | $q = <<<SQL |
|
| 1314 | SELECT 1 FROM pg_class, pg_namespace, pg_trigger |
|
| 1315 | WHERE relnamespace=pg_namespace.oid AND relkind='r' |
|
| 1316 | AND tgrelid=pg_class.oid |
|
| 1317 | AND nspname=%s AND relname=%s AND tgname=%s |
|
| 1318 | SQL; |
|
| 1319 | $res = $this->query( |
|
| 1320 | sprintf( |
|
| 1321 | $q, |
|
| 1322 | $this->addQuotes( $this->getCoreSchema() ), |
|
| 1323 | $this->addQuotes( $table ), |
|
| 1324 | $this->addQuotes( $trigger ) |
|
| 1325 | ) |
|
| 1326 | ); |
|
| 1327 | if ( !$res ) { |
|
| 1328 | return null; |
|
| 1329 | } |
|
| 1330 | $rows = $res->numRows(); |
|
| 1331 | ||
| 1332 | return $rows; |
|
| 1333 | } |
|
| 1334 | ||
| 1335 | function ruleExists( $table, $rule ) { |
|
| 1336 | $exists = $this->selectField( 'pg_rules', 'rulename', |
|
| @@ 1347-1361 (lines=15) @@ | ||
| 1344 | return $exists === $rule; |
|
| 1345 | } |
|
| 1346 | ||
| 1347 | function constraintExists( $table, $constraint ) { |
|
| 1348 | $sql = sprintf( "SELECT 1 FROM information_schema.table_constraints " . |
|
| 1349 | "WHERE constraint_schema = %s AND table_name = %s AND constraint_name = %s", |
|
| 1350 | $this->addQuotes( $this->getCoreSchema() ), |
|
| 1351 | $this->addQuotes( $table ), |
|
| 1352 | $this->addQuotes( $constraint ) |
|
| 1353 | ); |
|
| 1354 | $res = $this->query( $sql ); |
|
| 1355 | if ( !$res ) { |
|
| 1356 | return null; |
|
| 1357 | } |
|
| 1358 | $rows = $res->numRows(); |
|
| 1359 | ||
| 1360 | return $rows; |
|
| 1361 | } |
|
| 1362 | ||
| 1363 | /** |
|
| 1364 | * Query whether a given schema exists. Returns true if it does, false if it doesn't. |
|