Skip to content
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

Merged
merged 1 commit into from
Jul 23, 2017

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jul 18, 2017

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 request

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How 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.

…abase subroutines

Signed-off-by: DL6ER <dl6er@dl6er.de>
Copy link
Member Author

@DL6ER DL6ER left a 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);
Copy link
Member Author

@DL6ER DL6ER Jul 18, 2017

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);
Copy link
Member Author

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)
Copy link
Member Author

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);
Copy link
Member Author

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

@DL6ER DL6ER requested a review from AzureMarker July 18, 2017 10:14
@DL6ER DL6ER mentioned this pull request Jul 18, 2017
@@ -70,7 +70,6 @@ bool dbquery(const char *format, ...)
if(query == NULL)
{
logg("Memory allocation failed in dbquery()");
va_end(args);
Copy link
Member Author

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.

@DL6ER DL6ER merged commit 2ad0bea into development Jul 23, 2017
@DL6ER DL6ER deleted the fix/DBret branch July 23, 2017 09:53
DL6ER pushed a commit that referenced this pull request Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants