Skip to content

Conversation

lshw
Copy link

@lshw lshw commented Sep 11, 2025

debian12:
host:~# /usr/bin/mariadbd-multi start 2
Wide character in print at /usr/bin/mariadbd-multi line 711.

host:~# locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

  • The Jira issue number for this PR is: MDEV-______

Description

TODO: fill description here

Release Notes

TODO: What should the release notes say about this change?
Include any changed system variables, status variables or behaviour. Optionally list any https://mariadb.com/kb/ pages that need changing.

How can this PR be tested?

TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended.
Consult the documentation on "Writing good test cases".

If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

debian12:
host:~# /usr/bin/mariadbd-multi start 2
Wide character in print at /usr/bin/mariadbd-multi line 711.

host:~# locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
@CLAassistant
Copy link

CLAassistant commented Sep 11, 2025

CLA assistant check
All committers have signed the CLA.

@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Sep 11, 2025
@svoj svoj requested a review from Copilot September 17, 2025 12:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a UTF-8 encoding issue in the MariaDB multi-instance daemon script that was causing "Wide character in print" warnings when running in UTF-8 locales. The change adds proper UTF-8 encoding support to log file operations.

  • Adds UTF-8 encoding support to log file handles in the mysqld_multi.sh script

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@svoj svoj left a comment

Choose a reason for hiding this comment

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

Please change commit message so that it conforms to MariaDB guidelines, something like:

MDEV-37630 - logfile cannot output utf8

mariadb-multi emits "Wide character in print..." warning when LC_TIME is
set to use UTF-8 character set. It occurs when writing log entry
timestamp that contains non-ASCII day of week and month name, while log
file is open in ASCII text mode.

Fixed by changing timestamp format to contain only ASCII characters.

open (LOGFILE, ">>$opt_log")
or die "FATAL: w2log: Couldn't open log file: $opt_log\n";
binmode(LOGFILE, ":encoding(UTF-8)");
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't seem to be enough. If locale is set to something non-utf8, perl binmode will screw up the string:

LC_TIME="zh_CN.GB18030" perl -e 'use POSIX qw(strftime); open (LOGFILE, ">>log"); binmode(LOGFILE, ":encoding(UTF-8)"); print LOGFILE strftime "%a %b %e %H:%M:%S %Y\n", localtime; close(LOGFILE);'
iconv -f gb18030 -t utf8 < log

This simplest solution would be to change date format such that it doesn't contain non-ASCII characters, e.g %Y-%m-%d %H:%M:%S. Another option is to preserve date format, but use something else instead of strftime() like Time::Piece or DateTime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.
Development

Successfully merging this pull request may close these issues.

3 participants