emacs mysql_尝试将MySQL与Emacs结合使用时出现问题

我遇到了一个尝试将Emacs与MySQL结合使用的问题。首先让我提供相关的版本信息:

Local OS: Windows XP, SP3

Terminal emulator/SSH client: Putty 0.58

Remote OS (as reported by uname -a): Linux 2.6.19.7 (also happens on another installation whose Linux is 2.6.18)

Emacs version (running on remote OS): 21.3.1 (also happens on another installation whose Emacs is 21.4.1)

MySQL version (running on remote OS): 4.1.22 (also happens on another installation whose MySQL is 5.0.91)我总是在Emacs里面运行一个shell缓冲区,我想运行命令'mysql',这样我就可以运行SQL查询。但如果我输入

mysql -uuserid -ppassword它只是挂起。当我杀死mysql进程时,它会报告:

bash: [XXXXX: 2] tcsetattr: Invalid argument

(where XXXXX is the process id of the bash shell that's the parent of the mysql process that was killed.)多年前,我编写了一个名为tcsetattr()的C代码来为tty设备驱动程序设置标志。我记得它基于tty通过RS-232连接的想法,以及通过tcsetattr()控制的RS-232连接特性(波特率,奇偶校验等)设置的许多属性。显然, ttys,其中大部分是无关紧要的。它看起来像'mysql'可执行文件正在尝试执行一些在Emacs shell缓冲区中不起作用的硬件控制。

正如我进一步调查,我发现Emacs有一个名为sql-mysql的Lisp函数,它听起来像是直接运行MySQL查询。这听起来对我很好。但是当我尝试它时,我遇到了不同的问题。

我能找到的关于如何使用M-x sql-mysql的小文档相当不完整。它没有提供任何有关如何运行查询的信息。 http://www.emacswiki.org/emacs/SqlMode说,

"Type M-x sql-help RET to read the online help."所以我做到了。帮助建议跑步:

M-x sql-mysql调用MySQL,然后说,

"Once you have the SQLi buffer, you can enter SQL statements in the buffer. The output generated is appended to the buffer and a new prompt is generated."缓冲区从未显示提示。我无法点击Emacs的菜单栏中的项目,因为我通过ssh(客户端是腻子)连接,并且腻子似乎没有传送鼠标点击。所以我无法获取Emacs菜单栏中的“SQL”或“In / Out”菜单。

我试着向 *SQL* buffer发送一个C-c(通过输入C-c C-c),期望这会导致它退出,就像一个shell缓冲区一样。令我惊讶的是,在报告之前,它显示了我输入的查询的输出:

Ctrl-C -- exit!

Process SQL exited abnormally with code 1然后我注意到M-x sql-help也说:

"If you have a really complex SQL statement or if you are writing a procedure, you can do this in a separate buffer. Put the new buffer in `sql-mode' by calling M-x sql-mode. The name of this buffer can be anything. The name of the major mode is SQL."

"In this SQL buffer (SQL mode), you can send the region or the entire buffer to the interactive SQL buffer (SQLi mode). The results are appended to the SQLi buffer without disturbing your SQL buffer."所以我创建了第二个缓冲区,命名为“my-sql-buffer”并运行M-x sql模式。当我输入查询时:

show tables;进入该缓冲区并用RET终止它, *SQL* buffer中没有任何反应。我尝试将光标放在查询的末尾并输入C-c C-c。底部的小型缓冲器显示:

"Sent string to buffer *SQL*."但 *SQL* buffer中没有任何内容出现。我再输入C-c C-c几次。每次重新显示小缓冲器:

"Sent string to buffer *SQL*."在键入C-c C-c几次之后,突然输出出现在 *SQL* buffer中。这是来自以下的输出:

show tables;重复5次!除了最后一次停在中间。这种行为表明有东西在缓冲输出。我检查了输出了多少个字节(C-x h M-C- | wc -c),它输出了4096个字节!由于4K是一个常见的缓冲区大小,这证实了我怀疑某些东西在缓冲输出。但我无法弄清楚什么是缓冲以及如何关闭缓冲。

任何人都可以帮助我解决以下一个或多个问题:

如何从emacs中的bash提示符运行mysql可执行文件,并且在调用tcsetattr()时不会挂起它?

如何运行M-x sql-mysql,在 *SQL* buffer中输入查询并实际运行它,而不使SQL进程退出?

如何在每次查询时将输出刷新到 *SQL* ,然后将查询输入到处于sql-mode的第二个缓冲区中?

提供帮助。

Mark Rosenthal

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值