summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'unittest')
-rw-r--r--unittest/mysys/CMakeLists.txt3
-rw-r--r--unittest/mysys/ma_dyncol-t.c219
-rw-r--r--unittest/mysys/my_vsnprintf-t.c84
-rw-r--r--unittest/sql/my_apc-t.cc7
4 files changed, 164 insertions, 149 deletions
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt
index fb6154748ac..e17140b8016 100644
--- a/unittest/mysys/CMakeLists.txt
+++ b/unittest/mysys/CMakeLists.txt
@@ -20,6 +20,9 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql
MY_ADD_TESTS(bitmap base64 my_vsnprintf my_atomic my_rdtsc lf my_malloc
LINK_LIBRARIES mysys)
+MY_ADD_TESTS(ma_dyncol
+ LINK_LIBRARIES mysqlclient)
+
IF(WIN32)
MY_ADD_TESTS(my_delete LINK_LIBRARIES mysys)
ENDIF()
diff --git a/unittest/mysys/ma_dyncol-t.c b/unittest/mysys/ma_dyncol-t.c
index 4a9b687bc08..51e84bc4e40 100644
--- a/unittest/mysys/ma_dyncol-t.c
+++ b/unittest/mysys/ma_dyncol-t.c
@@ -35,96 +35,100 @@
void test_value_single_null()
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_NULL;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_NULL);
err:
ok(rc, "%s", "NULL");
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_uint(ulonglong num, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_UINT;
val.x.ulong_value= num;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_UINT) && (res.x.ulong_value == num);
num= res.x.ulong_value;
err:
ok(rc, "%s - %llu", name, num);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_sint(longlong num, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_INT;
val.x.long_value= num;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_INT) && (res.x.long_value == num);
num= res.x.ulong_value;
err:
ok(rc, "%s - %lld", name, num);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_double(double num, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
val.type= DYN_COL_DOUBLE;
val.x.double_value= num;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= (res.type == DYN_COL_DOUBLE) && (res.x.double_value == num);
num= res.x.ulong_value;
err:
ok(rc, "%s - %lf", name, num);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_decimal(const char *num)
@@ -133,21 +137,22 @@ void test_value_single_decimal(const char *num)
char buff[80];
int rc= FALSE;
int length= 80;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
- dynamic_column_prepare_decimal(&val); // special procedure for decimal!!!
+ mariadb_dyncol_prepare_decimal(&val); // special procedure for decimal!!!
if (string2decimal(num, &val.x.decimal.value, &end) != E_DEC_OK)
goto err;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DECIMAL) &&
(decimal_cmp(&res.x.decimal.value, &val.x.decimal.value) == 0));
@@ -155,7 +160,7 @@ void test_value_single_decimal(const char *num)
err:
ok(rc, "%s - %s", num, buff);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
static CHARSET_INFO *charset_list[]=
@@ -206,6 +211,7 @@ void test_value_single_string(const char *string, size_t len,
CHARSET_INFO *cs)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
@@ -214,14 +220,14 @@ void test_value_single_string(const char *string, size_t len,
val.x.string.value.str= (char*)string;
val.x.string.value.length= len;
val.x.string.charset= cs;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_STRING) &&
(res.x.string.value.length == len) &&
@@ -233,12 +239,13 @@ err:
(uint)res.x.string.charset->number, res.x.string.charset->name);
/* cleanup */
val.x.string.value.str= NULL; // we did not allocated it
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_date(uint year, uint month, uint day, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
@@ -247,13 +254,13 @@ void test_value_single_date(uint year, uint month, uint day, const char *name)
val.x.time_value.year= year;
val.x.time_value.month= month;
val.x.time_value.day= day;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DATE) &&
(res.x.time_value.time_type == MYSQL_TIMESTAMP_DATE) &&
@@ -263,13 +270,14 @@ void test_value_single_date(uint year, uint month, uint day, const char *name)
err:
ok(rc, "%s - %04u-%02u-%02u", name, year, month, day);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_value_single_time(uint neg, uint hour, uint minute, uint second,
uint mic, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
@@ -280,13 +288,13 @@ void test_value_single_time(uint neg, uint hour, uint minute, uint second,
val.x.time_value.minute= minute;
val.x.time_value.second= second;
val.x.time_value.second_part= mic;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_TIME) &&
(res.x.time_value.time_type == MYSQL_TIMESTAMP_TIME) &&
@@ -299,7 +307,7 @@ err:
ok(rc, "%s - %c%02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
hour, minute, second, mic);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
@@ -308,6 +316,7 @@ void test_value_single_datetime(uint neg, uint year, uint month, uint day,
uint mic, const char *name)
{
int rc= FALSE;
+ uint ids[1]= {1};
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
/* init values */
@@ -321,13 +330,13 @@ void test_value_single_datetime(uint neg, uint year, uint month, uint day,
val.x.time_value.minute= minute;
val.x.time_value.second= second;
val.x.time_value.second_part= mic;
- dynamic_column_value_init(&res);
+ mariadb_dyncol_value_init(&res);
/* create column */
- if (dynamic_column_create(&str, 1, &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, ids, &val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
- if (dynamic_column_get(&str, 1, &res))
+ if (mariadb_dyncol_get_num(&str, 1, &res))
goto err;
rc= ((res.type == DYN_COL_DATETIME) &&
(res.x.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) &&
@@ -343,7 +352,7 @@ err:
ok(rc, "%s - %c %04u-%02u-%02u %02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
year, month, day, hour, minute, second, mic);
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
@@ -373,7 +382,7 @@ void test_value_multi(ulonglong num0,
val[1].x.long_value= num1;
val[2].type= DYN_COL_DOUBLE;
val[2].x.double_value= num2;
- dynamic_column_prepare_decimal(val + 3); // special procedure for decimal!!!
+ mariadb_dyncol_prepare_decimal(val + 3); // special procedure for decimal!!!
if (string2decimal(num3, &val[3].x.decimal.value, &end3) != E_DEC_OK)
goto err;
val[4].type= DYN_COL_STRING;
@@ -404,14 +413,14 @@ void test_value_multi(ulonglong num0,
val[7].x.time_value.second_part= mic7;
val[8].type= DYN_COL_NULL;
for (i= 0; i < 9; i++)
- dynamic_column_value_init(res + i);
+ mariadb_dyncol_value_init(res + i);
/* create column */
- if (dynamic_column_create_many(&str, 9, column_numbers, val))
+ if (mariadb_dyncol_create_many_num(&str, 9, column_numbers, val, 1))
goto err;
dynstr_append(&str, "\1"); str.length--; //check for overflow
/* read column */
for (i= 0; i < 9; i++)
- if (dynamic_column_get(&str, column_numbers[i], res + i))
+ if (mariadb_dyncol_get_num(&str, column_numbers[i], res + i))
goto err;
rc= ((res[0].type == DYN_COL_UINT) &&
(res[0].x.ulong_value == num0) &&
@@ -452,7 +461,7 @@ err:
ok(rc, "%s", name);
/* cleanup */
val[4].x.string.value.str= NULL; // we did not allocated it
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
@@ -467,13 +476,13 @@ void test_value_multi_same_num()
for (i= 0; i < 5; i++)
val[i].type= DYN_COL_NULL;
/* create column */
- if (!dynamic_column_create_many(&str, 5, column_numbers, val))
+ if (!mariadb_dyncol_create_many_num(&str, 5, column_numbers, val, 1))
goto err;
rc= TRUE;
err:
ok(rc, "%s", "same column numbers check");
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
@@ -487,68 +496,69 @@ void test_update_multi(uint *column_numbers, uint *column_values,
val.type= DYN_COL_UINT;
val.x.ulong_value= column_values[0];
- if (dynamic_column_create(&str, column_numbers[0], &val))
+ if (mariadb_dyncol_create_many_num(&str, 1, column_numbers, &val, 1))
goto err;
for (i= 1; i < all; i++)
{
val.type= (null_values[i] ? DYN_COL_NULL : DYN_COL_UINT);
val.x.ulong_value= column_values[i];
- if (dynamic_column_update(&str, column_numbers[i], &val))
+ if (mariadb_dyncol_update_many_num(&str, 1, column_numbers +i, &val))
goto err;
/* check value(s) */
for (j= i; j >= (i < only_add ? 0 : i); j--)
{
- if (dynamic_column_get(&str, column_numbers[j], &val))
+ if (mariadb_dyncol_get_num(&str, column_numbers[j], &val))
goto err;
if (null_values[j])
{
if (val.type != DYN_COL_NULL ||
- dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_YES)
+ mariadb_dyncol_exists_num(&str, column_numbers[j]) == ER_DYNCOL_YES)
goto err;
}
else
{
if (val.type != DYN_COL_UINT ||
val.x.ulong_value != column_values[j] ||
- dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_NO)
+ mariadb_dyncol_exists_num(&str, column_numbers[j]) == ER_DYNCOL_NO)
goto err;
}
}
if (i < only_add)
{
- DYNAMIC_ARRAY num;
- if (dynamic_column_list(&str, &num))
+ uint elements, *num;
+ if (mariadb_dyncol_list_num(&str, &elements, &num))
+ {
+ my_free(num);
goto err;
+ }
/* cross check arrays */
- if ((int)num.elements != i + 1)
+ if ((int)elements != i + 1)
{
- delete_dynamic(&num);
+ my_free(num);
goto err;
}
for(j= 0; j < i + 1; j++)
{
int k;
for(k= 0;
- k < i + 1 && column_numbers[j] !=
- *dynamic_element(&num, k, uint*);
+ k < i + 1 && column_numbers[j] != num[k];
k++);
if (k >= i + 1)
{
- delete_dynamic(&num);
+ my_free(num);
goto err;
}
for(k= 0;
- k < i + 1 && column_numbers[k] !=
- *dynamic_element(&num, j, uint*);
+ k < i + 1 && column_numbers[k] != num[j];
k++);
if (k >= i + 1)
{
- delete_dynamic(&num);
+ my_free(num);
goto err;
}
}
- delete_dynamic(&num);
+ my_free(num);
}
}
@@ -556,41 +566,72 @@ void test_update_multi(uint *column_numbers, uint *column_values,
err:
ok(rc, "%s", "add/delete/update");
/* cleanup */
- dynamic_column_column_free(&str);
+ mariadb_dyncol_free(&str);
}
void test_empty_string()
{
DYNAMIC_COLUMN_VALUE val, res;
DYNAMIC_COLUMN str;
- DYNAMIC_ARRAY array_of_uint;
+ uint *array_of_uint;
+ uint number_of_uint;
int rc;
+ uint ids[1]= {1};
+ DYNAMIC_COLUMN_VALUE vals[1];
/* empty string */
bzero(&str, sizeof(str));
- rc= dynamic_column_get(&str, 1, &res);
+ rc= mariadb_dyncol_get_num(&str, 1, &res);
ok( (rc == ER_DYNCOL_OK) && (res.type == DYN_COL_NULL), "%s", "empty get");
- rc= dynamic_column_delete(&str, 1);
- ok( (rc == ER_DYNCOL_OK), "%s", "empty delete");
+ vals[0].type= DYN_COL_NULL;
+ rc= mariadb_dyncol_update_many_num(&str, 1, ids, vals);
+ ok( (rc == ER_DYNCOL_OK) && (str.str == 0), "%s", "empty delete");
- rc= dynamic_column_exists(&str, 1);
+ rc= mariadb_dyncol_exists_num(&str, 1);
ok( (rc == ER_DYNCOL_NO), "%s", "empty exists");
- rc= dynamic_column_list(&str, &array_of_uint);
- ok( (rc == ER_DYNCOL_OK) && (array_of_uint.elements == 0),
+ rc= mariadb_dyncol_list_num(&str, &number_of_uint, &array_of_uint);
+ ok( (rc == ER_DYNCOL_OK) && (number_of_uint == 0) && (str.str == 0),
"%s", "empty list");
val.type= DYN_COL_UINT;
val.x.ulong_value= 1212;
- rc= dynamic_column_update(&str, 1, &val);
+ rc= mariadb_dyncol_update_many_num(&str, 1, ids, &val);
if (rc == ER_DYNCOL_OK)
- rc= dynamic_column_get(&str, 1, &res);
- ok( (rc == ER_DYNCOL_OK) &&
+ rc= mariadb_dyncol_get_num(&str, 1, &res);
+ ok( (rc == ER_DYNCOL_OK) && (str.str != 0) &&
(res.type == DYN_COL_UINT) && (res.x.ulong_value == val.x.ulong_value),
"%s", "empty update");
+ mariadb_dyncol_free(&str);
+}
+
+static void test_mdev_4994()
+{
+ DYNAMIC_COLUMN dyncol;
+ LEX_STRING key= {0,0};
+ DYNAMIC_COLUMN_VALUE val;
+ int rc;
+
+ val.type= DYN_COL_NULL;
+
+ mariadb_dyncol_init(&dyncol);
+ rc= mariadb_dyncol_create_many_named(&dyncol, 1, &key, &val, 0); /* crash */
+ ok( (rc == ER_DYNCOL_OK), "%s", "test_mdev_4994");
+ mariadb_dyncol_free(&dyncol);
}
+static void test_mdev_4995()
+{
+ DYNAMIC_COLUMN dyncol;
+ uint column_count= 5;
+ int rc;
+
+ mariadb_dyncol_init(&dyncol);
+ rc= mariadb_dyncol_column_count(&dyncol,&column_count);
+
+ ok( (rc == ER_DYNCOL_OK), "%s", "test_mdev_4995");
+}
void test_update_many(uint *column_numbers, uint *column_values,
uint column_count,
@@ -633,11 +674,11 @@ void test_update_many(uint *column_numbers, uint *column_values,
res[i].type= DYN_COL_UINT;
res[i].x.ulong_value= result_values[i];
}
- if (dynamic_column_create_many(&str1, column_count, column_numbers, val))
+ if (mariadb_dyncol_create_many_num(&str1, column_count, column_numbers, val, 1))
goto err;
- if (dynamic_column_update_many(&str1, update_count, update_numbers, upd))
+ if (mariadb_dyncol_update_many_num(&str1, update_count, update_numbers, upd))
goto err;
- if (dynamic_column_create_many(&str2, result_count, result_numbers, res))
+ if (mariadb_dyncol_create_many_num(&str2, result_count, result_numbers, res, 1))
goto err;
if (str1.length == str2.length &&
memcmp(str1.str, str2.str, str1.length) ==0)
@@ -646,8 +687,8 @@ void test_update_many(uint *column_numbers, uint *column_values,
err:
ok(rc, "%s", "update_many");
/* cleanup */
- dynamic_column_column_free(&str1);
- dynamic_column_column_free(&str2);
+ mariadb_dyncol_free(&str1);
+ mariadb_dyncol_free(&str2);
}
int main(int argc __attribute__((unused)), char **argv)
@@ -656,7 +697,7 @@ int main(int argc __attribute__((unused)), char **argv)
char *big_string= (char *)malloc(1024*1024);
MY_INIT(argv[0]);
- plan(60);
+ plan(62);
if (!big_string)
exit(1);
@@ -664,21 +705,17 @@ int main(int argc __attribute__((unused)), char **argv)
big_string[i]= ('0' + (i % 10));
test_value_single_null();
test_value_single_uint(0, "0");
- test_value_single_uint(ULL(0xffffffffffffffff), "0xffffffffffffffff");
- test_value_single_uint(ULL(0xaaaaaaaaaaaaaaaa), "0xaaaaaaaaaaaaaaaa");
- test_value_single_uint(ULL(0x5555555555555555), "0x5555555555555555");
+ test_value_single_uint(0xffffffffffffffffULL, "0xffffffffffffffff");
+ test_value_single_uint(0xaaaaaaaaaaaaaaaaULL, "0xaaaaaaaaaaaaaaaa");
+ test_value_single_uint(0x5555555555555555ULL, "0x5555555555555555");
test_value_single_uint(27652, "27652");
test_value_single_sint(0, "0");
test_value_single_sint(1, "1");
test_value_single_sint(-1, "-1");
- test_value_single_sint(LL(0x7fffffffffffffff),
- "0x7fffffffffffffff");
- test_value_single_sint(LL(0xaaaaaaaaaaaaaaaa),
- "0xaaaaaaaaaaaaaaaa");
- test_value_single_sint(LL(0x5555555555555555),
- "0x5555555555555555");
- test_value_single_sint(LL(0x8000000000000000),
- "0x8000000000000000");
+ test_value_single_sint(0x7fffffffffffffffLL, "0x7fffffffffffffff");
+ test_value_single_sint(0xaaaaaaaaaaaaaaaaLL, "0xaaaaaaaaaaaaaaaa");
+ test_value_single_sint(0x5555555555555555LL, "0x5555555555555555");
+ test_value_single_sint(0x8000000000000000LL, "0x8000000000000000");
test_value_single_double(0.0, "0.0");
test_value_single_double(1.0, "1.0");
test_value_single_double(-1.0, "-1.0");
@@ -735,7 +772,7 @@ int main(int argc __attribute__((unused)), char **argv)
}
{
uint column_numbers[]= {10,1,12,37,4,57,6,76,87};
- test_value_multi(ULL(0xffffffffffffffff), LL(0x7fffffffffffffff),
+ test_value_multi(0xffffffffffffffffULL, 0x7fffffffffffffffLL,
99999999.999e120, "9999999999999999999999999999999",
big_string, 1024*1024, charset_list[0],
9999, 12, 31,
@@ -791,5 +828,9 @@ int main(int argc __attribute__((unused)), char **argv)
update_numbers, update_values, update_nulls, 4,
result_numbers, result_values, 3);
}
+ test_mdev_4994();
+ test_mdev_4995();
+
+ my_end(0);
return exit_status();
}
diff --git a/unittest/mysys/my_vsnprintf-t.c b/unittest/mysys/my_vsnprintf-t.c
index 5809d6144cc..45df97fbecd 100644
--- a/unittest/mysys/my_vsnprintf-t.c
+++ b/unittest/mysys/my_vsnprintf-t.c
@@ -19,6 +19,16 @@
char buf[1024]; /* let's hope that's enough */
+static void test_w_len(const char *res, size_t buflen, const char *fmt, ...)
+{
+ va_list args;
+ size_t len;
+ va_start(args,fmt);
+ len= my_vsnprintf(buf, buflen, fmt, args);
+ va_end(args);
+ ok(strlen(res) == len && strcmp(buf, res) == 0, "\"%s\"", buf);
+}
+
static void test1(const char *res, const char *fmt, ...)
{
va_list args;
@@ -51,7 +61,7 @@ static void test_many(const char **res, const char *fmt, ...)
int main(void)
{
- plan(59);
+ plan(39);
test1("Constant string",
"Constant string");
@@ -141,62 +151,6 @@ int main(void)
test1("G with a width (ignored) and precision: <12.35>",
"G with a width (ignored) and precision: <%10.5g>", 12.3456789);
- diag("================================================================");
-
- test1("Hello",
- "Hello");
- test1("Hello int, 1",
- "Hello int, %d", 1);
- test1("Hello int, -1",
- "Hello int, %d", -1);
- test1("Hello int, 1",
- "Hello int, %i", 1);
- test1("Hello int, -1",
- "Hello int, %i", -1);
- test1("Hello string 'I am a string'",
- "Hello string '%s'", "I am a string");
- test1("Hello hack hack hack hack hack hack hack 1",
- "Hello hack hack hack hack hack hack hack %d", 1);
- test1("Hello 1 hack 4",
- "Hello %d hack %d", 1, 4);
- test1("Hello 1 hack hack hack hack hack 4",
- "Hello %d hack hack hack hack hack %d", 1, 4);
- test1("Hello 'hack' hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
- "Hello '%s' hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", "hack");
- test1("Hello hhhhhhhhhhhhhh 1 sssssssssssssss",
- "Hello hhhhhhhhhhhhhh %d sssssssssssssss", 1);
- test1("Hello 1",
- "Hello %u", 1);
- test1("Hello 4294967295",
- "Hello %u", -1);
- test1("Hex: 20 ' 41'",
- "Hex: %lx '%6lx'", 32, 65);
- test1("conn 1 to: '(null)' user: '(null)' host: '(null)' ((null))",
- "conn %ld to: '%-.64s' user: '%-.32s' host: '%-.64s' (%-.64s)",
- 1L, NULL, NULL, NULL, NULL);
- test1("Hello string `I am a string`",
- "Hello string %`s", "I am a string");
- test1("Hello TEST",
- "Hello %05s", "TEST");
- test1("My `Q` test",
- "My %1$`-.1s test", "QQQQ");
- test1("My AAAA test done DDDD",
- "My %2$s test done %1$s", "DDDD", "AAAA");
- test1("My DDDD test CCCC, DDD",
- "My %1$s test %2$s, %1$-.3s", "DDDD", "CCCC");
- test1("My QQQQ test",
- "My %1$`-.4b test", "QQQQ");
- test1("My X test",
- "My %1$c test", 'X');
- test1("My <0000000010> test1 < a> test2 < A>",
- "My <%010d> test1 <%4x> test2 <%4X>", 10, 10, 10);
- test1("My <0000000010> test1 < a> test2 < a>",
- "My <%1$010d> test1 <%2$4x> test2 <%2$4x>", 10, 10);
- test1("My 00010 test",
- "My %1$*02$d test", 10, 5);
- test1("My `DDDD` test CCCC, `DDD`",
- "My %1$`s test %2$s, %1$`-.3s", "DDDD", "CCCC");
-
{
/* Test that %M works */
const char *results[]=
@@ -208,6 +162,22 @@ int main(void)
test_many(results, "Error %M", 1);
}
+ test1("M with 0 error code: 0 \"Internal error/check (Not system error)\"",
+ "M with 0 error code: %M", 0);
+
+ test1("M with positional: 0 \"Internal error/check (Not system error)\"",
+ "M with positional: %1$M", 0);
+
+ test1("M with width: 0 \"Internal error/ch",
+ "M with width: %.20M", 0);
+ test1("M with width positional: 0 \"Internal error/ch",
+ "M with width positional: %2$.*1$M", 20, 0);
+
+ test_w_len("M small buf: 0 \"In",
+ 19, "M small buf: %M", 0);
+ test_w_len("M small buf positional: 0 \"In",
+ 30, "M small buf positional: %1$M", 0);
+
return exit_status();
}
diff --git a/unittest/sql/my_apc-t.cc b/unittest/sql/my_apc-t.cc
index 8b599198302..05d6722ada4 100644
--- a/unittest/sql/my_apc-t.cc
+++ b/unittest/sql/my_apc-t.cc
@@ -27,6 +27,7 @@
/*
A fake THD with enter_cond/exit_cond and some other members.
*/
+PSI_stage_info stage_show_explain;
class THD
{
mysql_mutex_t* thd_mutex;
@@ -34,14 +35,14 @@ public:
bool killed;
THD() : killed(FALSE) {}
- inline const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t* mutex,
- const char* msg)
+ inline const char* ENTER_COND(mysql_cond_t *cond, mysql_mutex_t* mutex,
+ PSI_stage_info*, PSI_stage_info*)
{
mysql_mutex_assert_owner(mutex);
thd_mutex= mutex;
return NULL;
}
- inline void exit_cond(const char* old_msg)
+ inline void EXIT_COND(PSI_stage_info*)
{
mysql_mutex_unlock(thd_mutex);
}