Skip to content

Problem with utf8 chars in BLOB field #232

@adifairbank

Description

@adifairbank

There seems to be a bug in DBD::MariaDB with utf8 chars inserted into.a BLOB. It works fine using the mysql client, but see the following simple test script to reproduce the issue. You just need a "test" database with user "test" and no password.

I am testing this on Rocky Linux 9.7, mariadb-server-10.5.29, DBD::MariaDB 1.24.

#!/bin/perl

use DBI;

my $dbh = DBI->connect("DBI:MariaDB:database=test;host=127.0.0.1;port=3306", 'test', '', {RaiseError => 1});
my $str = "👉";
utf8::upgrade $str;

$dbh->do('CREATE TEMPORARY TABLE test_utf8 ( id  VARCHAR(24) NOT NULL PRIMARY KEY, blob_value BLOB ) ENGINE InnoDB DEFAULT CHARSET=utf8mb4');

$dbh->do("INSERT INTO test_utf8 (id, blob_value) VALUES (?, ?)", {}, "test", $str);
my $a = $dbh->selectall_arrayref("SELECT id,blob_value FROM test_utf8");

foreach (@$a) { print join ";", @$_, "\n"; }

On my system, I get output:

test;ð;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions