server icon indicating copy to clipboard operation
server copied to clipboard

MDEV-30062 Remove unnecessary delimiter from query for mariadb-client…

Open an3l opened this issue 2 years ago • 0 comments

  • Check which buffer to use as an argument for the call to the function pointer of mysql shortcut command. Buffer shouldn't have delimiter.
  • By default check if shortcut command processed is go which doesn't take any parameter (takes_params) or if a server side comment (/*! \C latin1 */ select 1) is applied. If so use pos buffer, otherwise create buffer without delimiter.
  • Order of call of function pointer matters.
  • Example with the fix when specifying the delimiter
MariaDB [(none)]> \h;

Breakpoint 1, com_help (buffer=0x5555555b476b <find_command(char)+297>, line=0x7fffffffd9a0 "\240\332\377\377\377\177") at /home/anel/GitHub/mariadb/server/src/10.3/client/mysql.cc:3148
3148	{
(gdb) n
+n
3150	  char * help_arg= strchr(line,' '), buff[32], *end;
(gdb) p line
+p line
$1 = 0x5555559f8b98 "\\h"
  • Without delimiter using the fix
MariaDB [(none)]> \h

Breakpoint 1, com_help (buffer=0x5555555b476b <find_command(char)+297>, line=0x7fffffffd9a0 "\240\332\377\377\377\177") at /home/anel/GitHub/mariadb/server/src/10.3/client/mysql.cc:3150
3150	{
(gdb) n
+n
3152	  char * help_arg= strchr(line,' '), buff[32], *end;
(gdb) p line
+p line
$2 = 0x5555559f8b98 "\\h"
  • This part is not affected by the fix,but added for a review
### No delimiter
MariaDB [(none)]> help

Breakpoint 1, com_help (buffer=0x555555a3dfc0, line=0x7fffffffd9f0 " \221\235UUU") at /home/anel/GitHub/mariadb/server/src/10.3/client/mysql.cc:3150
3150	{
(gdb) n
+n
3152	  char * help_arg= strchr(line,' '), buff[32], *end;
(gdb) p line
+p line
$3 = 0x555555a3dfc0 "help"

### There is a delimiter
MariaDB [(none)]> help;

Breakpoint 1, com_help (buffer=0x5555559f8b98, line=0x555555a3dfc4 ";") at /home/anel/GitHub/mariadb/server/src/10.3/client/mysql.cc:3150
3150	{
(gdb) n
+n
3152	  char * help_arg= strchr(line,' '), buff[32], *end;
(gdb) p line
+p line
$4 = 0x5555559f8b98 "help"

an3l avatar Nov 21 '22 16:11 an3l