/usr/share/phpmyadmin/libraries/classes/Query
Edit: /usr/share/phpmyadmin/libraries/classes/Query/Generator.php (14179B)
\'InnoDB\', t.DATA_FREE, 0)) AS SCHEMA_DATA_FREE';
}
$sql .= ' FROM `information_schema`.SCHEMATA s ';
if ($forceStats) {
$sql .= ' LEFT JOIN `information_schema`.TABLES t'
. ' ON BINARY t.TABLE_SCHEMA = BINARY s.SCHEMA_NAME';
}
$sql .= $sqlWhereSchema
. ' GROUP BY BINARY s.SCHEMA_NAME, s.DEFAULT_COLLATION_NAME'
. ' ORDER BY ';
if ($sortBy === 'SCHEMA_NAME' || $sortBy === 'DEFAULT_COLLATION_NAME') {
$sql .= 'BINARY ';
}
$sql .= Util::backquote($sortBy)
. ' ' . $sortOrder
. $limit;
$sql .= ') a';
return $sql;
}
public static function getInformationSchemaColumnsFullRequest(
?string $escapedDatabase,
?string $escapedTable,
?string $escapedColumn
): array {
$sqlWheres = [];
$arrayKeys = [];
// get columns information from information_schema
if ($escapedDatabase !== null) {
$sqlWheres[] = '`TABLE_SCHEMA` = \''
. $escapedDatabase . '\' ';
} else {
$arrayKeys[] = 'TABLE_SCHEMA';
}
if ($escapedTable !== null) {
$sqlWheres[] = '`TABLE_NAME` = \''
. $escapedTable . '\' ';
} else {
$arrayKeys[] = 'TABLE_NAME';
}
if ($escapedColumn !== null) {
$sqlWheres[] = '`COLUMN_NAME` = \''
. $escapedColumn . '\' ';
} else {
$arrayKeys[] = 'COLUMN_NAME';
}
// for PMA bc:
// `[SCHEMA_FIELD_NAME]` AS `[SHOW_FULL_COLUMNS_FIELD_NAME]`
$sql = 'SELECT *,'
. ' `COLUMN_NAME` AS `Field`,'
. ' `COLUMN_TYPE` AS `Type`,'
. ' `COLLATION_NAME` AS `Collation`,'
. ' `IS_NULLABLE` AS `Null`,'
. ' `COLUMN_KEY` AS `Key`,'
. ' `COLUMN_DEFAULT` AS `Default`,'
. ' `EXTRA` AS `Extra`,'
. ' `PRIVILEGES` AS `Privileges`,'
. ' `COLUMN_COMMENT` AS `Comment`'
. ' FROM `information_schema`.`COLUMNS`';
if (count($sqlWheres)) {
$sql .= "\n" . ' WHERE ' . implode(' AND ', $sqlWheres);
}
return [$sql, $arrayKeys];
}
/**
* Function to get sql query for renaming the index using SQL RENAME INDEX Syntax
*/
public static function getSqlQueryForIndexRename(
string $dbName,
string $tableName,
string $oldIndexName,
string $newIndexName
): string {
return sprintf(
'ALTER TABLE %s.%s RENAME INDEX %s TO %s;',
Util::backquote($dbName),
Util::backquote($tableName),
Util::backquote($oldIndexName),
Util::backquote($newIndexName)
);
}
}