Opened 2 years ago

Last modified 2 years ago

#64006 reopened defect

mysql* lacks editline or readline support

Reported by: laggardkernel (laggardkernel) Owned by: herbygillot (Herby Gillot)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: mysql editline readline Cc: chrstphrchvz (Christopher Chavez)
Port: mysql8

Description

MySQL supports line editor like editline (libedit) or readline. AFAIK, both of them are supported. It seemss editline is chosen by default even if the dependency is not declared during build, cause editline error was popped up when I connected the server with mysql -h localhost -u root -p

❯ mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

bind: Invalid command `ed-tty-sigint'.
bind: Invalid command `ed-tty-sigquit'.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql root@localhost:(none)>

# editline is missing
❯ otool -L /opt/local/bin/mysql
/opt/local/bin/mysql:
        /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
        /opt/local/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.0)
        /opt/local/libexec/openssl11/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /opt/local/libexec/openssl11/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
        /opt/local/lib/libncurses.6.dylib (compatibility version 6.0.0, current version 6.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

Related settings in my ~/.editrc

bind "^C" ed-tty-sigint
bind "^D" ed-tty-sigquit

Change History (9)

comment:1 Changed 2 years ago by laggardkernel (laggardkernel)

BTW, the newline \n in the prompt of mysql doesn't work either.

# ~/.my.cnf
[client]
default-character-set = utf8mb4

[mysql]
prompt='\nmysql \U:\d\n> '
default-character-set = utf8mb4
auto-rehash

It should be displayed like following

mysql root@localhost:(none)
>

Not sure if line editor takes charge of the prompt.

comment:2 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

Cc: chrstphrchvz added

comment:3 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

The mysql* portfiles should probably at least specify which of bundled libedit/external libedit/external readline/etc. to use to avoid opportunistic undeclared dependencies. The upstream preference in recent 5.6/5.7/8.0 releases appears to be libedit rather than readline.

comment:4 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

Looking at CMake code in MySQL, it currently is only using its bundled libedit, and not picking up external libedit. Since the bundled libedit is slightly older than MacPorts’ libedit and only has a few bug fixes patched onto it rather than any major MySQL-specific additions or modifications, I would consider switching to MacPorts’ libedit: this would involve adding depends_lib-append port:libedit and configure.args-append -DWITH_EDITLINE=system, but since WITH_EDITLINE does not accept a path, I would want to make sure this approach will only ever use MacPorts’ libedit.

I am not a UNIX veteran, and don’t know the first thing about editline/readline (other than that it lets me use the arrow keys), so I would want the reporter or someone knowledgeable to confirm this approach helps.

comment:5 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

comment:6 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

Resolution: fixed
Status: assignedclosed

In b3c93c57f53b36dbdaef52bdf6b801f57caa524a/macports-ports (master):

mysql56, mysql8: use MacPorts’ libedit

…instead of bundled libedit (as already done for mysql57 in 38aa1a0ec8)
Fixes: #64006

comment:7 Changed 2 years ago by laggardkernel (laggardkernel)

Sorry, I'm not familiar about how to compiling MySQL. I did tried the new revision 4 of mysql8 and I still encounter the error bind: Invalid command 'ed-tty-sigint'. But the libedit did get used by mysql.

❯ otool -L /opt/local/bin/mysql
/opt/local/bin/mysql:
        /opt/local/lib/libedit.0.dylib (compatibility version 1.0.0, current version 1.68.0)
        /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
        /opt/local/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.0)
        /opt/local/libexec/openssl11/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /opt/local/libexec/openssl11/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

And here is the otool output for Homebrew MySQL

otool -L /usr/local/bin/mysql
/usr/local/bin/mysql:
        /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
        /usr/local/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.0)
        /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

Is it because we're not using the system libedit? But ed-tty-sigint do exists in the MacPorts libedit, by checking man 7 editline. Currently I can drop the Ctrl-d and Ctrl-c keybindings to avoid the error, cause they seems to be enabled by default.

Besides, the newline \n still doesn't take effect in mysql command line.

comment:8 Changed 2 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: closedreopened

Requested by chrstphrchvz.

comment:9 Changed 2 years ago by herbygillot (Herby Gillot)

In 810ceb79a534c5543d6d1c2dd37af52196bc3a09/macports-ports (master):

mysql8: update to 8.0.28

  • use correct openssl binary for given OpenSSL dir
  • use MacPorts libedit
  • remove cmake patch for sw_ver

Fixes: #64259
See: #64006

Note: See TracTickets for help on using tickets.