Skip to content

Commit 4d4d121

Browse files
bagyi0vim-scripts
authored andcommitted
Version 15.0
Posted by David Fishburn New Features --------- - A new database confirguration parameter, g:dbext_default_DBTYPE_extra, is available to allow the user to customize command line parameters passed to the database binary used to execute the statement. This can be overriden affecting all new connections via your .vimr. Or for a specific buffer via connection profile or :DBPromptForBufferParameters (Ken Inglis, Michael Berkowski). Bug Fixes --------- - The dbext menu for List Variables displayed the wrong mapping. - For SQLite databases, if no database is specified now a warning message is displayed instead of an error message.
1 parent c87d8d4 commit 4d4d121

File tree

4 files changed

+92
-30
lines changed

4 files changed

+92
-30
lines changed

autoload/dbext.vim

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
" dbext.vim - Commn Database Utility
22
" Copyright (C) 2002-10, Peter Bagyinszki, David Fishburn
33
" ---------------------------------------------------------------
4-
" Version: 14.00
4+
" Version: 15.00
55
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
66
" Authors: Peter Bagyinszki <petike1 at dpg dot hu>
77
" David Fishburn <dfishburn dot vim at gmail dot com>
8-
" Last Modified: 2012 Mar 23
8+
" Last Modified: 2012 Apr 30
99
" Based On: sqlplus.vim (author: Jamis Buck)
1010
" Created: 2002-05-24
1111
" Homepage: http://vim.sourceforge.net/script.php?script_id=356
@@ -38,7 +38,7 @@ if v:version < 700
3838
echomsg "dbext: Version 4.00 or higher requires Vim7. Version 3.50 can stil be used with Vim6."
3939
finish
4040
endif
41-
let g:loaded_dbext_auto = 1400
41+
let g:loaded_dbext_auto = 1500
4242

4343
" Turn on support for line continuations when creating the script
4444
let s:cpo_save = &cpo
@@ -774,6 +774,18 @@ function! dbext#DB_getWType(name)
774774
return retval
775775
endfunction
776776

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+
777789
"" Returns hardcoded defaults for parameters.
778790
function! s:DB_getDefault(name)
779791
" Must use g:dbext_default_profile.'' so that it is expanded
@@ -863,6 +875,7 @@ function! s:DB_getDefault(name)
863875
elseif a:name ==# "MYSQL_cmd_options" |return (exists("g:dbext_default_MYSQL_cmd_options")?g:dbext_default_MYSQL_cmd_options.'':'')
864876
elseif a:name ==# "MYSQL_cmd_terminator" |return (exists("g:dbext_default_MYSQL_cmd_terminator")?g:dbext_default_MYSQL_cmd_terminator.'':';')
865877
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')
866879
elseif a:name ==# "MYSQL_SQL_Top_pat" |return (exists("g:dbext_default_MYSQL_SQL_Top_pat")?g:dbext_default_MYSQL_SQL_Top_pat.'':'\(.*\)')
867880
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 ')
868881
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)
16341647
\ s:DB_option('eng=', s:DB_get("srvname"), ';') .
16351648
\ s:DB_option('dbn=', s:DB_get("dbname"), ';') .
16361649
\ s:DB_option('links=', links, ';') .
1637-
\ s:DB_option('', s:DB_get("extra"), '')
1650+
\ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '')
16381651
if has("win32") && s:DB_get("integratedlogin") == 1
16391652
let cmd = cmd .
16401653
\ s:DB_option('int=', 'yes', ';')
@@ -1869,7 +1882,7 @@ function! s:DB_ULTRALITE_execSql(str)
18691882
\ s:DB_option('pwd=', s:DB_get("passwd"), ';') .
18701883
\ s:DB_option('dsn=', s:DB_get("dsnname"), ';') .
18711884
\ s:DB_option('dbf=', s:DB_get("dbname"), ';') .
1872-
\ s:DB_option('', s:DB_get("extra"), '')
1885+
\ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '')
18731886
let cmd = cmd . '" ' .
18741887
\ ' read ' . s:dbext_tempfile
18751888
let result = s:DB_runCmd(cmd, output, "")
@@ -1993,7 +2006,7 @@ function! s:DB_ASE_execSql(str)
19932006
\ s:DB_option('-H ', s:DB_get("host"), ' ') .
19942007
\ s:DB_option('-S ', s:DB_get("srvname"), ' ') .
19952008
\ s:DB_option('-D ', s:DB_get("dbname"), ' ') .
1996-
\ s:DB_option('', s:DB_get("extra"), '') .
2009+
\ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '') .
19972010
\ ' -i ' . s:dbext_tempfile
19982011

