Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19388 from MoonE/revert-query-stats-for…
Browse files Browse the repository at this point in the history
…-count

Revert "Show query stats for count(*) query"

Didn't manage to fix the duplicate query results, so this is reverts phpmyadmin#19221 phpmyadmin#19237 for now
Fixes phpmyadmin#19245
Should reopen phpmyadmin#16869
  • Loading branch information
MauricioFauth authored Dec 25, 2024
2 parents 08b992a + e9c3c28 commit 9ee8e20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 34 deletions.
22 changes: 7 additions & 15 deletions libraries/classes/Display/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class Results
* unlim_num_rows: int|numeric-string|false,
* fields_meta: FieldMetadata[],
* is_count: bool|null,
* is_group: bool|null,
* is_export: bool|null,
* is_func: bool|null,
* is_analyse: bool|null,
Expand Down Expand Up @@ -179,8 +178,6 @@ class Results

'is_count' => null,

'is_group' => null,

'is_export' => null,

'is_func' => null,
Expand Down Expand Up @@ -397,7 +394,6 @@ private function setDefaultTransformations(): void
* any appended "LIMIT" clause programmatically
* @param FieldMetadata[] $fieldsMeta meta information about fields
* @param bool $isCount statement is SELECT COUNT
* @param bool $isGroup statement has GROUP BY
* @param bool $isExport statement contains INTO OUTFILE
* @param bool $isFunction statement contains a function like SUM()
* @param bool $isAnalyse statement contains PROCEDURE ANALYSE
Expand All @@ -419,7 +415,6 @@ public function setProperties(
$unlimNumRows,
array $fieldsMeta,
$isCount,
$isGroup,
$isExport,
$isFunction,
$isAnalyse,
Expand All @@ -438,7 +433,6 @@ public function setProperties(
$this->properties['unlim_num_rows'] = $unlimNumRows;
$this->properties['fields_meta'] = $fieldsMeta;
$this->properties['is_count'] = $isCount;
$this->properties['is_group'] = $isGroup;
$this->properties['is_export'] = $isExport;
$this->properties['is_func'] = $isFunction;
$this->properties['is_analyse'] = $isAnalyse;
Expand Down Expand Up @@ -472,7 +466,6 @@ private function setDisplayPartsForPrintView(array $displayParts)
$displayParts['bkm_form'] = '0';
$displayParts['text_btn'] = '0';
$displayParts['pview_lnk'] = '0';
$displayParts['query_stats'] = '1';

return $displayParts;
}
Expand Down Expand Up @@ -517,7 +510,6 @@ private function setDisplayPartsForShow(array $displayParts)
$displayParts['bkm_form'] = '1';
$displayParts['text_btn'] = '1';
$displayParts['pview_lnk'] = '1';
$displayParts['query_stats'] = '0';

return $displayParts;
}
Expand All @@ -539,7 +531,6 @@ private function setDisplayPartsForNonData(array $displayParts)
$displayParts['sort_lnk'] = '0';
$displayParts['nav_bar'] = '0';
$displayParts['bkm_form'] = '1';
$displayParts['query_stats'] = '0';

