Skip to content

Commit

Permalink
Merge pull request #14 from hyee/release
Browse files Browse the repository at this point in the history
Merged from the Alpha branch and move to Java 1.8
  • Loading branch information
hyee committed Jun 24, 2017
2 parents 2da039a + bb09f92 commit a0529da
Show file tree
Hide file tree
Showing 126 changed files with 7,013 additions and 5,699 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.dat
data/init.cfg
data/init.cfg
cache/
plugin.cfg
jre/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ It is not intended to support all features of the existing CLI utilities that em

Download
-----------------------
DBCLI does not require compile or installation, but depends on JRE 1.7+. Click `Download ZIP`,extract and use. Or you can also download from the published releases<br/>
DBCLI does not require compile or installation, but depends on JRE 1.8+. Click `Download ZIP`,extract and use. Or you can also download from the published releases<br/>
Branch `With-JRE` contains the shrinked JRE bundle, if you don't have JRE installed,
you may switch to that branch to download. Due to the region and charset differences, this JRE bundle is not guaranteed to work well.<br/>

Expand All @@ -44,7 +44,7 @@ To avoid the word wrap in the terminal window which affects the print layout, fo
* In the `Font` tab, change the font size as smaller value.

###Configure environment
Before running dbcli, make sure that you have installed JRE 1.7+ in your local PC. If you are using the version of "With-JRE" branch, this step can be skipped.
Before running dbcli, make sure that you have installed JRE 1.8+ in your local PC. If you are using the version of "With-JRE" branch, this step can be skipped.

Create file `init.cfg` under the "data" directory with following content:

Expand Down
Binary file modified bin/ConsoleZ/Console.exe
Binary file not shown.
Binary file modified bin/ConsoleZ/ConsoleHook.dll
Binary file not shown.
7 changes: 4 additions & 3 deletions bin/ConsoleZ/console.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<fullscreen start_in_fullscreen="0" fullscreen_monitor="0">
<controls show_menu="1" show_toolbar="1" show_searchbar="1" show_statusbar="1" show_tabs="1" hide_single_tab="1" tabs_on_bottom="0" hide_tab_icons="0" hide_tab_close_button="0" show_scrollbars="1"/></fullscreen>
<controls show_menu="1" show_toolbar="1" show_searchbar="1" show_statusbar="0" show_tabs="1" hide_single_tab="0" tabs_on_bottom="0" hide_tab_icons="1" hide_tab_close_button="0" show_scrollbars="1"/>
<styles caption="1" resizable="1" taskbar_button="1" border="0" inside_border="2" tray_icon="1" quake_like="0" quake_animation_time="300" jumplist="1" integrated_ime="1" hide_when_inactive="0" per_monitor_dpi="0">
<styles caption="1" resizable="1" taskbar_button="1" border="0" inside_border="2" split_bar_size="0" tray_icon="1" quake_like="0" quake_animation_time="300" jumplist="1" integrated_ime="0" hide_when_inactive="0" per_monitor_dpi="0" keep_view_theme="0">
<selection_color r="128" g="128" b="128"/>
<highlight_color r="191" g="191" b="191"/></styles>
<position x="0" y="0" save_position="0" w="1000" h="700" save_size="0" z_order="0" dock="0" snap="-1" save_state="0" state="2"/>
Expand Down Expand Up @@ -150,6 +150,7 @@
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="ctrlC"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="wspload"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="wspsave"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="fwdmouse"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd1"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd2"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd3"/>
Expand Down Expand Up @@ -211,8 +212,8 @@
<color id="15" r="255" g="255" b="255"/>
</colors>
</tab>
<tab title="cmd" use_default_icon="0">
<console shell="" init_dir="" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
<tab title="bash" use_default_icon="0">
<console shell="C:\Windows\System32\bash.exe" init_dir="" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
</tab>
<tab title="PowerShell" use_default_icon="1">
<console shell="powershell" init_dir="" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
Expand Down
1 change: 0 additions & 1 deletion cache/afiedt.buf

This file was deleted.

