Merge pull request #18776 from u7723606/truncated-all-tables
Fix truncate operation for views
This commit is contained in:
commit
639674d65f
@ -14,6 +14,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Operations;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Sql;
|
||||
use PhpMyAdmin\Table;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Util;
|
||||
@ -21,6 +22,7 @@ use PhpMyAdmin\Utils\ForeignKey;
|
||||
|
||||
use function __;
|
||||
use function count;
|
||||
use function is_string;
|
||||
|
||||
final class EmptyTableController extends AbstractController
|
||||
{
|
||||
@ -82,6 +84,10 @@ final class EmptyTableController extends AbstractController
|
||||
$selectedCount = count($selected);
|
||||
|
||||
for ($i = 0; $i < $selectedCount; $i++) {
|
||||
if (! is_string($selected[$i]) || Table::get($selected[$i], $GLOBALS['db'], $this->dbi)->isView()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$aQuery = 'TRUNCATE ';
|
||||
$aQuery .= Util::backquote($selected[$i]);
|
||||
|
||||
|
||||
@ -7,8 +7,10 @@ namespace PhpMyAdmin\Partitioning;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\DatabaseName;
|
||||
use PhpMyAdmin\Dbal\TableName;
|
||||
use PhpMyAdmin\Table;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function sprintf;
|
||||
|
||||
final class Maintenance
|
||||
@ -135,6 +137,10 @@ final class Maintenance
|
||||
*/
|
||||
public function truncate(DatabaseName $db, TableName $table, string $partition): array
|
||||
{
|
||||
if (Table::get($table->getName(), $db->getName(), $this->dbi)->isView()) {
|
||||
return [false, __('This table is a view, it can not be truncated.')];
|
||||
}
|
||||
|
||||
$query = sprintf(
|
||||
'ALTER TABLE %s TRUNCATE PARTITION %s;',
|
||||
Util::backquote($table->getName()),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user