MySQL Internals Manual  /  Writing a Procedure  /  Required Server Code Patches

18.4 Required Server Code Patches

Currently procedures can only be compiled into the server staticly. There is no dynamic procedure for loading them dynamicly yet like we have for UDFs and plugins.

So you have to perform the following steps to register your procedure with the server:

  • register the .cc and .h file in the mysqld_SOURCES list in sql/Makefile.am, for example, right after the line that the sql_analyse.* files are on:

diff -ruN 5.0/sql/Makefile.am 5.0-myproc/sql/Makefile.am
 --- 5.0/sql/Makefile.am	2007-08-09 12:11:16.000000000 +0200
 +++ 5.0-myproc/sql/Makefile.am	2007-08-09 00:22:19.000000000 +0200
 @@ -94,6 +94,7 @@
  			sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
  			sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
  			sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
 +			procedure_rownum.cc procedure_rownum.h \
  			slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
  			client.c sql_client.cc mini_client_errors.c pack.c\
  			stacktrace.c repl_failsafe.h repl_failsafe.cc \
  • register the .cc source file in the sqlsources list in libmysqld/Makefile.am

diff -ruN 5.0/libmysqld/Makefile.am 5.0-myproc/libmysqld/Makefile.am
 --- 5.0/libmysqld/Makefile.am	2007-08-09 12:18:16.000000000 +0200
 +++ 5.0-myproc/libmysqld/Makefile.am	2007-08-09 00:21:55.000000000 +0200
 @@ -54,6 +54,7 @@
  	opt_sum.cc procedure.cc records.cc sql_acl.cc \
  	sql_load.cc discover.cc sql_locale.cc \
  	sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
 +	procedure_rownum.cc \
  	sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
  	sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc sql_parse.cc \
  	sql_prepare.cc sql_derived.cc sql_rename.cc \
  • include your .h file in sql/procedure.cc

diff -ruN 5.0/sql/procedure.cc 5.0-myproc/sql/procedure.cc
 --- 5.0/sql/procedure.cc	2007-08-09 12:11:16.000000000 +0200
 +++ 5.0-myproc/sql/procedure.cc	2007-08-09 00:21:04.000000000 +0200
 @@ -23,6 +23,7 @@
  #include "mysql_priv.h"
  #include "procedure.h"
  #include "sql_analyse.h"			// Includes procedure
 +#include "procedure_rownum.h"		// Includes procedure
  #ifdef USE_PROC_RANGE
  #include "proc_range.h"
  #endif
  • register your procedures init callback in the sql_procs array in sql/procedure.cc

diff -ruN 5.0/sql/procedure.cc 5.0-myproc/sql/procedure.cc
 --- 5.0/sql/procedure.cc	2007-08-09 12:11:16.000000000 +0200
 +++ 5.0-myproc/sql/procedure.cc	2007-08-09 00:21:04.000000000 +0200
 @@ -37,6 +38,7 @@
    { "split_count",proc_count_range_init },	// Internal procedure at TCX
    { "matris_ranges",proc_matris_range_init },	// Internal procedure at TCX
  #endif
 +  { "rownum", proc_rownum_init }, 		// Add RowNum column to result
    { "analyse",proc_analyse_init }		// Analyse a result
  };
  • run automake and autoconf to regenerate the Makefile.in

files and the configure script
  • run configure or refresh your previous configuration by running config.status

  • run make

  • if your build fails with don't know how to make xxx.cc required by xxx.o in the libmysqld/ directory you might need to create a symlink from libmysqld/xxx.cc to sql/xxx.cc yourself. The build system is not too clever about creating these symlinks for files added after the first compile ...


User Comments
Sign Up Login You must be logged in to post a comment.