Commit 938a8dc2 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

merge

parents 0c81c7ea 88aff4bf
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
*.la
*.lo
*.o
*.reject
*.spec
*/*_pure_*warnings
*/.pure
@@ -152,6 +153,7 @@ client/mysqlbinlog
client/mysqlcheck
client/mysqldump
client/mysqlimport
client/mysqlmanager-pwgen
client/mysqlmanagerc
client/mysqlshow
client/mysqltest
@@ -214,6 +216,7 @@ libmysqld/examples/mysqltest.c
libmysqld/examples/readline.cc
libmysqld/examples/sql_string.cc
libmysqld/examples/sql_string.h
libmysqld/examples/test-gdbinit
libmysqld/field.cc
libmysqld/field_conv.cc
libmysqld/filesort.cc
@@ -337,6 +340,7 @@ scripts/make_binary_distribution
scripts/msql2mysql
scripts/mysql_config
scripts/mysql_convert_table_format
scripts/mysql_explain_log
scripts/mysql_find_rows
scripts/mysql_fix_privilege_tables
scripts/mysql_install_db
@@ -413,5 +417,3 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
client/mysqlmanager-pwgen
*.reject
+114 −91
Original line number Diff line number Diff line
@@ -34122,10 +34122,12 @@ detect duplicated @code{UNIQUE} keys.
@item
By using @code{DATA DIRECTORY="directory"} or @code{INDEX
DIRECTORY="directory"} you can specify where the table handler should
put it's table and index files.  This only works for @code{MyISAM} tables
in @code{MySQL} 4.0, when you are not using the @code{--skip-symlink}
option. @xref{Symbolic links to tables}.
put it's table and index files.  Note that the directory should be a full
path to the directory (not relative path).
This only works for @code{MyISAM} tables in @code{MySQL} 4.0, when you
are not using the @code{--skip-symlink} option. @xref{Symbolic links to
tables}.
@end itemize
@@ -42012,7 +42014,7 @@ a stand-alone server without modifying any code.
@findex @code{mysql_server_init()}
@code{int mysql_server_init(int argc, const char **argv, const char **groups)}
@code{int mysql_server_init(int argc, char **argv, char **groups)}
@subsubheading Description
@@ -42032,8 +42034,8 @@ command-line arguments for the server.
The @code{NULL}-terminated list of strings in @code{groups}
selects which groups in the option files will be active.
@xref{Option files}.  For convenience, @code{groups} may be
@code{NULL}, in which case the @code{[server]} group will be
active.
@code{NULL}, in which case the @code{[server]} and @code{[emedded]} groups
will be active.
@subsubheading Example
@@ -42047,6 +42049,7 @@ static char *server_args[] = @{
  "--set-variable=key_buffer_size=32M"
@};
static char *server_groups[] = @{
  "embedded",
  "server",
  "this_program_SERVER",
  (char *)NULL
@@ -42379,6 +42382,9 @@ included the thread libraries on the link/compile line.
@menu
* libmysqld overview::          Overview of the Embedded MySQL Server Library
* libmysqld compiling::         Compiling Programs with @code{libmysqld}
* libmysqld restrictions::      
* libmysqld options::           
* libmysqld TODO::              
* libmysqld example::           A Simple Embedded Server Example
* libmysqld licensing::         Licensing the Embedded Server
@end menu
@@ -42391,21 +42397,100 @@ full-featured MySQL server inside the client application. The
main benefits are increased speed and more simple management for
embedded applications.
@node libmysqld compiling, libmysqld example, libmysqld overview, libmysqld
The API is identical for the embedded MySQL version and MySQL
client/server version.  To change an old threaded application to use the
embedded library, on normall only have to add calls to the following
functions:
@multitable @columnfractions .25 .7
@item @code{mysql_server_init()} @tab Should be called before any other other MySQL function is called, preferably early in the @code{main()} function.
@item @code{mysql_server_end()} @tab Should be called before doing an exit of your program.
@item @code{mysql_thread_init()} @tab Should be called in all threads you are created that will access MySQL.
@item @code{mysql_thread_end()} @tab Should be called before calling @code{pthread_exit()}
@end multitable
and link your code with @code{libmysqld.a} instead of @code{libmysqlclient.a}.
The above @code{mysql_server_xxx} functions are also included in
@code{libmysqld.a} to allow you to change between the embedded and the
client/server version by just linking your application with the right
library. @xref{mysql_server_init}.
@node libmysqld compiling, libmysqld restrictions, libmysqld overview, libmysqld
@subsubsection Compiling Programs with @code{libmysqld}
Currently, all of the support libraries must be explicitly
listed when linking with @code{-lmysqld}.  In the future,
@code{mysql_config --libmysqld-libs} will name the libraries to
make this easier.  Also, all of the supporting libraries will
probably be incorporated into libmysqld at some time to simplify
this even more.
When you link your program with @code{libmysqld}, you must also include
the system specific @code{pthread} libraries and some libraries that
@code{mysqld} uses.  You can get the full list of libraries by executing
@code{mysql_config --libmysqld-libs}.
 
The correct flags for compiling and linking a threaded program
must be used, even if you do not directly call any thread
functions in your code.
@node libmysqld example, libmysqld licensing, libmysqld compiling, libmysqld
@node libmysqld restrictions, libmysqld options, libmysqld compiling, libmysqld
@subsubsection Restrictions when using the Embedded MySQL Server
The embedded server has the following limitations:
(Some of these limitations can be changed by editing the @code{mysql_embed.h}
include files and recompiling MySQL)
@itemize @bullet
@item
No support for ISAM tables. (This is mainly done to make the library smaller)
@item
No UDF functions.
@item
No stack trace on core dump.
@item
No internal RAID support.
@end itemize
@node libmysqld options, libmysqld TODO, libmysqld restrictions, libmysqld
@subsubsection Using option files with the embedded server
The following is the recommended way to use option files to make it easy
to switch between a client/server application and one where MySQL is
embedded. @xref{Option files}.
@itemize @bullet
@item
Put common options in the @code{[server]} section. These will be read by
both MySQL versions.
@item
Put client/server specific options in the @code{[mysqld]} section.
@item
Put embedded MySQL specific options in the @code{[embedded]} section.
@item
Put application specific options in a @code{[ApplicationName_SERVER]}
section.
@end itemize
@node libmysqld TODO, libmysqld example, libmysqld options, libmysqld
@subsubsection Things left to do in Embedded Server (TODO)
@cindex TODO, embedded server
@itemize @bullet
@item
Currently we only provide a static version of the @code{mysqld} library,
in the future we will also provide a shared library for this.
@item
We are going to provide options to leave out some parts of MySQL to make
the library smaller.
@item
There is still a lot of speed optimization to do.
@item
Errors are written to stderr.  We will add an option to specify a
filename for these.
@item
We have to change InnoDB to not be so verbose when using in the embedded
version.
@end itemize
@node libmysqld example, libmysqld licensing, libmysqld TODO, libmysqld
@subsubsection A Simple Embedded Server Example
This example program and makefile should work without any
@@ -42449,7 +42534,7 @@ main(int argc, char **argv)
  /* This must be called before any other mysql functions.
   *
   * You can use mysql_server_init(0, NULL, NULL), and it will
   * initialize the server using groups = @{ "server", NULL @}.
   * initialize the server using groups = @{ "server", "embedded", NULL @}.
   *
   * In your $HOME/.my.cnf file, you probably want to put:
@@ -42647,79 +42732,9 @@ else
LDLIBS += -lpthread
endif
# Standard libraries.  This example assumes MySQL is in /usr/local/mysql
# Standard libraries
embed_libs := \
        $m/libmysqld/.libs/libmysqld.a \
        $m/isam/libnisam.a \
        $m/myisam/libmyisam.a \
        $m/heap/libheap.a \
        $m/merge/libmerge.a \
        $m/myisammrg/libmyisammrg.a
# Optionally-built libraries
ifneq (,$(shell test -r $m/innobase/usr/libusr.a && echo "yes"))
embed_libs += \
        $m/innobase/usr/libusr.a \
        $m/innobase/odbc/libodbc.a \
        $m/innobase/srv/libsrv.a \
        $m/innobase/que/libque.a \
        $m/innobase/srv/libsrv.a \
        $m/innobase/dict/libdict.a \
        $m/innobase/ibuf/libibuf.a \
        $m/innobase/row/librow.a \
        $m/innobase/pars/libpars.a \
        $m/innobase/btr/libbtr.a \
        $m/innobase/trx/libtrx.a \
        $m/innobase/read/libread.a \
        $m/innobase/usr/libusr.a \
        $m/innobase/buf/libbuf.a \
        $m/innobase/ibuf/libibuf.a \
        $m/innobase/eval/libeval.a \
        $m/innobase/log/liblog.a \
        $m/innobase/fsp/libfsp.a \
        $m/innobase/fut/libfut.a \
        $m/innobase/fil/libfil.a \
        $m/innobase/lock/liblock.a \
        $m/innobase/mtr/libmtr.a \
        $m/innobase/page/libpage.a \
        $m/innobase/rem/librem.a \
        $m/innobase/thr/libthr.a \
        $m/innobase/com/libcom.a \
        $m/innobase/sync/libsync.a \
        $m/innobase/data/libdata.a \
        $m/innobase/mach/libmach.a \
        $m/innobase/ha/libha.a \
        $m/innobase/dyn/libdyn.a \
        $m/innobase/mem/libmem.a \
        $m/innobase/sync/libsync.a \
        $m/innobase/ut/libut.a \
        $m/innobase/os/libos.a \
        $m/innobase/ut/libut.a
endif
ifneq (,$(shell test -r $m/bdb/build_unix/libdb.a && echo "yes"))
embed_libs += $m/bdb/build_unix/libdb.a
endif
# Support libraries
embed_libs += \
        $m/mysys/libmysys.a \
        $m/strings/libmystrings.a \
        $m/dbug/libdbug.a \
        $m/regex/libregex.a
# Optionally built support libraries
ifneq (,$(shell test -r $m/readline/libreadline.a && echo "yes"))
embed_libs += $m/readline/libreadline.a
endif
embed_libs := -L/usr/local/mysql/lib/mysql/ -lmysqld
# This works for simple one-file test programs
sources := $(wildcard *.c)
@@ -47449,6 +47464,8 @@ Changed @code{WEEK(#,0)} to match the calender in the USA.
@item
Speed up all internal list handling.
@item
Speed up @code{IS NULL()} and some other internal primitives.
@item
Creating full text indexes are now much faster.
@item
Tree-like cache to speed up bulk inserts and
@@ -47496,6 +47513,12 @@ Allow ANSI SQL syntax @code{X'hexadecimal-number'}
Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK}
@item
Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization.
@item
Added options @code{--master-data} and @code{--no-autocommit} to
@code{mysqldump} (Thanks to Brian Aker for this).
@item
Added script @code{mysql_explain_log.sh} to distribution.
(Thanks to mobile.de).
@end itemize
+8 −1
Original line number Diff line number Diff line
@@ -880,6 +880,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
    no )
      bdb_includes=
      bdb_libs=
      bdb_libs_with_path=
      ;;
    supplied-two )
      MYSQL_CHECK_INSTALLED_BDB([$bdb_includes], [$bdb_libs])
@@ -909,6 +910,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
          esac
         bdb_includes=
         bdb_libs=
	 bdb_libs_with_path=
          ;;
      esac
      ;;
@@ -937,6 +939,7 @@ dnl echo "DBG3: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"

  AC_SUBST(bdb_includes)
  AC_SUBST(bdb_libs)
  AC_SUBST(bdb_libs_with_path)
])

AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [
@@ -957,6 +960,7 @@ dnl echo ["MYSQL_CHECK_INSTALLED_BDB ($1) ($2)"]
        MYSQL_TOP_BUILDDIR([lib])
        bdb_includes="-I$inc"
        bdb_libs="-L$lib -ldb"
        bdb_libs_with_path="$lib/libdb.a"
      ])
      LDFLAGS="$save_LDFLAGS"
    else
@@ -985,6 +989,7 @@ dnl echo ["MYSQL_CHECK_BDB_DIR ($1)"]
        MYSQL_TOP_BUILDDIR([dir])
        bdb_includes="-I$dir/build_unix"
        bdb_libs="-L$dir/build_unix -ldb"
	bdb_libs_with_path="$dir/build_unix/libdb.a"
      else
        bdb_dir_ok="$bdb_version_ok"
      fi
@@ -1096,6 +1101,7 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
      AC_DEFINE(HAVE_INNOBASE_DB)
      have_innodb="yes"
      innodb_includes="-I../innobase/include"
      innodb_system_libs=""
dnl Some libs are listed several times, in order for gcc to sort out
dnl circular references.
      innodb_libs="\
@@ -1136,7 +1142,7 @@ dnl circular references.
 \$(top_builddir)/innobase/os/libos.a\
 \$(top_builddir)/innobase/ut/libut.a"

      AC_CHECK_LIB(rt, aio_read, [innodb_libs="$innodb_libs -lrt"])
      AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
      ;;
    * )
      AC_MSG_RESULT([Not using Innodb])
@@ -1145,6 +1151,7 @@ dnl circular references.

  AC_SUBST(innodb_includes)
  AC_SUBST(innodb_libs)
  AC_SUBST(innodb_system_libs)
])

dnl ---------------------------------------------------------------------------
+11 −33
Original line number Diff line number Diff line
@@ -47,10 +47,12 @@ int completion_hash_init(HashTable *ht, uint nSize)
  ht->arBuckets = (Bucket **) my_malloc(nSize* sizeof(Bucket *),
					MYF(MY_ZEROFILL | MY_WME));

  if (!ht->arBuckets) {
  if (!ht->arBuckets)
  {
    ht->initialized = 0;
    return FAILURE;
  }
  init_alloc_root(&ht->mem_root, 8192, 0);
  ht->pHashFunction = hashpjw;
  ht->nTableSize = nSize;
  ht->initialized = 1;
@@ -78,8 +80,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
      if (!memcmp(p->arKey, arKey, nKeyLength)) {
	entry *n;

	n = (entry *) my_malloc(sizeof(entry),
				MYF(MY_WME));
	n = (entry *) alloc_root(&ht->mem_root,sizeof(entry));
	n->pNext = p->pData;
	n->str = str;
	p->pData = n;
@@ -91,20 +92,16 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
    p = p->pNext;
  }

  p = (Bucket *) my_malloc(sizeof(Bucket),MYF(MY_WME));

  if (!p) {
  if (!(p = (Bucket *) alloc_root(&ht->mem_root, sizeof(Bucket))))
    return FAILURE;
  }

  p->arKey = arKey;
  p->nKeyLength = nKeyLength;
  p->h = h;

  p->pData = (entry*) my_malloc(sizeof(entry),MYF(MY_WME));
  if (!p->pData) {
    my_free((gptr) p,MYF(0));
  if (!(p->pData = (entry*) alloc_root(&ht->mem_root, sizeof(entry))))
    return FAILURE;
  }

  p->pData->str = str;
  p->pData->pNext = 0;
  p->count = 1;
@@ -209,24 +206,7 @@ Bucket *find_longest_match(HashTable *ht, char *str, uint length,

void completion_hash_clean(HashTable *ht)
{
  uint i;
  entry *e, *t;
  Bucket *b, *tmp;

  for (i=0; i<ht->nTableSize; i++) {
    b = ht->arBuckets[i];
    while (b) {
      e =  b->pData;
      while (e) {
	t = e;
	e = e->pNext;
	my_free((gptr) t,MYF(0));
      }
      tmp = b;
      b = b->pNext;
      my_free((gptr) tmp,MYF(0));
    }
  }
  free_root(&ht->mem_root,MYF(0));
  bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
}

@@ -241,9 +221,7 @@ void completion_hash_free(HashTable *ht)
void add_word(HashTable *ht,char *str)
{
  int i;
  int length= (int) strlen(str);

  for (i=1; i<=length; i++) {
  char *pos=str;
  for (i=1; *pos; i++, pos++)
    completion_hash_update(ht, str, i, str);
}
}
+15 −12
Original line number Diff line number Diff line
@@ -22,13 +22,15 @@
#define FAILURE 1

#include <sys/types.h>
#include <my_sys.h>

typedef struct _entry {
	char *str;
	struct _entry *pNext;
} entry;

typedef struct bucket {
typedef struct bucket
{
  uint h;					/* Used for numeric indexing */
  char *arKey;
  uint nKeyLength;
@@ -40,6 +42,7 @@ typedef struct bucket {
typedef struct hashtable {
  uint nTableSize;
  uint initialized;
  MEM_ROOT mem_root;
  uint(*pHashFunction) (char *arKey, uint nKeyLength);
  Bucket **arBuckets;
} HashTable;
Loading