Skip to content

Commit a3c9775

Browse files
author
Tor Didriksen
committed
Bug#16316074 RFE: MAKE TMPDIR A BUILD-TIME CONFIGURABLE OPTION
Bug#68338 RFE: make tmpdir a build-time configurable option Background: Some distributions use tmpfs for mounting /tmp by default, which has some advantages, but brings also new issues. Fedora started using tmpfs on /tmp in version 18 for example. If not configured otherwise in my.cnf, MySQL uses system's constant P_tmpdir expanded to /tmp on Linux. This can introduce some problems with limited space in /tmp and also some data loss in case of replication slave [1]. In case distributions would like to use /var/tmp, which should be better for MySQL purposes, then we have to patch the source or change tmpdir option in my.cnf, which is however not updated in case it has already existed. Thus, it would be useful to be able to specify default tmpdir path using a configure option, while using P_tmpdir in case it is not defined explicitly. Based on a contribution from Honza Horak
1 parent 42be8c1 commit a3c9775

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@ IF(SYSCONFDIR)
329329
SET(DEFAULT_SYSCONFDIR "${SYSCONFDIR}")
330330
ENDIF()
331331

332+
OPTION(TMPDIR
333+
"PATH to MySQL TMP dir. If unspecified, defaults to P_tmpdir in <stdio.h>" OFF)
334+
IF(TMPDIR)
335+
# Quote it, to make it a const char string.
336+
SET(DEFAULT_TMPDIR "\"${TMPDIR}\"")
337+
ELSE()
338+
# Do not quote it, to refer to the P_tmpdir macro in <stdio.h>.
339+
SET(DEFAULT_TMPDIR "P_tmpdir")
340+
ENDIF()
332341

333342
# Run platform tests
334343
INCLUDE(configure.cmake)

config.h.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
22

33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -600,6 +600,7 @@
600600
#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
601601
#cmakedefine PLUGINDIR "@PLUGINDIR@"
602602
#cmakedefine DEFAULT_SYSCONFDIR "@DEFAULT_SYSCONFDIR@"
603+
#cmakedefine DEFAULT_TMPDIR @DEFAULT_TMPDIR@
603604

604605
#cmakedefine SO_EXT "@CMAKE_SHARED_MODULE_SUFFIX@"
605606

libmysqld/lib_sql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
558558
opt_mysql_tmpdir=getenv("TMP");
559559
#endif
560560
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
561-
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
561+
opt_mysql_tmpdir= const_cast<char*>(DEFAULT_TMPDIR); /* purecov: inspected*/
562562

563563
init_ssl();
564564
umask(((~my_umask) & 0666));

mysys/mf_tempdir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
4343
pathlist=getenv("TMP");
4444
#endif
4545
if (!pathlist || !pathlist[0])
46-
pathlist=(char*) P_tmpdir;
46+
pathlist= DEFAULT_TMPDIR;
4747
}
4848
do
4949
{

mysys/mf_tempfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -111,7 +111,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
111111
sizeof(prefix_buff)-7),"XXXXXX") -
112112
prefix_buff);
113113
if (!dir && ! (dir =getenv("TMPDIR")))
114-
dir=P_tmpdir;
114+
dir= DEFAULT_TMPDIR;
115115
if (strlen(dir)+ pfx_len > FN_REFLEN-2)
116116
{
117117
errno=my_errno= ENAMETOOLONG;

0 commit comments

Comments
 (0)