-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error messages and check for more return codes in various database subroutines #117
Conversation
…abase subroutines Signed-off-by: DL6ER <dl6er@dl6er.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds a number of improvements. See individual comments here of GitHub + added the actual value of rc
in many logg()
statements.
@@ -298,12 +322,12 @@ void save_to_DB(void) | |||
} | |||
|
|||
// Step and check if successful | |||
int rc = sqlite3_step(stmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int rc
is now defined in line 272
|
||
// Count number of rows using the index timestamp is faster than select(*) | ||
sqlite3_prepare_v2(db, "SELECT COUNT(timestamp) FROM queries", -1, &stmt, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check for this return value
|
||
// Count number of rows using the index timestamp is faster than select(*) | ||
sqlite3_prepare_v2(db, "SELECT COUNT(timestamp) FROM queries", -1, &stmt, NULL); | ||
int rc = sqlite3_step(stmt); | ||
if (rc == SQLITE_ROW) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disentangled this slightly
dbclose(); | ||
return -1; | ||
} | ||
free(querystring); | ||
|
||
// Evaluate SQL statement | ||
sqlite3_step(dbstmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to check for this return value here, Thanks @Mcat12
@@ -70,7 +70,6 @@ bool dbquery(const char *format, ...) | |||
if(query == NULL) | |||
{ | |||
logg("Memory allocation failed in dbquery()"); | |||
va_end(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already called before in line 68. No need to do it again.
Add /stats/database/top_clients
By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:
Please submit all pull requests against the
development
branch. Failure to do so will delay or deny your requestHow familiar are you with the codebase?:
10
Improve error messages and check for more return codes in various database subroutines
This template was created based on the work of
udemy-dl
.