Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dying with non-ASCII utf8 DB message, with use warnings FATAL => 'all'; leads to "Wide character in subroutine entry" error message with DB-message omitted #108

Open
nataraj-hates-MS-for-stealing-github opened this issue Dec 17, 2022 · 6 comments

Comments

@nataraj-hates-MS-for-stealing-github
Copy link

nataraj-hates-MS-for-stealing-github commented Dec 17, 2022

Update: see #108 (comment) below, to get up to date bug description.

I've stabled a problem:
I have DB initialized with non-English (and not Latin) utf8 locale. (It is Russian, but this is not really importaint)

I am connecting to the DB via network (this one is important, peer connection works well)

I am running a query that fails with an error.

Program dies, (as I have RaiseError => 1) but does not print any error text, it is only prints Wide character in print error message.

When I reinitialized DB cluster running it with en_US.UTF8 locale, this problem have gone. I got proper error message.

Main question: is this problem known? If it is not, or known but did not fixed yet, I will explore it more, and provide more detailed but report.

@esabol
Copy link
Contributor

esabol commented Dec 17, 2022

Your report is unclear. Could you specify the steps to reproduce and provide a short Perl program which shows the problem? Thank you!

@nataraj-hates-MS-for-stealing-github
Copy link
Author

nataraj-hates-MS-for-stealing-github commented Dec 17, 2022

Hm... Tried to write step by step guide how to reproduce it, and found out that I can not reproduce this from scratch on clean environment... Will need more time to revert my dev server and project I am working on to original configuration, where I met this issue, and then will try to reproduce it there, finding the key point... This might take some time

@esabol
Copy link
Contributor

esabol commented Dec 17, 2022

Understood. Thank you for your efforts. In the meantime perhaps someone else will have some insight into the issue.

@nataraj-hates-MS-for-stealing-github

I found the cause...

If you set use warnings FATAL => 'all'; in your program, and try to run query that fails, on DB with non-latin utf8 locale for error messages, you will get Wide character in subroutine entry warning, and thus program will be terminated before real error message will be printed.

Quite a good way to shoot own leg...

But I guess this Wide character in subroutine entry warning should be fixed anyway, if it is possible, I guess...

Do you need more detailed instructions for bug reproduction?

@esabol
Copy link
Contributor

esabol commented Dec 18, 2022

Do you need more detailed instructions for bug reproduction?

Well, it wouldn't hurt....

@nataraj-hates-MS-for-stealing-github

On clean Debian (or Debian based) installation do:

sudo dpkg-reconfigure locales

add ru_RU.UTF-8 and choose it as default locale.

Exit shell and login again.

sudo apt-get install postgresql libdbd-pg-perl
sudo su postgres
createuser -P test-user  #set password 123
createdb -O test-user test-db
echo "create table test(i integer not null)" | psql -U test-user -h 127.0.0.1 test-db

Run following script:

#!/usr/bin/perl

use strict;
use warnings FATAL => 'all';
use DBD::Pg;

my $dbh = DBI->connect("dbi:Pg:dbname=test-db;host=127.0.0.1", "test-user", "123", {
    PrintError       => 0,
    RaiseError       => 1,
    AutoCommit       => 1,
    FetchHashKeyName => 'NAME_lc',
}) or die("Can't access the database");

my $sth = $dbh->prepare( "INSERT INTO test (i) values (?)");
$sth->bind_param(1, undef);
$sth->execute();

It will give you

Wide character in subroutine entry at ./test3.pl line 17.

This a real problem, you will have hard time finding the real cause of why program fails.

Now comment out use warnings FATAL => 'all'; and run script again. It will give you

Wide character in subroutine entry at ./test3.pl line 17.
DBD::Pg::st execute failed: ОШИБКА:  значение NULL в столбце "i" отношения "test" нарушает ограничение NOT NULL
DETAIL:  Ошибочная строка содержит (null). at ./test3.pl line 17.

Two last lines is expected error message in Russian, and first line should not be there from my point of view.

@nataraj-hates-MS-for-stealing-github nataraj-hates-MS-for-stealing-github changed the title Problem getting non-ASCII utf8 error via network connection Dying with non-ASCII utf8 DB message, with use warnings FATAL => 'all'; leads to "Wide character in subroutine entry" error message with DB-message omitted Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants