Skip to content

Commit 1d78406

Browse files
committed
Several updates for 'test_mysql_query_digests_stages-t.cpp'
- New regression payloads for fix in 5c3a063. - Added config option for 'null' replacement in 'mz' payloads. - When specifying 'regular' as command line option, it's now possible to also specify the path to the file holding the payloads to be tested.
1 parent 5c3a063 commit 1d78406

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

test/tap/tests/test_mysql_query_digests_stages-t.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ void process_mz_test_def(const nlohmann::json& test_def, const char* c_query, co
232232
bool no_digest = true;
233233
int lowercase = 0;
234234
bool keep_comment = false;
235+
bool replace_null = true;
235236

236237
if (mz_test_def.contains("digest_max_size")) {
237238
digest_max_size = mz_test_def.at("digest_max_size");
@@ -255,6 +256,9 @@ void process_mz_test_def(const nlohmann::json& test_def, const char* c_query, co
255256
if (mz_test_def.contains("keep_comment")) {
256257
keep_comment = mz_test_def.at("keep_comment");
257258
}
259+
if (mz_test_def.contains("replace_null")) {
260+
replace_null = mz_test_def.at("replace_null");
261+
}
258262

259263
int backup_digest_max_length = mysql_thread___query_digests_max_query_length;
260264
mysql_thread___query_digests_max_query_length = digest_max_size;
@@ -266,6 +270,8 @@ void process_mz_test_def(const nlohmann::json& test_def, const char* c_query, co
266270
mysql_thread___query_digests_no_digits = replace_digits;
267271
int lowercase_backup = mysql_thread___query_digests_lowercase;
268272
mysql_thread___query_digests_lowercase = lowercase_backup;
273+
int replace_null_backup = mysql_thread___query_digests_replace_null;
274+
mysql_thread___query_digests_replace_null = replace_null;
269275
int keep_comment_backup = mysql_thread___query_digests_keep_comment;
270276
mysql_thread___query_digests_keep_comment = keep_comment;
271277

@@ -287,6 +293,7 @@ void process_mz_test_def(const nlohmann::json& test_def, const char* c_query, co
287293
mysql_thread___query_digests_no_digits = no_digits_backup;
288294
mysql_thread___query_digests_lowercase = lowercase_backup;
289295
mysql_thread___query_digests_keep_comment = keep_comment_backup;
296+
mysql_thread___query_digests_replace_null = replace_null_backup;
290297

291298
if (query.size() >= QUERY_DIGEST_BUF) {
292299
free(c_res);
@@ -772,9 +779,10 @@ int main(int argc, char** argv) {
772779
bool exec_grouping_tests = true;
773780
bool exec_regular_tests = true;
774781
std::string tests_filter_str {};
782+
std::string digests_file_arg {};
775783

776784
// check parameters for test filtering
777-
if (argc == 2) {
785+
if (argc >= 2) {
778786
tests_filter_str = argv[1];
779787

780788
if (tests_filter_str.find("crashing") == std::string::npos) {
@@ -786,9 +794,15 @@ int main(int argc, char** argv) {
786794
if (tests_filter_str.find("regular") == std::string::npos) {
787795
exec_regular_tests = false;
788796
}
797+
798+
if (argc == 3) {
799+
digests_file_arg = argv[2];
800+
}
789801
}
790802

791-
const string digests_filepath { string(cl.workdir) + DIGESTS_TEST_FILENAME };
803+
const string digests_filepath {
804+
digests_file_arg.empty() ? string(cl.workdir) + DIGESTS_TEST_FILENAME : digests_file_arg
805+
};
792806
const string crashing_payloads { string(cl.workdir) + "tokenizer_payloads/crashing_payloads.hjson" };
793807

794808
uint32_t max_groups = 10;

test/tap/tests/tokenizer_payloads/regular_tokenizer_digests.hjson

+43
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,49 @@
957957
}
958958
]
959959
},
960+
{
961+
// Correct compression of final comment '--' with query exceeding 'query_digests_max_query_length'
962+
"q": [
963+
"insert into table (field1, field2, field3, field4, field5, field6) values ('00000000000000000000000000', null, '11111111111111111111111111', 'STOP', 1745624748961, '00000000000000000000000000') on duplicate key update field4 = 'STOP', field5 = 1745624748961, field6 = '11111111111111111111111111' -- cmt: OOOOOOOOOOOOOOOOOOOOOOOOOO:NNNNNNNNNNNNNNNNNNNNNNNNNN:N"
964+
],
965+
"mz": [
966+
{
967+
"digest_max_size": 299,
968+
"grouping_limit": 3,
969+
"replace_null": false,
970+
"groups_grouping_limit": 10,
971+
"digest": "insert into table (field1,field2,field3,field4,field5,field6) values (?,null,?,?,?,?) on duplicate key update field4 = ?,field5 = ?,field6 = ?"
972+
}
973+
]
974+
},
975+
{
976+
// Correct compression of final comment '--' with query exceeding 'query_digests_max_query_length'
977+
"q": [
978+
"SELECT '01JSQMJPDJEF' -- cmt: foo"
979+
],
980+
"mz": [
981+
{
982+
"digest_max_size": 25,
983+
"grouping_limit": 3,
984+
"groups_grouping_limit": 10,
985+
"digest": "SELECT ?"
986+
}
987+
]
988+
},
989+
{
990+
// Correct compression of final comment '--' with query exceeding 'query_digests_max_query_length'
991+
"q": [
992+
"SELECT '01JSQMJPDJEF' /* cmt: foo */"
993+
],
994+
"mz": [
995+
{
996+
"digest_max_size": 24,
997+
"grouping_limit": 3,
998+
"groups_grouping_limit": 10,
999+
"digest": "SELECT ?"
1000+
}
1001+
]
1002+
},
9601003
{
9611004
// digest_corner_cases_1.hjson - Testing the compression limits of number parsing when buffer is exceeded
9621005
"q": [

0 commit comments

Comments
 (0)