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