// This cpp file is a generated trace that consists of the following "sections": // // - Connection parameters for mysql_real_connect: // - Helper functions // - The actual trace (marked by ****** Begin/End of trace ******) // - Functions to create and populate the necessary tables // - A dump of the current mysql variables // This cpp file should be compilable with: // gcc -g -I ${MYSQL_DIR}/include ${THIS_FILE} ${MYSQL_DIR}/lib/libmysqlclient.a -lm -lz -lstdc++ // To replay the trace you should have a database "baan", or you can change the // DB_NAME variable below. // You should also have two users: bsp/bsp, who has SELECT, INSERT, UPDATE, DELETE // privileges on all objects and baan/baan (the owner), who has ALL PRIVILEGES. // You may choose to use other users/passwords by changing the USER_*/OWNER_* // variables below. // You can connect to MySQL through TCP/IP by setting the HOST_NAME variable, or // you can use sockets by setting HOST_NAME to NULL and setting the right UNIX_SOCKET. // // The trace replays successfully if the program silently terminates with exit status 0. #include #include #include #include #include #include #include #include // Connection parameters const char *MYSQL_CMD = "mysql"; // Used for table creation const char *HOST_NAME = NULL; const char *USER_NAME = "bsp"; const char *USER_PWD = "bsp"; const char *DB_NAME = "baan"; const char *UNIX_SOCKET = "/var/lib/mysql/mysql.sock"; // For ddl statements we use a different user/pwd const char *OWNER_NAME = "baan"; const char *OWNER_PWD = "baan"; // use "#define M_EXPECT_EQUALS (void)" to disable data validation typedef enum { STR, SESS, STMT } ; #define M_EXPECT_EQUALS(X,Y,T,V) if ( X==Y ); else { \ cout << "!!! Error (" << __LINE__ << "): " << endl \ << " Expected value:" << X << endl \ << " Returned value:" << Y << endl; \ switch (T) { \ case STR : cout << " error: " << (const char *)V << endl; break;\ case SESS: cout << " mysql error: " << mysql_error((MYSQL*)V) << endl; break;\ case STMT: cout << " mysql error: " << mysql_stmt_error((MYSQL_STMT*)V) << endl; break;\ } \ assert( 0 ); \ } \ #include "mysql.h" using namespace std; const char *enum_str[7] = {"Nul","Int","Flt","Dbl","Str","Raw","Dtm"}; class Value { public: typedef enum { Nul , Int , Flt , Dbl , Str , Raw , Dtm } Type; Value( string S, Type T ) { _str = S; _type = T; } int Equals( const Value &V ) const { return _type == V._type && _str == V._str; } void toStream( ostream& s ) const { s << "[" << enum_str[_type] << "]\"" << _str << "\""; } private: string _str; Type _type; }; ostream& operator<< (ostream& s,const Value& v) { v.toStream(s); return s; } class ValueList { public: ValueList operator + (const ValueList& other) const { ValueList newList; list::const_iterator i; for ( i = this->_vals.begin(); i != this->_vals.end(); i++ ) newList._vals.push_back(*i); for ( i = other._vals.begin(); i != other._vals.end(); i++ ) newList._vals.push_back(*i); return newList; } void operator += (const ValueList& other) { list::const_iterator i; for ( i = other._vals.begin(); i != other._vals.end(); i++ ) _vals.push_back(*i); } int operator == ( const ValueList& Other ) const { list::const_iterator i1 = _vals.begin(); list::const_iterator i2 = Other._vals.begin(); while ( i1 != _vals.end() && i2 != Other._vals.end() && i1->Equals(*i2) ) i1++, i2++; return i1 == _vals.end() && i2 == Other._vals.end(); } void toStream( ostream &s ) const { list::const_iterator i; for ( i = _vals.begin(); i != _vals.end(); i++ ) { if ( i != _vals.begin() ) s << ","; s << *i; } } protected: list _vals; }; ostream& operator<< (ostream &s,const ValueList&vl) { vl.toStream(s); return s; } class Null : public ValueList { // The NULL value public: Null(void) { _vals.push_back(Value("",Value::Nul)); } }; class I : public ValueList { // An integer value public: I(int I) { ostringstream s; s << I; _vals.push_back(Value(s.str(),Value::Int)); } }; class F : public ValueList { // A float value public: F(double D) { char str[40]; sprintf(str,"%.7g",D); _vals.push_back(Value(string(str),Value::Flt)); } }; class D : public ValueList { // A double value public: D(double D) { char str[40]; sprintf(str,"%.15lg",D); _vals.push_back(Value(string(str),Value::Dbl)); } }; class S : public ValueList { // A string value public: S(string S) { _vals.push_back(Value(S,Value::Str)); } S(const char *S, int len) { int i; string s; for ( i=0; iis_null ) { l += Null(); } else switch ( mysql_bind->buffer_type ) { case MYSQL_TYPE_LONG: l += I(*((int*)(mysql_bind->buffer))); break; case MYSQL_TYPE_FLOAT: l += F(*((float*)(mysql_bind->buffer))); break; case MYSQL_TYPE_DOUBLE: l += D(*((double*)(mysql_bind->buffer))); break; case MYSQL_TYPE_VAR_STRING: l += S((char*)mysql_bind->buffer,*mysql_bind->length); break; case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATETIME: { MYSQL_TIME *t = (MYSQL_TIME*)mysql_bind->buffer; l += T(t->year,t->month,t->day,t->hour,t->minute,t->second); } break; default: assert( 0 ); // Error or type to be implemented } } return l; } void create_tables(void); // Global variables const char *m_text; int m_ret; int m_count; int m_err; MYSQL_RES *m_result; MYSQL_ROW m_row; ValueList m_expect; const unsigned long select_cursor = CURSOR_TYPE_READ_ONLY; const unsigned long update_cursor = CURSOR_TYPE_FOR_UPDATE; const unsigned long no_cursor = CURSOR_TYPE_NO_CURSOR; // Helper functions void set_bind_attrs( MYSQL_BIND *mysql_bind, enum_field_types ext_type, void *buf, int bufsz, unsigned long *act_len, my_bool *is_null ) { mysql_bind->buffer_type = ext_type; mysql_bind->buffer = buf; mysql_bind->length = act_len; mysql_bind->is_null = is_null; mysql_bind->buffer_length = bufsz; } void bind_time(void *ptr,int ye,int mo,int da,int ho,int mi,int se) { MYSQL_TIME t = {ye,mo,da,ho,mi,se}; memcpy(ptr,&t,sizeof(t)); } int main(void) { // Create the tables needed to run this trace create_tables(); // ****** Begin of trace ****** MYSQL *sess_1; sess_1 = mysql_init( NULL ); assert(sess_1); mysql_real_connect(sess_1, HOST_NAME, USER_NAME, USER_PWD, DB_NAME, 0, UNIX_SOCKET, 0); mysql_autocommit(sess_1, 0); mysql_query(sess_1, "SET SESSION sql_mode=ERROR_FOR_DIVISION_BY_ZERO"); mysql_query(sess_1, "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED"); MYSQL_STMT *stmt_1; stmt_1 = mysql_stmt_init(sess_1); m_ret = mysql_stmt_attr_set(stmt_1,STMT_ATTR_CURSOR_TYPE,(const void *) &select_cursor); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_text = "SELECT a0.t_empno,a0.t_firstnme,a0.t_midinit,a0.t_lastname,a0.t_workdept,a0.t_phoneno_1,a0.t_phoneno_2,a0.t_phoneno_3,a0.t_hiredate,a0.t_job,a0.t_edlevel,a0.t_sex,a0.t_birthdte,a0.t_salary,a0.t_bonus,0,a1.t_deptno,a1.t_deptname,a1.t_mgrno,a1.t_location,a1.t_admrdept,0 FROM ( tdbtst120000 AS a0 LEFT JOIN tdbtst100000 AS a1 ON a1.t_deptno = a0.t_workdept) WHERE a0.t_empno = ?"; m_ret = mysql_stmt_prepare(stmt_1,m_text,strlen(m_text)); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_count = mysql_stmt_param_count(stmt_1); M_EXPECT_EQUALS( 1, m_count, 0, NULL ); MYSQL_BIND *param_1 = (MYSQL_BIND *)calloc(1, sizeof(MYSQL_BIND)); MYSQL_BIND *output_1 = (MYSQL_BIND *)calloc(22, sizeof(MYSQL_BIND)); char data_1[4]; unsigned long len_1; my_bool null_1; set_bind_attrs(¶m_1[0],MYSQL_TYPE_LONG,&data_1,4,&len_1,&null_1); char data_2[4]; unsigned long len_2; my_bool null_2; set_bind_attrs(&output_1[0],MYSQL_TYPE_LONG,&data_2,4,&len_2,&null_2); char data_3[20]; unsigned long len_3; my_bool null_3; set_bind_attrs(&output_1[1],MYSQL_TYPE_VAR_STRING,&data_3,20,&len_3,&null_3); char data_4[20]; unsigned long len_4; my_bool null_4; set_bind_attrs(&output_1[2],MYSQL_TYPE_VAR_STRING,&data_4,20,&len_4,&null_4); char data_5[20]; unsigned long len_5; my_bool null_5; set_bind_attrs(&output_1[3],MYSQL_TYPE_VAR_STRING,&data_5,20,&len_5,&null_5); char data_6[6]; unsigned long len_6; my_bool null_6; set_bind_attrs(&output_1[4],MYSQL_TYPE_VAR_STRING,&data_6,6,&len_6,&null_6); char data_7[20]; unsigned long len_7; my_bool null_7; set_bind_attrs(&output_1[5],MYSQL_TYPE_VAR_STRING,&data_7,20,&len_7,&null_7); char data_8[20]; unsigned long len_8; my_bool null_8; set_bind_attrs(&output_1[6],MYSQL_TYPE_VAR_STRING,&data_8,20,&len_8,&null_8); char data_9[20]; unsigned long len_9; my_bool null_9; set_bind_attrs(&output_1[7],MYSQL_TYPE_VAR_STRING,&data_9,20,&len_9,&null_9); char data_10[sizeof(MYSQL_TIME)]; unsigned long len_10; my_bool null_10; set_bind_attrs(&output_1[8],MYSQL_TYPE_DATE,&data_10,36,&len_10,&null_10); char data_11[20]; unsigned long len_11; my_bool null_11; set_bind_attrs(&output_1[9],MYSQL_TYPE_VAR_STRING,&data_11,20,&len_11,&null_11); char data_12[4]; unsigned long len_12; my_bool null_12; set_bind_attrs(&output_1[10],MYSQL_TYPE_LONG,&data_12,4,&len_12,&null_12); char data_13[4]; unsigned long len_13; my_bool null_13; set_bind_attrs(&output_1[11],MYSQL_TYPE_LONG,&data_13,4,&len_13,&null_13); char data_14[sizeof(MYSQL_TIME)]; unsigned long len_14; my_bool null_14; set_bind_attrs(&output_1[12],MYSQL_TYPE_DATE,&data_14,36,&len_14,&null_14); char data_15[8]; unsigned long len_15; my_bool null_15; set_bind_attrs(&output_1[13],MYSQL_TYPE_DOUBLE,&data_15,8,&len_15,&null_15); char data_16[4]; unsigned long len_16; my_bool null_16; set_bind_attrs(&output_1[14],MYSQL_TYPE_FLOAT,&data_16,4,&len_16,&null_16); char data_17[4]; unsigned long len_17; my_bool null_17; set_bind_attrs(&output_1[15],MYSQL_TYPE_LONG,&data_17,4,&len_17,&null_17); char data_18[6]; unsigned long len_18; my_bool null_18; set_bind_attrs(&output_1[16],MYSQL_TYPE_VAR_STRING,&data_18,6,&len_18,&null_18); char data_19[20]; unsigned long len_19; my_bool null_19; set_bind_attrs(&output_1[17],MYSQL_TYPE_VAR_STRING,&data_19,20,&len_19,&null_19); char data_20[4]; unsigned long len_20; my_bool null_20; set_bind_attrs(&output_1[18],MYSQL_TYPE_LONG,&data_20,4,&len_20,&null_20); char data_21[20]; unsigned long len_21; my_bool null_21; set_bind_attrs(&output_1[19],MYSQL_TYPE_VAR_STRING,&data_21,20,&len_21,&null_21); char data_22[6]; unsigned long len_22; my_bool null_22; set_bind_attrs(&output_1[20],MYSQL_TYPE_VAR_STRING,&data_22,6,&len_22,&null_22); char data_23[4]; unsigned long len_23; my_bool null_23; set_bind_attrs(&output_1[21],MYSQL_TYPE_LONG,&data_23,4,&len_23,&null_23); null_1 = 0; len_1 = 0; *((int*)data_1) = 10; mysql_stmt_bind_param(stmt_1,param_1); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_execute(stmt_1); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); mysql_stmt_bind_result(stmt_1,output_1); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_fetch(stmt_1); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); m_expect = I(10)+S("CHRISTINE ")+S("I ")+S("HAAS ")+S("A00 ")+S("15972 ")+S("1218 ")+S("23548 ")+T(1965,1,1,0,0,0)+S("PRES ")+I(18)+I(2)+T(1933,8,24,0,0,0)+D(52750)+F(1000)+I(0)+S("A00 ")+S("SPIFFY COMPUTER SERV")+I(10)+S(" ")+S("A00 ")+I(0); M_EXPECT_EQUALS(m_expect,m_output_to_valuelist( 22, output_1 ),STR,"Wrong row returned"); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_fetch(stmt_1); M_EXPECT_EQUALS(100,m_ret,STMT,stmt_1); m_count = mysql_warning_count(sess_1); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_free_result(stmt_1); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_ret = mysql_stmt_reset(stmt_1); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_1); m_ret = mysql_stmt_close(stmt_1); M_EXPECT_EQUALS(0,m_ret,0,NULL); m_ret = mysql_rollback(sess_1); M_EXPECT_EQUALS(0,m_ret,SESS,sess_1); mysql_close(sess_1); // ****** End of trace ****** } // Following code creates all tables needed to run this trace void create_tdbtst100000( void ) { FILE *fp = fopen("/tmp/baan_table_dump","w"); fprintf(fp,"%s\n","-- MySQL dump 10.10"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Host: localhost Database: baan"); fprintf(fp,"%s\n","-- ------------------------------------------------------"); fprintf(fp,"%s\n","-- Server version\0115.0.14-rc-nightly-20050922"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"); fprintf(fp,"%s\n","/*!40101 SET NAMES utf8 */;"); fprintf(fp,"%s\n","/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;"); fprintf(fp,"%s\n","/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;"); fprintf(fp,"%s\n","/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Table structure for table `tdbtst100000`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","DROP TABLE IF EXISTS `tdbtst100000`;"); fprintf(fp,"%s\n","CREATE TABLE `tdbtst100000` ("); fprintf(fp,"%s\n"," `t_deptno` varchar(6) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_deptname` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_mgrno` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_location` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_admrdept` varchar(6) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_Refcntd` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_Refcntu` int(11) NOT NULL,"); fprintf(fp,"%s\n"," PRIMARY KEY (`t_deptno`)"); fprintf(fp,"%s\n",") ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Dumping data for table `tdbtst100000`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `tdbtst100000` DISABLE KEYS */;"); fprintf(fp,"%s\n","LOCK TABLES `tdbtst100000` WRITE;"); fprintf(fp,"%s\n","INSERT INTO `tdbtst100000` VALUES ('A00 ','SPIFFY COMPUTER SERV',10,' ','A00 ',0,0),('B01 ','PLANNING ',20,' ','A00 ',0,0),('C01 ','INFORMATION CENTER ',30,' ','A00 ',0,0),('D01 ','DEVELOPMENT CENTER ',0,' ','A00 ',0,0),('D11 ','MANUFACTURING SYSTEM',60,' ','D01 ',0,0),('D21 ','ADMINISTRATION SYSTE',70,' ','D01 ',0,0),('E01 ','SUPPORT SERVICES ',50,' ','A00 ',0,0),('E11 ','OPERATIONS ',90,' ','E01 ',0,0),('E21 ','SOFTWARE SUPPORT ',100,' ','E01 ',0,0);"); fprintf(fp,"%s\n","UNLOCK TABLES;"); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `tdbtst100000` ENABLE KEYS */;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;"); fprintf(fp,"%s\n","/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"); fprintf(fp,"%s\n","/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;"); fprintf(fp,"%s\n","/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;"); fprintf(fp,"%s\n","/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;"); fprintf(fp,"%s\n","/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"); fprintf(fp,"%s\n","/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); fprintf(fp,"%s\n",""); fclose(fp); string cmd = MYSQL_CMD; if ( OWNER_NAME ) cmd += string(" --user=") + OWNER_NAME; if ( OWNER_PWD ) cmd += string(" --password=") + OWNER_PWD; if ( HOST_NAME ) cmd += string(" --host=") + HOST_NAME; if ( UNIX_SOCKET ) cmd += string(" --socket=") + UNIX_SOCKET; cmd += string(" ") + DB_NAME; cmd += " < /tmp/baan_table_dump"; int ret = system(cmd.data()); if ( ret != 0 ) fprintf(stderr,"Command \"%s\" failed\n",cmd.data()); } void create_tdbtst120000( void ) { FILE *fp = fopen("/tmp/baan_table_dump","w"); fprintf(fp,"%s\n","-- MySQL dump 10.10"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Host: localhost Database: baan"); fprintf(fp,"%s\n","-- ------------------------------------------------------"); fprintf(fp,"%s\n","-- Server version\0115.0.14-rc-nightly-20050922"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"); fprintf(fp,"%s\n","/*!40101 SET NAMES utf8 */;"); fprintf(fp,"%s\n","/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;"); fprintf(fp,"%s\n","/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"); fprintf(fp,"%s\n","/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;"); fprintf(fp,"%s\n","/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Table structure for table `tdbtst120000`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","DROP TABLE IF EXISTS `tdbtst120000`;"); fprintf(fp,"%s\n","CREATE TABLE `tdbtst120000` ("); fprintf(fp,"%s\n"," `t_empno` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_firstnme` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_midinit` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_lastname` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_workdept` varchar(6) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_phoneno_1` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_phoneno_2` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_phoneno_3` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_hiredate` date NOT NULL,"); fprintf(fp,"%s\n"," `t_job` varchar(20) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," `t_edlevel` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_sex` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_birthdte` date NOT NULL,"); fprintf(fp,"%s\n"," `t_salary` double NOT NULL,"); fprintf(fp,"%s\n"," `t_bonus` float NOT NULL,"); fprintf(fp,"%s\n"," `t_Refcntd` int(11) NOT NULL,"); fprintf(fp,"%s\n"," `t_Refcntu` int(11) NOT NULL,"); fprintf(fp,"%s\n"," PRIMARY KEY (`t_empno`),"); fprintf(fp,"%s\n"," UNIQUE KEY `Itdbtst120000_2` (`t_workdept`,`t_empno`)"); fprintf(fp,"%s\n",") ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n","-- Dumping data for table `tdbtst120000`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `tdbtst120000` DISABLE KEYS */;"); fprintf(fp,"%s\n","LOCK TABLES `tdbtst120000` WRITE;"); fprintf(fp,"%s\n","INSERT INTO `tdbtst120000` VALUES (10,'CHRISTINE ','I ','HAAS ','A00 ','15972 ','1218 ','23548 ','1965-01-01','PRES ',18,2,'1933-08-24',52750,1000,0,0),(20,'MICHAEL ','L ','THOMPSON ','B01 ','5164 ','27599 ','25190 ','1973-10-10','MANAGER ',18,1,'1948-02-02',41250,800,0,0),(30,'SALLY ','A ','KWAN ','C01 ','9478 ','19968 ','2310 ','1975-04-05','MANAGER ',20,2,'1941-05-11',38250,800,0,0),(50,'JOHN ','B ','GEYER ','E01 ','4375 ','22823 ','14762 ','1949-08-17','MANAGER ',16,1,'1925-09-15',40175,800,0,0),(60,'IRVING ','F ','STERN ','D11 ','1028 ','23402 ','2418 ','1973-09-14','MANAGER ',16,1,'1945-07-07',32250,500,0,0),(70,'EVA ','D ','PULASKI ','D21 ','19520 ','22171 ','32503 ','1980-09-30','MANAGER ',16,2,'1953-05-26',36170,700,0,0),(90,'EILEEN ','W ','HENDERSON ','E11 ','6933 ','27989 ','3896 ','1970-08-15','MANAGER ',16,2,'1941-05-15',29750,600,0,0),(100,'THEODORE ','Q ','SPENSER ','E21 ','14707 ','1498 ','32072 ','1980-06-19','MANAGER ',14,1,'1956-12-18',26150,500,0,0),(110,'VINCENZO ','G ','LUCCHESSI ','A00 ','15740 ','16047 ','2234 ','1958-05-16','SALESREP ',19,1,'1929-11-05',46500,900,0,0),(120,'SEAN ',' ','O\\'CONNELL ','A00 ','3275 ','4340 ','5832 ','1963-12-05','CLERK ',14,1,'1942-10-18',29250,600,0,0),(130,'DOLORES ','M ','QUINTANA ','C01 ','14216 ','15493 ','16966 ','1971-07-28','ANALYST ',16,2,'1925-09-15',23800,500,0,0),(140,'HEATHER ','A ','NICHOLLS ','C01 ','30764 ','22995 ','32329 ','1976-12-15','ANALYST ',18,2,'1946-01-19',28420,600,0,0),(150,'BRUCE ',' ','ADAMSON ','D11 ','25621 ','11648 ','14230 ','1972-02-12','DESIGNER ',16,1,'1947-05-17',25280,500,0,0),(160,'ELIZABETH ','R ','PIANKA ','D11 ','6345 ','6588 ','8396 ','1977-10-11','DESIGNER ',17,2,'1955-04-12',22250,400,0,0),(170,'MASATOSHI ','J ','YOSHIMURA ','D11 ','29194 ','18786 ','5457 ','1978-09-15','DESIGNER ',16,1,'1951-01-05',24680,500,0,0),(180,'MARILYN ','S ','SCOUTTEN ','D11 ','5278 ','28881 ','16126 ','1973-07-07','DESIGNER ',17,2,'1949-02-21',21340,500,0,0),(190,'JAMES ','H ','WALKER ','D11 ','23003 ','16523 ','27274 ','1974-07-26','DESIGNER ',16,1,'1952-06-25',20450,400,0,0),(200,'DAVID ',' ','BROWN ','D11 ','26612 ','26000 ','14007 ','1966-03-03','DESIGNER ',16,1,'1941-05-29',27740,600,0,0),(210,'WILLIAM ','T ','JONES ','D11 ','774 ','13176 ','2622 ','1979-04-11','DESIGNER ',17,1,'1953-02-23',18270,400,0,0),(220,'JENNIFER ','K ','LUTZ ','D11 ','25314 ','21587 ','31867 ','1968-08-29','DESIGNER ',18,2,'1948-03-19',29840,600,0,0),(230,'JAMES ','J ','JEFFERSON ','D21 ','6552 ','6721 ','7385 ','1966-11-21','CLERK ',14,1,'1935-05-30',22180,400,0,0),(240,'SALVATORE ','M ','MARINO ','D21 ','22216 ','20176 ','17659 ','1979-12-05','CLERK ',17,1,'1954-03-31',28760,600,0,0),(250,'DANIEL ','S ','SMITH ','D21 ','5032 ','7192 ','25007 ','1969-10-30','CLERK ',15,1,'1939-12-12',19180,400,0,0),(260,'SYBIL ','P ','JOHNSON ','D21 ','29652 ','27544 ','24212 ','1975-09-11','CLERK ',16,2,'1936-10-05',17250,300,0,0),(270,'MARIA ','L ','PEREZ ','D21 ','26329 ','22223 ','8325 ','1980-09-30','CLERK ',15,2,'1953-05-26',27380,500,0,0),(280,'ETHEL ','R ','SCHNEIDER ','E11 ','22144 ','1434 ','15052 ','1967-03-24','OPERATOR ',17,2,'1936-03-28',26250,500,0,0),(290,'JOHN ','R ','PARKER ','E11 ','28122 ','5712 ','19208 ','1980-05-30','OPERATOR ',12,1,'1946-07-09',15340,300,0,0),(300,'PHILIP ','X ','SMITH ','E11 ','17680 ','27551 ','10202 ','1972-06-19','OPERATOR ',14,1,'1936-10-27',17750,400,0,0),(310,'MAUDE ','F ','SETRIGHT ','E11 ','32231 ','31781 ','20050 ','1964-09-12','OPERATOR ',12,2,'1931-04-21',15900,300,0,0),(320,'RAMLAL ','V ','MEHTA ','E21 ','7446 ','32718 ','14876 ','1965-07-07','FIELDREP ',16,1,'1932-08-11',19950,400,0,0),(330,'WING ',' ','LEE ','E21 ','11336 ','5872 ','5226 ','1000-01-01','FIELDREP ',14,1,'1941-07-18',25370,500,0,0),(340,'JASON ','R ','GOUNOT ','E21 ','28911 ','18216 ','26017 ','1947-05-05','FIELDREP ',16,1,'1926-05-17',23840,500,0,0);"); fprintf(fp,"%s\n","UNLOCK TABLES;"); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `tdbtst120000` ENABLE KEYS */;"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;"); fprintf(fp,"%s\n","/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"); fprintf(fp,"%s\n","/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;"); fprintf(fp,"%s\n","/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;"); fprintf(fp,"%s\n","/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;"); fprintf(fp,"%s\n","/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"); fprintf(fp,"%s\n","/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); fprintf(fp,"%s\n",""); fclose(fp); string cmd = MYSQL_CMD; if ( OWNER_NAME ) cmd += string(" --user=") + OWNER_NAME; if ( OWNER_PWD ) cmd += string(" --password=") + OWNER_PWD; if ( HOST_NAME ) cmd += string(" --host=") + HOST_NAME; if ( UNIX_SOCKET ) cmd += string(" --socket=") + UNIX_SOCKET; cmd += string(" ") + DB_NAME; cmd += " < /tmp/baan_table_dump"; int ret = system(cmd.data()); if ( ret != 0 ) fprintf(stderr,"Command \"%s\" failed\n",cmd.data()); } void create_tables( void ) { create_tdbtst100000(); create_tdbtst120000(); } #if 0 // Output of "show variables" # # Variable_name Value # auto_increment_increment 1 # auto_increment_offset 1 # automatic_sp_privileges ON # back_log 50 # basedir /usr1/mysql/mysql-5.0.14-rc-nightly-20050922-linux-i686/ # binlog_cache_size 32768 # bulk_insert_buffer_size 8388608 # character_set_client latin1 # character_set_connection latin1 # character_set_database latin1 # character_set_results latin1 # character_set_server latin1 # character_set_system utf8 # character_sets_dir /usr1/mysql/mysql-5.0.14-rc-nightly-20050922-linux-i686/share/mysql/charsets/ # collation_connection latin1_swedish_ci # collation_database latin1_swedish_ci # collation_server latin1_swedish_ci # completion_type 0 # concurrent_insert 1 # connect_timeout 5 # datadir /usr1/mysql/mysql-5.0.14-rc-nightly-20050922-linux-i686/data/ # date_format %Y-%m-%d # datetime_format %Y-%m-%d %H:%i:%s # default_week_format 0 # delay_key_write ON # delayed_insert_limit 100 # delayed_insert_timeout 300 # delayed_queue_size 1000 # div_precision_increment 4 # engine_condition_pushdown OFF # expire_logs_days 0 # flush OFF # flush_time 0 # ft_boolean_syntax + -><()~*:""&| # ft_max_word_len 84 # ft_min_word_len 4 # ft_query_expansion_limit 20 # ft_stopword_file (built-in) # group_concat_max_len 1024 # have_archive NO # have_bdb NO # have_blackhole_engine NO # have_compress YES # have_crypt YES # have_csv NO # have_example_engine NO # have_federated_engine NO # have_geometry YES # have_innodb YES # have_isam NO # have_ndbcluster NO # have_openssl NO # have_query_cache YES # have_raid NO # have_rtree_keys YES # have_symlink YES # init_connect # init_file # init_slave # innodb_additional_mem_pool_size 1048576 # innodb_autoextend_increment 8 # innodb_buffer_pool_awe_mem_mb 0 # innodb_buffer_pool_size 8388608 # innodb_checksums ON # innodb_commit_concurrency 0 # innodb_concurrency_tickets 500 # innodb_data_file_path ibdata1:10M:autoextend # innodb_data_home_dir # innodb_doublewrite ON # innodb_fast_shutdown 1 # innodb_file_io_threads 4 # innodb_file_per_table OFF # innodb_flush_log_at_trx_commit 1 # innodb_flush_method # innodb_force_recovery 0 # innodb_lock_wait_timeout 2 # innodb_locks_unsafe_for_binlog OFF # innodb_log_arch_dir # innodb_log_archive OFF # innodb_log_buffer_size 1048576 # innodb_log_file_size 5242880 # innodb_log_files_in_group 2 # innodb_log_group_home_dir ./ # innodb_max_dirty_pages_pct 90 # innodb_max_purge_lag 0 # innodb_mirrored_log_groups 1 # innodb_open_files 300 # innodb_support_xa ON # innodb_sync_spin_loops 20 # innodb_table_locks ON # innodb_thread_concurrency 20 # innodb_thread_sleep_delay 10000 # interactive_timeout 28800 # join_buffer_size 131072 # key_buffer_size 16777216 # key_cache_age_threshold 300 # key_cache_block_size 1024 # key_cache_division_limit 100 # language /usr1/mysql/mysql-5.0.14-rc-nightly-20050922-linux-i686/share/mysql/english/ # large_files_support ON # large_page_size 0 # large_pages OFF # license GPL # local_infile ON # locked_in_memory OFF # log OFF # log_bin OFF # log_bin_trust_routine_creators OFF # log_error # log_slave_updates OFF # log_slow_queries OFF # log_warnings 1 # long_query_time 10 # low_priority_updates OFF # lower_case_file_system OFF # lower_case_table_names 0 # max_allowed_packet 1047552 # max_binlog_cache_size 4294967295 # max_binlog_size 1073741824 # max_connect_errors 10 # max_connections 100 # max_delayed_threads 20 # max_error_count 64 # max_heap_table_size 16777216 # max_insert_delayed_threads 20 # max_join_size 4294967295 # max_length_for_sort_data 1024 # max_relay_log_size 0 # max_seeks_for_key 4294967295 # max_sort_length 1024 # max_tmp_tables 32 # max_user_connections 0 # max_write_lock_count 4294967295 # multi_range_count 256 # myisam_data_pointer_size 6 # myisam_max_sort_file_size 2147483647 # myisam_recover_options OFF # myisam_repair_threads 1 # myisam_sort_buffer_size 8388608 # myisam_stats_method nulls_inequal # net_buffer_length 8192 # net_read_timeout 30 # net_retry_count 10 # net_write_timeout 60 # new OFF # old_passwords OFF # open_files_limit 1024 # optimizer_prune_level 1 # optimizer_search_depth 62 # pid_file /usr1/mysql/mysql-5.0.14-rc-nightly-20050922-linux-i686/data/nlbaldev1.pid # port 3306 # preload_buffer_size 32768 # protocol_version 10 # query_alloc_block_size 8192 # query_cache_limit 1048576 # query_cache_min_res_unit 4096 # query_cache_size 0 # query_cache_type ON # query_cache_wlock_invalidate OFF # query_prealloc_size 8192 # range_alloc_block_size 2048 # read_buffer_size 131072 # read_only OFF # read_rnd_buffer_size 262144 # relay_log_purge ON # relay_log_space_limit 0 # rpl_recovery_rank 0 # secure_auth OFF # server_id 1 # skip_external_locking ON # skip_networking OFF # skip_show_database OFF # slave_compressed_protocol OFF # slave_load_tmpdir /tmp/ # slave_net_timeout 3600 # slave_skip_errors OFF # slave_transaction_retries 10 # slow_launch_time 2 # socket /var/lib/mysql/mysql.sock # sort_buffer_size 524280 # sql_mode # sql_notes ON # sql_warnings ON # storage_engine MyISAM # sync_binlog 0 # sync_frm ON # sync_replication 0 # sync_replication_slave_id 0 # sync_replication_timeout 10 # system_time_zone CEST # table_cache 64 # table_lock_wait_timeout 50 # table_type MyISAM # thread_cache_size 0 # thread_stack 196608 # time_format %H:%i:%s # time_zone SYSTEM # timed_mutexes OFF # tmp_table_size 33554432 # tmpdir # transaction_alloc_block_size 8192 # transaction_prealloc_size 4096 # tx_isolation REPEATABLE-READ # updatable_views_with_limit YES # version 5.0.14-rc-nightly-20050922 # version_comment Source distribution # version_compile_machine i686 # version_compile_os pc-linux-gnu # wait_timeout 28800 # #endif // Output of "show variables"