1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00
Files
mariadb/plugin/fulltext/plugin_example.c
unknown 83583111ca WL#3201
" Configure support for server plugins "


storage/blackhole/ha_blackhole.h:
  Rename: sql/ha_blackhole.h -> storage/blackhole/ha_blackhole.h
BitKeeper/deleted/.del-storage.m4~24bf2fffdaa328ad:
  Delete: config/ac-macros/storage.m4
BitKeeper/deleted/.del-ha_archive.m4~a07fac7110b39294:
  Delete: config/ac-macros/ha_archive.m4
BitKeeper/deleted/.del-ha_blackhole.m4~8ed06eb91f6420ed:
  Delete: config/ac-macros/ha_blackhole.m4
BitKeeper/deleted/.del-ha_example.m4~1dfb268163297708:
  Delete: config/ac-macros/ha_example.m4
BitKeeper/deleted/.del-ha_federated.m4~7acddd58286acfd6:
  Delete: config/ac-macros/ha_federated.m4
BitKeeper/deleted/.del-ha_innodb.m4~6f141fb5b80c1f39:
  Delete: config/ac-macros/ha_innodb.m4
BitKeeper/deleted/.del-ha_partition.m4~bc57067550be5f89:
  Delete: config/ac-macros/ha_partition.m4
BitKeeper/deleted/.del-ha_tina.m4~f658506ebbc113ca:
  Delete: config/ac-macros/ha_tina.m4
BitKeeper/deleted/.del-handlerton.cc.in~377156e7b06067cc:
  Delete: sql/handlerton.cc.in
BitKeeper/deleted/.del-handlerton-win.cc~322a7e59507976df:
  Delete: sql/handlerton-win.cc
BUILD/SETUP.sh:
  WL#3201
    Changes in configure arguments
Makefile.am:
  WL#3201
    changes in build subst names
config/ac-macros/ha_berkeley.m4:
  WL#3201
    remove unused variable
    Makefile is always made
config/ac-macros/ha_ndbcluster.m4:
  WL#3201
    remove unused variables
    Split big macro
configure.in:
  WL#3201
    out with storage.m4, in with plugins.m4
    change how plugins are declared
    include makefiles, remove handlerton.cc, add sql_builtin.cc
include/mysql/plugin.h:
  WL#3201
    support static and dynamic build - MYSQL_DYNAMIC_PLUGIN
libmysqld/Makefile.am:
  WL#3201
    Storage engine files still left in sql subdir are not conditionally
    compiled. Should move them out soon,
plugin/Makefile.am:
  WL#3201
    update makefile
plugin/fulltext/Makefile.am:
  WL#3201
    update makefile
plugin/fulltext/plugin_example.c:
  WL#3201
    change to mysql_declare_plugin macro
sql/Makefile.am:
  WL#3201
    Storage engine files still left in sql subdir are not conditionally
    compiled. Should move them out soon,
sql/ha_berkeley.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/ha_federated.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/ha_heap.cc:
  WL#3201
    make into a plugin
sql/ha_innodb.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/ha_myisam.cc:
  WL#3201
    make into a plugin
sql/ha_myisammrg.cc:
  WL#3201
    make into a plugin
sql/ha_ndbcluster.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/ha_ndbcluster_binlog.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/ha_partition.cc:
  WL#3201
    make into a plugin
    conditionally compile content
sql/handler.cc:
  WL#3201
    Simplify how storage engines are found by db_type
    (hopefully we can get rid of it soon)
    Code cleanup
sql/handler.h:
  WL#3201
    new DB_TYPE_FIRST_DYNAMIC
    new func ha_finalize_handlerton()
    remove ha_register_builtin_plugins()
sql/log.cc:
  WL#3201
    make into a plugin
sql/mysqld.cc:
  WL#3201
    remove ha_register_builtin_plugins()
    alter init order so that storage engines are initialized before first use
sql/partition_info.cc:
  WL#3201
    conditionally compile content
sql/sql_delete.cc:
  WL#3201
    conditionally include ha_innodb.h
sql/sql_plugin.cc:
  WL#3201
    All compiled in plugins are in mysqld_builtins[]
    add funcs for plugin finalization
    install builtin plugins on initialization
sql/sql_show.cc:
  WL#3201
    Fix to use plugin_foreach()
sql/sql_yacc.yy:
  WL#3201
    SHOW FULL PLUGIN
storage/archive/Makefile.am:
  WL#3201
    setup as plugin makefile
storage/archive/ha_archive.cc:
  WL#3201
    Convert into a plugin
storage/archive/ha_archive.h:
  WL#3201
    azlib.h now in local dir
storage/blackhole/ha_blackhole.cc:
  WL#3201
    convert into a plugin
storage/csv/Makefile.am:
  WL#3201
    setup as plugin makefile
storage/csv/ha_tina.cc:
  WL#3201
    remove conditional compilation on MYSQL_PLUGIN
    mysql_declare_plugin macro change
storage/example/Makefile.am:
  WL#3201
    fix as new-style plugin makefile
storage/example/ha_example.cc:
  WL#3201
    remove conditional compilation on MYSQL_PLUGIN
    mysql_declare_plugin macro change
storage/innobase/Makefile.am:
  WL#3201
    Lets make life easier and reduce innodb into a single library file
config/ac-macros/plugins.m4:
  New BitKeeper file ``config/ac-macros/plugins.m4''
sql/sql_builtin.cc.in:
  New BitKeeper file ``sql/sql_builtin.cc.in''
storage/blackhole/Makefile.am:
  New BitKeeper file ``storage/blackhole/Makefile.am''
2006-04-13 13:49:29 -07:00

233 lines
5.6 KiB
C

/*
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; either version 2 of the License, or
(at your option) any later version.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdlib.h>
#include <ctype.h>
#include <mysql/plugin.h>
static long number_of_calls= 0; /* for SHOW STATUS, see below */
/*
Simple full-text parser plugin that acts as a replacement for the
built-in full-text parser:
- All non-whitespace characters are significant and are interpreted as
"word characters."
- Whitespace characters are space, tab, CR, LF.
- There is no minimum word length. Non-whitespace sequences of one
character or longer are words.
- Stopwords are used in non-boolean mode, not used in boolean mode.
*/
/*
simple_parser interface functions:
Plugin declaration functions:
- simple_parser_plugin_init()
- simple_parser_plugin_deinit()
Parser descriptor functions:
- simple_parser_parse()
- simple_parser_init()
- simple_parser_deinit()
*/
/*
Initialize the parser plugin at server start or plugin installation.
SYNOPSIS
simple_parser_plugin_init()
DESCRIPTION
Does nothing.
RETURN VALUE
0 success
1 failure (cannot happen)
*/
static int simple_parser_plugin_init(void)
{
return(0);
}
/*
Terminate the parser plugin at server shutdown or plugin deinstallation.
SYNOPSIS
simple_parser_plugin_deinit()
Does nothing.
RETURN VALUE
0 success
1 failure (cannot happen)
*/
static int simple_parser_plugin_deinit(void)
{
return(0);
}
/*
Initialize the parser on the first use in the query
SYNOPSIS
simple_parser_init()
DESCRIPTION
Does nothing.
RETURN VALUE
0 success
1 failure (cannot happen)
*/
static int simple_parser_init(MYSQL_FTPARSER_PARAM *param)
{
return(0);
}
/*
Terminate the parser at the end of the query
SYNOPSIS
simple_parser_deinit()
DESCRIPTION
Does nothing.
RETURN VALUE
0 success
1 failure (cannot happen)
*/
static int simple_parser_deinit(MYSQL_FTPARSER_PARAM *param)
{
return(0);
}
/*
Pass a word back to the server.
SYNOPSIS
add_word()
param parsing context of the plugin
word a word
len word length
DESCRIPTION
Fill in boolean metadata for the word (if parsing in boolean mode)
and pass the word to the server. The server adds the word to
a full-text index when parsing for indexing, or adds the word to
the list of search terms when parsing a search string.
*/
static void add_word(MYSQL_FTPARSER_PARAM *param, char *word, size_t len)
{
MYSQL_FTPARSER_BOOLEAN_INFO bool_info=
{ FT_TOKEN_WORD, 0, 0, 0, 0, ' ', 0 };
if (param->mode == MYSQL_FTPARSER_FULL_BOOLEAN_INFO)
param->mysql_add_word(param->mysql_ftparam, word, len, &bool_info);
else
param->mysql_add_word(param->mysql_ftparam, word, len, 0);
}
/*
Parse a document or a search query.
SYNOPSIS
simple_parser_parse()
param parsing context
DESCRIPTION
This is the main plugin function which is called to parse
a document or a search query. The call mode is set in
param->mode. This function simply splits the text into words
and passes every word to the MySQL full-text indexing engine.
*/
static int simple_parser_parse(MYSQL_FTPARSER_PARAM *param)
{
char *end, *start, *docend= param->doc + param->length;
number_of_calls++;
for (end= start= param->doc;; end++)
{
if (end == docend)
{
if (end > start)
add_word(param, start, end - start);
break;
}
else if (isspace(*end))
{
if (end > start)
add_word(param, start, end - start);
start= end + 1;
}
}
return(0);
}
/*
Plugin type-specific descriptor
*/
static struct st_mysql_ftparser simple_parser_descriptor=
{
MYSQL_FTPARSER_INTERFACE_VERSION, /* interface version */
simple_parser_parse, /* parsing function */
simple_parser_init, /* parser init function */
simple_parser_deinit /* parser deinit function */
};
/*
Plugin status variables for SHOW STATUS
*/
static struct st_mysql_show_var simple_status[]=
{
{"static", (char *)"just a static text", SHOW_CHAR},
{"called", (char *)&number_of_calls, SHOW_LONG},
{0,0,0}
};
/*
Plugin library descriptor
*/
mysql_declare_plugin(ftexample)
{
MYSQL_FTPARSER_PLUGIN, /* type */
&simple_parser_descriptor, /* descriptor */
"simple_parser", /* name */
"MySQL AB", /* author */
"Simple Full-Text Parser", /* description */
simple_parser_plugin_init, /* init function (when loaded) */
simple_parser_plugin_deinit,/* deinit function (when unloaded) */
0x0001, /* version */
simple_status /* status variables */
}
mysql_declare_plugin_end;