Coder Social home page Coder Social logo

perl6-dbmysql's People

Contributors

curttilmes avatar xliff avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

perl6-dbmysql's Issues

0000-00-00 00:00:00 legacy timestamp not supported

MySQL (up to 5.6) supports 0000-00-00 00:00:00 to express "empty date". In MySQL 5.7+ this can be controlled via NO_ZERO_DATE flags enabled by default.

Currently legacy timestamps are not supported:

create table foo (bar timestamp null default null) engine = innodb;
insert into foo values ('0000-00-00 00:00:00');
$db.execute("select bar from foo").value.say
Month out of range. Is: 0, should be in 1..12

I'm not sure how to handle those. Assume that 0000-00-00 00:00:00 is in fact NULL? But then MySQL has another case - NO_ZERO_IN_DATE - which accepts 2019-00-00 00:00:00 as "valid" date when disabled. So stepping into DateTime exception does not mean we always have NULL.

Maybe Failure should be returned and original string value should be passed to user as part of Failure message? Currently user gets OutOfRange exception:

X::OutOfRange.new(what => "Month", got => 0, range => "1..12", comment => Any)

Or maybe this should not be supported at all, so user is forced to convert to valid value on SELECT level and document this behavior?

NULL string interpreted as empty string

To reproduce:

CREATE TABLE foo ( bar char(1) ) engine=InnoDB;
INSERT INTO foo (bar) VALUES (NULL);
$mysql.execute("SELECT bar FROM foo").value.perl.say;

Result (should be Any()):

""

Same applies to VARCHAR type.

Odd NativeCall issue Encountered

Here is the error message:

Native call expected argument 3 with VMArray representation, but got a CArray (NativeCall::Types::CArray[uint32])
  in block mysql_options at /home/cbwood/Projects/rakudobrew/versions/moar-blead/install/share/perl6/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 636
  in method option at /home/cbwood/Projects/rakudobrew/versions/moar-blead/install/share/perl6/site/sources/95C0806CA001A1EB28D0FC597A2FE4FF5195D52C (DB::MySQL::Native) line 429
  in method connect at /home/cbwood/Projects/rakudobrew/versions/moar-blead/install/share/perl6/site/sources/BE89865FDE4F84357883D27506D5B5CF8AE4AF41 (DB::MySQL) line 27
  in method db at /home/cbwood/Projects/rakudobrew/versions/moar-blead/install/share/perl6/site/sources/03DA109C5B8532E87FCA813A145C35AABBCB9BC8 (DB) line 18
  in method db at /home/cbwood/Work/BizzellAppServer/app/lib/Bizzell/Roles/DB.pm6 (Bizzell::Roles::DB) line 155
  in block  at /home/cbwood/Work/BizzellAppServer/app/lib/Bizzell/Roles/DB.pm6 (Bizzell::Roles::DB) line 192
  in method prepareAllQueries at /home/cbwood/Work/BizzellAppServer/app/lib/Bizzell/Roles/DB.pm6 (Bizzell::Roles::DB) line 185
  in block <unit> at service.p6 line 44

I'll try and chase this down, further.

Segmentation fault on releasing resources with finish()

Simple prepare statement crashes with segmentation fault when using finish() on simple single row result:

#!/usr/bin/env perl6

use v6;

use DB::MySQL;
use lib 'lib';


my $dbh = DB::MySQL.new( 
        host => "dbhost",
        database => "db",
        port => 3306,
        user => "user",
        password => "password"
    ).db;
    
loop {
    my $query = "SELECT * FROM users";
    my $sth = $dbh.prepare($query);
    my @rows = $sth.execute().array;
    $sth.finish();
}
$dbh.finish;

Execution result:

backend$ perl6 t/stability_mysql.t6
Segmentation fault

DB schema:

CREATE TABLE `users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `login` varchar(128) NOT NULL,
  `password` varchar(64) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `login` (`login`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='' 

NULL integer interpreted as 0 (zero)

To reproduce:

CREATE TABLE foo ( bar int unsigned ) engine=InnoDB;
INSERT INTO foo (bar) VALUES (NULL);
$mysql.execute("SELECT bar FROM foo").value.say;

Result (should be Any):

0

Malformed UTF-8

When trying to print out data after successfully have run a query. I get the following error whenever i try to print text that contains Nordic vocals (ie øæå). I can loop over rows in a for loop, after having run query().arrays.

On a different server, the same code with the same query, works just fine. I even copied over the libmariadb file that the server used. Both server and my workstation runs linux. But still with the same problem. I assume that the problem is specific to my own workstation, though I wonder if there is a workaround?

Malformed UTF-8 at line 1 col 2
in sub mysql-value-Str at /home/x/rakudo/share/perl6/site/sources/715B7B691EFB5DDF0C875852F7F436F293969520 (DB::MySQL::Converter) line 14
in method bind-value at /home/x/rakudo/share/perl6/site/sources/715B7B691EFB5DDF0C875852F7F436F293969520 (DB::MySQL::Converter) line 253
in code at /home/x/rakudo/share/perl6/site/sources/507086ECAA98656966E41BC1EE8B998728F2C615 (DB::MySQL::Result) line 71
in method row at /home/x/rakudo/share/perl6/site/sources/507086ECAA98656966E41BC1EE8B998728F2C615 (DB::MySQL::Result) line 69
in method pull-one at /home/x/rakudo/share/perl6/site/sources/51F6397FB5D02B2A0E15A62EC3ACF47669DBF3DC (DB::Result) line 7

Support for optionally using MariaDB

It would be nice to allow specifying the name of the native library to use in order to allow using MariaDB instead of MySQL. Under Linux I currently create a symlink from libmysqlclient.so to libmariadbclient.so, which is not exactly elegant.

NULL bugs (already fixed in execute() ) are still present in query()

To reproduce:

CREATE TABLE foo ( bar timestamp NULL default NULL ) engine=InnoDB;
INSERT INTO foo (bar) VALUES (NULL);
$mysql.query("SELECT bar FROM foo").arrays;

Result:

Invalid DateTime string ''; use an ISO 8601 timestamp (yyyy-mm-ddThh:mm:ssZ or yyyy-mm-ddThh:mm:ss+01:00) instead

Issue where execute was fixed:
#2

Wrong number of params on insert

use DB::MySQL;
my DB::MySQL $x .=new(:user<xoos>);
$x.query("insert into customers (name) values (?)", "hello world");

is dying with:

Wrong number of params
  in method execute at /home/tonyo/downloads/.rakudobrew/moar-blead-master/install/share/perl6/site/sources/B7FEB638A8625E3D92CB2064EB9B456EA2C69806 (DB::MySQL::Statement) line 30
  in method query at /home/tonyo/downloads/.rakudobrew/moar-blead-master/install/share/perl6/site/sources/31DAC65B428E3BE7CAFC630257CA1C4190EE6AC3 (DB::Connection) line 50
  in method query at /home/tonyo/downloads/.rakudobrew/moar-blead-master/install/share/perl6/site/sources/A79D993708E8048217C956D0437DC98D02AF9B83 (DB) line 23
  in block <unit> at -e line 1

I'm going to debug later when I have a little more time to dedicate to this.

Invalid DateTime string ''; use an ISO 8601 timestamp

To reproduce:

CREATE TABLE foo ( bar timestamp NULL default NULL ) engine=InnoDB;
INSERT INTO foo (bar) VALUES (NULL);
$mysql.execute("SELECT bar FROM foo").value.say;

Causes crash with following message:

Invalid DateTime string ''; use an ISO 8601 timestamp (yyyy-mm-ddThh:mm:ssZ or yyyy-mm-ddThh:mm:ss+01:00) instead
  in sub mysql-value-DateTime at /home/user/perl/share/perl6/site/sources/EF6CD0A73312FC1C63E1530F4C0FE41D1F876318 (DB::MySQL::Converter) line 64
  in method value at /home/user/perl/share/perl6/site/sources/EF6CD0A73312FC1C63E1530F4C0FE41D1F876318 (DB::MySQL::Converter) line 224
  in code  at /home/user/perl/share/perl6/site/sources/B774B2C38C7D9BF29F2ED131653E72D08610F72D (DB::MySQL::Result) line 33
  in method row at /home/user/perl/share/perl6/site/sources/B774B2C38C7D9BF29F2ED131653E72D08610F72D (DB::MySQL::Result) line 31
  in method value at /home/user/perl/share/perl6/site/sources/F40C2ECE230750883C2A427A4B0CFB76091B6AFC (DB::Result) line 56
  in block <unit> at -e line 1

Looks like NULLable timestamp is not handled properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.