summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-12-18 00:17:25 +0300
committerunknown <konstantin@mysql.com>2004-12-18 00:17:25 +0300
commit996352b73e60cce2458cf72ab36c49126e635997 (patch)
tree75100b91f7d8e8ab02c6fa3120b8fbb75d8e7265 /tests
parent91a76445335eb251440e61b114b4fdbb0dba5813 (diff)
downloadmariadb-git-996352b73e60cce2458cf72ab36c49126e635997.tar.gz
Truncations patch: a post-review fix.
include/mysql.h: Adding an option for data truncations feature. libmysql/libmysql.c: No 'smart' behaviour now for data truncations: they are always reported, unless switched off with mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, (my_bool*) &(option=1)); sql-common/client.c: Add support for report-data-truncation variable in my.cnf tests/client_test.c: A test for MYSQL_REPORT_DATA_TRUNCATION option.
Diffstat (limited to 'tests')
-rw-r--r--tests/client_test.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/client_test.c b/tests/client_test.c
index f524415eb1c..f2faf656ea6 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -12302,6 +12302,56 @@ static void test_truncation()
myquery(rc);
}
+static void test_truncation_option()
+{
+ MYSQL_STMT *stmt;
+ const char *stmt_text;
+ int rc;
+ uint8 buf;
+ my_bool option= 0;
+ my_bool error;
+ MYSQL_BIND bind;
+
+ myheader("test_truncation_option");
+
+ /* Prepare the test table */
+ stmt_text= "select -1";
+
+ stmt= mysql_stmt_init(mysql);
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ check_execute(stmt, rc);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ bzero(&bind, sizeof(MYSQL_BIND));
+
+ bind.buffer= (void*) &buf;
+ bind.buffer_type= MYSQL_TYPE_TINY;
+ bind.is_unsigned= TRUE;
+ bind.error= &error;
+
+ rc= mysql_stmt_bind_result(stmt, &bind);
+ check_execute(stmt, rc);
+ rc= mysql_stmt_fetch(stmt);
+ DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED);
+ DIE_UNLESS(error);
+ rc= mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, (char*) &option);
+ myquery(rc);
+ /* need to rebind for the new setting to take effect */
+ rc= mysql_stmt_bind_result(stmt, &bind);
+ check_execute(stmt, rc);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+ rc= mysql_stmt_fetch(stmt);
+ check_execute(stmt, rc);
+ /* The only change is rc - error pointers are still filled in */
+ DIE_UNLESS(error == 1);
+ /* restore back the defaults */
+ option= 1;
+ mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, (char*) &option);
+
+ mysql_stmt_close(stmt);
+}
/*
Read and parse arguments and MySQL options from my.cnf
@@ -12517,6 +12567,7 @@ static struct my_tests_st my_tests[]= {
{ "test_basic_cursors", test_basic_cursors },
{ "test_cursors_with_union", test_cursors_with_union },
{ "test_truncation", test_truncation },
+ { "test_truncation_option", test_truncation_option },
{ 0, 0 }
};