Skip to content
/ server Public

Commit 366de0a

Browse files
committed
Merge branch '12.2' into 12.3
2 parents 6efa1cf + a3d1b82 commit 366de0a

File tree

318 files changed

+9894
-3923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+9894
-3923
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Docs/INFO_BIN
3131
Docs/INFO_SRC
3232
Makefile
3333
TAGS
34+
mariadb-plugin-columnstore.install.generated
3435
Testing/
3536
tmp/
3637
VERSION.dep

client/my_readline.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ typedef struct st_line_buffer
3434
bool truncated;
3535
} LINE_BUFFER;
3636

37-
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
3837
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
3938
extern char *batch_readline(LINE_BUFFER *buffer, bool binary_mode);
4039
extern void batch_readline_end(LINE_BUFFER *buffer);
40+
extern bool init_line_buffer(LINE_BUFFER *buffer, File file, ulong size,
41+
ulong max_size);
4142

4243
#endif /* CLIENT_MY_READLINE_INCLUDED */

client/mysql.cc

Lines changed: 86 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,88 @@ inline int get_command_index(char cmd_char)
12161216
return -1;
12171217
}
12181218

1219+
static LINE_BUFFER *batch_readline_init(ulong max_size, const char *path)
1220+
{
1221+
LINE_BUFFER *line_buff;
1222+
File file;
1223+
MY_STAT input_file_stat;
1224+
char buff[FN_REFLEN + 512];
1225+
1226+
if (path)
1227+
{
1228+
file= my_open(path, O_RDONLY | O_BINARY, MYF(0));
1229+
if (file < 0 && my_errno == ENOENT && script_dir)
1230+
{
1231+
char full_path[FN_REFLEN];
1232+
strxnmov(full_path, sizeof(full_path)-1, script_dir, "/", path, NULL);
1233+
file= my_open(full_path, O_RDONLY | O_BINARY, MYF(0));
1234+
}
1235+
if (file < 0)
1236+
{
1237+
#ifdef _WIN32
1238+
if (my_errno == EACCES && my_stat(path, &input_file_stat, MYF(0)) &&
1239+
MY_S_ISDIR(input_file_stat.st_mode))
1240+
my_snprintf(buff, sizeof(buff), "Can't read from a directory '%.*s'",
1241+
FN_REFLEN, path);
1242+
else
1243+
#endif
1244+
my_snprintf(buff, sizeof(buff), "Failed to open file '%.*s', error: %d",
1245+
FN_REFLEN, path, my_errno);
1246+
put_info(buff, INFO_ERROR, 0);
1247+
return 0;
1248+
}
1249+
}
1250+
else
1251+
{
1252+
file= my_fileno(stdin);
1253+
}
1254+
1255+
if (my_fstat(file, &input_file_stat, MYF(0)))
1256+
{
1257+
my_snprintf(buff, sizeof(buff), "Failed to stat file '%.*s', error: %d",
1258+
FN_REFLEN, path ? path : "stdin", my_errno);
1259+
goto err1;
1260+
}
1261+
1262+
if (MY_S_ISDIR(input_file_stat.st_mode))
1263+
{
1264+
my_snprintf(buff, sizeof(buff), "Can't read from a directory '%.*s'",
1265+
FN_REFLEN, path ? path : "stdin");
1266+
goto err1;
1267+
}
1268+
1269+
#ifndef _WIN32
1270+
if (MY_S_ISBLK(input_file_stat.st_mode))
1271+
{
1272+
my_snprintf(buff, sizeof(buff), "Can't read from a block device '%.*s'",
1273+
FN_REFLEN, path ? path : "stdin");
1274+
goto err1;
1275+
}
1276+
#endif
1277+
1278+
if (!(line_buff= (LINE_BUFFER*) my_malloc(PSI_NOT_INSTRUMENTED,
1279+
sizeof(*line_buff),
1280+
MYF(MY_WME | MY_ZEROFILL))))
1281+
{
1282+
goto err;
1283+
}
1284+
1285+
if (init_line_buffer(line_buff, file, IO_SIZE, max_size))
1286+
{
1287+
my_free(line_buff);
1288+
goto err;
1289+
}
1290+
1291+
return line_buff;
1292+
1293+
err1:
1294+
put_info(buff, INFO_ERROR, 0);
1295+
err:
1296+
if (path)
1297+
my_close(file, MYF(0));
1298+
return 0;
1299+
}
1300+
12191301
static int delimiter_index= -1;
12201302
static int charset_index= -1;
12211303
static int sandbox_index= -1;
@@ -1290,10 +1372,8 @@ int main(int argc,char *argv[])
12901372
}
12911373

