// 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"); // Set an exclusive lock MYSQL_STMT *stmt_2 = mysql_stmt_init(sess_1); m_ret = mysql_stmt_attr_set(stmt_2,STMT_ATTR_CURSOR_TYPE,(const void *) &select_cursor); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_2); m_text = "SELECT table_name FROM table_locks WHERE table_name = 'tdbtst120280' FOR UPDATE"; m_ret = mysql_stmt_prepare(stmt_2,m_text,strlen(m_text)); M_EXPECT_EQUALS( 0,m_ret,STMT,stmt_2 ); m_ret = mysql_stmt_execute(stmt_2); M_EXPECT_EQUALS( 0,m_ret,STMT,stmt_2 ); m_ret = mysql_stmt_fetch(stmt_2); M_EXPECT_EQUALS( 0,m_ret,STMT,stmt_2 ); mysql_stmt_close(stmt_2); MYSQL *sess_2; sess_2 = mysql_init( NULL ); assert(sess_2); mysql_real_connect(sess_2, HOST_NAME, USER_NAME, USER_PWD, DB_NAME, 0, UNIX_SOCKET, 0); mysql_autocommit(sess_2, 0); mysql_query(sess_2, "SET SESSION sql_mode=ERROR_FOR_DIVISION_BY_ZERO"); mysql_query(sess_2, "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED"); MYSQL_STMT *stmt_3; stmt_3 = mysql_stmt_init(sess_2); m_ret = mysql_stmt_attr_set(stmt_3,STMT_ATTR_CURSOR_TYPE,(const void *) &select_cursor); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_text = "SELECT a0.t_empno FROM tdbtst120280 a0 WHERE a0.t_empno = ?"; m_ret = mysql_stmt_prepare(stmt_3,m_text,strlen(m_text)); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_count = mysql_stmt_param_count(stmt_3); 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(16, 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); null_1 = 0; len_1 = 0; *((int*)data_1) = 10; mysql_stmt_bind_param(stmt_3,param_1); m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_execute(stmt_3); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); mysql_stmt_bind_result(stmt_3,output_1); m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_fetch(stmt_3); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); m_expect = I(10); M_EXPECT_EQUALS(m_expect,m_output_to_valuelist( 1, output_1 ),STR,"Wrong row returned"); // Try to acquire a lock on the locked row MYSQL_STMT *stmt_5 = mysql_stmt_init(sess_2); m_ret = mysql_stmt_attr_set(stmt_5,STMT_ATTR_CURSOR_TYPE,(const void *) &select_cursor); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_5); m_text = "SELECT table_name FROM table_locks WHERE table_name = 'tdbtst120280' LOCK IN SHARE MODE"; m_ret = mysql_stmt_prepare(stmt_5,m_text,strlen(m_text)); M_EXPECT_EQUALS( 0,m_ret,STMT,stmt_5 ); m_ret = mysql_stmt_execute(stmt_5); M_EXPECT_EQUALS( 1,m_ret,STMT,stmt_5 ); m_ret = mysql_stmt_errno(stmt_5); M_EXPECT_EQUALS( 1205,m_ret,STMT,stmt_5 ); // Lock wait timeout exceeded; try restarting transaction mysql_stmt_close(stmt_5); // Continue fetching on the open cursor m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_stmt_fetch(stmt_3); M_EXPECT_EQUALS(100,m_ret,STMT,stmt_3); // On 5.0.14 0926 the previous fetch results in two warnings: // "Lock wait timeout exceeded; try restarting transaction" // "Unknown error" m_count = mysql_warning_count(sess_2); M_EXPECT_EQUALS(0,m_count,0,NULL); m_ret = mysql_rollback(sess_2); M_EXPECT_EQUALS(0,m_ret,SESS,sess_2); m_ret = mysql_rollback(sess_1); M_EXPECT_EQUALS(0,m_ret,SESS,sess_1); m_ret = mysql_stmt_free_result(stmt_3); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_ret = mysql_stmt_reset(stmt_3); M_EXPECT_EQUALS(0,m_ret,STMT,stmt_3); m_ret = mysql_stmt_close(stmt_3); M_EXPECT_EQUALS(0,m_ret,0,NULL); mysql_close(sess_2); mysql_close(sess_1); // ****** End of trace ****** } // Following code creates all tables needed to run this trace void create_table_locks( 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 `table_locks`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","DROP TABLE IF EXISTS `table_locks`;"); fprintf(fp,"%s\n","CREATE TABLE `table_locks` ("); fprintf(fp,"%s\n"," `table_name` char(12) collate latin1_bin NOT NULL,"); fprintf(fp,"%s\n"," PRIMARY KEY (`table_name`)"); 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 `table_locks`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `table_locks` DISABLE KEYS */;"); fprintf(fp,"%s\n","LOCK TABLES `table_locks` WRITE;"); fprintf(fp,"%s\n","INSERT INTO `table_locks` VALUES ('tdbcap000000'),('tdbcap000280'),('tdbcap000282'),('tdbcap001000'),('tdbcap001280'),('tdbcap001282'),('tdbcap002000'),('tdbcap002280'),('tdbcap002282'),('tdbcap003000'),('tdbcap003280'),('tdbcap003282'),('tdbtst100000'),('tdbtst100001'),('tdbtst100280'),('tdbtst100281'),('tdbtst100282'),('tdbtst100283'),('tdbtst106000'),('tdbtst106001'),('tdbtst106280'),('tdbtst106281'),('tdbtst106282'),('tdbtst106283'),('tdbtst107000'),('tdbtst107001'),('tdbtst107280'),('tdbtst107281'),('tdbtst107282'),('tdbtst107283'),('tdbtst120000'),('tdbtst120001'),('tdbtst120280'),('tdbtst120281'),('tdbtst120282'),('tdbtst120283'),('tdbtst146000'),('tdbtst146001'),('tdbtst146280'),('tdbtst146281'),('tdbtst146282'),('tdbtst146283'),('tdbtst160000'),('tdbtst160001'),('tdbtst160280'),('tdbtst160281'),('tdbtst160282'),('tdbtst160283'),('tdbtst161000'),('tdbtst161280'),('tdbtst161282'),('tdbtst180000'),('tdbtst180001'),('tdbtst180280'),('tdbtst180281'),('tdbtst180282'),('tdbtst180283'),('tdbtst190000'),('tdbtst190001'),('tdbtst190280'),('tdbtst190281'),('tdbtst190282'),('tdbtst190283'),('tdbtst200000'),('tdbtst200280'),('tdbtst200282'),('tdbtst201000'),('tdbtst201280'),('tdbtst201282'),('tdbtst202000'),('tdbtst202280'),('tdbtst202282'),('tdbtst206000'),('tdbtst206001'),('tdbtst206280'),('tdbtst206281'),('tdbtst206282'),('tdbtst206283'),('tdbtst220000'),('tdbtst220280'),('tdbtst220282'),('tdbtst230000'),('tdbtst230280'),('tdbtst230282'),('tdbtst555280'),('tdbtst555282'),('tdbtst600000'),('tdbtst600280'),('tdbtst600282'),('tdbtst601000'),('tdbtst610000'),('tdbtst610280'),('tdbtst610282'),('tdbtst611000'),('tdbtst611280'),('tdbtst611282'),('tdbtst612000'),('tdbtst612280'),('tdbtst612282'),('tdbtst999000'),('tdbtst999280'),('tdbtst999282'),('tdbtxt010000'),('tdbtxt010001'),('tdbtxt010280'),('tdbtxt010281'),('tdbtxt010282'),('tdbtxt010283'),('tttaud110000');"); fprintf(fp,"%s\n","UNLOCK TABLES;"); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `table_locks` 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_tdbtst120280( 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 `tdbtst120280`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","DROP TABLE IF EXISTS `tdbtst120280`;"); fprintf(fp,"%s\n","CREATE TABLE `tdbtst120280` ("); 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 `Itdbtst120280_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 `tdbtst120280`"); fprintf(fp,"%s\n","--"); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n",""); fprintf(fp,"%s\n","/*!40000 ALTER TABLE `tdbtst120280` DISABLE KEYS */;"); fprintf(fp,"%s\n","LOCK TABLES `tdbtst120280` WRITE;"); fprintf(fp,"%s\n","INSERT INTO `tdbtst120280` 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 `tdbtst120280` 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_table_locks(); create_tdbtst120280(); } #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"