List:Internals« Previous MessageNext Message »
From:svoj Date:September 2 2005 12:00am
Subject:bk commit into 5.0 tree (svoj:1.1902)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1902 05/09/02 02:59:53 svoj@stripped +9 -0
  WL#2763 - MySQL plugin interface: step 1
  Better names for plugin types.
  WL#2672 - Fulltext: plugin parser example
  Added parser example to plugin/fulltext dir

  plugin/fulltext/cnet_parser.c
    1.1 05/09/02 02:59:49 svoj@stripped +143 -0
    New BitKeeper file ``plugin/fulltext/cnet_parser.c''

  plugin/fulltext/Makefile.am
    1.1 05/09/02 02:59:49 svoj@stripped +3 -0
    New BitKeeper file ``plugin/fulltext/Makefile.am''

  plugin/Makefile.am
    1.1 05/09/02 02:59:49 svoj@stripped +1 -0
    New BitKeeper file ``plugin/Makefile.am''

  sql/table.cc
    1.179 05/09/02 02:59:49 svoj@stripped +1 -1
    Shorter names for plugin types.

  plugin/fulltext/cnet_parser.c
    1.0 05/09/02 02:59:49 svoj@stripped +0 -0
    BitKeeper file /home/svoj/devel/mysql/CNET/mysql-5.0/plugin/fulltext/cnet_parser.c

  plugin/fulltext/Makefile.am
    1.0 05/09/02 02:59:49 svoj@stripped +0 -0
    BitKeeper file /home/svoj/devel/mysql/CNET/mysql-5.0/plugin/fulltext/Makefile.am

  plugin/Makefile.am
    1.0 05/09/02 02:59:49 svoj@stripped +0 -0
    BitKeeper file /home/svoj/devel/mysql/CNET/mysql-5.0/plugin/Makefile.am

  sql/sql_yacc.yy
    1.414 05/09/02 02:59:48 svoj@stripped +1 -1
    Shorter names for plugin types.

  sql/sql_plugin.cc
    1.8 05/09/02 02:59:48 svoj@stripped +1 -1
    Shorter names for plugin types.

  include/plugin.h
    1.6 05/09/02 02:59:48 svoj@stripped +5 -5
    Shorter names for plugin types.

  configure.in
    1.326 05/09/02 02:59:48 svoj@stripped +3 -1
    Added makefiles in plugin dir.

  Makefile.am
    1.73 05/09/02 02:59:48 svoj@stripped +4 -2
    Added plugin dir.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	svoj
# Host:	svoj-laptop.mysql.com
# Root:	/home/svoj/devel/mysql/CNET/mysql-5.0

--- 1.72/Makefile.am	2005-07-03 14:32:01 +05:00
+++ 1.73/Makefile.am	2005-09-02 02:59:48 +05:00
@@ -25,14 +25,16 @@
 			@thread_dirs@ pstack \
 			@sql_union_dirs@ scripts @man_dirs@ tests \
 			netware @libmysqld_dirs@ \
-			@bench_dirs@ support-files @tools_dirs@
+			@bench_dirs@ support-files @tools_dirs@ \
+	                plugin
 
 DIST_SUBDIRS =		. include @docs_dirs@ zlib \
 			@readline_topdir@ sql-common \
 			@thread_dirs@ pstack \
 			@sql_union_dirs@ scripts @man_dirs@ tests SSL\
 			BUILD netware os2 @libmysqld_dirs@ \
-			@bench_dirs@ support-files @tools_dirs@
+			@bench_dirs@ support-files @tools_dirs@ \
+	                plugin
 
 # Relink after clean
 linked_sources = linked_client_sources linked_server_sources \

--- 1.325/configure.in	2005-07-20 21:31:28 +05:00
+++ 1.326/configure.in	2005-09-02 02:59:48 +05:00
@@ -2795,7 +2795,9 @@
  cmd-line-utils/Makefile dnl
  cmd-line-utils/libedit/Makefile dnl
  zlib/Makefile dnl
- cmd-line-utils/readline/Makefile)
+ cmd-line-utils/readline/Makefile dnl
+ plugin/Makefile dnl
+ plugin/fulltext/Makefile)
  AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp >
stamp-h)
  AC_OUTPUT
 

