Skip to content

Commit

Permalink
MDEV-29582 deprecate mysql* names
Browse files Browse the repository at this point in the history
Eventually mysql symlinks will go away, as MariaDB and MySQL keep
diverging and we do not want to make it impossible to install
MariaDB and MySQL side-by-side when users want it.

It also useful if people start using MariaDB tools with MariaDB.

If the exe doesn't begine with "mariadb" or is a symlink,
print a warning to use the resolved name.

In my_readlink, add check on my_thread_var as its used by comp_err
and other build utils that also use my_init.
  • Loading branch information
grooverdan authored and vuvova committed Feb 10, 2023
1 parent ce4a289 commit b30b040
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/mysys_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ extern const char *globerrs[]; /* my_error_messages is here */
#define EE_PERM_LOCK_MEMORY 37
#define EE_MEMCNTL 38
#define EE_DUPLICATE_CHARSET 39
#define EE_ERROR_LAST 39 /* Copy last error nr */
#define EE_NAME_DEPRECATED 40
#define EE_ERROR_LAST 40 /* Copy last error nr */

/* Add error numbers before EE_ERROR_LAST and change it accordingly. */

Expand Down
2 changes: 2 additions & 0 deletions mysys/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const char *globerrs[GLOBERRS]=
"Lock Pages in memory access rights required",
"Memcntl %s cmd %s error",
"Warning: Charset id '%d' csname '%s' trying to replace existing csname '%s'",
"Notice: %s is deprecated and will be removed in a future release, use command '%s'"
};

void init_glob_errs(void)
Expand Down Expand Up @@ -109,6 +110,7 @@ void init_glob_errs()
EE(EE_PERM_LOCK_MEMORY)= "Lock Pages in memory access rights required";
EE(EE_MEMCNTL) = "Memcntl %s cmd %s error";
EE(EE_DUPLICATE_CHARSET)= "Warning: Charset id %d trying to replace csname %s with %s";
EE(EE_NAME_DEPRECATED) = "Notice: %s is deprecated and will be removed in a future release, use command '%s'"
}
#endif

Expand Down
10 changes: 10 additions & 0 deletions mysys/my_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,17 @@ my_bool my_init(void)

my_progname_short= "unknown";
if (my_progname)
{
char link_name[FN_REFLEN];
my_progname_short= my_progname + dirname_length(my_progname);
/*
If its a link a different program that doesn't begin with mariadb
like mariadb-repair might link to mariadb-check.
*/
if (strncmp(my_progname_short, "mariadb", 7)
&& my_readlink(link_name, my_progname, MYF(0)) == 0)
my_error(EE_NAME_DEPRECATED, MYF(MY_WME), my_progname, link_name);
}

/* Initialize our mutex handling */
my_mutex_init();
Expand Down
8 changes: 5 additions & 3 deletions mysys/my_symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int (*mysys_test_invalid_symlink)(const char *filename)= always_valid;
int my_readlink(char *to, const char *filename, myf MyFlags)
{
#ifndef HAVE_READLINK
strmov(to,filename);
strnmov(to, filename, FN_REFLEN);
return 1;
#else
int result=0;
Expand All @@ -54,11 +54,13 @@ int my_readlink(char *to, const char *filename, myf MyFlags)

if ((length=readlink(filename, to, FN_REFLEN-1)) < 0)
{
if (my_thread_var)
my_errno= errno;
/* Don't give an error if this wasn't a symlink */
if ((my_errno=errno) == EINVAL)
if (errno == EINVAL)
{
result= 1;
strmov(to,filename);
strnmov(to, filename, FN_REFLEN);
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions scripts/mysql_install_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ extra_file=""
dirname0=`dirname $0 2>/dev/null`
dirname0=`dirname $dirname0 2>/dev/null`

case "$0" in
*mysql*)
echo "Notice: $0 is deprecated and will be removed in a future release, use command mariadb-install-db" 1>&2
;;
esac

usage()
{
cat <<EOF
Expand Down
6 changes: 6 additions & 0 deletions scripts/mysql_secure_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ defaults_file=
defaults_extra_file=
no_defaults=

case "$0" in
*mysql*)
echo "Notice: $0 is deprecated and will be removed in a future release, use command mariadb-secure-installation" 1>&2
;;
esac

parse_arg()
{
echo "$1" | sed -e 's/^[^=]*=//'
Expand Down

0 comments on commit b30b040

Please sign in to comment.