if ($this->properties['is_maint']) {
$displayParts['text_btn'] = '1';
Expand Down Expand Up @@ -637,13 +628,14 @@ private function setDisplayPartsAndTotal(array $displayParts)
$db = $this->properties['db'];
$table = $this->properties['table'];
$unlimNumRows = $this->properties['unlim_num_rows'];
$numRows = $this->properties['num_rows'];
$printView = $this->properties['printview'];

// 2. Updates the display parts
if ($printView == '1') {
$displayParts = $this->setDisplayPartsForPrintView($displayParts);
} elseif (
$this->properties['is_analyse']
$this->properties['is_count'] || $this->properties['is_analyse']
|| $this->properties['is_maint'] || $this->properties['is_explain']
) {
$displayParts = $this->setDisplayPartsForNonData($displayParts);
Expand All @@ -666,9 +658,9 @@ private function setDisplayPartsAndTotal(array $displayParts)

// if for COUNT query, number of rows returned more than 1
// (may be being used GROUP BY)
if ($this->properties['is_count'] && ! $this->properties['is_group']) {
$displayParts['nav_bar'] = '0';
$displayParts['sort_lnk'] = '0';
if ($this->properties['is_count'] && $numRows > 1) {
$displayParts['nav_bar'] = '1';
$displayParts['sort_lnk'] = '1';
}

// 4. If navigation bar or sorting fields names URLs should be
Expand Down Expand Up @@ -3650,7 +3642,7 @@ public function getTable(
// 1.2 Defines offsets for the next and previous pages
$posNext = 0;
$posPrev = 0;
if ($displayParts['nav_bar'] == '1' || $displayParts['query_stats'] === '1') {
if ($displayParts['nav_bar'] == '1') {
[$posNext, $posPrev] = $this->getOffsets();
}

Expand Down Expand Up @@ -3683,7 +3675,7 @@ public function getTable(

// 2.1 Prepares a messages with position information
$sqlQueryMessage = '';
if ($displayParts['query_stats'] == '1' && $total > 0) {
if ($displayParts['nav_bar'] == '1') {
$message = $this->setMessageInformation(
$sortedColumnMessage,
$analyzedSqlResults,
Expand Down
7 changes: 0 additions & 7 deletions libraries/classes/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,6 @@ private function getQueryResponseForNoResultsReturned(
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1',
'query_stats' => '1',
];

$sqlQueryResultsTable = $this->getHtmlForSqlQueryResultsTable(
Expand Down Expand Up @@ -1227,7 +1226,6 @@ private function getHtmlForSqlQueryResultsTable(
$numRows,
$fieldsMeta,
$analyzedSqlResults['is_count'],
$analyzedSqlResults['is_group'],
$analyzedSqlResults['is_export'],
$analyzedSqlResults['is_func'],
$analyzedSqlResults['is_analyse'],
Expand All @@ -1252,7 +1250,6 @@ private function getHtmlForSqlQueryResultsTable(
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1',
'query_stats' => '1',
];

$tableHtml .= $displayResultsObject->getTable(
Expand All @@ -1277,7 +1274,6 @@ private function getHtmlForSqlQueryResultsTable(
$unlimNumRows,
$fieldsMeta,
$analyzedSqlResults['is_count'],
$analyzedSqlResults['is_group'],
$analyzedSqlResults['is_export'],
$analyzedSqlResults['is_func'],
$analyzedSqlResults['is_analyse'],
Expand Down Expand Up @@ -1485,7 +1481,6 @@ private function getQueryResponseForResultsReturned(
'bkm_form' => '1',
'text_btn' => '0',
'pview_lnk' => '1',
'query_stats' => '1',
];

if (! $editable) {
Expand All @@ -1497,7 +1492,6 @@ private function getQueryResponseForResultsReturned(
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1',
'query_stats' => '1',
];
}

Expand All @@ -1510,7 +1504,6 @@ private function getQueryResponseForResultsReturned(
'bkm_form' => '0',
'text_btn' => '0',
'pview_lnk' => '0',
'query_stats' => '0',
];
}

Expand Down
15 changes: 5 additions & 10 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6078,7 +6078,7 @@
<code>$sortExpression</code>
<code>$urlParams</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess occurrences="69">
<MixedArrayAccess occurrences="68">
<code>$_SESSION['tmpval']['display_binary']</code>
<code>$_SESSION['tmpval']['display_binary']</code>
<code>$_SESSION['tmpval']['display_binary']</code>
Expand Down Expand Up @@ -6124,8 +6124,7 @@
<code>$displayParams['data'][$rowNumber]</code>
<code>$displayParts['nav_bar']</code>
<code>$displayParts['nav_bar']</code>
<code>$displayParts['query_stats']</code>
<code>$displayParts['query_stats']</code>
<code>$displayParts['nav_bar']</code>
<code>$displayParts['sort_lnk']</code>
<code>$oneKey['index_list']</code>
<code>$oneKey['ref_db_name']</code>
Expand Down Expand Up @@ -13136,7 +13135,7 @@
<LessSpecificReturnStatement occurrences="1">
<code>$unlimNumRows</code>
</LessSpecificReturnStatement>
<MixedArgument occurrences="43">
<MixedArgument occurrences="41">
<code>$analyzedSqlResults</code>
<code>$analyzedSqlResults['is_affected']</code>
<code>$analyzedSqlResults['is_analyse']</code>
Expand All @@ -13149,8 +13148,6 @@
<code>$analyzedSqlResults['is_export']</code>
<code>$analyzedSqlResults['is_func']</code>
<code>$analyzedSqlResults['is_func']</code>
<code>$analyzedSqlResults['is_group']</code>
<code>$analyzedSqlResults['is_group']</code>
<code>$analyzedSqlResults['is_maint']</code>
<code>$analyzedSqlResults['is_maint']</code>
<code>$analyzedSqlResults['is_show']</code>
Expand Down Expand Up @@ -15285,7 +15282,7 @@
<DocblockTypeContradiction occurrences="1">
<code>assertSame</code>
</DocblockTypeContradiction>
<MixedArgument occurrences="17">
<MixedArgument occurrences="16">
<code>$actual</code>
<code>$analyzedSqlResults</code>
<code>$analyzedSqlResults</code>
Expand All @@ -15296,20 +15293,18 @@
<code>$analyzedSqlResults['is_explain']</code>
<code>$analyzedSqlResults['is_export']</code>
<code>$analyzedSqlResults['is_func']</code>
<code>$analyzedSqlResults['is_group']</code>
<code>$analyzedSqlResults['is_maint']</code>
<code>$analyzedSqlResults['is_show']</code>
<code>$output</code>
<code>$output</code>
</MixedArgument>
<MixedArrayAccess occurrences="9">
<MixedArrayAccess occurrences="8">
<code>$_SESSION['tmpval']['pftext']</code>
<code>$analyzedSqlResults['is_analyse']</code>
<code>$analyzedSqlResults['is_count']</code>
<code>$analyzedSqlResults['is_explain']</code>
<code>$analyzedSqlResults['is_export']</code>
<code>$analyzedSqlResults['is_func']</code>
<code>$analyzedSqlResults['is_group']</code>
<code>$analyzedSqlResults['is_maint']</code>
<code>$analyzedSqlResults['is_show']</code>
</MixedArrayAccess>
Expand Down
2 changes: 0 additions & 2 deletions test/classes/Display/ResultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ public function testGetTable(): void
3,
$fieldsMeta,
$analyzedSqlResults['is_count'],
$analyzedSqlResults['is_group'],
$analyzedSqlResults['is_export'],
$analyzedSqlResults['is_func'],
$analyzedSqlResults['is_analyse'],
Expand Down Expand Up @@ -1423,7 +1422,6 @@ public function testGetTable(): void
'bkm_form' => '1',
'text_btn' => '0',
'pview_lnk' => '1',
'query_stats' => '1',
];
self::assertNotFalse($dtResult);
$actual = $object->getTable($dtResult, $displayParts, $analyzedSqlResults);
Expand Down

0 comments on commit 9ee8e20

Please sign in to comment.