Skip to content

Commit 34c4cc5

Browse files
author
Bogdan Degtyariov
committed
Added a unit test for getting errors in the middle of a result set
1 parent 264cea7 commit 34c4cc5

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

xapi/tests/xapi-t.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <stdio.h>
2626
#include <string.h>
27+
#include <climits>
2728
#include "test.h"
2829

2930

@@ -584,4 +585,52 @@ TEST_F(xapi, doc_id_test)
584585
EXPECT_TRUE(strstr(json_string, id_buf[i]) != NULL);
585586
++i;
586587
}
588+
}
589+
590+
TEST_F(xapi, myc_344_sql_error_test)
591+
{
592+
SKIP_IF_NO_XPLUGIN
593+
594+
mysqlx_result_t *res;
595+
mysqlx_schema_t *schema;
596+
mysqlx_table_t *table;
597+
mysqlx_row_t *row;
598+
const char *err_msg;
599+
int64_t v1 = LLONG_MIN;
600+
int64_t v2 = LLONG_MAX;
601+
int64_t v = 0;
602+
int num = 0;
603+
604+
authenticate();
605+
606+
mysqlx_schema_create(get_session(), "cc_api_test");
607+
schema = mysqlx_get_schema(get_session(), "cc_api_test", 1);
608+
mysqlx_table_drop(schema, "myc_344");
609+
exec_sql("CREATE TABLE cc_api_test.myc_344(b bigint)");
610+
611+
table = mysqlx_get_table(schema, "myc_344", 1);
612+
613+
res = mysqlx_table_insert(table, "b", PARAM_SINT(v1), PARAM_END);
614+
EXPECT_TRUE(res != NULL);
615+
res = mysqlx_table_insert(table, "b", PARAM_SINT(v2), PARAM_END);
616+
EXPECT_TRUE(res != NULL);
617+
618+
res = mysqlx_sql(get_session(), "SELECT b+1000 from cc_api_test.myc_344", MYSQLX_NULL_TERMINATED);
619+
EXPECT_TRUE(mysqlx_error_message(res) == NULL);
620+
621+
while ((row = mysqlx_row_fetch_one(res)) != NULL)
622+
{
623+
switch (num)
624+
{
625+
case 0:
626+
EXPECT_EQ(RESULT_OK, mysqlx_get_sint(row, 0, &v));
627+
EXPECT_EQ(v1 + 1000, v);
628+
break;
629+
default:
630+
FAIL(); // No more rows expected
631+
}
632+
++num;
633+
}
634+
EXPECT_TRUE((err_msg = mysqlx_error_message(res)) != NULL);
635+
printf("\nExpected error: %s\n", err_msg);
587636
}

0 commit comments

Comments
 (0)