Created
September 26, 2022 14:41
-
-
Save yoku0825/2629031b69c06377f4dd5b5dc7552ef3 to your computer and use it in GitHub Desktop.
mysqlコマンドラインクライアントって、自分の出力がパイプかどうかどうやって判定してるんだろ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ strace -e write /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt="mysql80 \C> " -e "SELECT 1" | |
write(1, "+---+\n", 6+---+ | |
) = 6 | |
write(1, "| 1 |\n", 6| 1 | | |
) = 6 | |
write(1, "+---+\n", 6+---+ | |
) = 6 | |
write(1, "| 1 |\n", 6| 1 | | |
) = 6 | |
write(1, "+---+\n", 6+---+ | |
) = 6 | |
+++ exited with 0 +++ | |
$ strace -e write /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt="mysql80 \C> " -e "SELECT 1" | cat | |
write(1, "1\n1\n", 41 | |
1 | |
) = 4 | |
+++ exited with 0 +++ |
Author
yoku0825
commented
Sep 26, 2022
パイプあり
(gdb) b print_tab_data
+b print_tab_data
Breakpoint 1 at 0x413b64: file /home/yoku0825/mysql-8.0.30/client/mysql.cc, line 3934.
(gdb) r
+r
Starting program: /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt=mysql80\ \\C\>\ -e SELECT\ 1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 1, com_go () at /home/yoku0825/mysql-8.0.30/client/mysql.cc:3373
3373 print_tab_data(result);
Missing separate debuginfos, use: debuginfo-install keyutils-libs-1.5.8-3.el7.x86_64 libselinux-2.5-15.el7.x86_64 ncurses-libs-5.9-14.20130511.el7_4.x86_64
(gdb) bt
+bt
#0 com_go () at /home/yoku0825/mysql-8.0.30/client/mysql.cc:3373
#1 0x0000000000415a6b in read_and_execute(bool) () at /home/yoku0825/mysql-8.0.30/client/mysql.cc:2317
#2 0x000000000040ae94 in main () at /home/yoku0825/mysql-8.0.30/client/mysql.cc:1446
#3 0x00007ffff5ea7555 in __libc_start_main (main=0x40a640 <main>, argc=8, argv=0x7fffffffe238, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe228) at ../csu/libc-start.c:266
#4 0x000000000040b8b0 in _start ()
パイプなし
(gdb) b print_tab_data
+b print_tab_data
Breakpoint 1 at 0x413b64: file /home/yoku0825/mysql-8.0.30/client/mysql.cc, line 3934.
(gdb) r
+r
Starting program: /usr/mysql/8.0.30/bin/mysql -S /usr/mysql/8.0.30/data/mysql.sock -P 64080 --prompt=mysql80\ \\C\>\ -e SELECT\ 1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
+---+
| 1 |
+---+
| 1 |
+---+
[Inferior 1 (process 28252) exited normally]
Missing separate debuginfos, use: debuginfo-install keyutils-libs-1.5.8-3.el7.x86_64 libselinux-2.5-15.el7.x86_64 ncurses-libs-5.9-14.20130511.el7_4.x86_64
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment