{"id":468,"date":"2019-07-17T14:31:37","date_gmt":"2019-07-17T14:31:37","guid":{"rendered":"http:\/\/www.hammerdb.com\/blog\/?p=468"},"modified":"2019-07-18T11:06:20","modified_gmt":"2019-07-18T11:06:20","slug":"how-to-add-your-database-to-hammerdb-pt3-adding-to-and-modifying-the-source","status":"publish","type":"post","link":"https:\/\/www.hammerdb.com\/blog\/uncategorized\/how-to-add-your-database-to-hammerdb-pt3-adding-to-and-modifying-the-source\/","title":{"rendered":"How to add your database to HammerDB &#8211; Pt3 Adding to and modifying the source"},"content":{"rendered":"\n<p>From the previous post we now have source and binary copies of HammerDB for modification and test. The next step is to see if there is an Issue already created for the database we want to add or whether we should create one. In this example using MariaDB there is already an Issue created <a href=\"https:\/\/github.com\/TPC-Council\/HammerDB\/issues\/54\"><span class=\"js-issue-title\">Add MariaDB as a separate database <\/span> <span class=\"gh-header-number\">#54&nbsp; <\/span><\/a>although note that this can be for any database you choose.&nbsp; You now want to create a new branch for this work,&nbsp; in this case using the Issue number for branch.<\/p>\n<pre>git checkout -b 54<br>Switched to a new branch '54'<br>git branch<br>* 54<br>61<br>master<\/pre>\n<p>git status will also show you the current branch. You can now begin modifying the source to add your database.&nbsp; Firstly in the database.xml in the config directory add the information for your new database.&nbsp; Note in particular the prefix that will be used for variables and file and procedure names.&nbsp; The commands section is used to identify words for highlighting in the script editor only.&nbsp;<\/p>\n<pre>&lt;mariadb&gt;<br>&lt;name&gt;MariaDB&lt;\/name&gt;<br>&lt;description&gt;MariaDB&lt;\/description&gt;<br>&lt;prefix&gt;maria&lt;\/prefix&gt;<br>&lt;library&gt;mysqltcl&lt;\/library&gt;<br>&lt;workloads&gt;TPC-C TPC-H&lt;\/workloads&gt;<br>mysql::sel mysqluse mysqlescape mysqlsel mysqlnext mysqlseek mysqlmap mysqlexec mysqlclose mysqlinfo mysqlresult mysqlcol mysqlstate mysqlinsertid mysqlquery mysqlendquery mysqlbaseinfo mysqlping mysqlchangeuser mysqlreceive<br><!--<span class=\"hiddenSpellError\" pre=\"\" data-mce-bogus=\"1\"-->mariadb&gt;<\/pre>\n<p>Then create an xml file with the name of the database, in this case mariadb.xml with values that will become the user defined variables in your workload.<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;<br>&lt;mariadb&gt;<br>&lt;connection&gt;<br>&lt;maria_host&gt;127.0.0.1&lt;\/maria_host&gt;<br>&lt;maria_port&gt;3306&lt;\/maria_port&gt;<br>&lt;\/connection&gt;<br>&lt;tpcc&gt;<br>&lt;schema&gt;<br>&lt;maria_count_ware&gt;1&lt;\/maria_count_ware&gt;<br>&lt;maria_num_vu&gt;1&lt;\/maria_num_vu&gt;<br>&lt;maria_user&gt;root&lt;\/maria_user&gt;<br>&lt;maria_pass&gt;mysql&lt;\/maria_pass&gt;<br>&lt;maria_dbase&gt;tpcc&lt;\/maria_dbase&gt;<br>&lt;maria_storage_engine&gt;innodb&lt;\/maria_storage_engine&gt;<br>&lt;maria_partition&gt;false&lt;\/maria_partition&gt;<br>&lt;\/schema&gt;<br>&lt;driver&gt;<br>...<\/pre>\n<p>As a test having created the config files and copied them to the binaries directory and run it we can see that MariaDB has been added as a database but cannot find the files that define the configuration and workloads, clearly this is&nbsp; because we have not created them yet!<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-475\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria1.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria1.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria1-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria1-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>If you run the CLI you will see the same message. However you can now set your database to MariaDB and print dict will show the variables you defined in the XML file.<\/p>\n<pre>~\/HammerDB-Fork\/HammerDB-3.2$ .\/hammerdbcli <br>HammerDB CLI v3.2<br>Copyright (C) 2003-2019 Steve Shaw<br>Type \"help\" for a list of commands<br>The xml is well-formed, applying configuration<br>Error loading database source files\/mariadb\/mariaopt.tcl<br>Error loading database source files\/mariadb\/mariaoltp.tcl<br>Error loading database source files\/mariadb\/mariaolap.tcl<br>Error loading database source files\/mariadb\/mariaotc.tcl<br>hammerdb&gt;dbset db maria<br>Database set to MariaDB<br><br>hammerdb&gt;print dict<br>Dictionary Settings for MariaDB<br>connection {<br>maria_host = 127.0.0.1<br>maria_port = 3306<br>}<br>tpcc {<br>maria_count_ware = 1<br>maria_num_vu = 1<br>maria_user = root<br>maria_pass = mysql<br>maria_dbase = tpcc<br>maria_storage_engine = innodb<br>maria_partition = false<br>maria_total_iterations = 1000000<br>maria_raiseerror = false<br>maria_keyandthink = false<br>maria_driver = test<br>maria_rampup = 2<br>maria_duration = 5<br>maria_allwarehouse = false<br>maria_timeprofile = false<br>}<\/pre>\n<p class=\"gh-header-title\"><span class=\"gh-header-number\">&nbsp;What you clearly&nbsp; need to do next is to create the directory named after your database and the required files of mariadb\/mariaopt.tcl&nbsp; for the graphical options screens, mariadb\/mariamet.tcl&nbsp; for metrics, <\/span>mariadb\/mariaoltp.tcl for the scripts for the TPC-C&nbsp; workloads, mariadb\/mariaolap.tcl for the TPC-H workloads and mariadb\/mariaotc.tcl for the online transaction counter.&nbsp; You then need to modify these files according to your needs.&nbsp; In this case as MariaDB is a fork of MySQL and the workloads are so close we are going to copy all of the required files from the MySQL directory, rename them and update the variable and procedure names from mysql to mariadb. <\/p>\n<p>A key feature is that the XML file where you defined the variables is stored as a dict structure with the prefix config and the name of your database. In this case configmariadb.&nbsp; It is this dict which you use in the scripts to fetch and update the variables.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-494\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria6.png\" alt=\"\" width=\"836\" height=\"173\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria6.png 836w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria6-300x62.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria6-768x159.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a>Starting with mariadb\/mariaopt.tcl we are setting the graphical options to interact with this dict.&nbsp; In this case the options are the same for MariaDB as they are for MySQL however will be different for different databases. Copying the modified source to the binary directories enables testing.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-482 aligncenter\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria2.png\" alt=\"\" width=\"447\" height=\"267\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria2.png 447w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria2-300x179.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/a><\/p>\n<p>After modifying the graphical options we can then update and test the TPC-C schema build and tests in mariadb\/mariaoltp.tcl. As well as ensuring we are using configmariadb and updating the variable names we also need to change the procedure names to include the prefix defined in the XML file, in this case maria. Therefore the following procedures will exist for the schema build, test and timed test scripts respectively.<\/p>\n<pre><span class=\"pl-k\">proc<\/span> <span class=\"pl-en\">build_mariatpcc<\/span><br><span class=\"pl-k\">proc<\/span> <span class=\"pl-en\">loadmariatpcc<\/span> <br><span class=\"pl-k\">proc<\/span> <span class=\"pl-en\">loadtimedmariatpcc<\/span> <\/pre>\n<p>Once these changes have been made we can test the schema build.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-483\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria3.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria3.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria3-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria3-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>and timed test.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-484\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria4.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria4.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria4-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria4-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>and the transaction counter is updated in mariadb\/mariaotc.tcl<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-485\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria5.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria5.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria5-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria5-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>Similarly we can update the TPC-H workload in mariadb\/mariaolap.tcl and then test the schema build.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-495\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria7.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria7.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria7-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria7-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a>and TPC-H query test<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-497\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria9.png\" alt=\"\" width=\"813\" height=\"644\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria9.png 813w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria9-300x238.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2019\/07\/maria9-768x608.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>At this point we have now created a new database under MariaDB but are running exactly the same schema builds and tests as the regular MySQL schemas. However this now gives us the opportunity to make the changes we want for MariaDB only such as adding PL\/SQL compatibility for the TPC-C workload or changes to support column stores for TPC-H. The important point is that&nbsp; we have added support for a completely new database and all of the code changes do not impact any of the other databases in any way.<\/p>\n<p>Note that if you do not want your database to appear as an option in HammerDB it can be commented out in the database.xml file.<\/p>\n<pre><!--<span class=\"hiddenSpellError\" pre=\"\" data-mce-bogus=\"1\">Trafodion<\/span> deprecated, uncomment to enable as unsupported--><br>&lt;trafodion&gt;<br>&lt;name&gt;Trafodion&lt;\/name&gt;<br>&lt;description&gt;Trafodion&lt;\/description&gt;<br>&lt;prefix&gt;traf&lt;\/prefix&gt;<br>tdbc::odbc<br>&lt;workloads&gt;TPC-C&lt;\/workloads&gt;<br>tdbc::odbc<br>&lt;\/trafodion&gt;<br>--&gt;<\/pre>\n\n\n","protected":false},"excerpt":{"rendered":"<p>From the previous post we now have source and binary copies of HammerDB for modification and test. The next step is to see if there is an Issue already created for the database we want to add or whether we should create one. In this example using MariaDB there is already an Issue created Add &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hammerdb.com\/blog\/uncategorized\/how-to-add-your-database-to-hammerdb-pt3-adding-to-and-modifying-the-source\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to add your database to HammerDB &#8211; Pt3 Adding to and modifying the source&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"ppma_author":[5],"class_list":["post-468","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"authors":[{"term_id":5,"user_id":2,"is_guest":0,"slug":"hammerdb","display_name":"HammerDB","avatar_url":{"url":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png","url2x":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png"},"author_category":"","user_url":"http:\/\/www.hammerdb.com","last_name":"","first_name":"","job_title":"","description":""}],"_links":{"self":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/comments?post=468"}],"version-history":[{"count":14,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/468\/revisions"}],"predecessor-version":[{"id":528,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/468\/revisions\/528"}],"wp:attachment":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/media?parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/categories?post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/tags?post=468"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}