19992012
let result = s:DB_runCmd(cmd, output, "")
@@ -2185,13 +2198,13 @@ function! s:DB_DB2_execSql(str)
21852198

21862199
let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("bin"))
21872200

2188-
let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options")
2201+
let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options") . ' '
21892202
if s:DB_get("user") != ""
21902203
let cmd = cmd . ' -a ' . s:DB_get("user") . '/' .
21912204
\ s:DB_get("passwd") . ' '
21922205
endif
21932206
let cmd = cmd .
2194-
\ s:DB_option(' ', s:DB_get("extra"), ' ') .
2207+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), ' ') .
21952208
\ s:DB_option('-d ', s:DB_get("dbname"), ' ') .
21962209
\ s:DB_option('-l ', dbext#DB_getWType("cmd_terminator"), ' ').
21972210
\ ' -f ' . s:dbext_tempfile
@@ -2237,7 +2250,7 @@ function! s:DB_DB2_execSql(str)
22372250
let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("db2cmd_bin"))
22382251

22392252
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"), ' ') .
22412254
\ s:DB_option('-t', dbext#DB_getWType("cmd_terminator"), ' ') .
22422255
\ '-f ' . s:dbext_tempfile
22432256
endif
@@ -2415,7 +2428,7 @@ function! s:DB_INGRES_execSql(str)
24152428
let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("bin"))
24162429