--- 1.413/sql/sql_yacc.yy	2005-09-01 22:22:47 +05:00
+++ 1.414/sql/sql_yacc.yy	2005-09-02 02:59:48 +05:00
@@ -2827,7 +2827,7 @@
           {
 #ifdef HAVE_DLOPEN
             struct st_plugin_int *plugin;
-            if ((plugin= plugin_find(&$3, MYSQL_PLUGIN_TYPE_FTPARSER)))
+            if ((plugin= plugin_find(&$3, MYSQL_FTPARSER_PLUGIN)))
               $$= plugin;
             else
             {

--- 1.178/sql/table.cc	2005-09-02 01:45:36 +05:00
+++ 1.179/sql/table.cc	2005-09-02 02:59:49 +05:00
@@ -369,7 +369,7 @@
         parser_name.str= next_chunk;
         parser_name.length= strlen(next_chunk);
 #ifdef HAVE_DLOPEN
-        keyinfo->parser= plugin_find(&parser_name, MYSQL_PLUGIN_TYPE_FTPARSER);
+        keyinfo->parser= plugin_find(&parser_name, MYSQL_FTPARSER_PLUGIN);
 #endif
         if (! keyinfo->parser)
         {

--- 1.5/include/plugin.h	2005-09-01 22:22:47 +05:00
+++ 1.6/include/plugin.h	2005-09-02 02:59:48 +05:00
@@ -17,11 +17,11 @@
 #ifndef _my_plugin_h
 #define _my_plugin_h
 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0000
-#define MYSQL_PLUGIN_TYPE_UDF             0
-#define MYSQL_PLUGIN_TYPE_STORAGE_ENGINE  1
-#define MYSQL_PLUGIN_TYPE_FTPARSER        2
-#define MYSQL_PLUGIN_TYPE_MAX             3
-#define MYSQL_PLUGIN_TYPE_ANY             -1
+#define MYSQL_UDF_PLUGIN             0
+#define MYSQL_STORAGE_ENGINE_PLUGIN  1
+#define MYSQL_FTPARSER_PLUGIN        2
+#define MYSQL_MAX_PLUGIN             3
+#define MYSQL_ANY_PLUGIN             -1
 #define mysql_declare_plugin                                          \
 int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
 struct st_mysql_plugin _mysql_plugin_declarations_[]= {
--- New file ---
+++ plugin/Makefile.am	05/09/02 02:59:49
SUBDIRS= fulltext

--- New file ---
+++ plugin/fulltext/Makefile.am	05/09/02 02:59:49
INCLUDES= -I$(top_builddir)/include
lib_LTLIBRARIES= libcnet_parser.la
libcnet_parser_la_SOURCES= cnet_parser.c

--- New file ---
+++ plugin/fulltext/cnet_parser.c	05/09/02 02:59:49
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>

#include <my_global.h>
#include <m_ctype.h>
#include <plugin.h>


#define CNET_WORD_CASES_PATH "ordinary-dict.txt"

static char *words_buf;
static const char **words;
static size_t nwords; 
static size_t min_word_len= 3;


static int insert_word (const char *word)
{
  const char **tmp= realloc(words, sizeof(char *) * nwords + 1);
  if (! tmp)
    return(0);
  tmp[nwords]= word;
  nwords++;
  words= tmp;
  return(1);
}


static int cnet_parser_init_once (void)
{
  int fd;
  off_t len;
  char *start, *end;

  if ((fd= open(CNET_WORD_CASES_PATH, O_RDONLY)) < 0)
    goto err0;
  if ((len= lseek(fd, 0, SEEK_END)) < 0)
    goto err0;
  if (lseek(fd, 0, SEEK_SET) < 0)
    goto err0;
  if (! (words_buf= malloc(len + 1)))
    goto err0;
  if (read(fd, words_buf, len) != len)
    goto err1;
  words_buf[len]= 0;
  for (end= start= words_buf;; end++)
  {
    if (*end == '\n')
    {
      if (end - start > 1) insert_word(start);
      *end= 0;
      end++;
      start= end;
    }
    else if (! *end)
    {
      if (end - start > 1) insert_word(start);
      break;
    }
  }
  close(fd);
  return(0);

err1:
  free(words_buf);
  words_buf= 0;
err0:
  close(fd);
  return(1);
}


static int cnet_parser_deinit_once (void)
{
  free(words_buf);
  free(words);
  return(0);
}


static size_t check_in_array(const char *start, size_t bytes_left)
{
  size_t i;
  for (i= 0; i < nwords; i++)
  {
    size_t len= strlen(words[i]);
    if (len <= bytes_left && ! strncasecmp(start, words[i], len))
      return(len);
  }
  return(0);
}


static int cnet_parser_parse(MYSQL_FTPARSER_PARAM *param)
{
  char *end, *start, *docend= param->doc + param->length;
  size_t l;

  for (end= start= param->doc;; end++)
  {
    if (end == docend)
    {
      if (end - start > min_word_len)
        param->mysql_add_word(param->mysql_ftparam, start, end - start);
      break;
    }
    else if ((l= check_in_array(end, docend - end)))
    {
      param->mysql_add_word(param->mysql_ftparam, end, l);
      end+= l;
      if (end == docend)
        break;
      start= end + 1;
    }
    else if (! isalnum(*end))
    {
      if (end - start > min_word_len)
        param->mysql_add_word(param->mysql_ftparam, start, end - start);
      start= end + 1;
    }
  }
  return(0);
}


static struct st_mysql_ftparser cnet_parser_declaration=
{
  MYSQL_FTPARSER_INTERFACE_VERSION, cnet_parser_parse, 0, 0
};

mysql_declare_plugin
{
  MYSQL_FTPARSER_PLUGIN, &cnet_parser_declaration,
  "cnet_parser", "Sergey Vojtovich", "Fulltext [pre]parser example for CNET",
  cnet_parser_init_once, cnet_parser_deinit_once
}
mysql_declare_plugin_end;


--- 1.7/sql/sql_plugin.cc	2005-09-01 22:22:47 +05:00
+++ 1.8/sql/sql_plugin.cc	2005-09-02 02:59:48 +05:00
@@ -189,7 +189,7 @@
   struct st_plugin_int tmp;
   struct st_mysql_plugin *plugin;
   DBUG_ENTER("plugin_add");
-  if (plugin_find(name, MYSQL_PLUGIN_TYPE_ANY))
+  if (plugin_find(name, MYSQL_ANY_PLUGIN))
     DBUG_RETURN(FALSE);
   if (! (tmp.plugin_dl= plugin_dl_add(dl)))
     DBUG_RETURN(TRUE);
Thread
bk commit into 5.0 tree (svoj:1.1902)svoj1 Sep