Skip to content

Commit 8060672

Browse files
author
Artem Fadeev
committed
Fix svace warnings
Fixed arithmetics in check_dsa_file_size to avoid server startup failure when aqo.dsm_size_max in bytes overflows signed integer. Updated corresponding tap-test. Two unreachable paths were removed. (cherry-picked from master with a minor change in tap-test)
1 parent bc900f7 commit 8060672

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

cardinality_hooks.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,6 @@ aqo_estimate_num_groups(PlannerInfo *root, List *groupExprs,
447447
/* It is unclear that to do in situation of such kind. Just report it */
448448
elog(WARNING, "AQO is in the middle of the estimate_num_groups_hook chain");
449449

450-
if (groupExprs == NIL)
451-
return 1.0;
452-
453450
old_ctx_m = MemoryContextSwitchTo(AQOPredictMemCtx);
454451

455452
predicted = predict_num_groups(root, subpath, groupExprs, &fss);

storage.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,6 @@ aqo_get_file_size(const char *filename)
968968
ereport(LOG,
969969
(errcode_for_file_access(),
970970
errmsg("could not read file \"%s\": %m", filename)));
971-
if (file)
972-
FreeFile(file);
973971
unlink(filename);
974972
return -1;
975973
}
@@ -981,7 +979,7 @@ check_dsa_file_size(void)
981979
long data_size = aqo_get_file_size(PGAQO_DATA_FILE);
982980

983981
if (qtext_size == -1 || data_size == -1 ||
984-
qtext_size + data_size >= dsm_size_max * 1024 * 1024)
982+
((unsigned long) qtext_size + (unsigned long) data_size) >> 20 >= dsm_size_max)
985983
{
986984
elog(ERROR, "aqo.dsm_size_max is too small");
987985
}

t/004_dsm_size_max.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PostgreSQL::Test::Cluster;
66
use PostgreSQL::Test::Utils;
77

8-
use Test::More tests => 5;
8+
use Test::More tests => 6;
99

1010
my $node = PostgreSQL::Test::Cluster->new('aqotest');
1111
$node->init;
@@ -58,6 +58,12 @@
5858
$node->psql('postgres', 'select * from aqo_reset();');
5959
$node->stop();
6060

61+
# 3000mb (more than 2*31 bytes) overflows 4-byte signed int
62+
$node->append_conf('postgresql.conf', 'aqo.dsm_size_max = 3000');
63+
is($node->start(fail_ok => 1), 1, "Large aqo.dsm_size_max doesn't cause integer overflow");
64+
$node->stop();
65+
66+
6167
my $regex;
6268
$long_string = 'a' x 100000;
6369
$regex = qr/.*WARNING: \[AQO\] Not enough DSA\. AQO was disabled for this query/;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy