Skip to content

Conversation

@iluuu1994
Copy link
Member

Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

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

Missing require __DIR__ . '/mysql_pdo_test.inc';.

It makes me wonder why it's not available with libmysqlclient.

FIELD_TYPE_JSON is a mysqlnd only feature.
@iluuu1994 iluuu1994 force-pushed the fix-gh20122-for-libmysqlclient branch from f06ae2b to 0d2e3a2 Compare October 20, 2025 14:27
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

The reason seems to be that libmysqlclient defines only MYSQL_TYPE_JSON but not FIELD_TYPE_JSON. It's worth noting that the FIELD_TYPE_* defines are actual BC aliases for MYSQL_TYPE_*. However, JSON was likely introduced much more recently than these BC aliases were, so I think a BC alias for it was never made.

See also:
https://github.com/mysql/mysql-server/blob/b79ac1111737174c1b36ab5f63275f0191c000dc/include/field_types.h#L80

Same problem for VECTOR.

Makes me wonder if it's as simple as modifying #define PDO_MYSQL_NATIVE_TYPE_NAME(x) case FIELD_TYPE_##x: return #x; to use MYSQL_TYPE_ instead of FIELD_TYPE_

@kamil-tekiela
Copy link
Member

Ahh that explains it.

If you change the macro, for mysqlnd it should still work the same. As I can see the two values which are not MYSQL_TYPE_ are not listed in that PDO function. I suppose for libmysql it should be the same. I do not know why we use the BC variants of these defines.

@ndossche
Copy link
Member

What's the lowest version of libmysqlclient that we support? I'm asking because I'm concerned: what if MYSQL_TYPE_* doesn't exist on some version of libmysqclient we still support. That could be the reason why we use the BC aliases?

@kamil-tekiela
Copy link
Member

What's the lowest version of libmysqlclient that we support? I'm asking because I'm concerned: what if MYSQL_TYPE_* doesn't exist on some version of libmysqclient we still support. That could be the reason why we use the BC aliases?

I don't know if it's explicitely stated anywhere. I think we can assume that the latest PHP releases should definitely support all currently supported MySQL versions. As far as I know, MySQL 5 is out of support, but when PHP 8.3 was released it was still supported. I think it would be safe to assume at least MySQL 5.5 should be supported. And if the change was made before MySQL 5.1 then I am pretty sure we should not be concerned about it.

@ndossche
Copy link
Member

I checked out the mysql 5.0.0 sources and it does have the MYSQL_TYPE_* constants, so I believe it's safe to change.

ndossche added a commit to ndossche/php-src that referenced this pull request Oct 20, 2025
The FIELD_TYPE constants are for BC. The JSON/VECTOR types are not
defined in FIELD_TYPE for libmysqlclient.
MYSQL_TYPE appears to be available since MYSQL 5.0.0, so switch to that.

Replaces phpGH-20245.
@iluuu1994 iluuu1994 closed this Oct 20, 2025
ndossche added a commit to ndossche/php-src that referenced this pull request Oct 21, 2025
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.
ndossche added a commit to ndossche/php-src that referenced this pull request Oct 21, 2025
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.
ndossche added a commit that referenced this pull request Oct 23, 2025
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
JSON support was backported via mysql/mysql-server@3e14f9f in 5.7.8.
VECTOR was added in mysql 9.0.0 in mysql/mysql-server@8cd51511de7d

Replaces GH-20245.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants