webmcp

annotate framework/env/trace/sql.lua @ 302:04b648660f9a

Time triple (cpu/db/total) for trace system
author jbe
date Sun Mar 22 20:06:26 2015 +0100 (2015-03-22)
parents fe9ea7a03364
children e3e2a03f75b2
rev   line source
jbe/bsw@0 1 --[[--
jbe/bsw@0 2 trace.sql{
jbe@295 3 command = command, -- executed SQL command as string
jbe@295 4 execution_time = execution_time, -- execution time of the statement in seconds
jbe@295 5 error_position = error_position -- optional position in bytes where an error occurred
jbe/bsw@0 6 }
jbe/bsw@0 7
jbe/bsw@0 8 This command can be used to log SQL command execution. It is currently not invoked automatically.
jbe/bsw@0 9
jbe/bsw@0 10 --]]--
jbe/bsw@0 11
jbe/bsw@0 12 -- TODO: automatic use of this function?
jbe/bsw@0 13
jbe/bsw@0 14 function trace.sql(args)
jbe@41 15 if not trace._disabled then
jbe@41 16 local command = args.command
jbe@295 17 local execution_time = args.execution_time
jbe@41 18 local error_position = args.error_position
jbe@41 19 if type(command) ~= "string" then
jbe@41 20 error("No command string passed to trace.sql{...}.")
jbe@41 21 end
jbe@295 22 if type(execution_time) ~= "number" then
jbe@295 23 error("No execution time number passed to trace.sql{...}.")
jbe@295 24 end
jbe@41 25 if error_position and type(error_position) ~= "number" then
jbe@41 26 error("error_position must be a number.")
jbe@41 27 end
jbe@41 28 trace._new_entry{
jbe@297 29 type = "sql",
jbe@297 30 command = command,
jbe@297 31 execution_time = execution_time,
jbe@41 32 error_position = error_position
jbe@41 33 }
jbe@302 34 for i, entry in ipairs(trace._stack) do
jbe@302 35 entry.db_time = entry.db_time + execution_time
jbe@302 36 end
jbe/bsw@0 37 end
jbe/bsw@0 38 end

Impressum / About Us