I think bool should ne there atleast. Its 1bit(1byte) of data vs 8bytes or more
Announcement
Collapse
No announcement yet.
SQLite Lands JSONB For Much Faster JSON Functions
Collapse
X
-
Originally posted by cj.wijtmans View PostI think bool should ne there atleast. Its 1bit(1byte) of data vs 8bytes or more
Serial Type Codes Of The Record Format0 0 Value is a NULL. 1 1 Value is an 8-bit twos-complement integer. 2 2 Value is a big-endian 16-bit twos-complement integer. 3 3 Value is a big-endian 24-bit twos-complement integer. 4 4 Value is a big-endian 32-bit twos-complement integer. 5 6 Value is a big-endian 48-bit twos-complement integer. 6 8 Value is a big-endian 64-bit twos-complement integer. 7 8 Value is a big-endian IEEE 754-2008 64-bit floating point number. 8 0 Value is the integer 0. (Only available for schema format 4 and higher.) 9 0 Value is the integer 1. (Only available for schema format 4 and higher.) 10,11 variable Reserved for internal use. These serial type codes will never appear in a well-formed database file, but they might be used in transient and temporary database files that SQLite sometimes generates for its own use. The meanings of these codes can shift from one release of SQLite to the next. N≥12 and even (N-12)/2 Value is a BLOB that is (N-12)/2 bytes in length. N≥13 and odd (N-13)/2 Value is a string in the text encoding and (N-13)/2 bytes in length. The nul terminator is not stored. Last edited by patrick1946; 07 December 2023, 06:20 AM.
- Likes 1
Comment
-
Originally posted by cj.wijtmans View PostWell it is not only about storage its also about constraints a boolean is not simply an integer.
- Likes 1
Comment
-
Originally posted by patrick1946 View Post
Hmm, in many languages a boolean is a integer. Actually can you describe the usecase? Sqlite is mostly used as am embedded database. And in most embedded usecases there is no big advantage for an extra bool type.
Comment
-
Originally posted by cj.wijtmans View Postno its not, in some cases a boolean can be stored as a single bit. In some cases booleans can be handled differently in different contexts as well, how strongly depends on the language. So no a boolean is not a simple integer.
So in C++ it is a integer. I will not lookup other languages.
Sqlite is heavily used in embedded cases and there you use very often C++. So using a boolean as an integer is completely fine there.
- Likes 1
Comment
-
Originally posted by patrick1946 View Post
Comment
-
Originally posted by cj.wijtmans View Post
in C++ it can be either 1 bit or 1 byte or nothing at all. So again even if the underlying storage is an integer usually its not simply an integer. Not sure what you do not understand? There is a reason boolean is a seperate keyword these days.
I can't find an answer in the standard documentation. Does the C++ language standard require sizeof(bool) to always be 1 (for 1 byte), or is this size implementation-defined?
So the size is implementation defined but must be the size of a character or bigger. It can't be a bit because a bit has no address. You can use bit fields but that bit field has a type and must be the size of the type. Why it can't be a bit? Because you can't address a bit in memory.
- Likes 2
Comment
Comment