Loading ...
Sorry, an error occurred while loading the content.

Re: Problem with DBExecSQLUnderCursor command from dbext plugin

Expand Messages
  • David Fishburn
    ... For the non- ambiguous SQL :-) ... Yes, I agree. I think it should search backwards as it does now as well as stopping at the first cmd_terminator. ... I
    Message 1 of 4 , Aug 3, 2010
    • 0 Attachment

      -------- Original-Nachricht --------
      Datum: Tue, 03 Aug 2010 10:22:16 -0400
      Von: David Fishburn <dfishburn.vim@...>
      An: vim_use@...
      Betreff: Re: Problem with DBExecSQLUnderCursor command from dbext plugin
          On 8/3/2010 8:05 AM, Dennis Benzinger wrote:
      I have a problem with the DBExecSQLUnderCursor command from the dbext
      plugin. From the current cursor position it searches backwards for some
      keywords it knows about (e.g. select, create, etc.) and searches forward
      the statement terminator (e.g. ;). Everything between these two
      positions is
      then sent to the database. This breaks if the statement contains none of
      known keywords (e.g. show tables in MySQL) or if the statement contains
      more than one of the keywords (e.g. create table xyz_bak as select * from
      Can I configure dbext so that it searches backwards for a statement
      terminator to find the beginning of a statement? Would this break for
      other statements?
      What dbext searches for is configurable from your .vimrc:
      By default is looks for these keywords: 
      let dbext_default_query_statements = 
      allows you to override these values.
      This of course will not help you with the statement you outlined above 
      since it has both a SELECT and a CREATE keyword.
      I almost never use DBExecSQLUnderCursor for these types of issues.  What 
      I typically do is use LINEWISE visual mode, select the statement I want 
      executed and hit use <Leader>se (sql execute).
      What I would suggest you do, is when you run into these style of 
      statements, just visually select and execute and for the other 
      statements which are not ambiguous, use what you are used to.
      If I have to select the command manually what's the use of the
      DBExecSQLUnderCursor command?
      For the non- ambiguous SQL :-)

      I think it should at least stop the backwards search as soon as it finds a
      statement separator. Otherwise it's quite easy to execute the wrong statement
      if you're not fully aware of the way the statement to execute is selected.

      Yes, I agree.  I think it should search backwards as it does now as well as stopping at the first cmd_terminator.

      For example if you have
      delete *
      from important_table
      show tables
      and then execute DBExecSQLUnderCursor on the show tables line dbext will
      execute the delete statement.
      Would you accept a patch for dbext that introduces an option to instruct
      DBExecSQLUnderCursor to execute only the text between two statement separators?
      I am always happy to accept patches.  I prefer getting the entire Vim file and use my own diff to incorporate changes though.

      We can take this offline and you can email me directly.


      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.