webmcp

view 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
line source
1 --[[--
2 trace.sql{
3 command = command, -- executed SQL command as string
4 execution_time = execution_time, -- execution time of the statement in seconds
5 error_position = error_position -- optional position in bytes where an error occurred
6 }
8 This command can be used to log SQL command execution. It is currently not invoked automatically.
10 --]]--
12 -- TODO: automatic use of this function?
14 function trace.sql(args)
15 if not trace._disabled then
16 local command = args.command
17 local execution_time = args.execution_time
18 local error_position = args.error_position
19 if type(command) ~= "string" then
20 error("No command string passed to trace.sql{...}.")
21 end
22 if type(execution_time) ~= "number" then
23 error("No execution time number passed to trace.sql{...}.")
24 end
25 if error_position and type(error_position) ~= "number" then
26 error("error_position must be a number.")
27 end
28 trace._new_entry{
29 type = "sql",
30 command = command,
31 execution_time = execution_time,
32 error_position = error_position
33 }
34 for i, entry in ipairs(trace._stack) do
35 entry.db_time = entry.db_time + execution_time
36 end
37 end
38 end

Impressum / About Us