Skip to content

Instantly share code, notes, and snippets.

@perlpunk
Last active March 14, 2022 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perlpunk/7e96f3070a31c5f28a32a2d94ac4d634 to your computer and use it in GitHub Desktop.
Save perlpunk/7e96f3070a31c5f28a32a2d94ac4d634 to your computer and use it in GitHub Desktop.
reproducer.t
use Mojo::Base -strict;
use Test::More;
use File::Spec::Functions 'catfile';
use File::Temp;
use FindBin;
use Mojo::SQLite;
my $tempdir = File::Temp->newdir;
my $tempfile = catfile($tempdir, 'test.db');
# Clean up before start
my $sql = Mojo::SQLite->new->from_filename($tempfile);
$sql->db->query('drop table if exists mojo_migrations');
subtest 'XXXXXXXXXXXXXXXXXXXXXXXX' => sub {
my $query1 = <<EOF;
create table if not exists minion_workers (
id integer not null primary key autoincrement,
host text not null,
pid integer not null,
started text not null default current_timestamp,
notified text not null default current_timestamp
);
EOF
my $query2 = <<EOF;
alter table minion_workers add column inbox text not null
check(json_valid(inbox) and json_type(inbox) = 'array') default '[]';
EOF
my $query = $query1 . $query2;
my $db = $sql->db;
warn "??????????????????????????????????";
$db->dbh->do($query1);
warn "??????????????????????????????????";
$db->dbh->do($query2); # <---- dies here
warn "??????????????????????????????????";
pass "dummy";
};
done_testing();
@stoecker
Copy link

Minimal:
use Mojo::SQLite;
use DBI;

my $query1 = "create table if not exists t (host text)";
my $query2 = "alter table t add column c text check(json_valid(c)) default '[]'";

my $dbh = DBI->connect("dbi:SQLite:dbname=a.db","","");
$dbh->do($query1);
$dbh->do($query2);

my $sql = Mojo::SQLite->new->from_filename("t.db");
my $db = $sql->db;
$db->dbh->do($query1);
$db->dbh->do($query2); # <---- dies here

@stoecker
Copy link

Smaller again:
use DBI;
use DBD::SQLite::Constants ":database_connection_configuration_options";

system("rm a.db");
my $query1 = "create table if not exists t (host text)";
my $query2 = "alter table t add column c text check(json_valid(c)) default '[]'";

my $dbh = DBI->connect("dbi:SQLite:dbname=a.db","","");
$dbh->sqlite_db_config(SQLITE_DBCONFIG_DQS_DML, 0);
$dbh->do($query1);
$dbh->do($query2); # <---- dies here

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