MySQL++

Check-in [c4f89d91fb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added the MYSQLPP_UTF8_COL macro to go with MYSQLPP_UTF8_CS. MySQL isn't smart enough to upgrade "utf8_general_ci" ot "utf8mb4_general_ci" when the character set is "utf8mb4".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c4f89d91fb4baf12445f28ec00c96e88ca9a52d5a77551d20e40da7e5d81dcaf
User & Date: tangent 2018-07-26 17:12:53
References
2018-07-26
17:13 Closed ticket [5bcd7e102a]: Switch to utf8mb4 on MySQL 8+ plus 4 other changes artifact: 70788e31ab user: tangent
Context
2018-07-27
03:12
Comment improvement. check-in: f82f99180c user: tangent tags: trunk
2018-07-26
17:12
Added the MYSQLPP_UTF8_COL macro to go with MYSQLPP_UTF8_CS. MySQL isn't smart enough to upgrade "utf8_general_ci" ot "utf8mb4_general_ci" when the character set is "utf8mb4". check-in: c4f89d91fb user: tangent tags: trunk
16:59
Wrote up the changes-so-far for MySQL++ 3.2.4 in the ChangeLog.md file. check-in: 1484202d13 user: tangent tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.md.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Change Log

## 3.2.4, UNRELEASED

*   Added the `MYSQLPP_UTF8_CS` macro to allow a given bit of code use
    either the legacy "utf8" character set or the new full-Unicode
    "utf8mb4" version depending on whether MySQL++ is built against
    MySQL 5.5 or newer, the version where `utf8mb4` was added.  See the
    [Unicode chapter in the user manual][umuc] for more details.

*   Recent versions of MySQL and MariaDB have removed some obsolete
    features, causing MySQL++ build errors in places where the library
    wraps one of these features:

    *   MySQL 8.0 removed the embedded database feature, which caused
        build errors in four `Option::set()` overrides.  For MySQL 8.0




|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Change Log

## 3.2.4, UNRELEASED

*   Added the `MYSQLPP_UTF8_CS` and `MYSQLPP_UTF8_COL` macros to allow a
    given bit of code use either the legacy "utf8" character set or the new
    full-Unicode "utf8mb4" version depending on whether MySQL++ is built
    against MySQL 5.5 or newer, the version where `utf8mb4` was added.
    See the [Unicode chapter in the user manual][umuc] for more details.

*   Recent versions of MySQL and MariaDB have removed some obsolete
    features, causing MySQL++ build errors in places where the library
    wraps one of these features:

    *   MySQL 8.0 removed the embedded database feature, which caused
        build errors in four `Option::set()` overrides.  For MySQL 8.0

Changes to doc/userman/unicode.dbx.

90
91
92
93
94
95
96
97

98
99


100

101
102
103
104
105
106
107

    <para>Finally, in MySQL 8.0, &#x201C;utf8mb4&#x201D; became the
    default character set. For backwards compatibility,
    &#x201C;utf8&#x201D; remains an alias for
    &#x201C;utf8mb3.&#x201D;</para>

    <para>As of MySQL++ 3.2.4, we&#x2019;ve defined the
    <varname>MYSQLPP_UTF8_CS</varname> macro which expands to

    &#x201C;utf8mb4&#x201D; when you build it against MySQL 5.5 and
    newer and to &#x201C;utf8&#x201D; otherwise. We use this macro in


    our <filename>resetdb</filename> example.</para>

  </sect2>


  <sect2 id="unicode-unix">
    <title>Unicode on Unixy Systems</title>

    <para>Linux and Unix have system-wide UTF-8 support these days. If







|
>
|
<
>
>
|
>







90
91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
108
109
110

    <para>Finally, in MySQL 8.0, &#x201C;utf8mb4&#x201D; became the
    default character set. For backwards compatibility,
    &#x201C;utf8&#x201D; remains an alias for
    &#x201C;utf8mb3.&#x201D;</para>

    <para>As of MySQL++ 3.2.4, we&#x2019;ve defined the
    <varname>MYSQLPP_UTF8_CS</varname> and
    <varname>MYSQLPP_UTF8_COL</varname> macros which expand to
    &#x201C;utf8mb4&#x201D; and &#x201C;utf8mb4_general_ci&#x201D; when

    you build MySQL++ against MySQL 5.5 and newer and to
    &#x201C;utf8&#x201D; and &#x201C;utf8_general_ci&#x201D; otherwise.
    We use these macros in our <filename>resetdb</filename>
    example.</para>
  </sect2>


  <sect2 id="unicode-unix">
    <title>Unicode on Unixy Systems</title>

    <para>Linux and Unix have system-wide UTF-8 support these days. If

Changes to examples/resetdb.cpp.

136
137
138
139
140
141
142
143
144

145
146
147
148
149
150
151
				"CREATE TABLE stock (" <<
				"  item CHAR(30) NOT NULL, " <<
				"  num BIGINT NOT NULL, " <<
				"  weight DOUBLE NOT NULL, " <<
				"  price DECIMAL(6,2) NULL, " << // NaN & inf. == NULL
				"  sdate DATE NOT NULL, " <<
				"  description MEDIUMTEXT NULL) " <<
				"ENGINE = InnoDB " <<
				"CHARACTER SET " MYSQLPP_UTF8_CS " COLLATE utf8_general_ci";

		query.execute();

		// Set up the template query to insert the data.  The parse()
		// call tells the query object that this is a template and
		// not a literal query string.
		query << "insert into %6:table values " <<
				"(%0q, %1q, %2, %3, %4q, %5q:desc)";







|
|
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
				"CREATE TABLE stock (" <<
				"  item CHAR(30) NOT NULL, " <<
				"  num BIGINT NOT NULL, " <<
				"  weight DOUBLE NOT NULL, " <<
				"  price DECIMAL(6,2) NULL, " << // NaN & inf. == NULL
				"  sdate DATE NOT NULL, " <<
				"  description MEDIUMTEXT NULL) " <<
				"ENGINE = InnoDB" <<
				" CHARACTER SET " MYSQLPP_UTF8_CS
                " COLLATE " MYSQLPP_UTF8_COL;
		query.execute();

		// Set up the template query to insert the data.  The parse()
		// call tells the query object that this is a template and
		// not a literal query string.
		query << "insert into %6:table values " <<
				"(%0q, %1q, %2, %3, %4q, %5q:desc)";

Changes to lib/common.h.

218
219
220
221
222
223
224

225
226

227
228
229
#else
#	include <mysql.h>
#endif

// The Unicode chapter of the user manual justifies the following.
#if MYSQL_VERSION_ID >= 50500
#   define MYSQLPP_UTF8_CS "utf8mb4"

#else
#   define MYSQLPP_UTF8_CS "utf8"

#endif

#endif // !defined(MYSQLPP_COMMON_H)







>


>



218
219
220
221
222
223
224
225
226
227
228
229
230
231
#else
#	include <mysql.h>
#endif

// The Unicode chapter of the user manual justifies the following.
#if MYSQL_VERSION_ID >= 50500
#   define MYSQLPP_UTF8_CS "utf8mb4"
#   define MYSQLPP_UTF8_COL "utf8mb4_general_ci"
#else
#   define MYSQLPP_UTF8_CS "utf8"
#   define MYSQLPP_UTF8_COL "utf8_general_ci"
#endif

#endif // !defined(MYSQLPP_COMMON_H)