Folks,

Here's an interesting problem for you. I found a problem that did not make any sense, and in diagnosing the problem I found an issue with InnoDB vs MyISAM, so I wrote a short script to test it. The test case is a simple Open, Insert, Close series repeated 5 times with both engines. The results should be absolutely identical, except for the timestamp, but you can see the results below are not. The InnoDB engine is dropping all but the last insert.

mysql --version yields "mysql Ver 14.12 Distrib 5.0.24a, for pc-linux-gnu (x86_64) using readline 5.1", running on Ubunty Edgy.

Before I report this as a bug, can anyone see anything obvious that I'm missing.

The attached test case should generate:

Database engine is 'myisam'
(1L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(2L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(3L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(4L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(5L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
Database engine is 'innodb'
(1L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(2L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(3L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(4L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(5L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)

Instead, it generates:

Database engine is 'myisam'
(1L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(2L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(3L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(4L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
(5L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
Database engine is 'innodb'
(5L, datetime.datetime(2007, 5, 15, 14, 27, 59), 'Now is the time', 5)
#!/usr/bin/env python

import os
import sys
import MySQLdb
from subprocess import *

for engine in ('myisam', 'innodb'):
    try:
        myproc = Popen('mysql', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
    except OSError, e:
        print "Execution failed:", e
        sys.exit(1)

    print "Database engine is '%s'" % engine
    myproc.stdin.write(
        """\
        drop database if exists db01;
        create database db01;
        use db01;
        CREATE TABLE `Test1` (
        `dbid` int(11) NOT NULL auto_increment,
        `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
        `s1` varchar(16) NOT NULL default '',
        `i1` smallint(6) NOT NULL default '0',
        KEY  (`dbid`)
        ) ENGINE=%s DEFAULT CHARSET=latin1;
        """ % engine
        )
    
    myproc.stdin.close()
    myproc.wait()
    output = myproc.stdout.readlines()
    for line in output:
        print line
  
    for i in range(5):
        try:
            db = MySQLdb.connect(db="db01")
        except MySQLdb.Error,e:
            print 1,e
            break

        try:
            cursor = db.cursor()
        except MySQLdb.Error,e:
            print 2,e
            break

        try:
            cursor.execute("INSERT INTO Test1 (s1, i1) VALUES ('Now is the time', 5)")
        except MySQLdb.Error,e:
            print 3,e
            break

        try:
            cursor.execute('select * from Test1')
        except MySQLdb.Error,e:
            print 4,e
            break

        try:
            db.close()
        except MySQLdb.Error,e:
            print 5,e
            break

    try:
        rows = cursor.fetchall()
    except MySQLdb.Error,e:
        print 5,e
        break

    for row in rows:
        print row

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to