diff --git a/change log.txt b/change log.txt index e34d9629..633146d0 100644 --- a/change log.txt +++ b/change log.txt @@ -1,3 +1,5 @@ +2015-11-26: ! public: fix prompt issue + : fix errors of fetching null CLOB 2015-11-20: ! public: fix the issue of 'unpack200.exe' : fix the issue of SSH failure with shrinked JRE bundle : fix the issues of subsystem diff --git a/dbcli.bat b/dbcli.bat index 4b12afce..82d764d2 100644 --- a/dbcli.bat +++ b/dbcli.bat @@ -10,15 +10,14 @@ SET DBCLI_ENCODING=UTF-8 rem read config file If exist "data\init.cfg" (for /f "eol=# delims=" %%i in (data\init.cfg) do (%%i)) -If not exist "%TNS_ADM%\tnsnames.ora" if defined ORACLE_HOME (set TNS_ADM=%ORACLE_HOME%\network\admin) -SET JAVA="%JRE_HOME%\java.exe" -IF not exist %JAVA% (set JAVA="%JRE_HOME%\bin\java.exe" && IF not exist !JAVA! set JAVA=.\jre\bin\java.exe) -SET PATH=!EXT_PATH!;%PATH% - +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 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%;%PATH% if defined ANSICON_CMD ( SET ANSICON_EXC=nvd3d9wrap.dll;nvd3d9wrapx.dll SET ANSICON_DEF=!CONSOLE_COLOR! - echo %PROCESSOR_ARCHITECTURE%|findstr /i "64" >nul ||(!JAVA! -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) ) rem For win10, don't used both JLINE/Ansicon to escape the ANSI codes @@ -28,13 +27,13 @@ rem unpack jar files for the first use for /r %%i in (*.pack.gz) do ( set "var=%%i" &set "str=!var:@=!" echo Unpacking %%i to jar file for the first use... - .\jre\bin\unpack200 -q -r "%%i" "!str:~0,-8!" + unpack200 -q -r "%%i" "!str:~0,-8!" ) -(%ANSICON_CMD% !JAVA! -noverify -Xmx384M -cp .\lib\*;.\lib\ext\*%OTHER_LIB% ^ +(%ANSICON_CMD% "%JRE_HOME%\java.exe" -noverify -Xmx384M -cp .\lib\*;.\lib\ext\*%OTHER_LIB% ^ -XX:NewRatio=50 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions ^ -XX:+AggressiveOpts -XX:MaxGCPauseMillis=400 -XX:GCPauseIntervalMillis=8000 ^ -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 + -Doracle.net.tns_admin="%TNS_ADM%" -Djline.terminal=windows org.dbcli.Loader %DBCLI_PARAMS% %* )||pause EndLocal \ No newline at end of file diff --git a/lib/dbcli.jar b/lib/dbcli.jar index bf7039de..c3a2024e 100644 Binary files a/lib/dbcli.jar and b/lib/dbcli.jar differ diff --git a/lib/opencsv.jar b/lib/opencsv.jar index 25b92bb6..4a366ef5 100644 Binary files a/lib/opencsv.jar and b/lib/opencsv.jar differ diff --git a/lua/db_core.lua b/lua/db_core.lua index bec4ad87..ad735486 100644 --- a/lua/db_core.lua +++ b/lua/db_core.lua @@ -29,7 +29,7 @@ function db_Types:get(position,typeName,res,conn) if value == nil or res:wasNull() then return nil end if not self[typeName].handler then return value end - return self[typeName].handler(value,'get',conn) + return self[typeName].handler(value,'get',conn,res) end local number_types={ @@ -75,9 +75,11 @@ function db_Types:load_sql_types(className) end}, [4]={getter='getClob',setter='setStringForClob',--setString - handler=function(result,action,conn) + handler=function(result,action,conn,res) if action=="get" then - local str=result:getSubString(1,result:length()) + local succ,len=pcall(result.length,result) + if not succ then return nil end + local str=result:getSubString(1,len) result:free() return str end @@ -87,10 +89,12 @@ function db_Types:load_sql_types(className) [5]={getter='getBlob',setter='setBytesForBlob', --setBytes handler=function(result,action,conn) if action=="get" then - local str=result:getBytes(1,math.min(255,result:length())) + local succ,len=pcall(result.length,result) + if not succ then return nil end + local str=result:getBytes(1,math.min(255,len)) result:free() - local str1=string.rep('%2X',#str):format(str:byte(1,#str)):gsub(' ','0') - return str1 + str=string.rep('%2X',#str):format(str:byte(1,#str)):gsub(' ','0') + return str else return java.cast(result,'java.lang.String'):getBytes() end @@ -509,7 +513,6 @@ function db_core:exec(sql,args) self.current_stmt=nil --is_query=prep:execute() local is_output,index,typename=1,2,3 - for k,v in pairs(params) do if type(v) == "table" and v[is_output] == "#" then if type(v[index]) == "table" then diff --git a/lua/env.lua b/lua/env.lua index 8aef5242..298e9f4c 100644 --- a/lua/env.lua +++ b/lua/env.lua @@ -199,11 +199,11 @@ end local previous_prompt function env.set_subsystem(cmd,prompt) if cmd~=nil then - env.set_prompt(cmd,prompt or cmd,false,9) env._SUBSYSTEM=cmd + env.set_prompt(cmd,prompt or cmd,false,9) else - env.set_prompt(cmd,nil,false,9) env._SUBSYSTEM,_G._SUBSYSTEM=nil,nil + env.set_prompt(cmd,nil,false,9) end end @@ -475,11 +475,12 @@ function env.set_prompt(class,default,is_default,level) end end - if not default:match("[%a] *$") then - env.PRI_PROMPT=default + if env._SUBSYSTEM or (default and not default:match("[%w]%s*$")) then + env.PRI_PROMPT=default else env.PRI_PROMPT=(default or "").."> " end + env.CURRENT_PROMPT,env.MTL_PROMPT=env.PRI_PROMPT,(" "):rep(#env.PRI_PROMPT) return default end diff --git a/lua/subsystem.lua b/lua/subsystem.lua index 6183b0c1..5ed2c3e2 100644 --- a/lua/subsystem.lua +++ b/lua/subsystem.lua @@ -86,12 +86,15 @@ function system:call_process(cmd,is_native) table.insert(self.startup_cmd,1,os.find_extension(self.name)) if not self.work_dir then self.work_dir=env._CACHE_PATH end self:set_work_dir(self.work_dir,true) - + env.log_debug("sqlplus","Command :" ..table.concat(self.startup_cmd," ")) + env.log_debug("sqlplus","Work dir: "..self.work_dir) + env.log_debug("sqlplus","Environment: \n"..table.dump(self.env)) --self.process:wait_async(function(...) print(...);print("Sub-system is terminated") end) if not is_native then self.process=self.proc:create(self.idle_pattern,self.work_dir,self.startup_cmd,self.env) self.msg_stack={} self:run_command(nil,false) + if not self.process then return end if self.after_process_created then self:after_process_created() end @@ -111,7 +114,7 @@ function system:call_process(cmd,is_native) local help=[[ You are entering '%s' interactive mode, work dir is '%s'. To switch to the native CLI mode, execute '-n' or '.%s -n'. - Type 'lls' to list the files in current work dir, to change the work dir, execute 'llcd '. + Type 'lls' to list the files in current work dir, to change the work dir, execute 'lcd '. Type '.' to run the root command, 'bye' to leave, or 'exit' to terminate."]] help=help:format(self.name,self.work_dir,self.name):gsub("%s%s%s+",'\n') print(env.ansi.mask("PromptColor",help)) diff --git a/oracle/dbmsoutput.lua b/oracle/dbmsoutput.lua index 4fd3922f..cfc20fd5 100644 --- a/oracle/dbmsoutput.lua +++ b/oracle/dbmsoutput.lua @@ -45,7 +45,7 @@ output.stmt=marker..[[/*INTERNAL_DBCLI_CMD*/ function output.getOutput(db,sql) local isOutput=cfg.get("ServerOutput") local typ=db.get_command_type(sql) - if typ~='DECLARE' and typ~='BEGIN' and typ~='CALL' and typ~='EXECUTE' then return end + if typ=='SELECT' or typ=='WITH' then return end if not ((output.prev_sql or ""):find(marker,1,true)) and not sql:find(marker,1,true) and not db:is_internal_call(sql) then local args={enable=isOutput,buff="#VARCHAR",txn="#VARCHAR",lob="#CLOB"} if not pcall(db.internal_call,db,output.stmt,args) then return end diff --git a/oracle/ora/actives.sql b/oracle/ora/actives.sql index ac201043..af9d9750 100644 --- a/oracle/ora/actives.sql +++ b/oracle/ora/actives.sql @@ -35,7 +35,7 @@ u={(ROOT_SID =1 OR STATUS='ACTIVE' or sql_text is not null) and schemaname=sys_context('userenv','current_schema')} } &tmodel : default={0}, m={1} - @COST : 11.0={COALESCE(1440*(sysdate-SQL_EXEC_START),sql_secs/60)},10.0={nvl(sql_secs/60,wait_secs/60)},9.0={null} + @COST : 11.0={COALESCE(1440*(sysdate-sql_exec_start),sql_secs/60)},10.0={nvl(sql_secs,wait_secs)/60},9.0={null} @CHECK_ACCESS1: dba_objects={dba_objects},all_objects={all_objects} @CHECK_ACCESS2: gv$px_session/gv$sql/gv$process={} --]] diff --git a/oracle/ora/anjul/user.sql b/oracle/ora/anjul/user.sql index 2bee36b0..12b9bbb5 100644 --- a/oracle/ora/anjul/user.sql +++ b/oracle/ora/anjul/user.sql @@ -6,7 +6,7 @@ select username, account_status, profile, - authentication_type, + --authentication_type, created, expiry_date, lock_date, diff --git a/oracle/ora/topseg.sql b/oracle/ora/topseg.sql index 12f34b4a..279e4960 100644 --- a/oracle/ora/topseg.sql +++ b/oracle/ora/topseg.sql @@ -1,8 +1,8 @@ /*[[Show top segments, default sort by logical reads. Usage: topseg [-d] [-u|-a||[.]]] [] Options: -d : Show the detail segment, instead of grouping by object name - -u : Group the segments by schema - -a : Only show the segment statistics of current schema + -u : Only show the segment statistics of current schema + -a : Group the segments by schema Tips: The query is based on GV$SEGMENT_STATISTICS which can be very slow. Use 'set instance' to limit the target instance. --[[ @@ -12,7 +12,8 @@ --]] ]]*/ set rownum on sqltimeout 1800 -SELECT /*+NO_EXPAND MONITOR*/ min(obj#) obj#,owner, &cols object_type, +SELECT /*+NO_EXPAND MONITOR opt_param('_optimizer_sortmerge_join_enabled','false') */ + min(obj#) obj#,owner, &cols object_type, SUM(DECODE(statistic_name, 'logical reads', VALUE)) logi_reads, SUM(DECODE(statistic_name, 'physical reads', VALUE)) phy_reads, SUM(DECODE(statistic_name, 'physical writes', VALUE)) phy_writes, diff --git a/oracle/show/tbs.sql b/oracle/show/tbs.sql index c0666921..0aeae3b4 100644 --- a/oracle/show/tbs.sql +++ b/oracle/show/tbs.sql @@ -3,7 +3,7 @@ @CHECK_ACCESS: wmsys.wm_concat={wmsys.wm_concat(DISTINCT regexp_substr(file_name, '\w+'))}, default={null} --]] ]]*/ -SELECT /*+no_merge(d) no_merge(f)*/ D.TABLESPACE_NAME, +SELECT /*+no_merge(d) no_merge(f) opt_param('_optimizer_sortmerge_join_enabled','false')*/ D.TABLESPACE_NAME, siz "MAX_SIZE(G)", SPACE "FILE_SIZE(G)", SPACE - NVL(FREE_SPACE, 0) "USED_SPACE(G)",