-
Notifications
You must be signed in to change notification settings - Fork 70
Fix integer overflow #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix integer overflow #435
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b1f01cd
Fix MAX_BUCKETS_MEM overflow
artemgavrilov f10755c
Fix MAX_QUERY_BUF overflow
artemgavrilov b94f146
Fix int overflow in IsBucketValid function
artemgavrilov 54bfdf0
Add missing newline
artemgavrilov c08bf33
Remove test for max value of pgsm_query_shared_buffer parameter
artemgavrilov 70644ed
Tune tests
artemgavrilov a86d36d
Merge remote-tracking branch 'origin/main' into fix-integer-overflows
artemgavrilov c66e6ec
Cleanup
artemgavrilov b0c05ec
Use int64 type instead of long long
artemgavrilov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/usr/bin/perl | ||
|
|
||
| use strict; | ||
| use warnings; | ||
| use File::Basename; | ||
| use File::Compare; | ||
| use File::Copy; | ||
| use Test::More; | ||
| use lib 't'; | ||
| use pgsm; | ||
|
|
||
| # Get file name and CREATE out file name and dirs WHERE requried | ||
| PGSM::setup_files_dir(basename($0)); | ||
|
|
||
| # CREATE new PostgreSQL node and do initdb | ||
| my $node = PGSM->pgsm_init_pg(); | ||
| my $pgdata = $node->data_dir; | ||
|
|
||
| # UPDATE postgresql.conf to include/load pg_stat_monitor library | ||
| open my $conf, '>>', "$pgdata/postgresql.conf"; | ||
| print $conf "shared_preload_libraries = 'pg_stat_monitor'\n"; | ||
| print $conf "pg_stat_monitor.pgsm_bucket_time = 2147483647\n"; # Max value for this parameter | ||
| print $conf "pg_stat_monitor.pgsm_max_buckets = 20000\n"; # Max value for this parameter | ||
| close $conf; | ||
|
|
||
| # Start server | ||
| my $rt_value = $node->start; | ||
| ok($rt_value == 1, "Start Server"); | ||
|
|
||
| # CREATE EXTENSION and change out file permissions | ||
| my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']); | ||
| ok($cmdret == 0, "CREATE PGSM EXTENSION"); | ||
| PGSM::append_to_file($stdout); | ||
|
|
||
| # Run required commands/queries and dump output to out file. | ||
| ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); | ||
| ok($cmdret == 0, "Reset PGSM EXTENSION"); | ||
| PGSM::append_to_file($stdout); | ||
|
|
||
| ($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT 1 AS num;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); | ||
| ok($cmdret == 0, "Print results of a test query"); | ||
| PGSM::append_to_file($stdout); | ||
|
|
||
| ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); | ||
| ok($cmdret == 0, "Check query stats"); | ||
| PGSM::append_to_file($stdout); | ||
|
|
||
| # DROP EXTENSION | ||
| $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']); | ||
| ok($cmdret == 0, "DROP PGSM EXTENSION"); | ||
| PGSM::append_to_file($stdout); | ||
|
|
||
| # Stop the server | ||
| $node->stop; | ||
|
|
||
| # compare the expected and out file | ||
| my $compare = PGSM->compare_results(); | ||
|
|
||
| # Test/check if expected and result/out file match. If Yes, test passes. | ||
| is($compare,0,"Compare Files: $PGSM::expected_filename_with_path and $PGSM::out_filename_with_path files."); | ||
|
|
||
| # Done testing for this testcase file. | ||
| done_testing(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.