Code Duplication    Length = 15-22 lines in 2 locations

includes/libs/rdbms/database/DatabasePostgres.php 2 locations

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