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

Use bool instead of my_bool which has been removed since MySQL 8.0.1 #840

Merged
merged 1 commit into from
Apr 26, 2017
Merged

Conversation

yahonda
Copy link
Contributor

@yahonda yahonda commented Apr 14, 2017

This pull request addresses #838

Refer "Changes in MySQL 8.0.1 (2017-04-10, Development Milestone)"
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-1.html

Incompatible Change: The mysql.h header file now requires a C++ or C99 compiler to compile.
The my_bool type is no longer used in MySQL source code.
Any third-party code that used this type to represent C boolean variables
should use the bool or int C type instead. (Bug #25597667)

Refer "Changes in MySQL 8.0.1 (2017-04-10, Development Milestone)"
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-1.html

> Incompatible Change: The mysql.h header file now requires a C++ or C99 compiler to compile.
> The my_bool type is no longer used in MySQL source code.
> Any third-party code that used this type to represent C boolean variables
> should use the bool or int C type instead. (Bug #25597667)
Copy link
Collaborator

@sodabrew sodabrew left a comment

Choose a reason for hiding this comment

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

Thank you! I'll check on the other environments soon and get this merged.

@@ -1,5 +1,6 @@
#ifndef MYSQL2_RESULT_H
#define MYSQL2_RESULT_H
#include <stdbool.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there platforms these days that don't have stdbool.h available?

I'll check my Solaris and Windows environments. Off the cuff I think this will be a safe change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Bug #85131 Remove my_bool

  • mysql.h now requires a C++ or C99 header to compile. (All supported platforms have C99 compilers, but some are C89 by default and need mode switches like --std=gnu99 or --std=c99.)

Then as long as it is one of the "supported platforms", C99 should be supported.

I'm not familiar with Windows or Solaris C Compiler but googled and found these links:

Supports these ISO C99 language features:
_Bool

B.2.73 -xc99[=o]
The -xc99 option controls compiler recognition of the implemented features from the C99
standard (ISO/IEC 9899:1999, Programming Language - C).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember reading at one point that Ruby wants extensions to compile with C89? Is that still true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I did not find the information if Ruby requires C extensions compiled with C89.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I found it! While it looks dated at this point, the assumptions are stated here: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Assumptions

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also found that result.c is already using uintptr_t which is a C99 type from stdint.h but we've not included stdint.h ourselves, which is probably an error.

@yahonda
Copy link
Contributor Author

yahonda commented Apr 25, 2017

@tenderlove

Hi, This is the pull request we were talking at RailsConf this morning. Would you mind taking a look at this pull request and have some comments if mysql2 gem can use C99 boolean feature?

Thanks.

@sodabrew sodabrew added this to the 0.4.6 milestone Apr 26, 2017
@sodabrew sodabrew merged commit 5889d04 into brianmario:master Apr 26, 2017
@yahonda
Copy link
Contributor Author

yahonda commented Apr 26, 2017

Thanks!

@sodabrew
Copy link
Collaborator

sodabrew commented Dec 1, 2017

It may be the case that we need to use my_bool on older MySQL versions to avoid problems with endianness expansion missing the relevant bits. @junaruga here's where we switched from my_bool to bool in the first place.

sodabrew added a commit to sodabrew/mysql2 that referenced this pull request Dec 3, 2017
sodabrew added a commit to sodabrew/mysql2 that referenced this pull request Dec 3, 2017
sodabrew added a commit to sodabrew/mysql2 that referenced this pull request Mar 19, 2018
sodabrew added a commit that referenced this pull request Mar 19, 2018
jeremy added a commit to jeremy/mysql2 that referenced this pull request Mar 21, 2018
* master: (21 commits)
  Bump version to 0.5.0
  README note that MariaDB 10.3 and Ruby 2.6 are supported
  Initialize params_enc variable to resolve a warning
  Travis CI add MariaDB 10.3
  Travis CI add Ruby 2.6
  Use a local scope to avoid leaking the temporary variable for bind_count
  Revert "Layout/IndentHeredoc"
  Bump RuboCop limits for spec file length
  Style nit fix for brianmario#943
  Use a typedef my_bool to improve compatibility across MySQL versions
  Revert "Use `bool` instead of `my_bool` which has been removed since MySQL 8.0.1 (brianmario#840)"
  Style nit for brianmario#943
  Expose the `mysql_set_server_option`: (brianmario#943)
  Update usage section of README.md (brianmario#939)
  Travis CI should run MySQL 5.5 tests on Trusty
  Looks like Windows Ruby 2.0 still has the buggy mkmf
  Use CLIENT_CONNECT_ATTRS flag to test the connection attributes feature
  README note that MariaDB 10.2 is supported
  Travis CI drop tests for MySQL 5.1 on Ubuntu Precise
  Fix Ruby 2.4 on Appveyor
  ...
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