24172430
let cmd = dbext_bin . ' ' .
2418-
\ s:DB_option('', s:DB_get("extra"), ' ') .
2431+
\ s:DB_option('', dbext#DB_getWTypeDefault("extra"), ' ') .
24192432
\ s:DB_option('-S ', s:DB_get("dbname"), ' ') .
24202433
\ s:DB_option('', dbext#DB_getWType("cmd_options"), ' ') .
24212434
\ ' < ' . s:dbext_tempfile
@@ -2500,7 +2513,7 @@ function! s:DB_INTERBASE_execSql(str)
25002513
\ s:DB_option('-username ', s:DB_get("user"), ' ') .
25012514
\ s:DB_option('-password ', s:DB_get("passwd"), ' ') .
25022515
\ s:DB_option('', dbext#DB_getWType("cmd_options"), ' ') .
2503-
\ s:DB_option('', dbext#DB_getWType("extra"), ' ') .
2516+
\ s:DB_option('', dbext#DB_getWTypeDefault("extra"), ' ') .
25042517
\ '-input ' . s:dbext_tempfile .
25052518
\ s:DB_option(' ', s:DB_get("dbname"), '')
25062519
let result = s:DB_runCmd(cmd, output, "")
@@ -2587,9 +2600,9 @@ function! s:DB_MYSQL_execSql(str)
25872600
\ s:DB_option(' -h ', s:DB_get("host"), '') .
25882601
\ s:DB_option(' -P ', s:DB_get("port"), '') .
25892602
\ 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"), '') .
25922604
\ ' < ' . s:dbext_tempfile
2605+
" \ s:DB_option(' ', '-t', '') .
25932606
let result = s:DB_runCmd(cmd, output, "")
25942607

25952608
return result
@@ -2716,7 +2729,7 @@ endfunction "}}}
27162729
function! s:DB_SQLITE_execSql(str)
27172730

27182731
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")
27202733
return -1
27212734
endif
27222735

@@ -2754,7 +2767,7 @@ function! s:DB_SQLITE_execSql(str)
27542767

27552768
let cmd = dbext_bin . ' ' . dbext#DB_getWType("cmd_options")
27562769
let cmd = cmd .
2757-
\ s:DB_option(' ', s:DB_get("extra"), '') .
2770+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') .
27582771
\ s:DB_option(' ', s:DB_get("dbname"), '') .
27592772
\ ' < ' . s:dbext_tempfile
27602773
let result = s:DB_runCmd(cmd, output, "")
@@ -2885,7 +2898,7 @@ function! s:DB_ORA_execSql(str)
28852898
\ s:DB_option(" '", s:DB_get("user"), '') .
28862899
\ s:DB_option('/', s:DB_get("passwd"), '') .
28872900
\ s:DB_option('@', s:DB_get("srvname"), '') .
2888-
\ s:DB_option(' ', s:DB_get("extra"), '') .
2901+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') .
28892902
\ '" @' . s:dbext_tempfile
28902903
let result = s:DB_runCmd(cmd, output, "")
28912904

@@ -3091,7 +3104,7 @@ function! s:DB_PGSQL_execSql(str)
30913104
\ s:DB_option('-U ', s:DB_get("user"), ' ') .
30923105
\ s:DB_option('-h ', s:DB_get("host"), ' ') .
30933106
\ s:DB_option('-p ', s:DB_get("port"), ' ') .
3094-
\ s:DB_option(' ', s:DB_get("extra"), '') .
3107+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') .
30953108
\ ' -q -f ' . s:dbext_tempfile
30963109
let result = s:DB_runCmd(cmd, output, "")
30973110

@@ -3460,7 +3473,7 @@ function! s:DB_SQLSRV_execSql(str)
34603473
\ s:DB_option(' -H ', s:DB_get("host"), ' ') .
34613474
\ s:DB_option(' -S ', s:DB_get("srvname"), ' ') .
34623475
\ s:DB_option(' -d ', s:DB_get("dbname"), ' ') .
3463-
\ s:DB_option(' ', s:DB_get("extra"), '') .
3476+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') .
34643477
\ ' -i ' . s:dbext_tempfile
34653478
let result = s:DB_runCmd(cmd, output, "")
34663479

@@ -3601,7 +3614,7 @@ function! s:DB_FIREBIRD_execSql(str)
36013614
\ s:DB_option(' -u ', s:DB_get("user"), '') .
36023615
\ s:DB_option(' -p ', s:DB_get("passwd"), '') .
36033616
\ s:DB_option(' ', s:DB_get("dbname"), '') .
3604-
\ s:DB_option(' ', s:DB_get("extra"), '') .
3617+
\ s:DB_option(' ', dbext#DB_getWTypeDefault("extra"), '') .
36053618
\ ' < ' . s:dbext_tempfile
36063619
let result = s:DB_runCmd(cmd, output, "")
36073620

@@ -5882,11 +5895,11 @@ function! dbext#DB_auBufDelete(del_buf_nr) "{{{
58825895
let cur_bufhidden = &bufhidden
58835896
let cur_syntax = &syntax
58845897
let cur_filetype = &filetype
5885-
setlocal bufhidden=
58865898

58875899
let idx = index(s:dbext_buffers_with_dict_files, del_buf)
58885900

58895901
if idx > -1 || exists('g:loaded_dbext_auto')
5902+
setlocal bufhidden=
58905903
" Switch to the buffer being deleted
58915904
silent! exec del_buf.'buffer'
58925905

autoload/dbext_dbi.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
" It adds transaction support and the ability
55
" to reach any database currently supported
66
" by Perl and DBI.
7-
" Version: 14.00
7+
" Version: 15.00
88
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
99
" Authors: David Fishburn <dfishburn dot vim at gmail dot com>
10-
" Last Modified: 2012 Feb 24
10+
" Last Modified: 2012 Apr 05
1111
" Created: 2007-05-24
1212
" Homepage: http://vim.sourceforge.net/script.php?script_id=356
1313
"
@@ -124,7 +124,7 @@ if !has('perl')
124124
let g:loaded_dbext_dbi_msg = 'Vim does not have perl support enabled'
125125
finish
126126
endif
127-
let g:loaded_dbext_dbi = 1400
127+
let g:loaded_dbext_dbi = 1500
128128

129129
if !exists("dbext_dbi_debug")
130130
let g:dbext_dbi_debug = 0

doc/dbext.txt

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*dbext.txt* For Vim version 7.0. Last change: 2012 Mar 23
1+
*dbext.txt* For Vim version 7.0. Last change: 2012 May 01
22

33

44
VIM REFERENCE MANUAL
@@ -7,7 +7,7 @@
77
Peter Bagyinszki
88

99
Database extension plugin (dbext.vim) manual
10-
dbext.vim version 14.00
10+
dbext.vim version 15.00
1111

1212
For instructions on installing this file, type
1313
:help add-local-help
@@ -92,6 +92,27 @@ David Fishburn
9292
==============================================================================
9393
2. What's New *dbext-new*
9494

95+
Version 15.00
96+
97+
New Features
98+
---------
99+
- For Oracle connection profiles, support this form of server name,
100+
srvname=(description=(address=(protocol=TCP)(host=dbhost.our.domain.com)(port=1521))(connect_data=(server=dedicated)(service_name=gps03tst.our.domain.com)))
101+
(Fredrik Acosta).
102+
- A new database confirguration parameter, g:dbext_default_DBTYPE_extra, is
103+
available to allow the user to customize command line parameters passed to
104+
the database binary used to execute the statement. This can be overriden
105+
affecting all new connections via your .vimr. Or for a specific buffer
106+
via connection profile or :DBPromptForBufferParameters (Ken Inglis,
107+
Michael Berkowski).
108+
109+
Bug Fixes
110+
---------
111+
- The dbext menu for List Variables displayed the wrong mapping.
112+
- For SQLite databases, if no database is specified now a warning message
113+
is displayed instead of an error message.
114+
115+
95116
Version 14.00
96117

97118
New Features
@@ -1370,6 +1391,7 @@ Version 2.00
13701391
<
13711392
From within a profile (set within your vimrc): >
13721393
let g:dbext_default_profile_mysql = 'type=MYSQL:user=root:passwd=:dbname=mysql:extra=-t'
1394+
let g:dbext_default_profile_mysql_local = 'type=MYSQL:user=root:passwd=whatever:dbname=mysql:extra=--batch --raw --silent'
13731395
<
13741396
This has the net result of creating the following command line: >
13751397
dbisql -c "UID=dba;PWD=sql;CON=myconn"
@@ -1436,6 +1458,20 @@ Version 2.00
14361458
cmd_options
14371459
< - Optionally specify (or override) additional command line switches
14381460
for the database tool. >
1461+
extra
1462+
< - If additional parameters are required on a particular database
1463+
type's command line they can be specified using this option.
1464+
MySQL defaults this to '-t', to format the output with tabs.
1465+
This value can be overriden three different ways:
1466+
1. Changing the default for a specific database type: >
1467+
let g:dbext_default_MYSQL_extra = '--batch --raw'
1468+
< 2. Using the "extra" parameter specified in a connection
1469+
profile: >
1470+
let g:dbext_default_profile_mysql_local = 'type=MYSQL:user=root:passwd=whatever:dbname=mysql:extra=--batch --raw'
1471+
< 3. Using :DBPromptForBufferParameters and specifying a value
1472+
for the extra parameter. If this value is set to an empty
1473+
string, it will default to #1. If it is set to a value
1474+
or a blank space it can be overridden. >
14391475
on_error
14401476
< - Dictates the behaviour of the tool if an error is encountered during
14411477
execution. >
@@ -1461,35 +1497,43 @@ Version 2.00
14611497
dbext_default_PGSQL_cmd_header = ''
14621498
dbext_default_PGSQL_cmd_terminator = ''
14631499
dbext_default_PGSQL_cmd_options = ''
1500+
dbext_default_PGSQL_extra = ''
14641501
dbext_default_PGSQL_pgpass = expand('$HOME/.pgpass')
14651502
dbext_default_MYSQL_bin = 'isql'
14661503
dbext_default_MYSQL_cmd_header = ''
14671504
dbext_default_MYSQL_cmd_terminator = ''
14681505
dbext_default_MYSQL_cmd_options = ''
1506+
dbext_default_MYSQL_extra = '-t'
14691507
dbext_default_MYSQL_version = '5'
14701508
dbext_default_ASA_bin = 'dbisql'
14711509
dbext_default_ASA_cmd_header = ''
14721510
dbext_default_ASA_cmd_terminator = ';'
14731511
dbext_default_ASA_cmd_options = '-nogui'
1512+
dbext_default_ASA_extra = ''
14741513
dbext_default_INGRES_bin = 'sql'
14751514
dbext_default_INGRES_cmd_header = ''
14761515
dbext_default_INGRES_cmd_terminator = '\p\g'
14771516
dbext_default_INGRES_cmd_options = ''
1517+
dbext_default_INGRES_extra = ''
14781518
dbext_default_ASE_bin = "isql"
14791519
dbext_default_ASE_cmd_header = ""
14801520
dbext_default_ASE_cmd_terminator = "\ngo\n"
14811521
dbext_default_ASE_cmd_options = '-w 10000'
1522+
dbext_default_ASE_extra = ''
14821523
dbext_default_INTERBASE_bin = ''
14831524
dbext_default_INTERBASE_cmd_header = ''
14841525
dbext_default_INTERBASE_cmd_terminator = ''
14851526
dbext_default_INTERBASE_cmd_options = ''
1527+
dbext_default_INTERBASE_extra = ''
14861528
dbext_default_SQLITE_bin = 'sqlite'
14871529
dbext_default_SQLITE_cmd_header = ".mode column\n.headers ON\n"
14881530
dbext_default_SQLITE_cmd_terminator = ';'
1531+
dbext_default_SQLITE_extra = ''
14891532
dbext_default_SQLSRV_bin = "osql"
14901533
dbext_default_SQLSRV_cmd_header = ""
14911534
dbext_default_SQLSRV_cmd_terminator = ""
14921535
dbext_default_SQLSRV_cmd_options = '-w 10000 -r -b -n'
1536+
dbext_default_SQLSRV_extra = ''
14931537
dbext_default_ORA_bin = "sqlplus"
14941538
dbext_default_ORA_cmd_header =
14951539
\ "set pagesize 10000\n" .
@@ -1501,11 +1545,13 @@ Version 2.00
15011545
\ "set tab off\n\n"
15021546
dbext_default_ORA_cmd_terminator = ";"
15031547
dbext_default_ORA_cmd_options = '-S'
1548+
dbext_default_ORA_extra = ''
15041549
dbext_default_DB2_use_db2batch = 0
15051550
dbext_default_DB2_bin = 'db2batch'
15061551
dbext_default_DB2_cmd_header = ''
15071552
dbext_default_DB2_cmd_terminator = ';'
15081553
dbext_default_DB2_cmd_options = '-q del -s off'
1554+
dbext_default_DB2_extra = ''
15091555
dbext_default_DB2_db2cmd_bin = 'db2cmd'
15101556
dbext_default_DB2_db2cmd_cmd_options = '-c -w -i -t db2 -s'
15111557
@@ -2080,14 +2126,17 @@ To specify the type of database you connect to most often, you can place the
20802126
20812127
" MySQL
20822128
let g:dbext_default_profile_mysql_local = 'type=MYSQL:user=root:passwd=whatever:dbname=mysql:extra=-t'
2129+
let g:dbext_default_profile_mysql_local = 'type=MYSQL:user=root:passwd=whatever:dbname=mysql:extra=--batch --raw --silent'
20832130
let g:dbext_default_profile_mysql_local_DBI = 'type=DBI:user=root:passwd=whatever:driver=mysql:conn_parms=database=mysql;host=localhost'
20842131
let g:dbext_default_profile_mysql_local_ODBC = 'type=ODBC:user=root:passwd=whatever:dsnname=mysql'
20852132
20862133
" Oracle
20872134
let g:dbext_default_profile_ORA = 'type=ORA:srvname=ffs42ga:user=john:passwd=whatever'
20882135
" Oracle SQL Connect URL string (notice the : is escaped for the port option)
20892136
let g:dbext_default_profile_ORA_URL = 'type=ORA:srvname=//localhost\:3333/instance_name:user=scott:passwd=tiger'
2090-
2137+
" Different form of Oracle server name
2138+
let g:dbext_default_profile_ORA_Extended = 'type=ORA:user=scott:passwd=tiger:srvname=(description=(address=(protocol=TCP)(host=localhost)(port=1521))(connect_data=(server=dedicated)(service_name=10gR2)))'
2139+
20912140
" Postgress
20922141
let g:dbext_default_profile_PG = 'type=PGSQL:user=postgres'
20932142

0 commit comments

Comments
 (0)