简体   繁体   English

如何从SQL缓冲区向Emacs中的sql-mysql缓冲区发送大于4k的查询?

[英]How to send larger than 4k queries from SQL buffer to sql-mysql buffer in Emacs?

I've frequently run into an annoyance in Emacs's sql-mysql mode, and I'm wondering if anyone has a solution or better workaround. 我经常在Emacs的sql-mysql模式中遇到麻烦,我想知道是否有人有解决方案或更好的解决方法。 Anytime I try to send a query from an sql-mode buffer to an active SQL process buffer, that query cannot be larger than 4k. 无论何时我尝试将查询从sql-mode缓冲区发送到活动的SQL进程缓冲区,该查询都不能大于4k。 If it's larger than 4k, it appears that some sort of break - perhaps a newline - is inserted, and this causes the mysql interpreter to throw an error on the following line. 如果它大于4k,则会出现某种中断 - 可能是换行符 - 这会导致mysql解释器在下一行引发错误。

sql-mysql is implemented by sql.el , and uses the function sql-send-region to send query regions (or whole buffers) to the selected SQL process buffer. sql-mysqlsql.el实现,并使用函数sql-send-region将查询区域(或整个缓冲区)发送到选定的SQL进程缓冲区。 sql-send-region calls comint-send-region , which in turn calls process-send-region . sql-send-region调用comint-send-region ,后者又调用process-send-region process-send-region is a C function that calls send_process , both in src/process.c in the Emacs source. process-send-region是一个调用send_process的C函数, send_process都在Emacs源的src/process.c中。

It looks like this may just be a limitation produced by the 4k buffer on an IPC pipe. 看起来这可能只是IPC管道上4k缓冲区产生的限制。 Since it appears that kernel hacking is necessary to change this size, that's not a great answer. 由于看起来内核黑客攻击是改变这个大小所必需的,所以这不是一个好的答案。

What I guess I'm puzzled by is why the SQL sent through the pipe is not properly reassembled by the mysql client if it's larger than 4k. 我想我很困惑的是,如果mysql客户端大于4k,那么通过管道发送的SQL没有被mysql客户端正确地重新组装。 Any ideas? 有任何想法吗?

Emacs version: GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-03-25 on allspice, modified by Debian Emacs版本:2012-03-25关于allspice的GNU Emacs 23.3.1(x86_64-pc-linux-gnu,GTK +版本2.24.10),由Debian修改

mysql -V: mysql Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2 mysql -V:mysql Ver 14.14 Distrib 5.5.24,debian-linux-gnu(x86_64)使用readline 6.2

Sql Mysql Options: -A -C -n (NB I've tried both with and without -n (unbuffered) and neither fixed this issue) Sql Mysql选项:-A -C -n(注意我已尝试使用和不使用-n(无缓冲)并且都没有修复此问题)

I suspect the culprit to be Emacs's process communication code, used by comint , allocating PTYs to talk to processes. 我怀疑罪魁祸首是Emacs的进程通信代码,由comint ,分配PTYs来与进程通信。 While these are useful for interactive work because they allow job control, they are also limited in how much data they can transfer in one chunk without an intervening newline. 虽然这些对于交互式工作很有用,因为它们允许作业控制,但它们也可以在一个块中传输多少数据,而无需插入新行。 Emacs can also be told to use pipes, which do not have this limitation. Emacs也可以被告知使用管道,没有这个限制。

To test this, start a fresh Emacs, evaluate M-: (setq process-connection-type nil) , and start sql-mysql . 要测试这个,启动一个新的Emacs,评估M-: (setq process-connection-type nil) ,并启动sql-mysql If the problem goes away, this is your culprit. 如果问题消失,这就是你的罪魁祸首。 In that case, you will want to use something like: 在这种情况下,您将需要使用以下内容:

(add-hook 'sql-mysql-mode-hook
          (lambda ()
            (set (make-local-variable 'process-connection-type) nil)))

to make sure that process-connection-type gets reset only in MySQL interaction buffers. 确保只在MySQL交互缓冲区中重置process-connection-type


EDIT 编辑

According to http://tinyurl.com/car439o/ , Emacs no longer bothers to interrupt long PTY output with newline+EOF pairs. 根据http://tinyurl.com/car439o/,Emacs不再需要使用换行符+ EOF对来中断长PTY输出。 Although the commit is from 2010-04-13, it only appeared in Emacs 24, released in 2012. This would explain why the problem is apparently not reproducible in 24.2.1. 虽然提交时间是2010年4月13日,但它只出现在2012年发布的Emacs 24中。这可以解释为什么问题在24.2.1中显然不可复制。 If you are using Emacs prior to 24, try upgrading. 如果您在24之前使用Emacs,请尝试升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM