1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 11.4 into 11.8

This commit is contained in:
Marko Mäkelä
2025-03-05 20:39:47 +02:00
177 changed files with 5360 additions and 2623 deletions

View File

@@ -534,36 +534,53 @@ static bool write_db_opt(THD *thd, const char *path,
DESCRIPTION
create->default_table_charset is guaranteed to be alway set
Required by some callers
RETURN VALUES
0 File found
1 No database file or could not open it
-1 No database file (file was not found or 'empty' file was cached)
1 Could not open it
*/
bool load_db_opt(THD *thd, const char *path, Schema_specification_st *create)
int load_db_opt(THD *thd, const char *path, Schema_specification_st *create)
{
File file;
char buf[256+DATABASE_COMMENT_MAXLEN];
DBUG_ENTER("load_db_opt");
bool error=1;
int error= 0;
size_t nbytes;
myf utf8_flag= thd->get_utf8_flag();
bzero((char*) create,sizeof(*create));
create->default_table_charset= thd->variables.collation_server;
/* Check if options for this database are already in the hash */
if (!get_dbopt(thd, path, create))
DBUG_RETURN(0);
{
if (!create->default_table_charset)
error= -1; // db.opt did not exists
goto err1;
}
/* Otherwise, load options from the .opt file */
if ((file= mysql_file_open(key_file_dbopt,
path, O_RDONLY | O_SHARE, MYF(0))) < 0)
{
/*
Create an empty entry, to avoid doing an extra file open for every create
table.
*/
put_dbopt(path, create);
error= -1;
goto err1;
}
IO_CACHE cache;
if (init_io_cache(&cache, file, IO_SIZE, READ_CACHE, 0, 0, MYF(0)))
goto err2;
{
error= 1;
goto err2; // Not cached
}
while ((int) (nbytes= my_b_gets(&cache, (char*) buf, sizeof(buf))) > 0)
{
@@ -584,7 +601,7 @@ bool load_db_opt(THD *thd, const char *path, Schema_specification_st *create)
default-collation commands.
*/
if (!(create->default_table_charset=
get_charset_by_csname(pos+1, MY_CS_PRIMARY, MYF(utf8_flag))) &&
get_charset_by_csname(pos+1, MY_CS_PRIMARY, MYF(utf8_flag))) &&
!(create->default_table_charset=
get_charset_by_name(pos+1, MYF(utf8_flag))))
{
@@ -619,10 +636,11 @@ bool load_db_opt(THD *thd, const char *path, Schema_specification_st *create)
err2:
mysql_file_close(file, MYF(0));
err1:
if (!create->default_table_charset) // In case of error
create->default_table_charset= thd->variables.collation_server;
DBUG_RETURN(error);
}
/*
Retrieve database options by name. Load database options file or fetch from
cache.
@@ -649,11 +667,12 @@ err1:
db_create_info right after that.
RETURN VALUES (read NOTE!)
FALSE Success
TRUE Failed to retrieve options
0 File found
-1 No database file (file was not found or 'empty' file was cached)
1 Could not open it
*/
bool load_db_opt_by_name(THD *thd, const char *db_name,
int load_db_opt_by_name(THD *thd, const char *db_name,
Schema_specification_st *db_create_info)
{
char db_opt_path[FN_REFLEN + 1];