@@ 1073-1094 (lines=22) @@ | ||
1070 | return $this->relationExists( $sequence, 'S', $schema ); |
|
1071 | } |
|
1072 | ||
1073 | public function triggerExists( $table, $trigger ) { |
|
1074 | $q = <<<SQL |
|
1075 | SELECT 1 FROM pg_class, pg_namespace, pg_trigger |
|
1076 | WHERE relnamespace=pg_namespace.oid AND relkind='r' |
|
1077 | AND tgrelid=pg_class.oid |
|
1078 | AND nspname=%s AND relname=%s AND tgname=%s |
|
1079 | SQL; |
|
1080 | $res = $this->query( |
|
1081 | sprintf( |
|
1082 | $q, |
|
1083 | $this->addQuotes( $this->getCoreSchema() ), |
|
1084 | $this->addQuotes( $table ), |
|
1085 | $this->addQuotes( $trigger ) |
|
1086 | ) |
|
1087 | ); |
|
1088 | if ( !$res ) { |
|
1089 | return null; |
|
1090 | } |
|
1091 | $rows = $res->numRows(); |
|
1092 | ||
1093 | return $rows; |
|
1094 | } |
|
1095 | ||
1096 | public function ruleExists( $table, $rule ) { |
|
1097 | $exists = $this->selectField( 'pg_rules', 'rulename', |
|
@@ 1108-1122 (lines=15) @@ | ||
1105 | return $exists === $rule; |
|
1106 | } |
|
1107 | ||
1108 | public function constraintExists( $table, $constraint ) { |
|
1109 | $sql = sprintf( "SELECT 1 FROM information_schema.table_constraints " . |
|
1110 | "WHERE constraint_schema = %s AND table_name = %s AND constraint_name = %s", |
|
1111 | $this->addQuotes( $this->getCoreSchema() ), |
|
1112 | $this->addQuotes( $table ), |
|
1113 | $this->addQuotes( $constraint ) |
|
1114 | ); |
|
1115 | $res = $this->query( $sql ); |
|
1116 | if ( !$res ) { |
|
1117 | return null; |
|
1118 | } |
|
1119 | $rows = $res->numRows(); |
|
1120 | ||
1121 | return $rows; |
|
1122 | } |
|
1123 | ||
1124 | /** |
|
1125 | * Query whether a given schema exists. Returns true if it does, false if it doesn't. |