mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
MDEV-28746 Wrong error code ER_BAD_DB_ERROR for long filenames
Add check for path length if CreateFile fails with ERROR_PATH_NOT_FOUND.
This commit is contained in:
parent
d6e80c21d6
commit
66c06735a2
3 changed files with 18 additions and 7 deletions
2
mysql-test/main/create_windows.result
Normal file
2
mysql-test/main/create_windows.result
Normal file
|
@ -0,0 +1,2 @@
|
|||
create table `...................................................`(i int);
|
||||
ERROR HY000: Can't create table `test`.`...................................................` (errno: 38 "Filename too long")
|
10
mysql-test/main/create_windows.test
Normal file
10
mysql-test/main/create_windows.test
Normal file
|
@ -0,0 +1,10 @@
|
|||
--source include/windows.inc
|
||||
|
||||
# MDEV-28746 Wrong error code ER_BAD_DB_ERROR for long filenames
|
||||
|
||||
# There are 51 dots in the table name below, with every dot encoded with 5
|
||||
# bytes in "mysql file name encoding", making the filename length 255 byte.
|
||||
# Adding drive and extension makes it exceed MAX_PATH= 260 bytes
|
||||
let $t = `SELECT(REPEAT('.',51))`;
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
eval create table `$t`(i int);
|
|
@ -250,13 +250,12 @@ File my_win_sopen(const char *path, int oflag, int shflag, int pmode)
|
|||
if ((osfh= CreateFile(path, fileaccess, fileshare, &SecurityAttributes,
|
||||
filecreate, fileattrib, NULL)) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/*
|
||||
OS call to open/create file failed! map the error, release
|
||||
the lock, and return -1. note that it's not necessary to
|
||||
call _free_osfhnd (it hasn't been used yet).
|
||||
*/
|
||||
my_osmaperr(GetLastError()); /* map error */
|
||||
DBUG_RETURN(-1); /* return error to caller */
|
||||
DWORD last_error= GetLastError();
|
||||
if (last_error == ERROR_PATH_NOT_FOUND && strlen(path) >= MAX_PATH)
|
||||
errno= ENAMETOOLONG;
|
||||
else
|
||||
my_osmaperr(last_error); /* map error */
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if ((fh= my_open_osfhandle(osfh,
|
||||
|
|
Loading…
Add table
Reference in a new issue