12921374
if (status.batch && !status.line_buff &&
1293-
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
1375+
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, NULL)))
12941376
{
1295-
put_info("Can't initialize batch_readline - may be the input source is "
1296-
"a directory or a block device.", INFO_ERROR, 0);
12971377
free_defaults(defaults_argv);
12981378
my_end(0);
12991379
exit(1);
@@ -4742,11 +4822,9 @@ static int com_connect(String *buffer, char *line)
47424822
static int com_source(String *, char *line)
47434823
{
47444824
char source_name[FN_REFLEN], *end, *param;
4745-
char full_path[FN_REFLEN];
47464825
LINE_BUFFER *line_buff;
47474826
int error;
47484827
STATUS old_status;
4749-
FILE *sql_file;
47504828
my_bool save_ignore_errors;
47514829

47524830
if (status.sandbox)
@@ -4766,27 +4844,10 @@ static int com_source(String *, char *line)
47664844
end--;
47674845
end[0]=0;
47684846
unpack_filename(source_name,source_name);
4769-
/* open file name */
4770-
if (!(sql_file = my_fopen(source_name, O_RDONLY | O_BINARY,MYF(0))))
4771-
{
4772-
if (script_dir)
4773-
{
4774-
snprintf(full_path, sizeof(full_path), "%s/%s", script_dir, source_name);
4775-
sql_file = my_fopen(full_path, O_RDONLY | O_BINARY, MYF(0));
4776-
}
4777-
}
4778-
4779-
if (!sql_file)
4780-
{
4781-
char buff[FN_REFLEN + 60];
4782-
sprintf(buff, "Failed to open file '%s', error: %d", source_name, errno);
4783-
return put_info(buff, INFO_ERROR, 0);
4784-
}
47854847

4786-
if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, sql_file)))
4848+
if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, source_name)))
47874849
{
4788-
my_fclose(sql_file,MYF(0));
4789-
return put_info("Can't initialize batch_readline", INFO_ERROR, 0);
4850+
return ignore_errors ? -1 : 1;
47904851
}
47914852

