Created
August 25, 2009 10:40
-
-
Save yappo/174626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use DBI; | |
| use YAML; | |
| my $dbh = DBI->connect('DBI:SQLite:'); | |
| #my $dbh = DBI->connect('DBI:mysql:test'); | |
| $dbh->do('CREATE TABLE hyoshiok ( dan BIGINT, kogai BIGINT )'); | |
| sub insert { | |
| my($dan, $kogai) = @_; | |
| my $sth = $dbh->prepare('INSERT INTO hyoshiok (dan, kogai) VALUES(?, ?)'); | |
| $sth->bind_param(1, $dan, undef); | |
| $sth->bind_param(2, $kogai, undef); | |
| $sth->execute; | |
| $sth->finish; | |
| } | |
| insert 1 => 2147483648; | |
| insert 2 => 2147483648-1; | |
| insert 3 => 2147483648*2; | |
| insert 4 => 2147483648*2-1; | |
| insert 5 => 2147483648*2+1; | |
| my $ret = $dbh->selectall_hashref('SELECT * FROM hyoshiok', 'dan'); | |
| print Dump($ret); | |
| __END__ | |
| sqlite result: | |
| --- | |
| 1: | |
| dan: 1 | |
| kogai: 2147483648 | |
| 2: | |
| dan: 2 | |
| kogai: 2147483647 | |
| 3: | |
| dan: 3 | |
| kogai: 4294967296 | |
| 4: | |
| dan: 4 | |
| kogai: 4294967295 | |
| 5: | |
| dan: 5 | |
| kogai: 4294967297 | |
| [/tmp]$ fg | |
| emacs sqlite.pl | |
| mysql result: | |
| --- | |
| 1: | |
| dan: 1 | |
| kogai: -2147483648 | |
| 2: | |
| dan: 2 | |
| kogai: 2147483647 | |
| 3: | |
| dan: 3 | |
| kogai: 4294967296 | |
| 4: | |
| dan: 4 | |
| kogai: -1 | |
| 5: | |
| dan: 5 | |
| kogai: 4294967297 | |
| This is perl, v5.8.8 built for darwin-thread-multi-2level | |
| DBI : 1.607 | |
| DBD::SQLite : 1.21 | |
| DBD::mysql : 4.012 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment