[DATABASE] Check SQL boolean values with "IS TRUE"

This way UNKNOWN (NULL) explicitly turns to FALSE when three-valued logic is
reduced to binary.
In pgsqlschema, however, use "IS FALSE" as boolean attributes in pg_index are
non-nullable, there is no outer join and there's no clear preference for NULL
reduction.

Over-complicated constructions in TagCloud queries have been simplified, which
should not affect their performance.

Additionally, in TagCloud's lib/subscriptionspeopleselftagcloudsection.php
a typing mistake in an equi-join of "profile_tag" and "profile_list" on
"tagger" was fixed.
That regression was introduced in f446db8e2a
This commit is contained in:
Alexei Sorokin
2020-07-21 18:06:39 +03:00
committed by Diogo Peralta Cordeiro
parent a996ac797a
commit e902a9bdfc
14 changed files with 255 additions and 211 deletions

View File

@@ -260,14 +260,20 @@ class MysqlSchema extends Schema
*/
public function fetchIndexInfo(string $table): array
{
$query = 'SELECT INDEX_NAME AS `key_name`, INDEX_TYPE AS `key_type`, COLUMN_NAME AS `col` ' .
'FROM INFORMATION_SCHEMA.STATISTICS ' .
'WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME = \'%s\' AND NON_UNIQUE = TRUE ' .
'AND INDEX_NAME NOT IN (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL) ' .
'ORDER BY SEQ_IN_INDEX';
$schema = $this->conn->dsn['database'];
$sql = sprintf($query, $schema, $table);
$data = $this->fetchQueryData($sql);
$data = $this->fetchQueryData(
<<<END
SELECT INDEX_NAME AS `key_name`, INDEX_TYPE AS `key_type`, COLUMN_NAME AS `col`
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = '{$schema}' AND TABLE_NAME = '{$table}'
AND NON_UNIQUE IS TRUE
AND INDEX_NAME NOT IN (
SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE REFERENCED_TABLE_NAME IS NOT NULL
)
ORDER BY SEQ_IN_INDEX;
END
);
$rows = [];
foreach ($data as $row) {