List:Internals« Previous MessageNext Message »
From:xiao.feng Date:August 15 2006 8:49am
Subject:Re: How to compile an storage engine as an dll or so?
View as plain text  
Thank you very much!

when you finished build , can you  found libha_pbxt.so in $MYSQL/lib/?
You have modified  ./libmysqld/sql_builtin.cc, you build you own mysqld? Can libha_pbxt.so works well on official mysql binary?

libha_pbxt.so must depend on some mysql symbols which defined in handler.cc or some other cpp files, these symbols was built in mysqld, so work well.

I can complie my own storage engine on windows, it works well.
I want to write mty storage engine as dynamic linked .dll or .so, in order to work with MySQL official binary mysqld.

Thanks!

  ----- Original Message ----- 
  From: Paul McCullagh 
  To: MySQL Internal 
  Cc: xiao.feng 
  Sent: Tuesday, August 15, 2006 4:24 PM
  Subject: Re: How to compile an storage engine as an dll or so?


  Hi Xiao,

  On Aug 15, 2006, at 3:15 AM, xiao.feng wrote:

  >   How to compile an storage engine as an dll or so?
  >   I compiled Mysql 5.1.11 on windows for a hours, I have changed some 
  > vc2003 project file such as sp_builtin.cpp.
  >   I compiled all the builtin storage engine, but I want to write my 
  > own storage engine as dll.
  >   I have changed example project, but there is a lot of symbols missed.
  >   Thanks!

  I recently did this for the PrimeBase XT (PBXT) storage engine under 
  UNIX, so I am not sure how much this will help you under Windows.

  I have posted a list of changes I made below. The list could be taken 
  as a start for basic instructions on how to do this in general (maybe 
  we can get this stuff into the manual some time).

  If you follow the list, then the changes are easy because you just have 
  to search the file for the lines which contain the entry for the 
  "blackhole" storage engine.

  Then add below it the line for your own storage engine as I have done. 
  In some files there are 2 changes, which I have separated using "....".

  If you need to add some source files to your engine, besides ha_abc.cc 
  and ha_abc.h, then you need to change the file 
  ./storage/abc/Makefile.am (how to do this is not covered below).

  After you make and install, you should be able to load the storage 
  engine.

  - Paul


  5.1 INTEGRATION OF PBXT
  -----------------------

  (1) ./config.h.in

  /* Include Basic Write-only Read-never tables into mysqld */
  #undef WITH_BLACKHOLE_STORAGE_ENGINE

  /* Include High Availability Clustered tables into mysqld */
  #undef WITH_PBXT_STORAGE_ENGINE


  (2) ./configure.in

  MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
           [Basic Write-only Read-never tables], [max,max-no-ndb])
  MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
  MYSQL_PLUGIN_STATIC(blackhole,  [libblackhole.a])
  MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])

  MYSQL_STORAGE_ENGINE(pbxt,,[PrimeBase XT Storage Engine],
           [High performance multi-versioning transactional engine], 
  [max,max-no-ndb])
  MYSQL_PLUGIN_DIRECTORY(pbxt, [storage/pbxt])
  MYSQL_PLUGIN_STATIC(pbxt,  [libpbxt.a])
  MYSQL_PLUGIN_DYNAMIC(pbxt, [ha_pbxt.la])


  (3) ./CMakeLists.txt

  IF(WITH_BLACKHOLE_STORAGE_ENGINE)
     ADD_DEFINITIONS(-D WITH_BLACKHOLE_STORAGE_ENGINE)
     SET (mysql_plugin_defs 
  "${mysql_plugin_defs},builtin_blackhole_plugin")
  ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
  IF(WITH_PBXT_STORAGE_ENGINE)
     ADD_DEFINITIONS(-D WITH_PBXT_STORAGE_ENGINE)
     SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_pbxt_plugin")
  ENDIF(WITH_PBXT_STORAGE_ENGINE)


  (4) ./sql/CMakeLists.txt

  IF(WITH_BLACKHOLE_STORAGE_ENGINE)
     TARGET_LINK_LIBRARIES(mysqld blackhole)
  ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
  IF(WITH_PBXT_STORAGE_ENGINE)
     TARGET_LINK_LIBRARIES(mysqld pbxt)
  ENDIF(WITH_PBXT_STORAGE_ENGINE)


  (5) ./sql/mysql_priv.h

  #ifdef WITH_BLACKHOLE_STORAGE_ENGINE
  extern handlerton blackhole_hton;
  #define have_blackhole_db blackhole_hton.state
  #else
  extern SHOW_COMP_OPTION have_blackhole_db;
  #endif
  #ifdef WITH_PBXT_STORAGE_ENGINE
  extern handlerton pbxt_hton;
  #define have_pbxt_db pbxt_hton.state
  #else
  extern SHOW_COMP_OPTION have_pbxt_db;
  #endif


  (6) ./sql/mysqld.cc

  #undef have_blackhole_db
  #undef have_pbxt_db

  ....

  SHOW_COMP_OPTION have_blackhole_db= SHOW_OPTION_NO;
  SHOW_COMP_OPTION have_pbxt_db= SHOW_OPTION_NO;


  (7) ./sql/set_var.cc

  sys_var_have_variable sys_have_blackhole_db("have_blackhole_engine",
                                               &have_blackhole_db);
  sys_var_have_variable sys_have_pbxt_db("have_pbxt_engine",
                                               &have_pbxt_db);
  ....

     {sys_have_blackhole_db.name,(char*) &have_blackhole_db,           
  SHOW_HAVE},
     {sys_have_pbxt_db.name,     (char*) &have_pbxt_db,                
  SHOW_HAVE},


  (8) ./sql/sql_builtin.cc

  extern builtin_plugin
     builtin_binlog_plugin, builtin_berkeley_plugin, 
  builtin_blackhole_plugin, builtin_pbxt_plugin, ...

  ....

  struct st_mysql_plugin *mysqld_builtins[]=
  {
     builtin_binlog_plugin, builtin_berkeley_plugin, 
  builtin_blackhole_plugin, builtin_pbxt_plugin, ...


  (9) ./libmysqld/set_var.h

  sys_var_have_variable sys_have_blackhole_db("have_blackhole_engine",
                                               &have_blackhole_db);
  sys_var_have_variable sys_have_pbxt_db("have_pbxt_engine",
                                               &have_pbxt_db);

  ....

     {sys_have_blackhole_db.name,(char*) &have_blackhole_db,           
  SHOW_HAVE},
     {sys_have_pbxt_db.name,     (char*) &have_pbxt_db,                
  SHOW_HAVE},


  (10) ./libmysqld/sql_builtin.cc

  extern builtin_plugin
     builtin_binlog_plugin, builtin_berkeley_plugin, 
  builtin_blackhole_plugin, builtin_pbxt_plugin, ....

  ....

  struct st_mysql_plugin *mysqld_builtins[]=
  {
     builtin_binlog_plugin, builtin_berkeley_plugin, 
  builtin_blackhole_plugin, builtin_pbxt_plugin, ....


  (11) Create the required new files:

  mkdir ./storage/pbxt
  cd ./storage/example/

  sed s/EXAMPLE/PBXT/g Makefile.am | sed s/example/pbxt/g > 
  ../pbxt/Makefile.am
  sed s/EXAMPLE/PBXT/g CMakeLists.txt | sed s/example/pbxt/g > 
  ../pbxt/CMakeLists.txt
  sed s/EXAMPLE/PBXT/g ha_example.h | sed s/example/pbxt/g > 
  ../pbxt/ha_pbxt.h
  sed s/EXAMPLE/PBXT/g ha_example.cc | sed s/example/pbxt/g > 
  ../pbxt/ha_pbxt.cc

  Then I made the following changes by hand to ha_pbxt.cc:

  static const char pbxt_hton_comment[]= "Example storage engine";
  --->
  static const char pbxt_hton_comment[]= "... your text ...";


  DB_TYPE_PBXT_DB,
  --->
  DB_TYPE_FIRST_DYNAMIC, // (*)

  "Brian Aker, MySQL AB",
  --->
  "... your text ..."


  (*) According to the manual this Should be DB_TYPE_CUSTOM, but this is 
  not defined in the headers.

  You may also want to correct the fact that both a_pbxt.h and a_pbxt.cc 
  now have a few places where the word 'example' was replaced in 
  comments, which is not correct.

  cd ../..


  (12) Reconfigure everything. You will need automake version 1.9.6 for 
  this!

  aclocal
  autoheader
  autoconf
  automake

  Then, configure the build, for example:

  ./configure --prefix=/home/pbxt/mysql-5.1/test 
  --with-extra-charsets=complex --enable-thread-safe-client 
  --with-big-tables --with-debug --without-berkeley-db 
  --enable-local-infile --with-mysqld-user=pbxt
  make
  make install

  If you add: --with-plugin-pbxt, the engine will be statically linked to 
  mysqld.


  (13) Run the server, and load the plug-in (if not statically linked):

  INSTALL PLUGIN pbxt SONAME 'ha_pbxt';




  __  _______
  \ \/ _   _/     Paul McCullagh
    \  / | |       SNAP Innovation GmbH
    /  \ | |       Altonaer Poststr 9a
  / /\ \| |       22767 Hamburg
  ------------    Germany
  PrimeBase XT    www.primebase.com/xt
Thread
How to compile an storage engine as an dll or so?xiao.feng15 Aug
  • Re: How to compile an storage engine as an dll or so?Paul McCullagh15 Aug
    • Re: How to compile an storage engine as an dll or so?Sergei Golubchik16 Aug
      • Re: How to compile an storage engine as an dll or so?Paul McCullagh16 Aug
        • Re: How to compile an storage engine as an dll or so?Sergei Golubchik16 Aug
          • Version number in SHOW ENGINES (was Re: How to compile an storage engine as an dll or so?)Paul McCullagh16 Aug
            • Re: Version number in SHOW ENGINES (was Re: How to compile anstorage engine as an dll or so?)Stewart Smith19 Aug
              • Re: Version number in SHOW ENGINES (was Re: How to compile an storage engine as an dll or so?)Sergei Golubchik19 Aug
  • Re: How to compile an storage engine as an dll or so?xiao.feng15 Aug
    • Re: How to compile an storage engine as an dll or so?Paul McCullagh15 Aug
      • Re: How to compile an storage engine as an dll or so?Brian Aker15 Aug
        • Re: How to compile an storage engine as an dll or so?Paul McCullagh16 Aug
          • Re: How to compile an storage engine as an dll or so?Brian Aker16 Aug
  • Re: How to compile an storage engine as an dll or so?xiao.feng16 Aug
    • Re: How to compile an storage engine as an dll or so?Brian Aker16 Aug
    • Re: How to compile an storage engine as an dll or so?Stewart Smith16 Aug
  • Re: How to compile an storage engine as an dll or so?xiao.feng16 Aug
  • Re: How to compile an storage engine as an dll or so?xiao.feng16 Aug
  • How to detect SQL needed Columns in Storage Engine,not all columns?xiao.feng7 Sep
    • Re: How to detect SQL needed Columns in Storage Engine,not all columns?Sergei Golubchik7 Sep
    • Re: How to detect SQL needed Columns in Storage Engine,not all columns?xiao.feng7 Sep
    • How to create hidden Field in Storage Engine?xiao.feng11 Sep
      • Re: How to create hidden Field in Storage Engine?Sergei Golubchik11 Sep
      • Re: How to create hidden Field in Storage Engine?Brian Aker11 Sep
    • Re: How to create hidden Field in Storage Engine?xiao.feng12 Sep
      • Re: How to create hidden Field in Storage Engine?Brian Aker12 Sep
  • Re: How to compile an storage engine as an dll or so?xiao.feng9 Sep
Re: How to detect SQL needed Columns in Storage Engine,not all columns?xiao.feng8 Sep