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

Replace sprintf usage with snprintf #21

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

zach2good
Copy link
Contributor

@zach2good zach2good commented Nov 1, 2024

Extracts one of the smaller items from this previous PR: #16

License things (I saw some mention of this in other PRs):
The files I've modified are listed under LGPL v2.1, but I'm happy to hand over all rights to the maintainers and MariaDB group, to use in whatever way they like, under whatever license they want.

.gitignore Outdated
@@ -39,6 +39,8 @@ benchmark/mysql-connector-cpp/
benchmark/mariadb.json
benchmark/mysql.json
benchmark/main-benchmark
cmake-build-*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave some comments in the PR you referred. I'm gonna repeat them here.
These are too project-specific. I mean, I don't think they are default names of directories created by cmake/build by cmake generated projects. I am not sure I want these to be added to .gitignore for everybody. On other hand it's pretty common naming pattern. Once again - I am not sure about this

@@ -51,7 +51,7 @@ namespace mariadb
bool LoggerFactory::initLoggersIfNeeded()
{
if (!NO_LOGGER) {
NO_LOGGER.reset(new NoLogger());
NO_LOGGER = Shared::Logger(new NoLogger());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that PR I asked "Is there real need for this change? I don't think so" Now I guess the idea is to initialize in case it's not initialized. Like calling method of not initialized object is not a good idea. But it's not initialization and one line before we test that object as boolean and that involves method calling.
In 1.1 this dance around NO_LOGGER has been removed and I should do the same in 1.0 probably. But as for your PR - I guess there is probably no need to change this line

@@ -32,9 +32,11 @@ namespace mariadb
{
class LoggerFactory
{
private:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is that? also not needed. Everything is private in a class by default

@lawrinn
Copy link
Collaborator

lawrinn commented Nov 3, 2024

Thank you for another pull request. I've made my comments.
Also please state again, that you are submitting your code under the BSD-new license. I am afraid that needs to be done for each PR

Co-authored-by: JOAQUIN BEJAR <jb@taunais.com>
@zach2good
Copy link
Contributor Author

Thanks for following up and pushing that logging change into master! I've stripped down this PR so now it's just that snprintf change, and I've added the license stuff to the main post 👍

@zach2good zach2good changed the title NO_LOGGER, sprintf, and gitignore changes Replace sprintf usage with snprintf Nov 4, 2024
@lawrinn lawrinn merged commit da8799b into mariadb-corporation:master Nov 4, 2024
0 of 2 checks passed
@lawrinn
Copy link
Collaborator

lawrinn commented Nov 12, 2024

Out of curiosity - what do you use it for? also, since your patch against master that is 1.0 version, are you using 1.0 and if yes why not the 1.1? It is also ga, currently it is still in develop branch. To my taste it's a way better

@zach2good
Copy link
Contributor Author

zach2good commented Nov 12, 2024 via email

@zach2good zach2good deleted the various_refactors branch November 12, 2024 17:16
@zach2good
Copy link
Contributor Author

zach2good commented Nov 12, 2024 via email

@lawrinn
Copy link
Collaborator

lawrinn commented Nov 12, 2024

Well, 1.1. was supposed to become master once it goes ga, but then I've become reluctant of doing this pull requests are one of reasons - people submit their requests against master, and it's a way easier to merge from 1.0 to 1.1. then in opposite direction. Asking to rebase against different branch makes PR's a bit more cumbersome.
I didn't quite get your affected rows problem. Looking at the code it seems like you you are getting total number of rows in the resultset. But resultset has rowsCount() method. If you don't use resultset streaming it will give you the number of rows in the resultset object, otherwise it will be number of rows fetched at a time. I guess this is because of lack of documentation. In most cases you can refer to JDBC specification. The API is mostly following it
Thank you, it was interesting to read!

@lawrinn
Copy link
Collaborator

lawrinn commented Nov 12, 2024

hmm, it looks like you use rowsCount(). if (rset && rset->rowsCount() && rset->next())
also, that is redundant to check here rowsCount() imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants