webmcp

view framework/env/trace/sql.lua @ 297:fe9ea7a03364

Store execution time in trace.sql{...}
author jbe
date Sun Mar 22 18:55:34 2015 +0100 (2015-03-22)
parents 1fbdccf4f8e9
children 04b648660f9a
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 end
35 end

Impressum / About Us