About the value range of my_bool in MySQL API

Source: Internet
Author: User

My_bool is defined as char in MySQL.

The description in the official document is: A boolean type, for values that are true (non-zero) or false (zero). It means 0 is false, and non-0 is true.

However, in its interface and implementation, it does not seem to be determined in the way described in the document (the value of my_bool is false ).

For example, you can find an interface:

22.9.3.2. mysql_autocommit ()

My_bool mysql_autocommit (MySQL * MySQL, my_bool Mode)
Description

Sets autocommit mode on if mode is 1, off if mode is 0. (Note that only when mode is 1 is performed, not 0)
Return values

Zero if successful. Nonzero if an error occurred. (Since you want to use my_bool as a bool, why does the returned value return an error code .)
Errors

None.

We encountered a similar problem in the project. It is clear that the variable of the my_bool type is not 0 and cannot be determined as true. Khan, which is contrary to the document description.

Therefore, it is safer to use it as a bool, and use True False directly when assigning values.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.