47924853
/* Save old status */
@@ -4805,7 +4866,7 @@ static int com_source(String *, char *line)
48054866
ignore_errors= save_ignore_errors;
48064867
status=old_status; // Continue as before
48074868
in_com_source= aborted= 0;
4808-
my_fclose(sql_file,MYF(0));
4869+
my_close(line_buff->file, MYF(0));
48094870
batch_readline_end(line_buff);
48104871
/*
48114872
If we got an error during source operation, don't abort the client

client/mysqldump.cc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7311,6 +7311,85 @@ static void init_connection_pool(uint n_connections)
73117311
connection_pool.init(conn, n_connections);
73127312
}
73137313

7314+
/*
7315+
Fix permissions and ownership of given directory to be the same
7316+
as the root output directory.
7317+
7318+
The function is used for newly created database directories,
7319+
together with --dir option
7320+
7321+
This function is not thread-safe, nor does it need to be, because
7322+
it is called from the main thread only.
7323+
7324+
chmod/chown errors are ignored after the first one, with a warning printed,
7325+
so it is really the best effort attempt. We might see an error later
7326+
if the server can't write into the directory, and this will be the
7327+
real error.
7328+
7329+
On Windows, this function does nothing, because the permissions are
7330+
inherited from the parent directory anyway.
7331+
7332+
@param dirpath Directory path
7333+
*/
7334+
static void fix_permissions_and_owner(const char *dirpath)
7335+
{
7336+
#ifndef _WIN32
7337+
// Permissions and ownership of output directory (--dir)
7338+
static struct stat st_out_dir;
7339+
7340+
static bool fix_perms= true; // Try fixing permission bits
7341+
static bool fix_ownership_uid= true; // Try fixing user+group ownership
7342+
static bool fix_ownership_gid= false; // Try fixing group ownership only
7343+
7344+
static bool first_time= true;
7345+
if (first_time)
7346+
{
7347+
/* Find out permissions and ownership of output directory */
7348+
first_time= false;
7349+
if (stat(opt_dir, &st_out_dir) != 0)
7350+
{
7351+
die(EX_CONSCHECK, "Error: cannot stat output directory %s, errno %d",
7352+
opt_dir, errno);
7353+
}
7354+
}
7355+
7356+
/* Change permissions to be the same as for the output directory*/
7357+
if (fix_perms &&
7358+
chmod(dirpath, st_out_dir.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)))
7359+
{
7360+
fprintf(stderr,
7361+
"Warning: cannot set permissions on directory %s, errno %d\n",
7362+
dirpath, errno);
7363+
fix_perms= false;
7364+
}
7365+
7366+
/*
7367+
Change ownership to be the same as backup root dir.
7368+
If user can't be changed, try changing owner group only.
7369+
*/
7370+
if (fix_ownership_uid &&
7371+
chown(dirpath, st_out_dir.st_uid, st_out_dir.st_gid))
7372+
{
7373+
// No warning, error is expected, unless current user is root.
7374+
fix_ownership_uid= false;
7375+
fix_ownership_gid= true;
7376+
}
7377+
7378+
if (fix_ownership_gid && chown(dirpath, -1, st_out_dir.st_gid))
7379+
{
7380+
if (!(st_out_dir.st_mode & S_IWOTH))
7381+
{
7382+
/* Only warn if directory is not world-writable (group ownership
7383+
matters more in this case), to avoid spamming stderr.*/
7384+
fprintf(stderr,
7385+
"Warning: cannot set group ownership on directory %s, errno %d\n",
7386+
dirpath, errno);
7387+
}
7388+
fix_ownership_gid= false;
7389+
}
7390+
#endif
7391+
}
7392+
73147393
/*
73157394
If --dir option is in use, ensure that output directory for given db
73167395
exists.
@@ -7330,6 +7409,7 @@ static void ensure_out_dir_exists(const char *db)
73307409
}
73317410
if (my_mkdir(outdir, 0777, MYF(MY_WME)))
73327411
die(EX_MYSQLERR, "Error creating directory %s", outdir);
7412+
fix_permissions_and_owner(outdir);
73337413
}
73347414

73357415

client/readline.cc

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,11 @@
2323
#include <my_dir.h>
2424
#include "my_readline.h"
2525

26-
static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
27-
ulong max_size);
2826
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
2927
static size_t fill_buffer(LINE_BUFFER *buffer);
3028
static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length);
3129

3230

33-
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
34-
{
35-
LINE_BUFFER *line_buff;
36-
37-
#ifndef _WIN32
38-
MY_STAT input_file_stat;
39-
if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) ||
40-
MY_S_ISDIR(input_file_stat.st_mode) ||
41-
MY_S_ISBLK(input_file_stat.st_mode))
42-
return 0;
43-
#endif
44-
45-
if (!(line_buff=(LINE_BUFFER*)
46-
my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*line_buff),
47-
MYF(MY_WME | MY_ZEROFILL))))
48-
return 0;
49-
if (init_line_buffer(line_buff,my_fileno(file),IO_SIZE,max_size))
50-
{
51-
my_free(line_buff);
52-
return 0;
53-
}
54-
return line_buff;
55-
}
56-
57-
5831
char *batch_readline(LINE_BUFFER *line_buff, bool binary_mode)
5932
{
6033
char *pos;
@@ -105,8 +78,7 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str)
10578
Functions to handle buffered readings of lines from a stream
10679
******************************************************************************/
10780

