|
1 | 1 | " dbext.vim - Commn Database Utility
|
2 | 2 | " Copyright (C) 2002-10, Peter Bagyinszki, David Fishburn
|
3 | 3 | " ---------------------------------------------------------------
|
4 |
| -" Version: 14.00 |
| 4 | +" Version: 15.00 |
5 | 5 | " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
|
6 | 6 | " Authors: Peter Bagyinszki <petike1 at dpg dot hu>
|
7 | 7 | " David Fishburn <dfishburn dot vim at gmail dot com>
|
8 |
| -" Last Modified: 2012 Mar 23 |
| 8 | +" Last Modified: 2012 Apr 30 |
9 | 9 | " Based On: sqlplus.vim (author: Jamis Buck)
|
10 | 10 | " Created: 2002-05-24
|
11 | 11 | " Homepage: http://vim.sourceforge.net/script.php?script_id=356
|
@@ -38,7 +38,7 @@ if v:version < 700
|
38 | 38 | echomsg "dbext: Version 4.00 or higher requires Vim7. Version 3.50 can stil be used with Vim6."
|
39 | 39 | finish
|
40 | 40 | endif
|
41 |
| -let g:loaded_dbext_auto = 1400 |
| 41 | +let g:loaded_dbext_auto = 1500 |
42 | 42 |
|
43 | 43 | " Turn on support for line continuations when creating the script
|
44 | 44 | let s:cpo_save = &cpo
|
@@ -774,6 +774,18 @@ function! dbext#DB_getWType(name)
|
774 | 774 | return retval
|
775 | 775 | endfunction
|
776 | 776 |
|
| 777 | +"" Get buffer defaulting to the buffer set value |
| 778 | +"" or if empty use the database type default. |
| 779 | +function! dbext#DB_getWTypeDefault(name) |
| 780 | + let retval = s:DB_get(a:name) |
| 781 | + |
| 782 | + if retval == "" && exists("b:dbext_type") |
| 783 | + let retval = s:DB_get(b:dbext_type.'_'.a:name) |
| 784 | + endif |
| 785 | + |
| 786 | + return retval |
| 787 | +endfunction |
| 788 | + |
777 | 789 | "" Returns hardcoded defaults for parameters.
|
778 | 790 | function! s:DB_getDefault(name)
|
779 | 791 | " Must use g:dbext_default_profile.'' so that it is expanded
|
@@ -863,6 +875,7 @@ function! s:DB_getDefault(name)
|
863 | 875 | elseif a:name ==# "MYSQL_cmd_options" |return (exists("g:dbext_default_MYSQL_cmd_options")?g:dbext_default_MYSQL_cmd_options.'':'')
|
864 | 876 | elseif a:name ==# "MYSQL_cmd_terminator" |return (exists("g:dbext_default_MYSQL_cmd_terminator")?g:dbext_default_MYSQL_cmd_terminator.'':';')
|
865 | 877 | elseif a:name ==# "MYSQL_version" |return (exists("g:dbext_default_MYSQL_version")?g:dbext_default_MYSQL_version.'':'5')
|
| 878 | + elseif a:name ==# "MYSQL_extra" |return (exists("g:dbext_default_MYSQL_extra")?g:dbext_default_MYSQL_extra.'':'-t') |
866 | 879 | elseif a:name ==# "MYSQL_SQL_Top_pat" |return (exists("g:dbext_default_MYSQL_SQL_Top_pat")?g:dbext_default_MYSQL_SQL_Top_pat.'':'\(.*\)')
|
867 | 880 | elseif a:name ==# "MYSQL_SQL_Top_sub" |return (exists("g:dbext_default_MYSQL_SQL_Top_sub")?g:dbext_default_MYSQL_SQL_Top_sub.'':'\1 LIMIT @dbext_topX ')
|
868 | 881 | elseif a:name ==# "FIREBIRD_bin" |return (exists("g:dbext_default_FIREBIRD_bin")?g:dbext_default_FIREBIRD_bin.'':'isql')
|
@@ -1634,7 +1647,7 @@ function! s:DB_ASA_execSql(str)
|
1634 | 1647 | \ s:DB_option('eng=', s:DB_get("srvname"), ';') .
|
1635 | 1648 | \ s:DB_option('dbn=', s:DB_get("dbname"), ';') .
|
1636 | 1649 | \ s:DB_option('links=', links, ';') .
|
1637 |
| - \ s:DB_option('', s:DB_get("extra"), '') |
| 1650 | + \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '') |
1638 | 1651 | if has("win32") && s:DB_get("integratedlogin") == 1
|
1639 | 1652 | let cmd = cmd .
|
1640 | 1653 | \ s:DB_option('int=', 'yes', ';')
|
@@ -1869,7 +1882,7 @@ function! s:DB_ULTRALITE_execSql(str)
|
1869 | 1882 | \ s:DB_option('pwd=', s:DB_get("passwd"), ';') .
|
1870 | 1883 | \ s:DB_option('dsn=', s:DB_get("dsnname"), ';') .
|
1871 | 1884 | \ s:DB_option('dbf=', s:DB_get("dbname"), ';') .
|
1872 |
| - \ s:DB_option('', s:DB_get("extra"), '') |
| 1885 | + \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '') |
1873 | 1886 | let cmd = cmd . '" ' .
|
1874 | 1887 | \ ' read ' . s:dbext_tempfile
|
1875 | 1888 | let result = s:DB_runCmd(cmd, output, "")
|
@@ -1993,7 +2006,7 @@ function! s:DB_ASE_execSql(str)
|
1993 | 2006 | \ s:DB_option('-H ', s:DB_get("host"), ' ') .
|
1994 | 2007 | \ s:DB_option('-S ', s:DB_get("srvname"), ' ') .
|
1995 | 2008 | \ s:DB_option('-D ', s:DB_get("dbname"), ' ') .
|
1996 |
| - \ s:DB_option('', s:DB_get("extra"), '') . |
| 2009 | + \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '') . |
1997 | 2010 | \ ' -i ' . s:dbext_tempfile
|
1998 | 2011 |
|
1999 | 2012 | let result = s:DB_runCmd(cmd, output, "")
|
@@ -2185,13 +2198,13 @@ function! s:DB_DB2_execSql(str)
|
2185 | 2198 |
|
2186 | 2199 | let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("bin"))
|
2187 | 2200 |
|
2188 |
| - let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options") |
| 2201 | + let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options") . ' ' |
2189 | 2202 | if s:DB_get("user") != ""
|
2190 | 2203 | let cmd = cmd . ' -a ' . s:DB_get("user") . '/' .
|
2191 | 2204 | \ s:DB_get("passwd") . ' '
|
2192 | 2205 | endif
|
2193 | 2206 | let cmd = cmd .
|
2194 |
| - \ s:DB_option(' ', s:DB_get("extra"), ' ') . |
| 2207 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), ' ') . |
2195 | 2208 | \ s:DB_option('-d ', s:DB_get("dbname"), ' ') .
|
2196 | 2209 | \ s:DB_option('-l ', dbext#DB_getWType("cmd_terminator"), ' ').
|
2197 | 2210 | \ ' -f ' . s:dbext_tempfile
|
@@ -2237,7 +2250,7 @@ function! s:DB_DB2_execSql(str)
|
2237 | 2250 | let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("db2cmd_bin"))
|
2238 | 2251 |
|
2239 | 2252 | let cmd = dbext_bin . ' ' . dbext#DB_getWType("db2cmd_cmd_options")
|
2240 |
| - let cmd = cmd . ' ' . s:DB_option('', s:DB_get("extra"), ' ') . |
| 2253 | + let cmd = cmd . ' ' . s:DB_option('', dbext#DB_getWTypeDefault("extra"), ' ') . |
2241 | 2254 | \ s:DB_option('-t', dbext#DB_getWType("cmd_terminator"), ' ') .
|
2242 | 2255 | \ '-f ' . s:dbext_tempfile
|
2243 | 2256 | endif
|
@@ -2415,7 +2428,7 @@ function! s:DB_INGRES_execSql(str)
|
2415 | 2428 | let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("bin"))
|
2416 | 2429 |
|
2417 | 2430 | let cmd = dbext_bin . ' ' .
|
2418 |
| - \ s:DB_option('', s:DB_get("extra"), ' ') . |
| 2431 | + \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), ' ') . |
2419 | 2432 | \ s:DB_option('-S ', s:DB_get("dbname"), ' ') .
|
2420 | 2433 | \ s:DB_option('', dbext#DB_getWType("cmd_options"), ' ') .
|
2421 | 2434 | \ ' < ' . s:dbext_tempfile
|
@@ -2500,7 +2513,7 @@ function! s:DB_INTERBASE_execSql(str)
|
2500 | 2513 | \ s:DB_option('-username ', s:DB_get("user"), ' ') .
|
2501 | 2514 | \ s:DB_option('-password ', s:DB_get("passwd"), ' ') .
|
2502 | 2515 | \ s:DB_option('', dbext#DB_getWType("cmd_options"), ' ') .
|
2503 |
| - \ s:DB_option('', dbext#DB_getWType("extra"), ' ') . |
| 2516 | + \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), ' ') . |
2504 | 2517 | \ '-input ' . s:dbext_tempfile .
|
2505 | 2518 | \ s:DB_option(' ', s:DB_get("dbname"), '')
|
2506 | 2519 | let result = s:DB_runCmd(cmd, output, "")
|
@@ -2587,9 +2600,9 @@ function! s:DB_MYSQL_execSql(str)
|
2587 | 2600 | \ s:DB_option(' -h ', s:DB_get("host"), '') .
|
2588 | 2601 | \ s:DB_option(' -P ', s:DB_get("port"), '') .
|
2589 | 2602 | \ s:DB_option(' -D ', s:DB_get("dbname"), '') .
|
2590 |
| - \ s:DB_option(' ', '-t', '') . |
2591 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 2603 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
2592 | 2604 | \ ' < ' . s:dbext_tempfile
|
| 2605 | + " \ s:DB_option(' ', '-t', '') . |
2593 | 2606 | let result = s:DB_runCmd(cmd, output, "")
|
2594 | 2607 |
|
2595 | 2608 | return result
|
@@ -2716,7 +2729,7 @@ endfunction "}}}
|
2716 | 2729 | function! s:DB_SQLITE_execSql(str)
|
2717 | 2730 |
|
2718 | 2731 | if s:DB_get("dbname") == ""
|
2719 |
| - call s:DB_errorMsg("dbext:You must specify a database name/file") |
| 2732 | + call s:DB_warningMsg("dbext:You must specify a database name/file") |
2720 | 2733 | return -1
|
2721 | 2734 | endif
|
2722 | 2735 |
|
@@ -2754,7 +2767,7 @@ function! s:DB_SQLITE_execSql(str)
|
2754 | 2767 |
|
2755 | 2768 | let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options")
|
2756 | 2769 | let cmd = cmd .
|
2757 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 2770 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
2758 | 2771 | \ s:DB_option(' ', s:DB_get("dbname"), '') .
|
2759 | 2772 | \ ' < ' . s:dbext_tempfile
|
2760 | 2773 | let result = s:DB_runCmd(cmd, output, "")
|
@@ -2885,7 +2898,7 @@ function! s:DB_ORA_execSql(str)
|
2885 | 2898 | \ s:DB_option(" '", s:DB_get("user"), '') .
|
2886 | 2899 | \ s:DB_option('/', s:DB_get("passwd"), '') .
|
2887 | 2900 | \ s:DB_option('@', s:DB_get("srvname"), '') .
|
2888 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 2901 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
2889 | 2902 | \ '" @' . s:dbext_tempfile
|
2890 | 2903 | let result = s:DB_runCmd(cmd, output, "")
|
2891 | 2904 |
|
@@ -3091,7 +3104,7 @@ function! s:DB_PGSQL_execSql(str)
|
3091 | 3104 | \ s:DB_option('-U ', s:DB_get("user"), ' ') .
|
3092 | 3105 | \ s:DB_option('-h ', s:DB_get("host"), ' ') .
|
3093 | 3106 | \ s:DB_option('-p ', s:DB_get("port"), ' ') .
|
3094 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 3107 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
3095 | 3108 | \ ' -q -f ' . s:dbext_tempfile
|
3096 | 3109 | let result = s:DB_runCmd(cmd, output, "")
|
3097 | 3110 |
|
@@ -3460,7 +3473,7 @@ function! s:DB_SQLSRV_execSql(str)
|
3460 | 3473 | \ s:DB_option(' -H ', s:DB_get("host"), ' ') .
|
3461 | 3474 | \ s:DB_option(' -S ', s:DB_get("srvname"), ' ') .
|
3462 | 3475 | \ s:DB_option(' -d ', s:DB_get("dbname"), ' ') .
|
3463 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 3476 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
3464 | 3477 | \ ' -i ' . s:dbext_tempfile
|
3465 | 3478 | let result = s:DB_runCmd(cmd, output, "")
|
3466 | 3479 |
|
@@ -3601,7 +3614,7 @@ function! s:DB_FIREBIRD_execSql(str)
|
3601 | 3614 | \ s:DB_option(' -u ', s:DB_get("user"), '') .
|
3602 | 3615 | \ s:DB_option(' -p ', s:DB_get("passwd"), '') .
|
3603 | 3616 | \ s:DB_option(' ', s:DB_get("dbname"), '') .
|
3604 |
| - \ s:DB_option(' ', s:DB_get("extra"), '') . |
| 3617 | + \ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') . |
3605 | 3618 | \ ' < ' . s:dbext_tempfile
|
3606 | 3619 | let result = s:DB_runCmd(cmd, output, "")
|
3607 | 3620 |
|
@@ -5882,11 +5895,11 @@ function! dbext#DB_auBufDelete(del_buf_nr) "{{{
|
5882 | 5895 | let cur_bufhidden = &bufhidden
|
5883 | 5896 | let cur_syntax = &syntax
|
5884 | 5897 | let cur_filetype = &filetype
|
5885 |
| - setlocal bufhidden= |
5886 | 5898 |
|
5887 | 5899 | let idx = index(s:dbext_buffers_with_dict_files, del_buf)
|
5888 | 5900 |
|
5889 | 5901 | if idx > -1 || exists('g:loaded_dbext_auto')
|
| 5902 | + setlocal bufhidden= |
5890 | 5903 | " Switch to the buffer being deleted
|
5891 | 5904 | silent! exec del_buf.'buffer'
|
5892 | 5905 |
|
|
0 commit comments