From a175314c3e5827eb193872241446f2f8f5c9d33c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 20:07:14 +0200 Subject: Adding upstream version 1:10.5.12. Signed-off-by: Daniel Baumann --- libmysqld/examples/CMakeLists.txt | 63 +++++ libmysqld/examples/builder-sample/emb_sample.bpr | 208 ++++++++++++++ libmysqld/examples/builder-sample/emb_sample.cpp | 39 +++ libmysqld/examples/builder-sample/emb_samples.cpp | 300 +++++++++++++++++++++ libmysqld/examples/builder-sample/emb_samples.dfm | Bin 0 -> 15895 bytes libmysqld/examples/builder-sample/emb_samples.h | 77 ++++++ libmysqld/examples/builder-sample/images/db.ico | Bin 0 -> 318 bytes libmysqld/examples/builder-sample/images/find.ico | Bin 0 -> 766 bytes libmysqld/examples/builder-sample/images/logo.ico | Bin 0 -> 2022 bytes libmysqld/examples/builder-sample/images/mysql.bmp | Bin 0 -> 8760 bytes libmysqld/examples/builder-sample/images/net.ico | Bin 0 -> 766 bytes libmysqld/examples/builder-sample/snapshot.jpg | Bin 0 -> 36274 bytes libmysqld/examples/test-run | 154 +++++++++++ 13 files changed, 841 insertions(+) create mode 100644 libmysqld/examples/CMakeLists.txt create mode 100644 libmysqld/examples/builder-sample/emb_sample.bpr create mode 100644 libmysqld/examples/builder-sample/emb_sample.cpp create mode 100644 libmysqld/examples/builder-sample/emb_samples.cpp create mode 100644 libmysqld/examples/builder-sample/emb_samples.dfm create mode 100644 libmysqld/examples/builder-sample/emb_samples.h create mode 100644 libmysqld/examples/builder-sample/images/db.ico create mode 100644 libmysqld/examples/builder-sample/images/find.ico create mode 100644 libmysqld/examples/builder-sample/images/logo.ico create mode 100644 libmysqld/examples/builder-sample/images/mysql.bmp create mode 100644 libmysqld/examples/builder-sample/images/net.ico create mode 100644 libmysqld/examples/builder-sample/snapshot.jpg create mode 100755 libmysqld/examples/test-run (limited to 'libmysqld/examples') diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt new file mode 100644 index 00000000..2a10def8 --- /dev/null +++ b/libmysqld/examples/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/libmysqld/include + ${PCRE_INCLUDES} + ${CMAKE_SOURCE_DIR}/sql + ${MY_READLINE_INCLUDE_DIR} + ) + + +ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT) + + +MYSQL_ADD_EXECUTABLE(mariadb-embedded ../../client/completion_hash.cc + ../../client/mysql.cc ../../client/readline.cc + COMPONENT Client) +TARGET_LINK_LIBRARIES(mariadb-embedded mysqlserver) +IF(UNIX) + TARGET_LINK_LIBRARIES(mariadb-embedded ${MY_READLINE_LIBRARY}) +ENDIF(UNIX) + +MYSQL_ADD_EXECUTABLE(mariadb-test-embedded ../../client/mysqltest.cc + COMPONENT Test) +TARGET_LINK_LIBRARIES(mariadb-test-embedded mysqlserver pcre2-posix pcre2-8) +SET_SOURCE_FILES_PROPERTIES(../../client/mysqltest.cc PROPERTIES COMPILE_FLAGS "${PCRE2_DEBIAN_HACK}") + +IF(CMAKE_GENERATOR MATCHES "Xcode") +# It does not seem possible to tell Xcode the resulting target might need +# to be linked with C++ runtime. The project needs to have at least one C++ +# file. Add a dummy one. + ADD_CUSTOM_COMMAND(OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc + ) + MYSQL_ADD_EXECUTABLE(mariadb-client-test-embedded + ${CMAKE_CURRENT_BINARY_DIR}/mysql_client_test_embedded_dummy.cc + ../../tests/mysql_client_test.c) +ELSE() + MYSQL_ADD_EXECUTABLE(mariadb-client-test-embedded ../../tests/mysql_client_test.c + COMPONENT Test) + SET_TARGET_PROPERTIES(mariadb-client-test-embedded PROPERTIES HAS_CXX TRUE) +ENDIF() +TARGET_LINK_LIBRARIES(mariadb-client-test-embedded mysqlserver) + +IF(UNIX) +SET_TARGET_PROPERTIES(mariadb-embedded PROPERTIES ENABLE_EXPORTS TRUE) +SET_TARGET_PROPERTIES(mariadb-test-embedded PROPERTIES ENABLE_EXPORTS TRUE) +SET_TARGET_PROPERTIES(mariadb-client-test-embedded PROPERTIES ENABLE_EXPORTS TRUE) +ENDIF() diff --git a/libmysqld/examples/builder-sample/emb_sample.bpr b/libmysqld/examples/builder-sample/emb_sample.bpr new file mode 100644 index 00000000..ab66dce8 --- /dev/null +++ b/libmysqld/examples/builder-sample/emb_sample.bpr @@ -0,0 +1,208 @@ +# Copyright (c) 2002 MySQL AB +# Use is subject to license terms. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = emb_sample.exe +OBJFILES = emb_sample.obj emb_samples.obj +RESFILES = emb_sample.res +RESDEPEN = $(RESFILES) emb_samples.dfm +LIBFILES = libmysqld.lib +LIBRARIES = +SPARELIBS = Vcl40.lib +PACKAGES = Vcl40.bpi Vclx40.bpi vcljpg40.bpi bcbsmp40.bpi Qrpt40.bpi Vcldb40.bpi \ + ibsmp40.bpi vcldbx40.bpi TeeUI40.bpi teedb40.bpi tee40.bpi nmfast40.bpi \ + dclocx40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl;..\..\..\include -Od -Hc \ + -H=$(BCB)\lib\vcl40.csm -w -Ve -r- -a8 -k -y -v -vi- -c -b- -w-par -w-inl -Vx \ + -tW -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl;..\..\..\include -$YD -$W -$O- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl;..\..\..\include +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /i..\..\..\include /mx /w2 /zd +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpe -x -Gn -v +# --------------------------------------------------------------------------- +ALLOBJ = c0w32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1046 +CodePage=1252 + +[Version Info Keys] +CompanyName=MySQL AB +FileDescription=Embedded Server Sample +FileVersion=1.0.0.0 +InternalName=Builder Embedded Server Sample +LegalCopyright=GNU +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\include;$(BCB)\include\vcl;..\..\..\include +Item1=$(BCB)\include;$(BCB)\include\vcl;..\..\..\inluce + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/libmysqld/examples/builder-sample/emb_sample.cpp b/libmysqld/examples/builder-sample/emb_sample.cpp new file mode 100644 index 00000000..61b867c9 --- /dev/null +++ b/libmysqld/examples/builder-sample/emb_sample.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2002 MySQL AB +// Use is subject to license terms. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("emb_sample.res"); +USEFORM("emb_samples.cpp", Form1); +USELIB("libmysqld.lib"); +//--------------------------------------------------------------------------- +WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + try + { + Application->Initialize(); + Application->Title = "MySQL Embedded Server Sample"; + Application->CreateForm(__classid(TForm1), &Form1); + Application->Run(); + } + catch (Exception &exception) + { + Application->ShowException(&exception); + } + return 0; +} +//--------------------------------------------------------------------------- diff --git a/libmysqld/examples/builder-sample/emb_samples.cpp b/libmysqld/examples/builder-sample/emb_samples.cpp new file mode 100644 index 00000000..94787d58 --- /dev/null +++ b/libmysqld/examples/builder-sample/emb_samples.cpp @@ -0,0 +1,300 @@ +// Copyright (c) 2002, 2004, 2007 MySQL AB +// Use is subject to license terms. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +//--------------------------------------------------------------------------- +#include +#pragma hdrstop + +#include "emb_samples.h" +#include +#include +#include +#include +#include +#include +#include +bool b_new_line = false; +const char *server_groups[] = { + "", "embedded", "server", NULL +}; +MYSQL *MySQL; +deque fill_rows(MYSQL_RES *res); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +#pragma resource "*.dfm" +TForm1 *Form1; +//--------------------------------------------------------------------------- +deque fill_rows(MYSQL_RES *res) +{ + MYSQL_ROW row; + deque rows; + + while ((row=mysql_fetch_row(res)) != 0) + { + mysql_field_seek(res,0); + for (unsigned int i=0 ; i < mysql_num_fields(res); i++) + rows.push_back(row[i]); + } + return rows; +} +//--------------------------------------------------------------------------- +__fastcall TForm1::TForm1(TComponent* Owner) + : TForm(Owner) +{ +} +//--------------------------------------------------------------------------- + +void __fastcall TForm1::Timer1Timer(TObject *Sender) +{ + if (is_server_started) + { + ToggleButton->Caption = "Quit"; + Timer1->Enabled = false; + } +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::FormCreate(TObject *Sender) +{ + is_server_started = false; + computer_ip(); /* get the computer name and IP number */ + /* init the tree database screen */ + db_root = DBView->Items->Add(NULL, db_root_caption.UpperCase()); + db_root->ImageIndex = 0; +} +//--------------------------------------------------------------------------- +/* button which handle the init of mysql server or quit the app */ +void __fastcall TForm1::ToggleButtonClick(TObject *Sender) +{ + if (!is_server_started) + { + mysql_server_init(NULL, NULL, (char **)server_groups) ; + connect_server(); + get_dbs(); + } + else + { + mysql_server_end(); + Close(); + } +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::computer_ip(void) +{ + WORD wVersionRequested; + WSADATA WSAData; + wVersionRequested = MAKEWORD(1,1); + WSAStartup(wVersionRequested,&WSAData); + hostent *P; + char s[128]; + in_addr in; + char *P2; + + gethostname(s, 128); + P = gethostbyname(s); + db_root_caption = P->h_name; + in.S_un.S_un_b.s_b1 = P->h_addr_list[0][0]; + in.S_un.S_un_b.s_b2 = P->h_addr_list[0][1]; + in.S_un.S_un_b.s_b3 = P->h_addr_list[0][2]; + in.S_un.S_un_b.s_b4 = P->h_addr_list[0][3]; + P2 = inet_ntoa(in); + db_root_caption += " ( " + (AnsiString)P2 + " )"; +} +//--------------------------------------------------------------------------- +bool __fastcall TForm1::connect_server() +{ + bool ret_value = false; + + MySQL = mysql_init(MySQL); + if (!MySQL) + return ret_value; + if (mysql_real_connect(MySQL, NULL, NULL, NULL, NULL, 0, NULL, 0)) + { + ret_value = true; + is_server_started = true; + } + MySQL->reconnect= 1; + return ret_value; +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::FormDestroy(TObject *Sender) +{ + if (is_server_started) + mysql_server_end(); +} +//--------------------------------------------------------------------------- + +void __fastcall TForm1::DBViewClick(TObject *Sender) +{ + if (DBView->Selected != db_root && DBView->Selected != NULL) + { + get_tables(DBView->Selected->Text); + clean_desc_grid(); + } +} +//--------------------------------------------------------------------------- +bool __fastcall TForm1::get_tables(String db_name) +{ + MYSQL_RES *res; + AnsiString s_cmd; + + TableView->Items->Clear(); + s_cmd = "use "; + s_cmd+= db_name.c_str(); + + if (mysql_query(MySQL, s_cmd.c_str()) || + !(res=mysql_list_tables(MySQL,"%"))) + return false; + + tables_node = TableView->Items->Add(NULL, db_name.c_str()); + tables_node->ImageIndex = 1; + tables_node->SelectedIndex = 1; + + deque rows = fill_rows(res); + + mysql_free_result(res); + fill_tree(rows,tables_tree,tables_node,TableView,2); + + return true; +} +//--------------------------------------------------------------------------- +bool __fastcall TForm1::get_dbs(void) +{ + MYSQL_RES *res; + + if (!is_server_started) + return false; + + if (!(res=mysql_list_dbs(MySQL,"%"))) + return false; + + deque rows = fill_rows(res); + + mysql_free_result(res); + fill_tree(rows,MySQLDbs,db_root,DBView,1); + info_server->Text = mysql_get_server_info(MySQL); + + return true; +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::fill_tree(deque rows, + TTreeNode *root, + TTreeNode *child, + TTreeView *View, + int image_index) +{ + deque::iterator r; + for(r = rows.begin(); r != rows.end() ; r++) + { + root = View->Items->AddChild(child, (*r).c_str()); + root->ImageIndex = image_index; + root->SelectedIndex = image_index; + } + child->Expanded = true; +} +//--------------------------------------------------------------------------- +bool __fastcall TForm1::get_desc_table(String table_name) +{ + MYSQL_RES *res, *res1; + MYSQL_ROW row; + AnsiString use_db, show_cols, show_desc; + unsigned int num_fields; + int fields_control = 0, grid_row = 1, fields_number; + b_new_line= true; + + clean_desc_grid(); + use_db = "use "; + use_db+= DBView->Selected->Text.c_str(); + show_desc = "desc "; + show_cols = "show full columns from "; + show_cols+= table_name.c_str(); + show_desc+= table_name.c_str(); + + if (mysql_query(MySQL, use_db.c_str() )) + return false; + + if (mysql_query(MySQL, show_cols.c_str() ) || + !(res1=mysql_store_result(MySQL))) + { + if (mysql_query(MySQL, show_desc.c_str() ) || + !(res1=mysql_store_result(MySQL))) + return false ; + } + mysql_fetch_row(res1); + mysql_field_seek(res1,0); + fields_number = (mysql_num_fields(res1) - 2); + mysql_free_result(res1); + + if (mysql_query(MySQL, show_cols.c_str() ) || + !(res=mysql_store_result(MySQL))) + { + if (mysql_query(MySQL, show_desc.c_str() ) || + !(res=mysql_store_result(MySQL))) + return false ; + } + titles_grid(); + while ((row=mysql_fetch_row(res)) != 0) + { + mysql_field_seek(res,0); + for (num_fields=0 ; num_fields < mysql_num_fields(res); num_fields++) + { + if (fields_control <= fields_number ) + { + desc_table_grid->Cells[fields_control][grid_row] = row[num_fields]; + fields_control++; + } + else + { + desc_table_grid->Cells[(fields_control)][grid_row] = row[num_fields]; + fields_control = 0; + grid_row++ ; + desc_table_grid->RowCount++; + } + } + } + desc_table_grid->RowCount--; + mysql_free_result(res); + return true; +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::TableViewClick(TObject *Sender) +{ + if (DBView->Selected != db_root && DBView->Selected != NULL) + if (DBView->Selected != tables_tree) + get_desc_table(TableView->Selected->Text); +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::clean_desc_grid(void) +{ + desc_table_grid->RowCount= 2; + desc_table_grid->Cells[0][1] = ""; + desc_table_grid->Cells[1][1] = ""; + desc_table_grid->Cells[2][1] = ""; + desc_table_grid->Cells[3][1] = ""; + desc_table_grid->Cells[4][1] = ""; + desc_table_grid->Cells[5][1] = ""; +} +//--------------------------------------------------------------------------- +void __fastcall TForm1::titles_grid(void) +{ + desc_table_grid->Cells[0][0] = "Field"; + desc_table_grid->Cells[1][0] = "Type"; + desc_table_grid->Cells[2][0] = "Null"; + desc_table_grid->Cells[3][0] = "Key"; + desc_table_grid->Cells[4][0] = "Default"; + desc_table_grid->Cells[5][0] = "Extra"; + desc_table_grid->Cells[6][0] = "Privileges"; +} + diff --git a/libmysqld/examples/builder-sample/emb_samples.dfm b/libmysqld/examples/builder-sample/emb_samples.dfm new file mode 100644 index 00000000..399509ee Binary files /dev/null and b/libmysqld/examples/builder-sample/emb_samples.dfm differ diff --git a/libmysqld/examples/builder-sample/emb_samples.h b/libmysqld/examples/builder-sample/emb_samples.h new file mode 100644 index 00000000..310f051a --- /dev/null +++ b/libmysqld/examples/builder-sample/emb_samples.h @@ -0,0 +1,77 @@ +// Copyright (c) 2002 MySQL AB +// Use is subject to license terms. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +//--------------------------------------------------------------------------- +#ifndef emb_samplesH +#define emb_samplesH +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//--------------------------------------------------------------------------- +class TForm1 : public TForm +{ +__published: // IDE-managed Components + TGroupBox *GroupBox1; + TTreeView *DBView; + TTreeView *TableView; + TStringGrid *desc_table_grid; + TImageList *ImageList2; + TStatusBar *StatusBar1; + TImage *Image1; + TBitBtn *ToggleButton; + TTimer *Timer1; + TLabel *Label1; + TEdit *info_server; + TLabel *Label2; + void __fastcall Timer1Timer(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall ToggleButtonClick(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall DBViewClick(TObject *Sender); + void __fastcall TableViewClick(TObject *Sender); +private: // User declarations +public: // User declarations + bool is_server_started; + AnsiString db_root_caption; + TTreeNode *db_root, *MySQLDbs, *tables_node, *tables_tree; + void __fastcall computer_ip(void); + bool __fastcall get_dbs(void); + bool __fastcall get_tables(String db_name); + bool __fastcall get_desc_table(String table_name); + bool __fastcall connect_server(); + void __fastcall clean_desc_grid(void); + void __fastcall titles_grid(void); + void __fastcall fill_tree(deque rows, + TTreeNode *root, + TTreeNode *child, + TTreeView *View, + int image_index); + + __fastcall TForm1(TComponent* Owner); +}; +//--------------------------------------------------------------------------- +extern PACKAGE TForm1 *Form1; +//--------------------------------------------------------------------------- +#endif diff --git a/libmysqld/examples/builder-sample/images/db.ico b/libmysqld/examples/builder-sample/images/db.ico new file mode 100644 index 00000000..ca749002 Binary files /dev/null and b/libmysqld/examples/builder-sample/images/db.ico differ diff --git a/libmysqld/examples/builder-sample/images/find.ico b/libmysqld/examples/builder-sample/images/find.ico new file mode 100644 index 00000000..2e0f96c5 Binary files /dev/null and b/libmysqld/examples/builder-sample/images/find.ico differ diff --git a/libmysqld/examples/builder-sample/images/logo.ico b/libmysqld/examples/builder-sample/images/logo.ico new file mode 100644 index 00000000..9409cad7 Binary files /dev/null and b/libmysqld/examples/builder-sample/images/logo.ico differ diff --git a/libmysqld/examples/builder-sample/images/mysql.bmp b/libmysqld/examples/builder-sample/images/mysql.bmp new file mode 100644 index 00000000..ed5c7f90 Binary files /dev/null and b/libmysqld/examples/builder-sample/images/mysql.bmp differ diff --git a/libmysqld/examples/builder-sample/images/net.ico b/libmysqld/examples/builder-sample/images/net.ico new file mode 100644 index 00000000..bb11e34b Binary files /dev/null and b/libmysqld/examples/builder-sample/images/net.ico differ diff --git a/libmysqld/examples/builder-sample/snapshot.jpg b/libmysqld/examples/builder-sample/snapshot.jpg new file mode 100644 index 00000000..b132fac8 Binary files /dev/null and b/libmysqld/examples/builder-sample/snapshot.jpg differ diff --git a/libmysqld/examples/test-run b/libmysqld/examples/test-run new file mode 100755 index 00000000..7c221ad9 --- /dev/null +++ b/libmysqld/examples/test-run @@ -0,0 +1,154 @@ +#! /bin/sh + +# Copyright (C) 2001, 2006 MySQL AB +# Use is subject to license terms +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +# This is slapped together as a quick way to run the tests and +# is not meant for prime time. Please hack at it and submit +# changes, though, so we can gradually turn it into something +# that will run on all platforms (or incorporate it into the +# standard mysql-test-run). + +# All paths below must be relative to $test_data_dir +top_builddir=../.. +mysql_test_dir=$top_builddir/mysql-test +examples=$top_builddir/libmysqld/examples +mysqltest=$examples/mysqltest_embedded +datadir=$mysql_test_dir/var/master-data +test_data_dir=test +gdb=0 +list=0 +run= +tests= +start= +clean=1 + +cr=" +" +er="\b\b\b\b\b\b\b\b" + +usage () { + cat <&2 + exit 1 +fi + +test -n "$tests" || + tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \ + sed -e 's,^.*/,,' -e 's,.test$,,'` + +echo "cleaning data directory '$datadir/$test_data_dir'" +if test $clean = 1 +then + rm -f $datadir/ib_* $datadir/ibdata* + rm -f $datadir/log.00* + rm -f $datadir/test/*.db +fi +rm -f $datadir/../tmp/* +rm -f test-gdbinit + +TZ=GMT-3; export TZ + +# At least one of the tests needs the following environment variable +MYSQL_TEST_DIR=`( cd $mysql_test_dir ; pwd )` ; export MYSQL_TEST_DIR + +skip=1 +test -z "$start" && skip=0 + +for b in $tests +do + test $list -eq 1 && { echo " $b"; continue; } + test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0 + test $skip -eq 1 && { echo "skipping '$b'"; continue; } + + t="t/$b.test" + r="r/$b.result" + + # Only test if $t exists; there is no $r for some tests + test -f $mysql_test_dir/$t || { + echo "test '$mysql_test_dir/$t' doesn't exist" >&2 + continue + } + args="$init_args -v --basedir=$mysql_test_dir/ -R $r -x $t --server-arg=--datadir=$datadir" + if test -f "$mysql_test_dir/t/$b-master.opt" ; then + args="$args --server-file=t/$b-master.opt" + fi + + args="$args $test_data_dir" # Add database last + echo "set args $args$run" > test-gdbinit + #if false && test -n "$run" + if test -n "$run" -o $gdb -eq 1 + then + echo -e "$er>>> $b" + else + echo -e "$er>>> $b> \c" + read junk + fi + if test $gdb -eq 1 + then + if [ -x "$top_builddir/libtool" ]; then + $top_builddir/libtool gdb -x test-gdbinit -q $mysqltest + else + gdb -x test-gdbinit -q $mysqltest + fi + res=$? + rm -f test-gdbinit + else + $mysqltest $args + res=$? + fi + + test $res -eq 0 -o $res -eq 2 || echo "!!! error: $res" +done -- cgit v1.2.3