jbe/bsw@0: --[[-- jbe/bsw@0: trace.sql{ jbe@295: command = command, -- executed SQL command as string jbe@295: execution_time = execution_time, -- execution time of the statement in seconds jbe@295: error_position = error_position -- optional position in bytes where an error occurred jbe/bsw@0: } jbe/bsw@0: jbe/bsw@0: This command can be used to log SQL command execution. It is currently not invoked automatically. jbe/bsw@0: jbe/bsw@0: --]]-- jbe/bsw@0: jbe/bsw@0: -- TODO: automatic use of this function? jbe/bsw@0: jbe/bsw@0: function trace.sql(args) jbe@41: if not trace._disabled then jbe@41: local command = args.command jbe@295: local execution_time = args.execution_time jbe@41: local error_position = args.error_position jbe@41: if type(command) ~= "string" then jbe@41: error("No command string passed to trace.sql{...}.") jbe@41: end jbe@295: if type(execution_time) ~= "number" then jbe@295: error("No execution time number passed to trace.sql{...}.") jbe@295: end jbe@41: if error_position and type(error_position) ~= "number" then jbe@41: error("error_position must be a number.") jbe@41: end jbe@41: trace._new_entry{ jbe@297: type = "sql", jbe@297: command = command, jbe@297: execution_time = execution_time, jbe@41: error_position = error_position jbe@41: } jbe@302: for i, entry in ipairs(trace._stack) do jbe@302: entry.db_time = entry.db_time + execution_time jbe@302: end jbe/bsw@0: end jbe/bsw@0: end