22 changes: 22 additions & 0 deletions change log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
2017-06-23: + oracle: new command 'show undo'
* oracle: move 'ora lsi' as 'show lsi', as well as the optimization
2017-06-21: + oracle: new commands 'show im' and 'show rscache'
: new PL/SQL packge 'runstats_pkg'(Similar to Tome Kyte's version)
2017-06-15: * public: refresh lib luajit
+ oracle: enhancement on 'loadtrace' which supports loading trace from view(12c)
2017-06-12: + public: new option 'set bypassemptyrs on/off'
! oracle: fixed wrong output timezone with 'TIMESTAMP(*) WITH TIMEZONE' data type
2017-06-11: * oracle: compression transferring on awrdump/addmdump/ashdump to save network time
2017-06-10: + public: enhancement on "snap":
1). supports parameters in file: before_sql and after_sql
2). supports linux style EOF: syntax: snap <<EOF ... EOF
3). comma as number's thousand sepetor
4). eliminates zero number rows
5). merged 'snap sysevent' into 'snap systime'
2017-06-10: !public: many bug fixes
2017-06-10: + oracle: "ora spd" for 12c only
2017-06-10: * oracle: some small changes on existing command
2017-02-25: + oracle: "ora rtaddm/dsqlm/dumptrace" for 12c only
2017-02-24: * public: some fixes and changes; performance optimization on lib `jnlua`
2017-02-04: + public: new option "set heading on/off"
=======================begin v1.2================================================
2017-01-20: * public: miscellaneous changes
2017-01-19: ! oracle: some fixes related to input prompt after conn to db;
support 12c new 'with' clause featurs
Expand Down
Empty file removed data/plugin.cfg
Empty file.
Binary file modified db2/db2jcc4.jar
Binary file not shown.
Binary file modified db2/db2jcc_license_cu.jar
Binary file not shown.
18 changes: 11 additions & 7 deletions dbcli.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ rem if JRE_HOME is not defined in init.cfg, find java.exe in default path
if not defined JRE_HOME (
for /F %%p in ('where java.exe') do (
for /f tokens^=2-5^ delims^=.-_^" %%j in ('"%%p" -fullversion 2^>^&1') do (
if 17000 LSS %%j%%k%%l%%m set "JRE_HOME=%%~dpsp"
if 18000 LSS %%j%%k%%l%%m set "JRE_HOME=%%~dpsp"
)))

If not exist "%TNS_ADM%\tnsnames.ora" if defined ORACLE_HOME (set TNS_ADM=%ORACLE_HOME%\network\admin )
for %%x in ("!JRE_HOME!") do set JRE_HOME=%%~sx
IF %JRE_HOME:~-1%==\ SET JRE_HOME=%JRE_HOME:~0,-1%
If not exist "%TNS_ADM%\tnsnames.ora" if defined ORACLE_HOME (set "TNS_ADM=%ORACLE_HOME%\network\admin" )


IF not exist "%JRE_HOME%\java.exe" if exist "%JRE_HOME%\bin\java.exe" (set "JRE_HOME=%JRE_HOME%\bin") else (set JRE_HOME=.\jre\bin)

for %%x in ("!JRE_HOME!") do set "JRE_HOME=%%~sx"
IF %JRE_HOME:~-1%==\ SET "JRE_HOME=%JRE_HOME:~0,-1%"