108-
static bool
109-
init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
81+
bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
11082
{
11183
buffer->file=file;
11284
buffer->bufread=size;

cmake/build_configurations/mysql_release.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ ELSEIF(DEB)
120120
SET(WITH_ZLIB system CACHE STRING "")
121121
SET(WITH_LIBWRAP ON)
122122
SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON)
123-
# No hurd implementation
124-
IF(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "i686-AT386")
123+
# On Hurd systems (GNU) there is no auth socket implementation
124+
IF(NOT CMAKE_SYSTEM_NAME STREQUAL "GNU")
125125
SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "")
126126
ENDIF()
127127
SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "")

cmake/mariadb_connector_c.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ ENDIF()
77
SET(CONC_WITH_SIGNCODE ${SIGNCODE})
88
SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS})
99
SET(CONC_WITH_EXTERNAL_ZLIB ON)
10-
SET(CLIENT_PLUGIN_PARSEC OFF)
1110

12-
CHECK_INCLUDE_FILES (threads.h HAVE_THREADS_H)
13-
IF(HAVE_THREADS_H)
14-
SET(CLIENT_PLUGIN_PARSEC DYNAMIC)
15-
ENDIF()
1611

1712
IF(NOT CONC_WITH_SSL)
1813
IF(SSL_DEFINES MATCHES "WOLFSSL")

extra/mariabackup/xtrabackup.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ static void backup_file_op_fail(uint32_t space_id, int type,
12371237
msg("DDL tracking : create %" PRIu32 " \"%.*s\"",
12381238
space_id, int(len), name);
12391239
fail = !check_if_skip_table(spacename.c_str());
1240-
if (!opt_no_lock && fail &&
1240+
if (fail && !opt_no_lock &&
12411241
check_if_fts_table(spacename.c_str())) {
12421242
/* Ignore the FTS internal table because InnoDB does
12431243
create intermediate table and their associative FTS
@@ -1264,6 +1264,11 @@ static void backup_file_op_fail(uint32_t space_id, int type,
12641264
break;
12651265
case FILE_DELETE:
12661266
fail = !check_if_skip_table(spacename.c_str())
1267+
/* Ignore the FTS internal table because InnoDB may
1268+
drop intermediate table and their associative FTS
1269+
internal table as a part of inplace rollback operation.
1270+
backup_set_alter_copy_lock() downgrades the
1271+
MDL_BACKUP_DDL before inplace phase of alter */
12671272
&& !check_if_fts_table(spacename.c_str());
12681273
msg("DDL tracking : delete %" PRIu32 " \"%.*s\"",
12691274
space_id, int(len), name);
@@ -5877,6 +5882,8 @@ void CorruptedPages::backup_fix_ddl(ds_ctxt *ds_data, ds_ctxt *ds_meta)
58775882
node, 0, dest_name.c_str(),
58785883
wf_write_through, *this);
58795884
}
5885+
5886+
DBUG_MARIABACKUP_EVENT("after_backup_fix_ddl", {});
58805887
}
58815888

58825889

@@ -6120,16 +6127,12 @@ xb_delta_open_matching_space(
61206127
ut_ad(fil_space_t::physical_size(flags) == info.page_size);
61216128

61226129
mysql_mutex_lock(&fil_system.mutex);
6123-
fil_space_t* space = fil_space_t::create(uint32_t(info.space_id),
6124-
flags, false, 0,
6125-
FIL_ENCRYPTION_DEFAULT, true);
6130+
std::ignore = fil_space_t::create(uint32_t(info.space_id),
6131+
flags, false, 0,
6132+
FIL_ENCRYPTION_DEFAULT, true);
61266133
mysql_mutex_unlock(&fil_system.mutex);
6127-
if (space) {
6128-
*success = xb_space_create_file(real_name, info.space_id,
6129-
flags, &file);
6130-
} else {
6131-
msg("Can't create tablespace %s\n", dest_space_name);
6132-
}
6134+
*success = xb_space_create_file(real_name, info.space_id,
6135+
flags, &file);
61336136

61346137
goto exit;
61356138
}

0 commit comments

Comments
 (0)