00050 {
00051
const char *server_groups[] = {
"test_libmysqld_SERVER",
"embedded",
"server",NULL};
00052
00053
00054
00055
00056
00057
00058
00059 {
00060
int i;
00061
char *argv[10];
00062
char temp_path[1000];
00063 ::GetTempPath(1000, temp_path);
00064
00065
for (i = 0; i < 10; i++)
00066 argv[i] = NULL;
00067
00068 argv[0] =
new char[100];
00069 strcpy(argv[0],
"fd.exe");
00070 argv[1] =
new char[1000];
00071 sprintf(argv[1],
"--datadir=%s", temp_path);
00072 argv[2] =
new char[100];
00073 strcpy(argv[2],
"--language=.");
00074 argv[3] =
new char[100];
00075 strcpy(argv[3],
"--skip-innodb");
00076 argv[4] =
new char[100];
00077 strcpy(argv[4],
"--set-variable=key_buffer_size=8M");
00078 argv[5] =
new char[100];
00079 strcpy(argv[5],
"--set-variable=sort_buffer_size=1M");
00080
00081
int argc = 6;
00082
if (mysql_server_init(argc, argv, (
char **)server_groups))
00083 {
00084 ::MessageBox(NULL,
"mysql_server_init() failed",
"MySQL", MB_OK);
00085
return -1;
00086 }
00087
00088
00089
if (!mysql_thread_safe())
00090 {
00091 ::MessageBox(NULL,
"You are using a non thread safe libmysqld",
"Warning", MB_OK);
00092 }
00093
00094
00095
00096 {
00097
MyErrlog log;
00098 {
00099 Database db(
"fd",&log);
00100
if (!db.Connected())
00101 {
00102
00103 Database db(
"",&log);
00104 Query q(db);
00105
00106
if (!q.Connected())
00107 {
00108 ::MessageBox(NULL,
"Not connected",
"Query", MB_OK);
00109 }
00110
00111 q.execute(
"create database fd");
00112 q.execute(
"use fd");
00113
00114
00115 q.execute(
"CREATE TABLE category ("
00116
" num int(11) NOT NULL auto_increment,"
00117
" name varchar(255) default NULL,"
00118
" PRIMARY KEY (num)"
00119
") TYPE=MyISAM;");
00120
00121 q.execute(
"CREATE TABLE item ("
00122
" num int(11) NOT NULL auto_increment,"
00123
" typ enum('File','URL') NOT NULL default 'File',"
00124
" category int(11) NOT NULL default '0',"
00125
" name varchar(255),"
00126
" data mediumtext NOT NULL,"
00127
" sz integer,"
00128
" sha1 char(40),"
00129
" PRIMARY KEY (num),"
00130
" KEY typ (typ,category),"
00131
" KEY category (category),"
00132
" UNIQUE(sz,sha1)"
00133
") TYPE=MyISAM;");
00134
00135 q.execute(
"CREATE TABLE linkitemtag ("
00136
" item int(11) NOT NULL default '0',"
00137
" tag int(11) NOT NULL default '0',"
00138
" PRIMARY KEY (item,tag),"
00139
" KEY tag (tag)"
00140
") TYPE=MyISAM;");
00141
00142 q.execute(
"CREATE TABLE tag ("
00143
" num int(11) NOT NULL auto_increment,"
00144
" name varchar(255) default NULL,"
00145
" PRIMARY KEY (num)"
00146
") TYPE=MyISAM;");
00147
00148 }
00149 }
00150
00151 {
00152 Database db(
"fd", &log);
00153
00154 {
00155 Query q(db);
00156 }
00157
MyApp app(hInstance, hPrevInstance, db);
00158 app.
Init(lpCmdLine, nCmdShow);
00159 }
00160 }
00161 mysql_server_end();
00162
00163
00164
for (i = 0; i < 10; i++)
00165 {
00166
if (argv[i])
00167
delete[] argv[i];
00168 }
00169 }
00170
00171
return 0;
00172 }