IF not exist "%JRE_HOME%\java.exe" if exist "%JRE_HOME%\bin\java.exe" (set JRE_HOME=%JRE_HOME%\bin) else (set JRE_HOME=.\jre\bin)
SET PATH=%JRE_HOME%;%EXT_PATH%;.\bin;%PATH%
if defined ANSICON_CMD (
SET ANSICON_EXC=nvd3d9wrap.dll;nvd3d9wrapx.dll
SET ANSICON_DEF=ansicon
echo %PROCESSOR_ARCHITECTURE%|findstr /i "64" >nul ||(!JRE_HOME!\java.exe -version 2>&1 |findstr /i "64-bit" >nul)||(set ANSICON_CMD=.\lib\x86\ansicon.exe)
echo %PROCESSOR_ARCHITECTURE%|findstr /i "64" >nul ||("!JRE_HOME!\java.exe" -version 2>&1 |findstr /i "64-bit" >nul)||(set ANSICON_CMD=.\lib\x86\ansicon.exe)
if not exist "!ANSICON_CMD!" (
set "ANSICON_CMD="
set "ANSICON_DEF=jline"
Expand All @@ -46,7 +49,8 @@ for /r %%i in (*.pack.gz) do (
unpack200 -q -r "%%i" "!str:~0,-8!"
)

(%ANSICON_CMD% "!JRE_HOME!\java.exe" -noverify -Xmx384M -cp .\lib\*;.\lib\ext\*%OTHER_LIB% ^
(%ANSICON_CMD% "!JRE_HOME!\java.exe" -noverify -Xmx384M -cp .\lib\*;.\lib\ext\*;%OTHER_LIB% ^
-XX:+UseG1GC -XX:+UseStringDeduplication ^
-Dfile.encoding=%DBCLI_ENCODING% -Dsun.jnu.encoding=%DBCLI_ENCODING% -Dclient.encoding.override=%DBCLI_ENCODING% ^
-Dinput.encoding=%DBCLI_ENCODING% -Duser.language=en -Duser.region=US -Duser.country=US ^
-Doracle.net.tns_admin="%TNS_ADM%" -Djline.terminal=windows org.dbcli.Loader %DBCLI_PARAMS% %* )||pause
Expand Down
Binary file modified lib/dbcli.jar
Binary file not shown.
Binary file modified lib/disruptor-3.3.6.jar
Binary file not shown.
Binary file added lib/gogo.jar
Binary file not shown.
Binary file modified lib/jline.jar
Binary file not shown.
Binary file modified lib/jna.jar
Binary file not shown.
Binary file modified lib/jnlua.jar
Binary file not shown.
Binary file modified lib/jsch.jar
Binary file not shown.
Binary file modified lib/jzlib-1.1.3.jar
Binary file not shown.
Binary file added lib/mac/libjnlua.dylib
Binary file not shown.
Binary file added lib/mac/liblua.dylib
Binary file not shown.
20 changes: 20 additions & 0 deletions lib/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ end


function table.dump(tbl,indent,maxdep,tabs)
if type(tbl)~="table" then return tbl end
maxdep=tonumber(maxdep) or 9
if maxdep<=1 then
return tostring(tbl)
Expand Down Expand Up @@ -389,3 +390,22 @@ function string.ulen(s)
return len1,len2
end

function try(args)
local succ,res=pcall(args[1])
local catch=args.catch or args[2]
local finally=args.finally or args[3]

if not succ and catch then
if(type(res)=="string" and env.ansi) then
res=res:match(env.ansi.pattern.."(.-)"..env.ansi.pattern)
end
succ,res=pcall(catch,res)
end

if finally then
succ,res=pcall(finally)
end

if not succ then env.raise_error(res) end
return res
end
Binary file modified lib/opencsv.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/uv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function os.exists(file,ext)
file=file..'.'..ext
attr=uv.fs.stat(file)
end
return attr and attr.type,file
return attr and attr.type,attr and file
end

local function noop() end
Expand Down
Binary file modified lib/x64/jnlua5.1.dll
Binary file not shown.
Binary file modified lib/x64/lua5.1.dll
Binary file not shown.
Binary file modified lib/x86/jnlua5.1.dll
Binary file not shown.
Binary file modified lib/x86/lua5.1.dll
Binary file not shown.
Binary file modified lib/x86/luajit.exe
Binary file not shown.
4 changes: 3 additions & 1 deletion lua/ansi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,11 @@ function ansi.onload()
ansi.color,ansi.map=color,cfg
end

ansi.pattern="\27%[[%d;]*[mK]"

function ansi.strip_ansi(str)
if not enabled then return str end
return str:gsub("\27%[[%d;]*[mK]","")
return str:gsub(ansi.pattern,"")
end

function string.strip_ansi(str)
Expand Down
50 changes: 41 additions & 9 deletions lua/db_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function db_Types:set(typeName,value,conn)
end
end

function db_Types:getTyeName(typeID)
return self[typeID] and self[typeID].name
end

--return column value according to the specific resulset and column index
function db_Types:get(position,typeName,res,conn)
--local value=res:getObject(position)
Expand Down Expand Up @@ -259,7 +263,7 @@ function ResultSet:rows(rs,count,limit,null_value)
return rows
end

function ResultSet:print(res,conn)
function ResultSet:print(res,conn,prefix)
local result,hdl={},nil
--print(table.dump(self:getHeads(res,-1)))
local maxrows,pivot=cfg.get("printsize"),cfg.get("pivot")
Expand All @@ -272,10 +276,7 @@ function ResultSet:print(res,conn)
hdl:add(row)
end
end

grid.print(hdl or result)
db_core.print_feed("SELECT",#result-1)
print("")
grid.print(hdl or result,nil,nil,nil,nil,prefix,(cfg.get("feed")=="on" and '\n'..(#result-1).." rows returned." or "").."\n")
end

function ResultSet:print_old(res,conn)
Expand Down Expand Up @@ -328,8 +329,31 @@ db_core.feed_list={
USE ="Database changed"
}

local excluded_keywords={
OR=1,
REPLACE=1,
NONEDITIONABLE=1,
EDITIONABLE=1,
NO=1,
FORCE=1,
EDITIONING=1,
GLOBAL=1,
TEMPORARY=1,
SHARED=1,
DUPLICATED=1
}

function db_core.get_command_type(sql)
return sql:gsub("%s*/%*.-%*/%s*",' '):trim():upper():gsub("%s*OR%s+REPLACE%s*"," "):match("^(%a+)%s*(%a*)")
local list={}
for word in sql:gsub("%s*/%*.-%*/%s*",' '):gmatch("[^%s%(%)]+") do
local w=word:upper()
if #list>2 or not excluded_keywords[w] then
list[#list+1]=(#list < 3 and word or w):gsub('["`]','')
if #list > 3 then break end
end
end
for i=#list+1,3 do list[i]='' end
return table.unpack(list)
end

function db_core.print_feed(sql,result)
Expand Down Expand Up @@ -550,7 +574,6 @@ function db_core:exec(sql,args)
end
end


local outputs={}

for k,v in pairs(args) do
Expand All @@ -563,10 +586,11 @@ function db_core:exec(sql,args)

local params1=nil
local result={is_query and prep:getResultSet() or prep:getUpdateCount()}

local i=0;
while true do
params1,is_query=pcall(prep.getMoreResults,prep,2)
if not params1 or not is_query then break end
if result[1]==-1 then table.remove(result,1) end
result[#result+1]=prep:getResultSet()
end

Expand Down Expand Up @@ -700,7 +724,15 @@ end
function db_core:query(sql,args)
local result = self:exec(sql,args)
if result and type(result)~="number" then
self.resultset:print(result,self.conn)
if type(result)=="table" then
for _,rs in ipairs(result) do
if type(rs) ~='number' then
self.resultset:print(rs,self.conn)
end
end
else
self.resultset:print(result,self.conn)
end
end
end

Expand Down
19 changes: 14 additions & 5 deletions lua/env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ function env.parse_args(cmd,rest,is_cross_line)
rest=rest:sub(#terminator_str+1):trim()
arg_count=math.min(2,arg_count)
end

end
end

Expand Down Expand Up @@ -649,6 +650,9 @@ function env.parse_args(cmd,rest,is_cross_line)
local is_multi_cmd=char~=quote and is_cross_line==true and _CMDS[name] and _CMDS[name].MULTI
if count>=arg_count-2 or is_multi_cmd then--the last parameter
piece=rest:sub(i+1):gsub("^(%s+)",""):gsub('^"(.*)"$','%1')
if terminator and piece:find(terminator_str,1,true)==1 then
piece=piece:sub(#terminator_str+1):gsub("^%s+","")
end
if is_multi_cmd and _CMDS[name].ARGS==1 then
args[count],piece=args[count]..' '..piece,''
elseif piece~='' then
Expand Down Expand Up @@ -709,7 +713,7 @@ local function _eval_line(line,exec,is_internal,not_skip)
env.exec_command(env._SUBSYSTEM,{line})
return;
else
return cmd,{line}
return env._SUBSYSTEM,{line}
end
end

Expand Down Expand Up @@ -789,16 +793,20 @@ local function _eval_line(line,exec,is_internal,not_skip)
end
end

function env.eval_line(lines,is_internal,is_skip)
function env.eval_line(lines,exec,is_internal,is_skip)
if env.event then
lines=env.event.callback('BEFORE_EVAL',{lines})[1]
end
if type(lines)~="string" then
print(debug.traceback())
return nil
end
local stack=lines:split("[\n\r]+")
for index,line in ipairs(stack) do
if index==#stack then
return _eval_line(line,is_internal,is_skip)
return _eval_line(line,exec,is_internal,is_skip)
else
_eval_line(line,false,false)
_eval_line(line,exec,false,false)
end
end
end
Expand Down Expand Up @@ -1019,6 +1027,7 @@ function env.save_data(file,txt)
txt=env.MessagePack.pack(txt)
f:write(txt)
f:close()
return file
end

function env.write_cache(file,txt)
Expand Down Expand Up @@ -1093,7 +1102,7 @@ function env.ask(question,range,default)
end
--env.printer.write(desc..': ')
env.IS_ASKING=question
value,env.IS_ASKING=reader:readLine(env.space..desc..": "),nil
value,env.IS_ASKING=reader:readLine(env.space,null,desc..": "),nil
value=value and value:trim() or ""

value=value:gsub('\\([0-9]+)',function(x) return string.char(tonumber(x)) end)
Expand Down
Loading

0 comments on commit a0529da

Please sign in to comment.