Skip to content

metadata checks (charsetnr) in various mysqli tests fail #21338

@9EOR9

Description

@9EOR9

Description

The following test:

sapi/cli/php -f run-tests.php ext/mysqli/tests/mysqli_fetch_field.phpt

Resulted in this output:

========DIFF========
--
       ["decimals"]=>
       int(0)
     }
057+ [004] Expecting charset utf8/33 got 192
     bool(false)
     mysqli_result object is already closed
     array(1) {
--
========DONE========
FAIL mysqli_fetch_field() [ext/mysqli/tests/mysqli_fetch_field.phpt] 
=====================================================================
Number of tests :     1                 1
Tests skipped   :     0 (  0.0%) --------
Tests warned    :     0 (  0.0%) (  0.0%)
Tests failed    :     1 (100.0%) (100.0%)
Tests passed    :     0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      : 0.110 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
mysqli_fetch_field() [ext/mysqli/tests/mysqli_fetch_field.phpt]
=====================================================================

mysqli_set_charset() selects a character set by name only.
However, in MySQL/MariaDB a character set can have multiple collations, and the actual collation used determines the internal character set number (charsetnr) returned in metadata.

Several tests in the ext/mysqli test suite assume that setting utf8mb3 results in charsetnr = 33 (which corresponds to utf8mb3_general_ci). This assumption is not valid when the server default collation differs.

As a result, multiple tests fail depending on server configuration.

Possible workarounds (quick fix):

  • use %d in the expect section
  • use SET NAMES utf8mb3 COLLATE 'utf8mb3_general_ci' if you want to explicitly test for this character set/collation.

PHP Version

PHP 8.3.6 (cli) (built: Jan  7 2026 08:40:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions