Skip to content

Commit d55a540

Browse files
committed
ora ext DBXtractDdl,DBEnableSrvOut,DBDisableSrvOut
Several general fixes for UTF8 - dbext_dbi_debug - changed spelling to use 'g:' prefix - perl prologue - explicitly asking perl to use UTF8 in both source code and input/output encoding - display of non-ASCII results (importang for UTF8!) of query is added (v26 had $val =~tr/\x80-\xFF/ /; which replaced all non-ASCII things with blanks)! - db_print_results - fixed bug if empty line happened in the non-expected place - FuzzyFinder badly interact with dbext in that it creates global variable FuzzyFinderMode 2 New oracle+DBI specific extensions: - DBXtractDdl - new command which is only implemented for oracle/DBI driver - DBEnableSrvOut - DBDisableSrvOut - new commands to interact with dbms_output from oracle (enable/disable). dbms_output is enabled by default - empty lines in output are forced to stay - otherwise output of DDL is not useable
1 parent 37f4bf5 commit d55a540

File tree

3 files changed

+529
-11
lines changed

3 files changed

+529
-11
lines changed

autoload/dbext.vim

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,11 @@ function! s:DB_resetGlobalParameters()
11571157
silent! let g:
11581158
redir END
11591159

1160+
" ans 2022-04-09: prevent dbext barking on us because FuzzyFinder
1161+
" remembers something in his global variable FuzzyFinderMode about db_ext!!! (something
1162+
" of my recent searches apparently)
1163+
let @a = substitute(@a, "\nFuzzyFin.*\n","\n",'')
1164+
11601165
if @a =~ 'db_ext'
11611166
call s:DB_warningMsg("You have used a previous version of db_ext. ")
11621167
call s:DB_warningMsg("The configuration parameters have changed. ")
@@ -5015,6 +5020,42 @@ function! s:DB_DBI_getListTable(table_prefix)
50155020
return result
50165021
endfunction
50175022

5023+
function! s:DB_DBI_extractDdl(object_name_like)
5024+
"let owner = s:DB_getObjectOwner(a:object_name_like)
5025+
"let table_name = s:DB_getObjectName(a:object_name_like)
5026+
5027+
if s:DB_DBI_Autoload() == -1
5028+
return -1
5029+
endif
5030+
5031+
if dbext#DB_connect("extract ddl " . a:object_name_like) == -1
5032+
return -1
5033+
endif
5034+
5035+
" If empty, use undef, if not, place single quotes around it and add a %
5036+
"let owner = (owner == ''?'undef':"'".owner."%'")
5037+
"let table_name = (table_name == ''?'undef':"'".table_name."%'")
5038+
"let driver = s:DB_get('driver')
5039+
"let table_type = s:DB_getDefault('DBI_table_type_'.driver)
5040+
"if table_type == ""
5041+
" let table_type = s:DB_getDefault('DBI_table_type')
5042+
"endif
5043+
"let table_type = "'".table_type."'"
5044+
5045+
let cmd = "perl db_ora_extract_ddl('".a:object_name_like."')"
5046+
exec cmd
5047+
if g:dbext_dbi_result == -1
5048+
" call s:DB_errorMsg(g:dbext_dbi_msg)
5049+
call s:DB_runCmd("perl DBI", cmd, g:dbext_dbi_msg)
5050+
return -1
5051+
endif
5052+
5053+
let result = g:dbext_dbi_result
5054+
call s:DB_runCmd("perl DBI", cmd, result)
5055+
5056+
return result
5057+
endfunction
5058+
50185059
function! s:DB_DBI_getListProcedure(proc_prefix)
50195060
let owner = s:DB_getObjectOwner(a:proc_prefix)
50205061
let object = s:DB_getObjectName(a:proc_prefix)
@@ -6177,9 +6218,37 @@ function! s:DB_getLoginScript(filename)
61776218
endif
61786219
endif
61796220

6221+
"ans: debug the login_script
6222+
"echomsg "login_script:"
6223+
"echomsg sql
61806224
return sql
61816225
endfunction
61826226

6227+
function! dbext#DB_enableSrvOut(...)
6228+
6229+
let cmd = "perl db_enable_srv_out('dummy')"
6230+
exec cmd
6231+
if g:dbext_dbi_result == -1
6232+
" call s:DB_errorMsg(g:dbext_dbi_msg)
6233+
call s:DB_runCmd("perl DBI", cmd, g:dbext_dbi_msg)
6234+
return -1
6235+
endif
6236+
6237+
endfunction
6238+
6239+
function! dbext#DB_disableSrvOut(...)
6240+
6241+
6242+
let cmd = "perl db_disable_srv_out('dummy')"
6243+
exec cmd
6244+
if g:dbext_dbi_result == -1
6245+
" call s:DB_errorMsg(g:dbext_dbi_msg)
6246+
call s:DB_runCmd("perl DBI", cmd, g:dbext_dbi_msg)
6247+
return -1
6248+
endif
6249+
6250+
endfunction
6251+
61836252
function! dbext#DB_describeTable(...)
61846253
if(a:0 > 0)
61856254
let table_name = s:DB_getObjectAndQuote(a:1)
@@ -6299,6 +6368,25 @@ function! dbext#DB_getListTable(...)
62996368
return dbext#DB_execFuncTypeWCheck('getListTable', table_prefix)
63006369
endfunction
63016370

6371+
function! dbext#DB_extractDdl(...)
6372+
if(a:0 > 0)
6373+
" Strip any leading or trailing spaces
6374+
let object_name_like = substitute(a:1,'\s*\(\w*\)\s*','\1','')
6375+
else
6376+
let object_name_like = s:DB_getInput(
6377+
\ "Enter object_name_like: ",
6378+
\ '',
6379+
\ "dbext_cancel"
6380+
\ )
6381+
if object_name_like == "dbext_cancel"
6382+
return ""
6383+
endif
6384+
endif
6385+
" it is only oracle and DBI specific, but we need generic handling fro
6386+
" winnr() etc to assign s:dbext_prev_winnr and friends properly...
6387+
return dbext#DB_execFuncTypeWCheck('extractDdl', object_name_like)
6388+
endfunction
6389+
63026390
function! dbext#DB_getListProcedure(...)
63036391
if(a:0 > 0)
63046392
" Strip any leading or trailing spaces
@@ -7840,6 +7928,7 @@ function! s:DB_addToResultBuffer(output, do_clear)
78407928
" silent! exec "put = data"
78417929
let cmd = "perl db_print_results('".dbi_orient."')"
78427930
exec cmd
7931+
"norm Goans was here(2).
78437932
else
78447933
let g:dbext_rows_affected = 0
78457934
let l:start_of_output = line('$')
@@ -7854,11 +7943,13 @@ function! s:DB_addToResultBuffer(output, do_clear)
78547943
endif
78557944

78567945
" Since this is a small window, remove any blanks lines
7857-
silent %g/^\s*$/d
7946+
" ans: this squashes my DDL output - because empty lines will be removed
7947+
"silent %g/^\s*$/d
78587948
" Fix the ^M characters, if any
78597949
silent execute "%s/\<C-M>\\+$//e"
78607950
" Dont allow modifications, and do not wrap the text, since
78617951
" the data may be lined up for columns
7952+
"norm Goans was here.
78627953
setlocal nomodified
78637954
setlocal nowrap
78647955
setlocal noswapfile

0 commit comments

Comments
 (0)