You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for conc-49:
local_infile_init didn't open files with binary flag
This commit is contained in:
@@ -88,7 +88,7 @@ int mysql_local_infile_init(void **ptr, const char *filename, void *userdata)
|
|||||||
if (CodePage == -1)
|
if (CodePage == -1)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
info->fd= sopen(info->filename, _O_RDONLY, _SH_DENYNO , _S_IREAD | _S_IWRITE);
|
info->fd= sopen(info->filename, _O_RDONLY | _O_BINARY, _SH_DENYNO , _S_IREAD | _S_IWRITE);
|
||||||
#else
|
#else
|
||||||
info->fd = open(info->filename, O_RDONLY | O_BINARY, my_umask);
|
info->fd = open(info->filename, O_RDONLY | O_BINARY, my_umask);
|
||||||
#endif
|
#endif
|
||||||
@@ -116,7 +116,7 @@ int mysql_local_infile_init(void **ptr, const char *filename, void *userdata)
|
|||||||
"Character conversion error: %d", GetLastError());
|
"Character conversion error: %d", GetLastError());
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
info->fd= _wsopen(w_filename, _O_RDONLY, _SH_DENYNO , _S_IREAD | _S_IWRITE);
|
info->fd= _wsopen(w_filename, _O_RDONLY | _O_BINARY, _SH_DENYNO , _S_IREAD | _S_IWRITE);
|
||||||
my_errno= errno;
|
my_errno= errno;
|
||||||
my_free((gptr)w_filename, MYF(0));
|
my_free((gptr)w_filename, MYF(0));
|
||||||
}
|
}
|
||||||
|
@@ -813,6 +813,26 @@ static int test_bug49694(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_conc49(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
MYSQL_RES *res;
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS conc49");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE conc49 (a int, b int, c int) Engine=InnoDB DEFAULT CHARSET=latin1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(mysql, "LOAD DATA LOCAL INFILE './sample.csv' INTO TABLE conc49 FIELDS ESCAPED BY ' ' TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n'");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "SELECT a FROM conc49");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
res= mysql_store_result(mysql);
|
||||||
|
rc= mysql_num_rows(res);
|
||||||
|
mysql_free_result(res);
|
||||||
|
FAIL_IF(rc != 3, "3 rows expected");
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int test_ldi_path(MYSQL *mysql)
|
static int test_ldi_path(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@@ -885,6 +905,7 @@ static int test_conc44(MYSQL *mysql)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc49", test_conc49, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_bug28075", test_bug28075, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_bug28075", test_bug28075, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_bug28505", test_bug28505, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_bug28505", test_bug28505, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_debug_example", test_debug_example, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_debug_example", test_debug_example, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
3
unittest/libmariadb/sample.csv
Normal file
3
unittest/libmariadb/sample.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
"1","1","1"
|
||||||
|
"2","2","2"
|
||||||
|
"3","3","3"
|
|
Reference in New Issue
Block a user