sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Include full SQL query in error log

Open dragokas opened this issue 3 years ago • 8 comments

Is it possible to include a full text of SQL query for errors like:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STEAM_1:0:xxxxxxx'' at line 1

because such error text say not much.

I can't see which source code line number it is related to. Thank you.

dragokas avatar Dec 14 '21 18:12 dragokas

You can log callback name when you use LogError or something like that, it helps to find bad queries but if you dont use same callback for different queries (in this case you can put optional data when doing queries, then compare this data in the callback code.

MAGNAT2645 avatar Dec 15 '21 03:12 MAGNAT2645

Queries may have passwords and stuff.

dvander avatar Dec 15 '21 03:12 dvander

dvander, rhetorical question: in such case why SM revealed my secret SteamId in above error log. Logging is anyway executed locally. It's a purely problem of user to post on forum logs having secret information without asterisk them firstly.

Even if so, providing at least the source code line number will be enough.

MAGNAT2645, thanks, it's a walkaround, but visually looks as a bad design.

dragokas avatar Dec 15 '21 14:12 dragokas

dvander, rhetorical question: in such case why SM revealed my secret SteamId in above error log. Logging is anyway executed locally. It's a purely problem of user to post on forum logs having secret information without asterisk them firstly.

The error message you see in the log currently is exactly what is provided by the MySQL client library.

asherkin avatar Dec 15 '21 14:12 asherkin

Well, I think LogStackTrace() should help then.

dragokas avatar Dec 15 '21 14:12 dragokas

hmmm, LogStackTrace say not much.

L 12/15/2021 - 20:45:41: [SM] Called from: xxx.smx
L 12/15/2021 - 20:45:41: [SM] Call stack trace:
L 12/15/2021 - 20:45:41: [SM]   [0] LogStackTrace
L 12/15/2021 - 20:45:41: [SM]   [1] Line 1424, xxx.sp::SQL_Tx_BackupFailure

only 1 level deep. If common callback is used, it is not helpful. Need at least 2 level.

dragokas avatar Dec 15 '21 17:12 dragokas

There is no 2nd level. That's the entire callstack for a threaded query. Such is the misfortune of debugging asynchronous stuff.

It could be possible to grab the callstack at the time the query is created, and pass it through to the thread, for debugging purposes.

dvander avatar Dec 15 '21 21:12 dvander

Also you can just save query text to Datapack and pass them as data argument.

CrazyHackGUT avatar Dec 21 '21 11:12 CrazyHackGUT