Skip to content

Commit e0f5635

Browse files
committed
Use MYSQL_TYPE constants instead of FIELD_TYPE
The FIELD_TYPE constants are for BC. The JSON/VECTOR types are not defined in FIELD_TYPE for libmysqlclient. MYSQL_TYPE is available since MYSQL 5.0.0, so switch to that. Since MYSQL_TYPEs are enums and not defines, we need version checks instead. JSON was added in mysql 8.0.0 in mysql/mysql-server@c24045514581 VECTOR was added in mysql 9.0.0 in mysql/mysql-server@8cd51511de7d Replaces phpGH-20245.
1 parent 0a2717e commit e0f5635

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/pdo_mysql/mysql_statement.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static int pdo_mysql_stmt_get_col(
715715

716716
static char *type_to_name_native(int type) /* {{{ */
717717
{
718-
#define PDO_MYSQL_NATIVE_TYPE_NAME(x) case FIELD_TYPE_##x: return #x;
718+
#define PDO_MYSQL_NATIVE_TYPE_NAME(x) case MYSQL_TYPE_##x: return #x;
719719

720720
switch (type) {
721721
PDO_MYSQL_NATIVE_TYPE_NAME(STRING)
@@ -749,10 +749,11 @@ static char *type_to_name_native(int type) /* {{{ */
749749
#ifdef FIELD_TYPE_NEWDATE
750750
PDO_MYSQL_NATIVE_TYPE_NAME(NEWDATE)
751751
#endif
752-
#ifdef FIELD_TYPE_VECTOR
752+
/* The following 2 don't have BC FIELD_TYPE_* aliases. */
753+
#if MYSQL_VERSION_ID >= 90000 || defined(PDO_USE_MYSQLND)
753754
PDO_MYSQL_NATIVE_TYPE_NAME(VECTOR)
754755
#endif
755-
#ifdef FIELD_TYPE_JSON
756+
#if MYSQL_VERSION_ID >= 80000 || defined(PDO_USE_MYSQLND)
756757
PDO_MYSQL_NATIVE_TYPE_NAME(JSON)
757758
#endif
758759
PDO_MYSQL_NATIVE_TYPE_NAME(TIME)

0 commit comments

Comments
 (0)