24
24
25
25
#include < stdio.h>
26
26
#include < string.h>
27
+ #include < climits>
27
28
#include " test.h"
28
29
29
30
@@ -584,4 +585,52 @@ TEST_F(xapi, doc_id_test)
584
585
EXPECT_TRUE (strstr (json_string, id_buf[i]) != NULL );
585
586
++i;
586
587
}
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 (" \n Expected error: %s\n " , err_msg);
587
636
}
0 commit comments