| @@ 1112-1133 (lines=22) @@ | ||
| 1109 | return $this->relationExists( $sequence, 'S', $schema ); |
|
| 1110 | } |
|
| 1111 | ||
| 1112 | function triggerExists( $table, $trigger ) { |
|
| 1113 | $q = <<<SQL |
|
| 1114 | SELECT 1 FROM pg_class, pg_namespace, pg_trigger |
|
| 1115 | WHERE relnamespace=pg_namespace.oid AND relkind='r' |
|
| 1116 | AND tgrelid=pg_class.oid |
|
| 1117 | AND nspname=%s AND relname=%s AND tgname=%s |
|
| 1118 | SQL; |
|
| 1119 | $res = $this->query( |
|
| 1120 | sprintf( |
|
| 1121 | $q, |
|
| 1122 | $this->addQuotes( $this->getCoreSchema() ), |
|
| 1123 | $this->addQuotes( $table ), |
|
| 1124 | $this->addQuotes( $trigger ) |
|
| 1125 | ) |
|
| 1126 | ); |
|
| 1127 | if ( !$res ) { |
|
| 1128 | return null; |
|
| 1129 | } |
|
| 1130 | $rows = $res->numRows(); |
|
| 1131 | ||
| 1132 | return $rows; |
|
| 1133 | } |
|
| 1134 | ||
| 1135 | function ruleExists( $table, $rule ) { |
|
| 1136 | $exists = $this->selectField( 'pg_rules', 'rulename', |
|
| @@ 1147-1161 (lines=15) @@ | ||
| 1144 | return $exists === $rule; |
|
| 1145 | } |
|
| 1146 | ||
| 1147 | function constraintExists( $table, $constraint ) { |
|
| 1148 | $sql = sprintf( "SELECT 1 FROM information_schema.table_constraints " . |
|
| 1149 | "WHERE constraint_schema = %s AND table_name = %s AND constraint_name = %s", |
|
| 1150 | $this->addQuotes( $this->getCoreSchema() ), |
|
| 1151 | $this->addQuotes( $table ), |
|
| 1152 | $this->addQuotes( $constraint ) |
|
| 1153 | ); |
|
| 1154 | $res = $this->query( $sql ); |
|
| 1155 | if ( !$res ) { |
|
| 1156 | return null; |
|
| 1157 | } |
|
| 1158 | $rows = $res->numRows(); |
|
| 1159 | ||
| 1160 | return $rows; |
|
| 1161 | } |
|
| 1162 | ||
| 1163 | /** |
|
| 1164 | * Query whether a given schema exists. Returns true if it does, false if it doesn't. |
|