Support for DB2

2014-06-01
3 days ago
  • I would like to know if you are interested in providing DB2 support. I know that HammerDB supports Oracle, SQL Server and other databases, and it will be interesting to provide support to this RDBM from IBM.

    I am a DB2 DBA and developer, and I could help you with the DB2 part. I do not know anything about TCL, so I could help with the DB2 elements.

    At the same time, I see that HammerDB uses the XXTCL project to connect to the databases, and I checked the DB2TCL project, but it seems a little old without maintenance (almost 10 years without commits - https://www.ohloh.net/p/db2tcl). Is it a problem?

    I would like to help you porting HammerDB to DB2.

     
  • Steve Shaw
    Steve Shaw
    2014-06-02

    Hi,

    Yes adding DB2 support would certainly be desirable. The reason DB2 support has not yet been added (it is the same for Sybase) is for the reason you correctly identify - the presence of an up to date native TCL driver. This needs to be built on both Linux and Windows (32 and 64-bit) and tested for performance and reliability eg the interface needs to be thread-safe. Looking in the code as you say it has not been updated for 10 years and the README says:
    DB2TCL tested only on Linux 2.4.x systems and Solaris 8
    Nevertheless sometimes if an interface was completed then it may work and could be built to run on Windows as well. If you would like to take a look at the DB2TCL driver and see if it works then this could be a good start to work towards seeing if adding DB2 support is feasible - The first task in adding a new database is to do the TPC-C schema build (knowledge of the best schema layout is useful here), after this to write the DB2 native stored procedures and then the TPC-C driver before moving on to TPC-H so it is always a fair amount of work to add a new database but adding DB2 support would seem worthwhile if the DB2TCL interface will work.

    Cheers,

    Steve

     
  • Steve Shaw
    Steve Shaw
    3 days ago

    As a follow up for anyone searching on the topic of DB2 support for HammerDB, the opportunity has arisen to take a look and see if HammerDB can support DB2 and whether the native driver for DB2 is functional. Well not too surprising the existing interface code 'as-is' does not compile however after some modifications and updates it has been possible to get it working as intended by the original author against the sample database in DB2 10.1 on Linux 64-bit and it does seem functional and fast. Not all requirements have been fully investigated as yet however given the working interface it does seem reasonable to now see if HammerDB can be extended to support DB2.

    db2inst1@db2v10:~/HammerDB-2.17/lib> ls -l db2tcl1.0.0/
    total 52
    -rwxr-xr-x 1 db2inst1 db2grp1   849 Jul 30 18:55 libdb2tcl.la
    -rwxr-xr-x 1 db2inst1 db2grp1 41983 Jul 30 18:55 libdb2tcl.so.0.0.1
    -rw-r--r-- 1 db2inst1 db2grp1   118 Jul 30 19:03 pkgIndex.tcl
    
    db2inst1@db2v10:~/HammerDB-2.17/lib/db2tcl1.0.0> more pkgIndex.tcl 
    #
    # Tcl package index file
    #
    package ifneeded db2tcl 1.0 \
        [list load [file join $dir libdb2tcl.so.0.0.1] db2tcl]
    
    db2inst1@db2v10:~/HammerDB-2.17> export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
    db2inst1@db2v10:~/HammerDB-2.17> ./bin/tclsh8.6
    % package require db2tcl
    1.0
    % db2_connect sample
    db2sql1
    % db2_select db2sql1 {Select * from employee} 
    db2sql1.65537.14
    % db2_getnumrow db2sql1.65537.14
    14
    % db2_fetchrow db2sql1.65537.14
    000010 CHRISTINE I HAAS A00 3978 1995-01-01 {PRES    } 18 F 1963-08-24 152750.00 1000.00 4220.00
    % db2_finish db2sql1.65537.14
    % db2_disconnect db2sql1
    % exit
    ------
    #
    package require db2tcl
    set sql1 {Select * from employee}
    set db_handle [ db2_connect SAMPLE ]
    set stmnt_handle [ db2_select $db_handle $sql1 ]
    puts [ db2_getnumrows $stmnt_handle ]
    while {[set line [db2_fetchrow $stmnt_handle]] != ""} {
      puts "$line"
    }
    db2_finish $stmnt_handle 
    db2_disconnect $db_handle
    #Multiuser HammerDB test
    
    db2inst1@db2v10:~/TCL/db2tcl-0.0.6/tests> /usr/local/bin/tclsh8.6 
    % package require db2tcl
    1.0
    % source ./test1.tcl
    Executing test1:
    Connect to database SAMPLE...
    Drop table db2tcl if exist...
    Could not drop table db2tcl.
    
    Create table db2tcl...
    Insert data into table db2tcl...
    Query table DB2TCL by operator select... 
    Fetch all rows from query result...
    1 {West                     }
    2 {Gour                     }
    3 {Manger                   }
    4 {Slava                    }
    Begin transaction...
    Insert data into table db2tcl...
    Rollback transaction...
    Query table DB2TCL by operator select... 
    Fetch all rows from query result...
    1 {West                     }
    2 {Gour                     }
    3 {Manger                   }
    4 {Slava                    }
    Begin transaction...
    Insert data into table db2tcl...
    Commit transaction...
    Query table DB2TCL by operator select... 
    Fetch all rows from query result...
    1 {West                     }
    2 {Gour                     }
    3 {Manger                   }
    4 {Slava                    }
    5 {Pupkin                   }
    6 {Dudkin                   }
    Disconnect from database SAMPLE...
    % source test2.tcl
    Executing test2:
    Connect to database SAMPLE and query result...
    Fetch 4 rows...
    1 {West                     }
    2 {Gour                     }
    3 {Manger                   }
    4 {Slava                    }
    Disconnect from database SAMPLE...
    % source test3.tcl
    Executing test3:
    First connection to database SAMPLE...
    Second connection to database SAMPLE...
    Third connection to database SAMPLE...
    db2sql1 db2sql2 db2sql3
    db2sql1 db2sql2 db2sql3
    db2sql1 db2sql2 db2sql3
    % source test4.tcl
    Executing test4:
    Connect to database SAMPLE...
    Query table DB2TCL by operator select... 
    Fetch all rows from query result...
    1 {West                     }
    Disconnect from database SAMPLE...
    % source test5.tcl
    Executing test5:
    Connect to database SAMPLE...
    Query table DB2TCL by operator select... 
    Fetch all rows from query result...
    1 {West                     }
    2 {Gour                     }
    3 {Manger                   }
    4 {Slava                    }
    5 {Pupkin                   }
    6 {Dudkin                   }
    %
    

    Cheers,

    Steve