summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc4
-rw-r--r--cmd-line-utils/libedit/Makefile.am34
-rw-r--r--cmd-line-utils/libedit/README50
-rw-r--r--cmd-line-utils/libedit/TEST/test.c269
-rw-r--r--cmd-line-utils/libedit/chared.c45
-rw-r--r--cmd-line-utils/libedit/chared.h9
-rw-r--r--cmd-line-utils/libedit/common.c27
-rw-r--r--cmd-line-utils/libedit/compat.h43
-rw-r--r--cmd-line-utils/libedit/compat_conf.h2
-rw-r--r--cmd-line-utils/libedit/config.h14
-rw-r--r--cmd-line-utils/libedit/editline.3619
-rw-r--r--cmd-line-utils/libedit/editrc.5491
-rw-r--r--cmd-line-utils/libedit/el.c204
-rw-r--r--cmd-line-utils/libedit/el.h6
-rw-r--r--cmd-line-utils/libedit/el_term.h28
-rw-r--r--cmd-line-utils/libedit/emacs.c15
-rw-r--r--cmd-line-utils/libedit/fgetln.h3
-rw-r--r--cmd-line-utils/libedit/filecomplete.c558
-rw-r--r--cmd-line-utils/libedit/filecomplete.h (renamed from cmd-line-utils/libedit/fgetln.c)72
-rw-r--r--cmd-line-utils/libedit/hist.c8
-rw-r--r--cmd-line-utils/libedit/histedit.h24
-rw-r--r--cmd-line-utils/libedit/history.c62
-rw-r--r--cmd-line-utils/libedit/key.c148
-rw-r--r--cmd-line-utils/libedit/key.h6
-rw-r--r--cmd-line-utils/libedit/libedit_term.h124
-rw-r--r--cmd-line-utils/libedit/makelist.sh16
-rw-r--r--cmd-line-utils/libedit/map.c64
-rw-r--r--cmd-line-utils/libedit/np/fgetln.c50
-rw-r--r--cmd-line-utils/libedit/np/strlcat.c80
-rw-r--r--cmd-line-utils/libedit/np/strlcpy.c77
-rw-r--r--cmd-line-utils/libedit/np/unvis.c99
-rw-r--r--cmd-line-utils/libedit/np/vis.c409
-rw-r--r--cmd-line-utils/libedit/np/vis.h19
-rw-r--r--cmd-line-utils/libedit/parse.c12
-rw-r--r--cmd-line-utils/libedit/parse.h4
-rw-r--r--cmd-line-utils/libedit/prompt.c8
-rw-r--r--cmd-line-utils/libedit/read.c60
-rw-r--r--cmd-line-utils/libedit/read.h9
-rw-r--r--cmd-line-utils/libedit/readline.c838
-rw-r--r--cmd-line-utils/libedit/readline/readline.h38
-rw-r--r--cmd-line-utils/libedit/refresh.c76
-rw-r--r--cmd-line-utils/libedit/search.c9
-rw-r--r--cmd-line-utils/libedit/sig.c20
-rw-r--r--cmd-line-utils/libedit/sig.h3
-rw-r--r--cmd-line-utils/libedit/strlcpy.c73
-rw-r--r--cmd-line-utils/libedit/strlcpy.h2
-rw-r--r--cmd-line-utils/libedit/sys.h27
-rw-r--r--cmd-line-utils/libedit/term.c336
-rw-r--r--cmd-line-utils/libedit/tokenizer.c8
-rw-r--r--cmd-line-utils/libedit/tokenizer.h54
-rw-r--r--cmd-line-utils/libedit/tty.c89
-rw-r--r--cmd-line-utils/libedit/tty.h6
-rw-r--r--cmd-line-utils/libedit/unvis.c311
-rw-r--r--cmd-line-utils/libedit/vi.c39
-rw-r--r--cmd-line-utils/libedit/vis.c392
-rw-r--r--cmd-line-utils/libedit/vis.h92
-rw-r--r--configure.in15
-rw-r--r--include/my_global.h1
-rw-r--r--include/my_sys.h3
-rw-r--r--include/thr_lock.h3
-rw-r--r--mysql-test/Makefile.am8
-rw-r--r--mysql-test/collections/README30
-rw-r--r--mysql-test/collections/README.experimental25
-rw-r--r--mysql-test/collections/default.daily1
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/collections/default.push5
-rw-r--r--mysql-test/collections/default.weekly0
-rw-r--r--mysql-test/extra/binlog_tests/binlog_truncate.test27
-rw-r--r--mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_truncate.test23
-rw-r--r--mysql-test/extra/rpl_tests/rpl_truncate_helper.test56
-rw-r--r--mysql-test/include/check-warnings.test2
-rw-r--r--mysql-test/include/count_sessions.inc21
-rw-r--r--mysql-test/include/ps_modify.inc1
-rw-r--r--mysql-test/include/wait_until_count_sessions.inc112
-rw-r--r--mysql-test/lib/My/ConfigFactory.pm8
-rw-r--r--mysql-test/lib/My/Platform.pm10
-rw-r--r--mysql-test/lib/My/SafeProcess.pm2
-rw-r--r--mysql-test/lib/My/SafeProcess/safe_process.cc16
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_process_win.cc9
-rw-r--r--mysql-test/lib/mtr_report.pm40
-rw-r--r--mysql-test/lib/mtr_unique.pm14
-rwxr-xr-xmysql-test/mysql-test-run.pl165
-rw-r--r--mysql-test/r/auto_increment.result12
-rw-r--r--mysql-test/r/commit_1innodb.result8
-rw-r--r--mysql-test/r/csv_not_null.result5
-rw-r--r--mysql-test/r/delayed.result26
-rw-r--r--mysql-test/r/func_misc.result5
-rw-r--r--mysql-test/r/func_sapdb.result14
-rw-r--r--mysql-test/r/grant2.result23
-rw-r--r--mysql-test/r/have_outfile.require2
-rw-r--r--mysql-test/r/innodb_ignore_builtin.result9
-rw-r--r--mysql-test/r/lock_tables_lost_commit.result12
-rw-r--r--mysql-test/r/merge.result11
-rw-r--r--mysql-test/r/mysqlbinlog_row_trans.result32
-rw-r--r--mysql-test/r/mysqldump.result183
-rw-r--r--mysql-test/r/null.result8
-rw-r--r--mysql-test/r/outfile.resultbin2150 -> 2149 bytes
-rw-r--r--mysql-test/r/ps_2myisam.result5
-rw-r--r--mysql-test/r/ps_3innodb.result5
-rw-r--r--mysql-test/r/ps_4heap.result5
-rw-r--r--mysql-test/r/ps_5merge.result10
-rw-r--r--mysql-test/r/status.result2
-rw-r--r--mysql-test/r/warnings.result3
-rw-r--r--mysql-test/r/xml.result11
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_truncate_innodb.result63
-rw-r--r--mysql-test/suite/binlog/r/binlog_truncate_myisam.result12
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result7
-rw-r--r--mysql-test/suite/binlog/t/binlog_truncate_innodb-master.opt1
-rw-r--r--mysql-test/suite/binlog/t/binlog_truncate_innodb.test29
-rw-r--r--mysql-test/suite/binlog/t/binlog_truncate_myisam.test11
-rw-r--r--mysql-test/suite/binlog/t/binlog_unsafe.test14
-rw-r--r--mysql-test/suite/binlog/t/disabled.def2
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_trig_09.result3
-rw-r--r--mysql-test/suite/funcs_1/r/memory_trig_09.result3
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_trig_09.result3
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_trig_09.result3
-rw-r--r--mysql-test/suite/funcs_1/triggers/triggers_09.inc1
-rw-r--r--mysql-test/suite/maria/r/ps_maria.result5
-rw-r--r--mysql-test/suite/ndb/r/ps_7ndb.result5
-rw-r--r--mysql-test/suite/parts/inc/partition_auto_increment.inc10
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_blackhole.result2
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_innodb.result8
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_memory.result8
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_myisam.result8
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_ndb.result8
-rw-r--r--mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result12
-rw-r--r--mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result12
-rw-r--r--mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_truncate_2myisam.result262
-rw-r--r--mysql-test/suite/rpl/r/rpl_truncate_3innodb.result280
-rw-r--r--mysql-test/suite/rpl/t/rpl_err_ignoredtable.test2
-rw-r--r--mysql-test/suite/rpl_ndb/t/disabled.def3
-rw-r--r--mysql-test/t/auto_increment.test2
-rw-r--r--mysql-test/t/csv_not_null.test1
-rw-r--r--mysql-test/t/delayed.test43
-rw-r--r--mysql-test/t/func_misc.test9
-rw-r--r--mysql-test/t/func_sapdb.test18
-rw-r--r--mysql-test/t/grant2.test124
-rw-r--r--mysql-test/t/grant3.test16
-rw-r--r--mysql-test/t/innodb_ignore_builtin-master.opt1
-rw-r--r--mysql-test/t/innodb_ignore_builtin.test8
-rw-r--r--mysql-test/t/lock_tables_lost_commit.test27
-rw-r--r--mysql-test/t/merge.test14
-rw-r--r--mysql-test/t/mysqldump.test253
-rw-r--r--mysql-test/t/null.test2
-rw-r--r--mysql-test/t/openssl_1.test32
-rw-r--r--mysql-test/t/outfile.test16
-rw-r--r--mysql-test/t/status.test29
-rw-r--r--mysql-test/t/warnings.test1
-rw-r--r--mysql-test/t/xml.test14
-rw-r--r--mysys/my_error.c10
-rw-r--r--mysys/my_init.c8
-rw-r--r--mysys/safemalloc.c2
-rw-r--r--mysys/thr_lock.c9
-rwxr-xr-xnetware/BUILD/nwbootstrap196
-rwxr-xr-xnetware/BUILD/nwbuild86
-rw-r--r--netware/Makefile.am2
-rw-r--r--scripts/make_binary_distribution.sh9
-rw-r--r--scripts/mysqld_multi.sh5
-rw-r--r--sql-bench/bench-init.pl.sh11
-rw-r--r--sql/item.cc25
-rw-r--r--sql/item_timefunc.h1
-rw-r--r--sql/item_xmlfunc.cc8
-rw-r--r--sql/log_event.cc89
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/set_var.cc5
-rw-r--r--sql/share/errmsg.txt48
-rw-r--r--sql/sql_base.cc11
-rw-r--r--sql/sql_class.cc8
-rw-r--r--sql/sql_delete.cc22
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_insert.cc5
-rw-r--r--sql/sql_parse.cc7
-rw-r--r--sql/sql_plugin.cc3
-rw-r--r--sql/sql_select.cc73
-rw-r--r--sql/sql_select.h9
-rw-r--r--sql/sql_table.cc17
-rw-r--r--sql/sql_update.cc8
-rw-r--r--storage/innobase/handler/ha_innodb.cc10
-rw-r--r--storage/maria/ha_maria.cc4
-rw-r--r--storage/myisam/ha_myisam.cc4
-rw-r--r--storage/myisammrg/myrg_open.c27
-rw-r--r--support-files/Makefile.am1
-rw-r--r--support-files/mysql.spec.sh16
188 files changed, 4004 insertions, 5323 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index d61d2781e14..d7de0e0bc3f 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2277,8 +2277,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end);
if not.
*/
-#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE)
extern "C" char *no_completion(const char*,int)
+#elif defined(USE_LIBEDIT_INTERFACE)
+extern "C" int no_completion(const char*,int)
#else
extern "C" char *no_completion()
#endif
diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am
index 23ee20894ec..ddafa4aab44 100644
--- a/cmd-line-utils/libedit/Makefile.am
+++ b/cmd-line-utils/libedit/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to create Makefile.in
-# Makefile for the GNU readline library.
-# Copyright (C) 1994,1996,1997 Free Software Foundation, Inc.
ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
AHDR = vi.h emacs.h common.h
@@ -12,32 +10,22 @@ noinst_LIBRARIES = libedit.a
libedit_a_SOURCES = chared.c el.c history.c map.c prompt.c readline.c \
search.c tokenizer.c vi.c common.c emacs.c \
hist.c key.c parse.c read.c refresh.c sig.c term.c \
- tty.c help.c fcns.c
-
-EXTRA_libedit_a_SOURCES = np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c \
- np/fgetln.c
+ tty.c help.c fcns.c filecomplete.c \
+ np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c \
+ np/fgetln.c
libedit_a_LIBADD = @LIBEDIT_LOBJECTS@
libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@
-noinst_HEADERS = readline/readline.h \
-\
- chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \
- sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \
- search.h tty.h libedit_term.h vis.h
+pkginclude_HEADERS = readline/readline.h
-EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c np/fgetln.c
+noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \
+ sys.h config.h hist.h map.h prompt.h read.h \
+ search.h tty.h filecomplete.h np/vis.h
-CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c
+EXTRA_DIST = makelist.sh
-# Make sure to include stuff from this directory first, to get right "config.h"
-# Automake puts into DEFAULT_INCLUDES this source and corresponding
-# build directory together with ../../include to let all make files
-# find the central "config.h". This variable is used before INCLUDES
-# above. But in automake 1.10 the order of these are changed. Put the
-# includes of this directory into DEFS to always be sure it is first
-# before DEFAULT_INCLUDES on the compile line.
-DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR -I. -I$(srcdir)
+CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c
SUFFIXES = .sh
@@ -101,6 +89,4 @@ term.o: vi.h emacs.h common.h help.h fcns.h
tty.o: vi.h emacs.h common.h help.h fcns.h
help.o: vi.h emacs.h common.h help.h fcns.h
fcns.o: vi.h emacs.h common.h help.h fcns.h
-
-# Don't update the files from bitkeeper
-%::SCCS/s.%
+filecomplete.o: vi.h emacs.h common.h help.h fcns.h
diff --git a/cmd-line-utils/libedit/README b/cmd-line-utils/libedit/README
new file mode 100644
index 00000000000..0b698a6150d
--- /dev/null
+++ b/cmd-line-utils/libedit/README
@@ -0,0 +1,50 @@
+An approximate method to merge from upstream is:
+
+ # Fetch latest from upstream (we also include some compat stuff)
+ $ CVS_RSH=ssh; export CVS_RSH
+ $ CVSROOT="anoncvs@stripped:/cvsroot"
+ $ cvs co -d libedit -P src/lib/libedit
+ $ mkdir libedit/np
+ $ for f in src/common/lib/libc/string/strlcat.c \
+ > src/common/lib/libc/string/strlcpy.c \
+ > src/include/vis.h \
+ > src/lib/libc/gen/unvis.c \
+ > src/lib/libc/gen/vis.c \
+ > src/tools/compat/fgetln.c
+ > do
+ > cvs co -P ${f}
+ > mv ${f} libedit/np
+ > done
+ $ rm -rf src
+ $ cd libedit
+
+ # Remove files we don't need/use
+ $ rm -rf CVS TEST Makefile shlib_version *.[0-9]
+ $ (cd readline; rm -rf CVS Makefile)
+
+ # Rename files to match our naming
+ $ mv makelist makelist.sh
+ $ mv term.h el_term.h
+
+ # Remove NetBSD-specific bits
+ $ for file in $(find . -type f)
+ > do
+ > cp ${file} ${file}.orig
+ > sed -e 's/#include "term.h"/#include "el_term.h"/g' \
+ > -e 's/sig_handler/el_sig_handler/g' \
+ > -e 's/isprint/el_isprint/g' \
+ > -e '/^__RCSID/d' \
+ > ${file}.orig >${file}
+ > rm ${file}.orig
+ > done
+
+then merge remaining bits by hand. All MySQL-specific changes should be
+marked with XXXMYSQL to make them easier to identify and merge. To generate
+a 'clean' diff against upstream you can use the above commands but use
+
+ cvs co -D "2009/02/06 20:09:00" [..]
+
+to fetch the baseline of most recent merge.
+
+Please feed any fixes to Jonathan Perkin <jperkin@stripped> who will endeavour
+to merge them upstream and keep diffs minimal.
diff --git a/cmd-line-utils/libedit/TEST/test.c b/cmd-line-utils/libedit/TEST/test.c
deleted file mode 100644
index 605341eac62..00000000000
--- a/cmd-line-utils/libedit/TEST/test.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/* $NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include "compat.h"
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
-#if !defined(lint) && !defined(SCCSID)
-#if 0
-static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $");
-#endif
-#endif /* not lint && not SCCSID */
-
-/*
- * test.c: A little test program
- */
-#include "sys.h"
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include "histedit.h"
-#include "tokenizer.h"
-
-static int continuation = 0;
-static EditLine *el = NULL;
-
-static u_char complete(EditLine *, int);
- int main(int, char **);
-static char *prompt(EditLine *);
-static void sig(int);
-
-static char *
-prompt(EditLine *el)
-{
- static char a[] = "Edit$";
- static char b[] = "Edit>";
-
- return (continuation ? b : a);
-}
-
-static void
-sig(int i)
-{
-
- (void) fprintf(stderr, "Got signal %d.\n", i);
- el_reset(el);
-}
-
-static unsigned char
-complete(EditLine *el, int ch)
-{
- DIR *dd = opendir(".");
- struct dirent *dp;
- const char* ptr;
- const LineInfo *lf = el_line(el);
- int len;
-
- /*
- * Find the last word
- */
- for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--)
- continue;
- len = lf->cursor - ++ptr;
-
- for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
- if (len > strlen(dp->d_name))
- continue;
- if (strncmp(dp->d_name, ptr, len) == 0) {
- closedir(dd);
- if (el_insertstr(el, &dp->d_name[len]) == -1)
- return (CC_ERROR);
- else
- return (CC_REFRESH);
- }
- }
-
- closedir(dd);
- return (CC_ERROR);
-}
-
-int
-main(int argc, char *argv[])
-{
- int num;
- const char *buf;
- Tokenizer *tok;
- int lastevent = 0, ncontinuation;
- History *hist;
- HistEvent ev;
-
- (void) signal(SIGINT, sig);
- (void) signal(SIGQUIT, sig);
- (void) signal(SIGHUP, sig);
- (void) signal(SIGTERM, sig);
-
- hist = history_init(); /* Init the builtin history */
- /* Remember 100 events */
- history(hist, &ev, H_SETSIZE, 100);
-
- tok = tok_init(NULL); /* Initialize the tokenizer */
-
- /* Initialize editline */
- el = el_init(*argv, stdin, stdout, stderr);
-
- el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */
- el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */
- el_set(el, EL_PROMPT, prompt); /* Set the prompt function */
-
- /* Tell editline to use this history interface */
- el_set(el, EL_HIST, history, hist);
-
- /* Add a user-defined function */
- el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
-
- /* Bind tab to it */
- el_set(el, EL_BIND, "^I", "ed-complete", NULL);
-
- /*
- * Bind j, k in vi command mode to previous and next line, instead
- * of previous and next history.
- */
- el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL);
- el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL);
-
- /*
- * Source the user's defaults file.
- */
- el_source(el, NULL);
-
- while ((buf = el_gets(el, &num)) != NULL && num != 0) {
- int ac;
- char **av;
-#ifdef DEBUG
- (void) fprintf(stderr, "got %d %s", num, buf);
-#endif
- if (!continuation && num == 1)
- continue;
-
- if (tok_line(tok, buf, &ac, &av) > 0)
- ncontinuation = 1;
-
-#if 0
- if (continuation) {
- /*
- * Append to the right event in case the user
- * moved around in history.
- */
- if (history(hist, &ev, H_SET, lastevent) == -1)
- err(1, "%d: %s\n", lastevent, ev.str);
- history(hist, &ev, H_ADD , buf);
- } else {
- history(hist, &ev, H_ENTER, buf);
- lastevent = ev.num;
- }
-#else
- /* Simpler */
- history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf);
-#endif
-
- continuation = ncontinuation;
- ncontinuation = 0;
-
- if (strcmp(av[0], "history") == 0) {
- int rv;
-
- switch (ac) {
- case 1:
- for (rv = history(hist, &ev, H_LAST); rv != -1;
- rv = history(hist, &ev, H_PREV))
- (void) fprintf(stdout, "%4d %s",
- ev.num, ev.str);
- break;
-
- case 2:
- if (strcmp(av[1], "clear") == 0)
- history(hist, &ev, H_CLEAR);
- else
- goto badhist;
- break;
-
- case 3:
- if (strcmp(av[1], "load") == 0)
- history(hist, &ev, H_LOAD, av[2]);
- else if (strcmp(av[1], "save") == 0)
- history(hist, &ev, H_SAVE, av[2]);
- break;
-
- badhist:
- default:
- (void) fprintf(stderr,
- "Bad history arguments\n");
- break;
- }
- } else if (el_parse(el, ac, av) == -1) {
- switch (fork()) {
- case 0:
- execvp(av[0], av);
- perror(av[0]);
- _exit(1);
- /*NOTREACHED*/
- break;
-
- case -1:
- perror("fork");
- break;
-
- default:
- if (wait(&num) == -1)
- perror("wait");
- (void) fprintf(stderr, "Exit %x\n", num);
- break;
- }
- }
-
- tok_reset(tok);
- }
-
- el_end(el);
- tok_end(tok);
- history_end(hist);
-
- return (0);
-}
diff --git a/cmd-line-utils/libedit/chared.c b/cmd-line-utils/libedit/chared.c
index 4cb6e00d26e..e4823db7147 100644
--- a/cmd-line-utils/libedit/chared.c
+++ b/cmd-line-utils/libedit/chared.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $ */
+/* $NetBSD: chared.c,v 1.26 2009/02/06 12:45:25 sketch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* chared.c: Character editor utilities
@@ -40,6 +46,8 @@
#include <stdlib.h>
#include "el.h"
+private void ch__clearmacro (EditLine *);
+
/* value to leave unused in line buffer */
#define EL_LEAVE 2
@@ -51,13 +59,13 @@ cv_undo(EditLine *el)
{
c_undo_t *vu = &el->el_chared.c_undo;
c_redo_t *r = &el->el_chared.c_redo;
- int size;
+ unsigned int size;
/* Save entire line for undo */
size = el->el_line.lastchar - el->el_line.buffer;
vu->len = size;
vu->cursor = el->el_line.cursor - el->el_line.buffer;
- memcpy(vu->buf, el->el_line.buffer, (size_t)size);
+ memcpy(vu->buf, el->el_line.buffer, size);
/* save command info for redo */
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
@@ -439,6 +447,8 @@ cv__endword(char *p, char *high, int n, int (*wtest)(int))
protected int
ch_init(EditLine *el)
{
+ c_macro_t *ma = &el->el_chared.c_macro;
+
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
if (el->el_line.buffer == NULL)
return (-1);
@@ -479,11 +489,10 @@ ch_init(EditLine *el)
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
- el->el_chared.c_macro.level = -1;
- el->el_chared.c_macro.offset = 0;
- el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
- sizeof(char *));
- if (el->el_chared.c_macro.macro == NULL)
+ ma->level = -1;
+ ma->offset = 0;
+ ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
+ if (ma->macro == NULL)
return (-1);
return (0);
}
@@ -492,7 +501,7 @@ ch_init(EditLine *el)
* Reset the character editor
*/
protected void
-ch_reset(EditLine *el)
+ch_reset(EditLine *el, int mclear)
{
el->el_line.cursor = el->el_line.buffer;
el->el_line.lastchar = el->el_line.buffer;
@@ -513,9 +522,19 @@ ch_reset(EditLine *el)
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
- el->el_chared.c_macro.level = -1;
-
el->el_history.eventno = 0;
+
+ if (mclear)
+ ch__clearmacro(el);
+}
+
+private void
+ch__clearmacro(el)
+ EditLine *el;
+{
+ c_macro_t *ma = &el->el_chared.c_macro;
+ while (ma->level >= 0)
+ el_free((ptr_t)ma->macro[ma->level--]);
}
/* ch_enlargebufs():
@@ -623,9 +642,9 @@ ch_end(EditLine *el)
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
el_free((ptr_t) el->el_chared.c_kill.buf);
el->el_chared.c_kill.buf = NULL;
+ ch_reset(el, 1);
el_free((ptr_t) el->el_chared.c_macro.macro);
el->el_chared.c_macro.macro = NULL;
- ch_reset(el);
}
diff --git a/cmd-line-utils/libedit/chared.h b/cmd-line-utils/libedit/chared.h
index 2dd0a5795c7..fa8f5a58d83 100644
--- a/cmd-line-utils/libedit/chared.h
+++ b/cmd-line-utils/libedit/chared.h
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $ */
+/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -48,7 +48,7 @@
#define EL_MAXMACRO 10
/*
- * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
+ * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
* like real vi: i.e. the transition from command<->insert modes moves
* the cursor.
*
@@ -116,11 +116,10 @@ typedef struct el_chared_t {
} el_chared_t;
-#define STReof "^D\b\b"
#define STRQQ "\"\""
#define isglob(a) (strchr("*[]?", (a)) != NULL)
-#define isword(a) (isprint(a))
+#define isword(a) (el_isprint(a))
#define NOP 0x00
#define DELETE 0x01
@@ -161,7 +160,7 @@ protected int c_gets(EditLine *, char *, const char *);
protected int c_hpos(EditLine *);
protected int ch_init(EditLine *);
-protected void ch_reset(EditLine *);
+protected void ch_reset(EditLine *, int);
protected int ch_enlargebufs(EditLine *, size_t);
protected void ch_end(EditLine *);
diff --git a/cmd-line-utils/libedit/common.c b/cmd-line-utils/libedit/common.c
index 81bf9bf29ff..d4d024eae10 100644
--- a/cmd-line-utils/libedit/common.c
+++ b/cmd-line-utils/libedit/common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $ */
+/* $NetBSD: common.c,v 1.21 2008/09/30 08:37:42 aymeric Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* common.c: Common Editor functions
@@ -130,7 +136,7 @@ ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
+ed_delete_next_char(EditLine *el, int c)
{
#ifdef notdef /* XXX */
#define EL el->el_line
@@ -147,9 +153,8 @@ ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
#ifdef KSHVI
return (CC_ERROR);
#else
- term_overwrite(el, STReof, 4);
- /* then do a EOF */
- term__flush();
+ /* then do an EOF */
+ term_writechar(el, c);
return (CC_EOF);
#endif
} else {
@@ -207,13 +212,13 @@ ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
el->el_line.cursor = el->el_line.lastchar;
if (el->el_map.type == MAP_VI) {
-#ifdef VI_MOVE
- el->el_line.cursor--;
-#endif
if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
+#ifdef VI_MOVE
+ el->el_line.cursor--;
+#endif
}
return (CC_CURSOR);
}
@@ -609,7 +614,7 @@ protected el_action_t
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
{
- ch_reset(el);
+ ch_reset(el, 0);
return (CC_REFRESH);
}
@@ -904,7 +909,7 @@ ed_command(EditLine *el, int c __attribute__((__unused__)))
int tmplen;
tmplen = c_gets(el, tmpbuf, "\n: ");
- term__putc('\n');
+ term__putc(el, '\n');
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
term_beep(el);
diff --git a/cmd-line-utils/libedit/compat.h b/cmd-line-utils/libedit/compat.h
deleted file mode 100644
index 3693a2db809..00000000000
--- a/cmd-line-utils/libedit/compat.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __LIBEDIT_COMPATH_H
-#define __LIBEDIT_COMPATH_H
-
-#define __RCSID(x)
-#define __COPYRIGHT(x)
-
-#include "compat_conf.h"
-
-#ifndef HAVE_VIS_H
-/* string visual representation - may want to reimplement */
-#define strvis(d,s,m) strcpy(d,s)
-#define strunvis(d,s) strcpy(d,s)
-#endif
-
-#ifndef HAVE_FGETLN
-#include "fgetln.h"
-#endif
-
-#ifndef HAVE_ISSETUGID
-#define issetugid() (getuid()!=geteuid() || getegid()!=getgid())
-#endif
-
-#ifndef HAVE_STRLCPY
-#include "strlcpy.h"
-#endif
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-#endif
-
-#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#define __attribute__(A)
-#endif
-
-#endif
diff --git a/cmd-line-utils/libedit/compat_conf.h b/cmd-line-utils/libedit/compat_conf.h
deleted file mode 100644
index e2b9557f5b1..00000000000
--- a/cmd-line-utils/libedit/compat_conf.h
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "my_config.h"
diff --git a/cmd-line-utils/libedit/config.h b/cmd-line-utils/libedit/config.h
index 642123d1ddc..2c3989ee316 100644
--- a/cmd-line-utils/libedit/config.h
+++ b/cmd-line-utils/libedit/config.h
@@ -1,16 +1,2 @@
-
#include "my_config.h"
#include "sys.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#define __RCSID(x)
-#define __COPYRIGHT(x)
-#endif
-#define __RENAME(x)
-#define _DIAGASSERT(x)
-
-#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#define __attribute__(A)
-#endif
-
-
diff --git a/cmd-line-utils/libedit/editline.3 b/cmd-line-utils/libedit/editline.3
deleted file mode 100644
index 1b812ebcc79..00000000000
--- a/cmd-line-utils/libedit/editline.3
+++ /dev/null
@@ -1,619 +0,0 @@
-.\" $NetBSD: editline.3,v 1.21 2001/04/02 18:29:49 wiz Exp $
-.\"
-.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd November 12, 1999
-.Os
-.Dt EDITLINE 3
-.Sh NAME
-.Nm editline ,
-.Nm el_init ,
-.Nm el_end ,
-.Nm el_reset ,
-.Nm el_gets ,
-.Nm el_getc ,
-.Nm el_push ,
-.Nm el_parse ,
-.Nm el_set ,
-.Nm el_source ,
-.Nm el_resize ,
-.Nm el_line ,
-.Nm el_insertstr ,
-.Nm el_deletestr ,
-.Nm history_init ,
-.Nm history_end ,
-.Nm history
-.Nd line editor and history functions
-.Sh LIBRARY
-.Lb libedit
-.Sh SYNOPSIS
-.Fd #include <histedit.h>
-.Ft EditLine *
-.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
-.Ft void
-.Fn el_end "EditLine *e"
-.Ft void
-.Fn el_reset "EditLine *e"
-.Ft const char *
-.Fn el_gets "EditLine *e" "int *count"
-.Ft int
-.Fn el_getc "EditLine *e" "char *ch"
-.Ft void
-.Fn el_push "EditLine *e" "const char *str"
-.Ft int
-.Fn el_parse "EditLine *e" "int argc" "char *argv[]"
-.Ft int
-.Fn el_set "EditLine *e" "int op" "..."
-.Ft int
-.Fn el_get "EditLine *e" "int op" "void *result"
-.Ft int
-.Fn el_source "EditLine *e" "const char *file"
-.Ft void
-.Fn el_resize "EditLine *e"
-.Ft const LineInfo *
-.Fn el_line "EditLine *e"
-.Ft int
-.Fn el_insertstr "EditLine *e" "const char *str"
-.Ft void
-.Fn el_deletestr "EditLine *e" "int count"
-.Ft History *
-.Fn history_init
-.Ft void
-.Fn history_end "History *h"
-.Ft int
-.Fn history "History *h" "HistEvent *ev" "int op" "..."
-.Sh DESCRIPTION
-The
-.Nm
-library provides generic line editing and history functions,
-similar to those found in
-.Xr sh 1 .
-.Pp
-These functions are available in the
-.Nm libedit
-library (which needs the
-.Nm libtermcap
-library).
-Programs should be linked with
-.Fl ledit ltermcap .
-.Sh LINE EDITING FUNCTIONS
-The line editing functions use a common data structure,
-.Fa EditLine ,
-which is created by
-.Fn el_init
-and freed by
-.Fn el_end .
-.Pp
-The following functions are available:
-.Bl -tag -width 4n
-.It Fn el_init
-Initialise the line editor, and return a data structure
-to be used by all other line editing functions.
-.Fa prog
-is the name of the invoking program, used when reading the
-.Xr editrc 5
-file to determine which settings to use.
-.Fa fin ,
-.Fa fout
-and
-.Fa ferr
-are the input, output, and error streams (respectively) to use.
-In this documentation, references to
-.Dq the tty
-are actually to this input/output stream combination.
-.It Fn el_end
-Clean up and finish with
-.Fa e ,
-assumed to have been created with
-.Fn el_init .
-.It Fn el_reset
-Reset the tty and the parser.
-This should be called after an error which may have upset the tty's
-state.
-.It Fn el_gets
-Read a line from the tty.
-.Fa count
-is modified to contain the number of characters read.
-Returns the line read if successful, or
-.Dv NULL
-if no characters were read or if an error occurred.
-.It Fn el_getc
-Read a character from the tty.
-.Fa ch
-is modified to contain the character read.
-Returns the number of characters read if successful, -1 otherwise.
-.It Fn el_push
-Pushes
-.Fa str
-back onto the input stream.
-This is used by the macro expansion mechanism.
-Refer to the description of
-.Ic bind
-.Fl s
-in
-.Xr editrc 5
-for more information.
-.It Fn el_parse
-Parses the
-.Fa argv
-array (which is
-.Fa argc
-elements in size)
-to execute builtin
-.Nm
-commands.
-If the command is prefixed with
-.Dq prog:
-then
-.Fn el_parse
-will only execute the command if
-.Dq prog
-matches the
-.Fa prog
-argument supplied to
-.Fn el_init .
-The return value is
--1 if the command is unknown,
-0 if there was no error or
-.Dq prog
-didn't match, or
-1 if the command returned an error.
-Refer to
-.Xr editrc 5
-for more information.
-.It Fn el_set
-Set
-.Nm
-parameters.
-.Fa op
-determines which parameter to set, and each operation has its
-own parameter list.
-.Pp
-The following values for
-.Fa op
-are supported, along with the required argument list:
-.Bl -tag -width 4n
-.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
-Define prompt printing function as
-.Fa f ,
-which is to return a string that contains the prompt.
-.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
-Define right side prompt printing function as
-.Fa f ,
-which is to return a string that contains the prompt.
-.It Dv EL_TERMINAL , Fa "const char *type"
-Define terminal type of the tty to be
-.Fa type ,
-or to
-.Ev TERM
-if
-.Fa type
-is
-.Dv NULL .
-.It Dv EL_EDITOR , Fa "const char *mode"
-Set editing mode to
-.Fa mode ,
-which must be one of
-.Dq emacs
-or
-.Dq vi .
-.It Dv EL_SIGNAL , Fa "int flag"
-If
-.Fa flag
-is non-zero,
-.Nm
-will install its own signal handler for the following signals when
-reading command input:
-.Dv SIGCONT ,
-.Dv SIGHUP ,
-.Dv SIGINT ,
-.Dv SIGQUIT ,
-.Dv SIGSTOP ,
-.Dv SIGTERM ,
-.Dv SIGTSTP ,
-and
-.Dv SIGWINCH .
-Otherwise, the current signal handlers will be used.
-.It Dv EL_BIND , Xo
-.Fa "const char *" ,
-.Fa "..." ,
-.Dv NULL
-.Xc
-Perform the
-.Ic bind
-builtin command.
-Refer to
-.Xr editrc 5
-for more information.
-.It Dv EL_ECHOTC , Xo
-.Fa "const char *" ,
-.Fa "..." ,
-.Dv NULL
-.Xc
-Perform the
-.Ic echotc
-builtin command.
-Refer to
-.Xr editrc 5
-for more information.
-.It Dv EL_SETTC , Xo
-.Fa "const char *" ,
-.Fa "..." ,
-.Dv NULL
-.Xc
-Perform the
-.Ic settc
-builtin command.
-Refer to
-.Xr editrc 5
-for more information.
-.It Dv EL_SETTY , Xo
-.Fa "const char *" ,
-.Fa "..." ,
-.Dv NULL
-.Xc
-Perform the
-.Ic setty
-builtin command.
-Refer to
-.Xr editrc 5
-for more information.
-.It Dv EL_TELLTC , Xo
-.Fa "const char *" ,
-.Fa "..." ,
-.Dv NULL
-.Xc
-Perform the
-.Ic telltc
-builtin command.
-Refer to
-.Xr editrc 5
-for more information.
-.It Dv EL_ADDFN , Xo
-.Fa "const char *name" ,
-.Fa "const char *help" ,
-.Fa "unsigned char (*func)(EditLine *e, int ch)
-.Xc
-Add a user defined function,
-.Fn func ,
-referred to as
-.Fa name
-which is invoked when a key which is bound to
-.Fa name
-is entered.
-.Fa help
-is a description of
-.Fa name .
-At invocation time,
-.Fa ch
-is the key which caused the invocation.
-The return value of
-.Fn func
-should be one of:
-.Bl -tag -width "CC_REDISPLAY"
-.It Dv CC_NORM
-Add a normal character.
-.It Dv CC_NEWLINE
-End of line was entered.
-.It Dv CC_EOF
-EOF was entered.
-.It Dv CC_ARGHACK
-Expecting further command input as arguments, do nothing visually.
-.It Dv CC_REFRESH
-Refresh display.
-.It Dv CC_REFRESH_BEEP
-Refresh display, and beep.
-.It Dv CC_CURSOR
-Cursor moved, so update and perform
-.Dv CC_REFRESH.
-.It Dv CC_REDISPLAY
-Redisplay entire input line.
-This is useful if a key binding outputs extra information.
-.It Dv CC_ERROR
-An error occurred.
-Beep, and flush tty.
-.It Dv CC_FATAL
-Fatal error, reset tty to known state.
-.El
-.It Dv EL_HIST , Xo
-.Fa "History *(*func)(History *, int op, ...)" ,
-.Fa "const char *ptr"
-.Xc
-Defines which history function to use, which is usually
-.Fn history .
-.Fa ptr
-should be the value returned by
-.Fn history_init .
-.It Dv EL_EDITMODE , Fa "int flag"
-If
-.Fa flag
-is non-zero,
-editing is enabled (the default).
-Note that this is only an indication, and does not
-affect the operation of
-.Nm "" .
-At this time, it is the caller's responsibility to
-check this
-(using
-.Fn el_get )
-to determine if editing should be enabled or not.
-.El
-.It Fn el_get
-Get
-.Nm
-parameters.
-.Fa op
-determines which parameter to retrieve into
-.Fa result .
-.Pp
-The following values for
-.Fa op
-are supported, along with actual type of
-.Fa result :
-.Bl -tag -width 4n
-.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
-Return a pointer to the function that displays the prompt.
-.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
-Return a pointer to the function that displays the rightside prompt.
-.It Dv EL_EDITOR , Fa "const char *"
-Return the name of the editor, which will be one of
-.Dq emacs
-or
-.Dq vi .
-.It Dv EL_SIGNAL , Fa "int *"
-Return non-zero if
-.Nm
-has installed private signal handlers (see
-.Fn el_get
-above).
-.It Dv EL_EDITMODE, Fa "int *"
-Return non-zero if editing is enabled.
-.El
-.It Fn el_source
-Initialise
-.Nm
-by reading the contents of
-.Fa file .
-.Fn el_parse
-is called for each line in
-.Fa file .
-If
-.Fa file
-is
-.Dv NULL ,
-try
-.Pa $PWD/.editrc
-then
-.Pa $HOME/.editrc .
-Refer to
-.Xr editrc 5
-for details on the format of
-.Fa file .
-.It Fn el_resize
-Must be called if the terminal size changes.
-If
-.Dv EL_SIGNAL
-has been set with
-.Fn el_set ,
-then this is done automatically.
-Otherwise, it's the responsibility of the application to call
-.Fn el_resize
-on the appropriate occasions.
-.It Fn el_line
-Return the editing information for the current line in a
-.Fa LineInfo
-structure, which is defined as follows:
-.Bd -literal
-typedef struct lineinfo {
- const char *buffer; /* address of buffer */
- const char *cursor; /* address of cursor */
- const char *lastchar; /* address of last character */
-} LineInfo;
-.Ed
-.It Fn el_insertstr
-Insert
-.Fa str
-into the line at the cursor.
-Returns -1 if
-.Fa str
-is empty or won't fit, and 0 otherwise.
-.It Fn el_deletestr
-Delete
-.Fa num
-characters before the cursor.
-.El
-.Sh HISTORY LIST FUNCTIONS
-The history functions use a common data structure,
-.Fa History ,
-which is created by
-.Fn history_init
-and freed by
-.Fn history_end .
-.Pp
-The following functions are available:
-.Bl -tag -width 4n
-.It Fn history_init
-Initialise the history list, and return a data structure
-to be used by all other history list functions.
-.It Fn history_end
-Clean up and finish with
-.Fa h ,
-assumed to have been created with
-.Fn history_init .
-.It Fn history
-Perform operation
-.Fa op
-on the history list, with optional arguments as needed by the
-operation.
-.Fa ev
-is changed accordingly to operation.
-The following values for
-.Fa op
-are supported, along with the required argument list:
-.Bl -tag -width 4n
-.It Dv H_SETSIZE , Fa "int size"
-Set size of history to
-.Fa size
-elements.
-.It Dv H_GETSIZE
-Get number of events currently in history.
-.It Dv H_END
-Cleans up and finishes with
-.Fa h ,
-assumed to be created with
-.Fn history_init .
-.It Dv H_CLEAR
-Clear the history.
-.It Dv H_FUNC , Xo
-.Fa "void *ptr" ,
-.Fa "history_gfun_t first" ,
-.Fa "history_gfun_t next" ,
-.Fa "history_gfun_t last" ,
-.Fa "history_gfun_t prev" ,
-.Fa "history_gfun_t curr" ,
-.Fa "history_sfun_t set" ,
-.Fa "history_vfun_t clear" ,
-.Fa "history_efun_t enter" ,
-.Fa "history_efun_t add"
-.Xc
-Define functions to perform various history operations.
-.Fa ptr
-is the argument given to a function when it's invoked.
-.It Dv H_FIRST
-Return the first element in the history.
-.It Dv H_LAST
-Return the last element in the history.
-.It Dv H_PREV
-Return the previous element in the history.
-.It Dv H_NEXT
-Return the next element in the history.
-.It Dv H_CURR
-Return the current element in the history.
-.It Dv H_SET
-Set the cursor to point to the requested element.
-.It Dv H_ADD , Fa "const char *str"
-Append
-.Fa str
-to the current element of the history, or create an element with
-.It Dv H_APPEND , Fa "const char *str"
-Append
-.Fa str
-to the last new element of the history.
-.It Dv H_ENTER , Fa "const char *str"
-Add
-.Fa str
-as a new element to the history, and, if necessary,
-removing the oldest entry to keep the list to the created size.
-.It Dv H_PREV_STR , Fa "const char *str"
-Return the closest previous event that starts with
-.Fa str .
-.It Dv H_NEXT_STR , Fa "const char *str"
-Return the closest next event that starts with
-.Fa str .
-.It Dv H_PREV_EVENT , Fa "int e"
-Return the previous event numbered
-.Fa e .
-.It Dv H_NEXT_EVENT , Fa "int e"
-Return the next event numbered
-.Fa e .
-.It Dv H_LOAD , Fa "const char *file"
-Load the history list stored in
-.Fa file .
-.It Dv H_SAVE , Fa "const char *file"
-Save the history list to
-.Fa file .
-.El
-.Pp
-.Fn history
-returns 0 if the operation
-.Fa op
-succeeds. Otherwise, -1 is returned and
-.Fa ev
-is updated to contain more details about the error.
-.El
-.\"XXX.Sh EXAMPLES
-.\"XXX: provide some examples
-.Sh SEE ALSO
-.Xr editrc 5 ,
-.Xr sh 1 ,
-.Xr signal 3 ,
-.Xr termcap 3
-.Sh HISTORY
-The
-.Nm
-library first appeared in
-.Bx 4.4 .
-.Dv CC_REDISPLAY
-appeared in
-.Nx 1.3 .
-.Dv CC_REFRESH_BEEP ,
-.Dv EL_EDITMODE
-and the readline emulation appeared in
-.Nx 1.4 .
-.Dv EL_RPROMPT
-appeared in
-.Nx 1.5 .
-.Sh AUTHORS
-The
-.Nm
-library was written by Christos Zoulas.
-Luke Mewburn wrote this manual and implemented
-.Dv CC_REDISPLAY ,
-.Dv CC_REFRESH_BEEP ,
-.Dv EL_EDITMODE ,
-and
-.Dv EL_RPROMPT .
-Jaromir Dolecek implemented the readline emulation.
-.Sh BUGS
-The tokenization functions are not publically defined in
-.Fd <histedit.h>.
-.Pp
-At this time, it is the responsibility of the caller to
-check the result of the
-.Dv EL_EDITMODE
-operation of
-.Fn el_get
-(after an
-.Fn el_source
-or
-.Fn el_parse )
-to determine if
-.Nm
-should be used for further input.
-I.e.,
-.Dv EL_EDITMODE
-is purely an indication of the result of the most recent
-.Xr editrc 5
-.Ic edit
-command.
diff --git a/cmd-line-utils/libedit/editrc.5 b/cmd-line-utils/libedit/editrc.5
deleted file mode 100644
index b1122618939..00000000000
--- a/cmd-line-utils/libedit/editrc.5
+++ /dev/null
@@ -1,491 +0,0 @@
-.\" $NetBSD: editrc.5,v 1.11 2001/06/19 13:42:09 wiz Exp $
-.\"
-.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd November 8, 2000
-.Os
-.Dt EDITRC 5
-.Sh NAME
-.Nm editrc
-.Nd configuration file for editline library
-.Sh SYNOPSIS
-.Nm
-.Sh DESCRIPTION
-The
-.Nm
-file defines various settings to be used by the
-.Xr editline 3
-library.
-.Pp
-The format of each line is:
-.Dl [prog:]command [arg [...]]
-.Pp
-.Ar command
-is one of the
-.Xr editline 3
-builtin commands.
-Refer to
-.Sx BUILTIN COMMANDS
-for more information.
-.Pp
-.Ar prog
-is the program name string that a program defines when it calls
-.Xr el_init 3
-to setup
-.Xr editline 3 ,
-which is usually
-.Va argv[0] .
-.Ar command
-will be executed for any program which matches
-.Ar prog .
-.Pp
-.Ar prog
-may also be a
-.Xr regex 3
-style
-regular expression, in which case
-.Ar command
-will be executed for any program that matches the regular expression.
-.Pp
-If
-.Ar prog
-is absent,
-.Ar command
-is executed for all programs.
-.Sh BUILTIN COMMANDS
-The
-.Nm editline
-library has some builtin commands, which affect the way
-that the line editing and history functions operate.
-These are based on similar named builtins present in the
-.Xr tcsh 1
-shell.
-.Pp
-The following builtin commands are available:
-.Bl -tag -width 4n
-.It Ic bind Xo
-.Op Fl a
-.Op Fl e
-.Op Fl k
-.Op Fl l
-.Op Fl r
-.Op Fl s
-.Op Fl v
-.Op Ar key Op Ar command
-.Xc
-Without options, list all bound keys, and the editor command to which
-each is bound.
-If
-.Ar key
-is supplied, show the bindings for
-.Ar key .
-If
-.Ar key command
-is supplied, bind
-.Ar command
-to
-.Ar key .
-Options include:
-.Bl -tag -width 4n
-.It Fl e
-Bind all keys to the standard GNU Emacs-like bindings.
-.It Fl v
-Bind all keys to the standard
-.Xr vi 1 -like
-bindings.
-.It Fl a
-List or change key bindings in the
-.Xr vi 1
-mode alternate (command mode) key map.
-.It Fl k
-.Ar key
-is interpreted as a symbolic arrow key name, which may be one of
-.Sq up ,
-.Sq down ,
-.Sq left
-or
-.Sq right .
-.It Fl l
-List all editor commands and a short description of each.
-.It Fl r
-Remove a key's binding.
-.It Fl s
-.Ar command
-is taken as a literal string and treated as terminal input when
-.Ar key
-is typed.
-Bound keys in
-.Ar command
-are themselves reinterpreted, and this continues for ten levels of
-interpretation.
-.El
-.Pp
-.Ar command
-may be one of the commands documented in
-.Sx "EDITOR COMMANDS"
-below, or another key.
-.Pp
-.Ar key
-and
-.Ar command
-can contain control characters of the form
-.Sm off
-.Sq No ^ Ar character
-.Sm on
-.Po
-e.g.
-.Sq ^A
-.Pc ,
-and the following backslashed escape sequences:
-.Pp
-.Bl -tag -compact -offset indent -width 4n
-.It Ic \ea
-Bell
-.It Ic \eb
-Backspace
-.It Ic \ee
-Escape
-.It Ic \ef
-Formfeed
-.It Ic \en
-Newline
-.It Ic \er
-Carriage return
-.It Ic \et
-Horizontal tab
-.It Ic \ev
-Vertical tab
-.Sm off
-.It Sy \e Ar nnn
-.Sm on
-The ASCII character corresponding to the octal number
-.Ar nnn .
-.El
-.Pp
-.Sq \e
-nullifies the special meaning of the following character,
-if it has any, notably
-.Sq \e
-and
-.Sq ^ .
-.It Ic echotc Xo
-.Op Fl sv
-.Ar arg
-.Ar ...
-.Xc
-Exercise terminal capabilities given in
-.Ar arg Ar ... .
-If
-.Ar arg
-is
-.Sq baud ,
-.Sq cols ,
-.Sq lines ,
-.Sq rows ,
-.Sq meta or
-.Sq tabs ,
-the value of that capability is printed, with
-.Dq yes
-or
-.Dq no
-indicating that the terminal does or does not have that capability.
-.Pp
-.Fl s
-returns an emptry string for non-existent capabilities, rather than
-causing an error.
-.Fl v
-causes messages to be verbose.
-.It Ic edit Op Li on | Li off
-Enable or disable the
-.Nm editline
-functionality in a program.
-.It Ic history
-List the history.
-.It Ic telltc
-List the values of all the terminal capabilities (see
-.Xr termcap 5 ).
-.It Ic settc Ar cap Ar val
-Set the terminal capability
-.Ar cap
-to
-.Ar val ,
-as defined in
-.Xr termcap 5 .
-No sanity checking is done.
-.It Ic setty Xo
-.Op Fl a
-.Op Fl d
-.Op Fl q
-.Op Fl x
-.Op Ar +mode
-.Op Ar -mode
-.Op Ar mode
-.Xc
-Control which tty modes that
-.Nm
-won't allow the user to change.
-.Fl d ,
-.Fl q
-or
-.Fl x
-tells
-.Ic setty
-to act on the
-.Sq edit ,
-.Sq quote
-or
-.Sq execute
-set of tty modes respectively; defaulting to
-.Fl x .
-.Pp
-Without other arguments,
-.Ic setty
-lists the modes in the chosen set which are fixed on
-.Po
-.Sq +mode
-.Pc
-or off
-.Po
-.Sq -mode
-.Pc .
-.Fl a
-lists all tty modes in the chosen set regardless of the setting.
-With
-.Ar +mode ,
-.Ar -mode
-or
-.Ar mode ,
-fixes
-.Ar mode
-on or off or removes control of
-.Ar mode
-in the chosen set.
-.El
-.Sh EDITOR COMMANDS
-The following editor commands are available for use in key bindings:
-.\" Section automatically generated with makelist
-.Bl -tag -width 4n
-.It Ic vi-paste-next
-Vi paste previous deletion to the right of the cursor.
-.It Ic vi-paste-prev
-Vi paste previous deletion to the left of the cursor.
-.It Ic vi-prev-space-word
-Vi move to the previous space delimited word.
-.It Ic vi-prev-word
-Vi move to the previous word.
-.It Ic vi-next-space-word
-Vi move to the next space delimited word.
-.It Ic vi-next-word
-Vi move to the next word.
-.It Ic vi-change-case
-Vi change case of character under the cursor and advance one character.
-.It Ic vi-change-meta
-Vi change prefix command.
-.It Ic vi-insert-at-bol
-Vi enter insert mode at the beginning of line.
-.It Ic vi-replace-char
-Vi replace character under the cursor with the next character typed.
-.It Ic vi-replace-mode
-Vi enter replace mode.
-.It Ic vi-substitute-char
-Vi replace character under the cursor and enter insert mode.
-.It Ic vi-substitute-line
-Vi substitute entire line.
-.It Ic vi-change-to-eol
-Vi change to end of line.
-.It Ic vi-insert
-Vi enter insert mode.
-.It Ic vi-add
-Vi enter insert mode after the cursor.
-.It Ic vi-add-at-eol
-Vi enter insert mode at end of line.
-.It Ic vi-delete-meta
-Vi delete prefix command.
-.It Ic vi-end-word
-Vi move to the end of the current space delimited word.
-.It Ic vi-to-end-word
-Vi move to the end of the current word.
-.It Ic vi-undo
-Vi undo last change.
-.It Ic vi-command-mode
-Vi enter command mode (use alternative key bindings).
-.It Ic vi-zero
-Vi move to the beginning of line.
-.It Ic vi-delete-prev-char
-Vi move to previous character (backspace).
-.It Ic vi-list-or-eof
-Vi list choices for completion or indicate end of file if empty line.
-.It Ic vi-kill-line-prev
-Vi cut from beginning of line to cursor.
-.It Ic vi-search-prev
-Vi search history previous.
-.It Ic vi-search-next
-Vi search history next.
-.It Ic vi-repeat-search-next
-Vi repeat current search in the same search direction.
-.It Ic vi-repeat-search-prev
-Vi repeat current search in the opposite search direction.
-.It Ic vi-next-char
-Vi move to the character specified next.
-.It Ic vi-prev-char
-Vi move to the character specified previous.
-.It Ic vi-to-next-char
-Vi move up to the character specified next.
-.It Ic vi-to-prev-char
-Vi move up to the character specified previous.
-.It Ic vi-repeat-next-char
-Vi repeat current character search in the same search direction.
-.It Ic vi-repeat-prev-char
-Vi repeat current character search in the opposite search direction.
-.It Ic em-delete-or-list
-Delete character under cursor or list completions if at end of line.
-.It Ic em-delete-next-word
-Cut from cursor to end of current word.
-.It Ic em-yank
-Paste cut buffer at cursor position.
-.It Ic em-kill-line
-Cut the entire line and save in cut buffer.
-.It Ic em-kill-region
-Cut area between mark and cursor and save in cut buffer.
-.It Ic em-copy-region
-Copy area between mark and cursor to cut buffer.
-.It Ic em-gosmacs-traspose
-Exchange the two characters before the cursor.
-.It Ic em-next-word
-Move next to end of current word.
-.It Ic em-upper-case
-Uppercase the characters from cursor to end of current word.
-.It Ic em-capitol-case
-Capitalize the characters from cursor to end of current word.
-.It Ic em-lower-case
-Lowercase the characters from cursor to end of current word.
-.It Ic em-set-mark
-Set the mark at cursor.
-.It Ic em-exchange-mark
-Exchange the cursor and mark.
-.It Ic em-universal-argument
-Universal argument (argument times 4).
-.It Ic em-meta-next
-Add 8th bit to next character typed.
-.It Ic em-toggle-overwrite
-Switch from insert to overwrite mode or vice versa.
-.It Ic em-copy-prev-word
-Copy current word to cursor.
-.It Ic em-inc-search-next
-Emacs incremental next search.
-.It Ic em-inc-search-prev
-Emacs incremental reverse search.
-.It Ic ed-end-of-file
-Indicate end of file.
-.It Ic ed-insert
-Add character to the line.
-.It Ic ed-delete-prev-word
-Delete from beginning of current word to cursor.
-.It Ic ed-delete-next-char
-Delete character under cursor.
-.It Ic ed-kill-line
-Cut to the end of line.
-.It Ic ed-move-to-end
-Move cursor to the end of line.
-.It Ic ed-move-to-beg
-Move cursor to the beginning of line.
-.It Ic ed-transpose-chars
-Exchange the character to the left of the cursor with the one under it.
-.It Ic ed-next-char
-Move to the right one character.
-.It Ic ed-prev-word
-Move to the beginning of the current word.
-.It Ic ed-prev-char
-Move to the left one character.
-.It Ic ed-quoted-insert
-Add the next character typed verbatim.
-.It Ic ed-digit
-Adds to argument or enters a digit.
-.It Ic ed-argument-digit
-Digit that starts argument.
-.It Ic ed-unassigned
-Indicates unbound character.
-.It Ic ed-tty-sigint
-Tty interrupt character.
-.It Ic ed-tty-dsusp
-Tty delayed suspend character.
-.It Ic ed-tty-flush-output
-Tty flush output characters.
-.It Ic ed-tty-sigquit
-Tty quit character.
-.It Ic ed-tty-sigtstp
-Tty suspend character.
-.It Ic ed-tty-stop-output
-Tty disallow output characters.
-.It Ic ed-tty-start-output
-Tty allow output characters.
-.It Ic ed-newline
-Execute command.
-.It Ic ed-delete-prev-char
-Delete the character to the left of the cursor.
-.It Ic ed-clear-screen
-Clear screen leaving current line at the top.
-.It Ic ed-redisplay
-Redisplay everything.
-.It Ic ed-start-over
-Erase current line and start from scratch.
-.It Ic ed-sequence-lead-in
-First character in a bound sequence.
-.It Ic ed-prev-history
-Move to the previous history line.
-.It Ic ed-next-history
-Move to the next history line.
-.It Ic ed-search-prev-history
-Search previous in history for a line matching the current.
-.It Ic ed-search-next-history
-Search next in history for a line matching the current.
-.It Ic ed-prev-line
-Move up one line.
-.It Ic ed-next-line
-Move down one line.
-.It Ic ed-command
-Editline extended command.
-.El
-.\" End of section automatically generated with makelist
-.Sh SEE ALSO
-.Xr editline 3 ,
-.Xr regex 3 ,
-.Xr termcap 5
-.Sh AUTHORS
-The
-.Nm editline
-library was written by Christos Zoulas,
-and this manual was written by Luke Mewburn,
-with some sections inspired by
-.Xr tcsh 1 .
diff --git a/cmd-line-utils/libedit/el.c b/cmd-line-utils/libedit/el.c
index c32a01b2151..d99946eb68f 100644
--- a/cmd-line-utils/libedit/el.c
+++ b/cmd-line-utils/libedit/el.c
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp $ */
+/* $NetBSD: el.c,v 1.47 2009/01/18 12:17:24 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* el.c: EditLine interface functions
@@ -58,9 +64,12 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
memset(el, 0, sizeof(EditLine));
- el->el_infd = fileno(fin);
+ el->el_infile = fin;
el->el_outfile = fout;
el->el_errfile = ferr;
+
+ el->el_infd = fileno(fin);
+
if ((el->el_prog = el_strdup(prog)) == NULL) {
el_free(el);
return NULL;
@@ -126,7 +135,7 @@ el_reset(EditLine *el)
{
tty_cookedmode(el);
- ch_reset(el); /* XXX: Do we want that? */
+ ch_reset(el, 0); /* XXX: Do we want that? */
}
@@ -136,29 +145,29 @@ el_reset(EditLine *el)
public int
el_set(EditLine *el, int op, ...)
{
- va_list va;
+ va_list ap;
int rv = 0;
if (el == NULL)
return (-1);
- va_start(va, op);
+ va_start(ap, op);
switch (op) {
case EL_PROMPT:
case EL_RPROMPT:
- rv = prompt_set(el, va_arg(va, el_pfunc_t), op);
+ rv = prompt_set(el, va_arg(ap, el_pfunc_t), op);
break;
case EL_TERMINAL:
- rv = term_set(el, va_arg(va, char *));
+ rv = term_set(el, va_arg(ap, char *));
break;
case EL_EDITOR:
- rv = map_set_editor(el, va_arg(va, char *));
+ rv = map_set_editor(el, va_arg(ap, char *));
break;
case EL_SIGNAL:
- if (va_arg(va, int))
+ if (va_arg(ap, int))
el->el_flags |= HANDLE_SIGNALS;
else
el->el_flags &= ~HANDLE_SIGNALS;
@@ -167,6 +176,7 @@ el_set(EditLine *el, int op, ...)
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
+ case EL_GETTC:
case EL_ECHOTC:
case EL_SETTY:
{
@@ -174,7 +184,7 @@ el_set(EditLine *el, int op, ...)
int i;
for (i = 1; i < 20; i++)
- if ((argv[i] = va_arg(va, char *)) == NULL)
+ if ((argv[i] = va_arg(ap, char *)) == NULL)
break;
switch (op) {
@@ -213,9 +223,9 @@ el_set(EditLine *el, int op, ...)
case EL_ADDFN:
{
- char *name = va_arg(va, char *);
- char *help = va_arg(va, char *);
- el_func_t func = va_arg(va, el_func_t);
+ char *name = va_arg(ap, char *);
+ char *help = va_arg(ap, char *);
+ el_func_t func = va_arg(ap, el_func_t);
rv = map_addfunc(el, name, help, func);
break;
@@ -223,15 +233,15 @@ el_set(EditLine *el, int op, ...)
case EL_HIST:
{
- hist_fun_t func = va_arg(va, hist_fun_t);
- ptr_t ptr = va_arg(va, char *);
+ hist_fun_t func = va_arg(ap, hist_fun_t);
+ ptr_t ptr = va_arg(ap, char *);
rv = hist_set(el, func, ptr);
break;
}
case EL_EDITMODE:
- if (va_arg(va, int))
+ if (va_arg(ap, int))
el->el_flags &= ~EDIT_DISABLED;
else
el->el_flags |= EDIT_DISABLED;
@@ -240,17 +250,17 @@ el_set(EditLine *el, int op, ...)
case EL_GETCFN:
{
- el_rfunc_t rc = va_arg(va, el_rfunc_t);
+ el_rfunc_t rc = va_arg(ap, el_rfunc_t);
rv = el_read_setfn(el, rc);
break;
}
case EL_CLIENTDATA:
- el->el_data = va_arg(va, void *);
+ el->el_data = va_arg(ap, void *);
break;
case EL_UNBUFFERED:
- rv = va_arg(va, int);
+ rv = va_arg(ap, int);
if (rv && !(el->el_flags & UNBUFFERED)) {
el->el_flags |= UNBUFFERED;
read_prepare(el);
@@ -262,7 +272,7 @@ el_set(EditLine *el, int op, ...)
break;
case EL_PREP_TERM:
- rv = va_arg(va, int);
+ rv = va_arg(ap, int);
if (rv)
(void) tty_rawmode(el);
else
@@ -270,12 +280,45 @@ el_set(EditLine *el, int op, ...)
rv = 0;
break;
+ case EL_SETFP:
+ {
+ FILE *fp;
+ int what;
+
+ what = va_arg(ap, int);
+ fp = va_arg(ap, FILE *);
+
+ rv = 0;
+ switch (what) {
+ case 0:
+ el->el_infile = fp;
+ el->el_infd = fileno(fp);
+ break;
+ case 1:
+ el->el_outfile = fp;
+ break;
+ case 2:
+ el->el_errfile = fp;
+ break;
+ default:
+ rv = -1;
+ break;
+ }
+ break;
+ }
+
+ case EL_REFRESH:
+ re_clear_display(el);
+ re_refresh(el);
+ term__flush(el);
+ break;
+
default:
rv = -1;
break;
}
- va_end(va);
+ va_end(ap);
return (rv);
}
@@ -284,90 +327,71 @@ el_set(EditLine *el, int op, ...)
* retrieve the editline parameters
*/
public int
-el_get(EditLine *el, int op, void *ret)
+el_get(EditLine *el, int op, ...)
{
+ va_list ap;
int rv;
- if (el == NULL || ret == NULL)
- return (-1);
+ if (el == NULL)
+ return -1;
+
+ va_start(ap, op);
+
switch (op) {
case EL_PROMPT:
case EL_RPROMPT:
- rv = prompt_get(el, (void *) &ret, op);
+ rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op);
break;
case EL_EDITOR:
- rv = map_get_editor(el, (void *) &ret);
+ rv = map_get_editor(el, va_arg(ap, const char **));
break;
case EL_SIGNAL:
- *((int *) ret) = (el->el_flags & HANDLE_SIGNALS);
+ *va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS);
rv = 0;
break;
case EL_EDITMODE:
- *((int *) ret) = (!(el->el_flags & EDIT_DISABLED));
+ *va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED);
rv = 0;
break;
case EL_TERMINAL:
- term_get(el, (const char **)ret);
+ term_get(el, va_arg(ap, const char **));
rv = 0;
break;
-#if 0 /* XXX */
- case EL_BIND:
- case EL_TELLTC:
- case EL_SETTC:
- case EL_ECHOTC:
- case EL_SETTY:
+ case EL_GETTC:
{
- const char *argv[20];
+ static char name[] = "gettc";
+ char *argv[20];
int i;
- for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
- if ((argv[i] = va_arg(va, char *)) == NULL)
+ for (i = 1; i < (int)(sizeof(argv) / sizeof(argv[0])); i++)
+ if ((argv[i] = va_arg(ap, char *)) == NULL)
break;
switch (op) {
- case EL_BIND:
- argv[0] = "bind";
- rv = map_bind(el, i, argv);
- break;
-
- case EL_TELLTC:
- argv[0] = "telltc";
- rv = term_telltc(el, i, argv);
- break;
-
- case EL_SETTC:
- argv[0] = "settc";
- rv = term_settc(el, i, argv);
- break;
-
- case EL_ECHOTC:
- argv[0] = "echotc";
- rv = term_echotc(el, i, argv);
- break;
-
- case EL_SETTY:
- argv[0] = "setty";
- rv = tty_stty(el, i, argv);
+ case EL_GETTC:
+ argv[0] = name;
+ rv = term_gettc(el, i, argv);
break;
default:
rv = -1;
- EL_ABORT((el->errfile, "Bad op %d\n", op));
+ EL_ABORT((el->el_errfile, "Bad op %d\n", op));
break;
}
break;
}
+#if 0 /* XXX */
case EL_ADDFN:
{
- char *name = va_arg(va, char *);
- char *help = va_arg(va, char *);
- el_func_t func = va_arg(va, el_func_t);
+ char *name = va_arg(ap, char *);
+ char *help = va_arg(ap, char *);
+ el_func_t func = va_arg(ap, el_func_t);
rv = map_addfunc(el, name, help, func);
break;
@@ -375,31 +399,57 @@ el_get(EditLine *el, int op, void *ret)
case EL_HIST:
{
- hist_fun_t func = va_arg(va, hist_fun_t);
- ptr_t ptr = va_arg(va, char *);
+ hist_fun_t func = va_arg(ap, hist_fun_t);
+ ptr_t ptr = va_arg(ap, char *);
rv = hist_set(el, func, ptr);
}
break;
#endif /* XXX */
case EL_GETCFN:
- *((el_rfunc_t *)ret) = el_read_getfn(el);
+ *va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
rv = 0;
break;
case EL_CLIENTDATA:
- *((void **)ret) = el->el_data;
+ *va_arg(ap, void **) = el->el_data;
rv = 0;
break;
case EL_UNBUFFERED:
- *((int *) ret) = (!(el->el_flags & UNBUFFERED));
+ *va_arg(ap, int *) = (!(el->el_flags & UNBUFFERED));
rv = 0;
break;
+ case EL_GETFP:
+ {
+ int what;
+ FILE **fpp;
+
+ what = va_arg(ap, int);
+ fpp = va_arg(ap, FILE **);
+ rv = 0;
+ switch (what) {
+ case 0:
+ *fpp = el->el_infile;
+ break;
+ case 1:
+ *fpp = el->el_outfile;
+ break;
+ case 2:
+ *fpp = el->el_errfile;
+ break;
+ default:
+ rv = -1;
+ break;
+ }
+ break;
+ }
default:
rv = -1;
+ break;
}
+ va_end(ap);
return (rv);
}
@@ -428,17 +478,17 @@ el_source(EditLine *el, const char *fname)
fp = NULL;
if (fname == NULL) {
+#ifdef HAVE_ISSETUGID
static const char elpath[] = "/.editrc";
+/* XXXMYSQL: Portability fix (for which platforms?) */
#ifdef MAXPATHLEN
char path[MAXPATHLEN];
#else
char path[4096];
#endif
-#ifdef HAVE_ISSETUGID
if (issetugid())
return (-1);
-#endif
if ((ptr = getenv("HOME")) == NULL)
return (-1);
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
@@ -446,6 +496,14 @@ el_source(EditLine *el, const char *fname)
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
return (-1);
fname = path;
+#else
+ /*
+ * If issetugid() is missing, always return an error, in order
+ * to keep from inadvertently opening up the user to a security
+ * hole.
+ */
+ return (-1);
+#endif
}
if (fp == NULL)
fp = fopen(fname, "r");
diff --git a/cmd-line-utils/libedit/el.h b/cmd-line-utils/libedit/el.h
index d9379d7c8aa..05d88ad88ba 100644
--- a/cmd-line-utils/libedit/el.h
+++ b/cmd-line-utils/libedit/el.h
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ */
+/* $NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -110,6 +110,7 @@ typedef struct el_state_t {
struct editline {
char *el_prog; /* the program name */
+ FILE *el_infile; /* Stdio stuff */
FILE *el_outfile; /* Stdio stuff */
FILE *el_errfile; /* Stdio stuff */
int el_infd; /* Input file descriptor */
@@ -136,7 +137,8 @@ struct editline {
protected int el_editmode(EditLine *, int, const char **);
-#define el_isprint(x) ((unsigned char) (x) < 0x80 ? isprint(x) : 1)
+/* XXXMYSQL: Bug#23097 mysql can't insert korean on mysql prompt. */
+#define el_isprint(x) ((unsigned char) (x) < 0x80 ? isprint(x) : 1)
#ifdef DEBUG
#define EL_ABORT(a) do { \
diff --git a/cmd-line-utils/libedit/el_term.h b/cmd-line-utils/libedit/el_term.h
index 00ca48e38e2..0e7ddd555f4 100644
--- a/cmd-line-utils/libedit/el_term.h
+++ b/cmd-line-utils/libedit/el_term.h
@@ -1,4 +1,4 @@
-/* $NetBSD: term.h,v 1.15 2003/09/14 21:48:55 christos Exp $ */
+/* $NetBSD: term.h,v 1.19 2008/09/10 15:45:37 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -81,25 +81,6 @@ typedef struct {
#define A_K_EN 5
#define A_K_NKEYS 6
-#ifdef _SUNOS
-extern int tgetent(char *, const char *);
-extern int tgetflag(char *);
-extern int tgetnum(char *);
-extern int tputs(const char *, int, int (*)(int));
-extern char* tgoto(const char*, int, int);
-extern char* tgetstr(char*, char**);
-#endif
-
-
-#if !HAVE_DECL_TGOTO
-/*
- 'tgoto' is not declared in the system header files, this causes
- problems on 64-bit systems. The function returns a 64 bit pointer
- but caller see it as "int" and it's thus truncated to 32-bit
-*/
-extern char* tgoto(const char*, int, int);
-#endif
-
protected void term_move_to_line(EditLine *, int);
protected void term_move_to_char(EditLine *, int);
protected void term_clear_EOL(EditLine *, int);
@@ -119,10 +100,12 @@ protected void term_end(EditLine *);
protected void term_get(EditLine *, const char **);
protected int term_set(EditLine *, const char *);
protected int term_settc(EditLine *, int, const char **);
+protected int term_gettc(EditLine *, int, char **);
protected int term_telltc(EditLine *, int, const char **);
protected int term_echotc(EditLine *, int, const char **);
-protected int term__putc(int);
-protected void term__flush(void);
+protected void term_writec(EditLine *, int);
+protected int term__putc(EditLine *, int);
+protected void term__flush(EditLine *);
/*
* Easy access macros
@@ -134,6 +117,7 @@ protected void term__flush(void);
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
+#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP)
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
diff --git a/cmd-line-utils/libedit/emacs.c b/cmd-line-utils/libedit/emacs.c
index 79f2bf0c818..135bd75f566 100644
--- a/cmd-line-utils/libedit/emacs.c
+++ b/cmd-line-utils/libedit/emacs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $ */
+/* $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* emacs.c: Emacs functions
@@ -45,15 +51,14 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
+em_delete_or_list(EditLine *el, int c)
{
if (el->el_line.cursor == el->el_line.lastchar) {
/* if I'm at the end */
if (el->el_line.cursor == el->el_line.buffer) {
/* and the beginning */
- term_overwrite(el, STReof, 4); /* then do a EOF */
- term__flush();
+ term_writec(el, c); /* then do an EOF */
return (CC_EOF);
} else {
/*
diff --git a/cmd-line-utils/libedit/fgetln.h b/cmd-line-utils/libedit/fgetln.h
deleted file mode 100644
index b2ddce01da9..00000000000
--- a/cmd-line-utils/libedit/fgetln.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <stdio.h>
-
-char *fgetln(FILE *stream, size_t *len);
diff --git a/cmd-line-utils/libedit/filecomplete.c b/cmd-line-utils/libedit/filecomplete.c
new file mode 100644
index 00000000000..4c63f57bc45
--- /dev/null
+++ b/cmd-line-utils/libedit/filecomplete.c
@@ -0,0 +1,558 @@
+/* $NetBSD: filecomplete.c,v 1.13 2009/01/26 17:32:41 apb Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jaromir Dolecek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* AIX requires this to be the first thing in the file. */
+#if defined (_AIX) && !defined (__GNUC__)
+ #pragma alloca
+#endif
+
+#include "config.h"
+
+/* XXXMYSQL */
+#ifdef __GNUC__
+# undef alloca
+# define alloca(n) __builtin_alloca (n)
+#else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifndef _AIX
+extern char *alloca ();
+# endif
+# endif
+#endif
+
+#if !defined(lint) && !defined(SCCSID)
+#endif /* not lint && not SCCSID */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <pwd.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
+#include "np/vis.h"
+#endif
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#include "el.h"
+#include "fcns.h" /* for EL_NUM_FCNS */
+#include "histedit.h"
+#include "filecomplete.h"
+
+static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
+ '>', '<', '=', ';', '|', '&', '{', '(', '\0' };
+
+
+/********************************/
+/* completion functions */
+
+/*
+ * does tilde expansion of strings of type ``~user/foo''
+ * if ``user'' isn't valid user name or ``txt'' doesn't start
+ * w/ '~', returns pointer to strdup()ed copy of ``txt''
+ *
+ * it's callers's responsibility to free() returned string
+ */
+char *
+fn_tilde_expand(const char *txt)
+{
+ struct passwd pwres, *pass;
+ char *temp;
+ size_t len = 0;
+ char pwbuf[1024];
+
+ if (txt[0] != '~')
+ return (strdup(txt));
+
+ temp = strchr(txt + 1, '/');
+ if (temp == NULL) {
+ temp = strdup(txt + 1);
+ if (temp == NULL)
+ return NULL;
+ } else {
+ len = temp - txt + 1; /* text until string after slash */
+ temp = malloc(len);
+ if (temp == NULL)
+ return NULL;
+ (void)strncpy(temp, txt + 1, len - 2);
+ temp[len - 2] = '\0';
+ }
+ /* XXXMYSQL: use non-_r functions for now */
+ if (temp[0] == 0) {
+ pass = getpwuid(getuid());
+ } else {
+ pass = getpwnam(temp);
+ }
+ free(temp); /* value no more needed */
+ if (pass == NULL)
+ return (strdup(txt));
+
+ /* update pointer txt to point at string immedially following */
+ /* first slash */
+ txt += len;
+
+ temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
+ if (temp == NULL)
+ return NULL;
+ (void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
+
+ return (temp);
+}
+
+
+/*
+ * return first found file name starting by the ``text'' or NULL if no
+ * such file can be found
+ * value of ``state'' is ignored
+ *
+ * it's caller's responsibility to free returned string
+ */
+char *
+fn_filename_completion_function(const char *text, int state)
+{
+ static DIR *dir = NULL;
+ static char *filename = NULL, *dirname = NULL, *dirpath = NULL;
+ static size_t filename_len = 0;
+ struct dirent *entry;
+ char *temp;
+ size_t len;
+
+ if (state == 0 || dir == NULL) {
+ temp = strrchr(text, '/');
+ if (temp) {
+ char *nptr;
+ temp++;
+ nptr = realloc(filename, strlen(temp) + 1);
+ if (nptr == NULL) {
+ free(filename);
+ return NULL;
+ }
+ filename = nptr;
+ (void)strcpy(filename, temp);
+ len = temp - text; /* including last slash */
+ nptr = realloc(dirname, len + 1);
+ if (nptr == NULL) {
+ free(filename);
+ return NULL;
+ }
+ dirname = nptr;
+ (void)strncpy(dirname, text, len);
+ dirname[len] = '\0';
+ } else {
+ if (*text == 0)
+ filename = NULL;
+ else {
+ filename = strdup(text);
+ if (filename == NULL)
+ return NULL;
+ }
+ dirname = NULL;
+ }
+
+ if (dir != NULL) {
+ (void)closedir(dir);
+ dir = NULL;
+ }
+
+ /* support for ``~user'' syntax */
+ free(dirpath);
+
+ if (dirname == NULL && (dirname = strdup("./")) == NULL)
+ return NULL;
+
+ if (*dirname == '~')
+ dirpath = fn_tilde_expand(dirname);
+ else
+ dirpath = strdup(dirname);
+
+ if (dirpath == NULL)
+ return NULL;
+
+ dir = opendir(dirpath);
+ if (!dir)
+ return (NULL); /* cannot open the directory */
+
+ /* will be used in cycle */
+ filename_len = filename ? strlen(filename) : 0;
+ }
+
+ /* find the match */
+ while ((entry = readdir(dir)) != NULL) {
+ /* skip . and .. */
+ if (entry->d_name[0] == '.' && (!entry->d_name[1]
+ || (entry->d_name[1] == '.' && !entry->d_name[2])))
+ continue;
+ if (filename_len == 0)
+ break;
+ /* otherwise, get first entry where first */
+ /* filename_len characters are equal */
+ if (entry->d_name[0] == filename[0]
+#if HAVE_STRUCT_DIRENT_D_NAMLEN
+ && entry->d_namlen >= filename_len
+#else
+ && strlen(entry->d_name) >= filename_len
+#endif
+ && strncmp(entry->d_name, filename,
+ filename_len) == 0)
+ break;
+ }
+
+ if (entry) { /* match found */
+
+#if HAVE_STRUCT_DIRENT_D_NAMLEN
+ len = entry->d_namlen;
+#else
+ len = strlen(entry->d_name);
+#endif
+
+ temp = malloc(strlen(dirname) + len + 1);
+ if (temp == NULL)
+ return NULL;
+ (void)sprintf(temp, "%s%s", dirname, entry->d_name);
+ } else {
+ (void)closedir(dir);
+ dir = NULL;
+ temp = NULL;
+ }
+
+ return (temp);
+}
+
+
+static const char *
+append_char_function(const char *name)
+{
+ struct stat stbuf;
+ char *expname = *name == '~' ? fn_tilde_expand(name) : NULL;
+ const char *rs = " ";
+
+ if (stat(expname ? expname : name, &stbuf) == -1)
+ goto out;
+ if (S_ISDIR(stbuf.st_mode))
+ rs = "/";
+out:
+ if (expname)
+ free(expname);
+ return rs;
+}
+/*
+ * returns list of completions for text given
+ * non-static for readline.
+ */
+char ** completion_matches(const char *, char *(*)(const char *, int));
+char **
+completion_matches(const char *text, char *(*genfunc)(const char *, int))
+{
+ char **match_list = NULL, *retstr, *prevstr;
+ size_t match_list_len, max_equal, which, i;
+ size_t matches;
+
+ matches = 0;
+ match_list_len = 1;
+ while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
+ /* allow for list terminator here */
+ if (matches + 3 >= match_list_len) {
+ char **nmatch_list;
+ while (matches + 3 >= match_list_len)
+ match_list_len <<= 1;
+ nmatch_list = realloc(match_list,
+ match_list_len * sizeof(char *));
+ if (nmatch_list == NULL) {
+ free(match_list);
+ return NULL;
+ }
+ match_list = nmatch_list;
+
+ }
+ match_list[++matches] = retstr;
+ }
+
+ if (!match_list)
+ return NULL; /* nothing found */
+
+ /* find least denominator and insert it to match_list[0] */
+ which = 2;
+ prevstr = match_list[1];
+ max_equal = strlen(prevstr);
+ for (; which <= matches; which++) {
+ for (i = 0; i < max_equal &&
+ prevstr[i] == match_list[which][i]; i++)
+ continue;
+ max_equal = i;
+ }
+
+ retstr = malloc(max_equal + 1);
+ if (retstr == NULL) {
+ free(match_list);
+ return NULL;
+ }
+ (void)strncpy(retstr, match_list[1], max_equal);
+ retstr[max_equal] = '\0';
+ match_list[0] = retstr;
+
+ /* add NULL as last pointer to the array */
+ match_list[matches + 1] = (char *) NULL;
+
+ return (match_list);
+}
+
+/*
+ * Sort function for qsort(). Just wrapper around strcasecmp().
+ */
+static int
+_fn_qsort_string_compare(const void *i1, const void *i2)
+{
+ const char *s1 = ((const char * const *)i1)[0];
+ const char *s2 = ((const char * const *)i2)[0];
+
+ return strcasecmp(s1, s2);
+}
+
+/*
+ * Display list of strings in columnar format on readline's output stream.
+ * 'matches' is list of strings, 'len' is number of strings in 'matches',
+ * 'max' is maximum length of string in 'matches'.
+ */
+void
+fn_display_match_list (EditLine *el, char **matches, int len, int max)
+{
+ int i, idx, limit, count;
+ int screenwidth = el->el_term.t_size.h;
+
+ /*
+ * Find out how many entries can be put on one line, count
+ * with two spaces between strings.
+ */
+ limit = screenwidth / (max + 2);
+ if (limit == 0)
+ limit = 1;
+
+ /* how many lines of output */
+ count = len / limit;
+ if (count * limit < len)
+ count++;
+
+ /* Sort the items if they are not already sorted. */
+ qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
+ _fn_qsort_string_compare);
+
+ idx = 1;
+ for(; count > 0; count--) {
+ for(i = 0; i < limit && matches[idx]; i++, idx++)
+ (void)fprintf(el->el_outfile, "%-*s ", max,
+ matches[idx]);
+ (void)fprintf(el->el_outfile, "\n");
+ }
+}
+
+/*
+ * Complete the word at or before point,
+ * 'what_to_do' says what to do with the completion.
+ * \t means do standard completion.
+ * `?' means list the possible completions.
+ * `*' means insert all of the possible completions.
+ * `!' means to do standard completion, and list all possible completions if
+ * there is more than one.
+ *
+ * Note: '*' support is not implemented
+ * '!' could never be invoked
+ */
+int
+fn_complete(EditLine *el,
+ char *(*complet_func)(const char *, int),
+ char **(*attempted_completion_function)(const char *, int, int),
+ const char *word_break, const char *special_prefixes,
+ const char *(*app_func)(const char *), int query_items,
+ int *completion_type, int *over, int *point, int *end)
+{
+ const LineInfo *li;
+ char *temp, **matches;
+ const char *ctemp;
+ size_t len;
+ int what_to_do = '\t';
+ int retval = CC_NORM;
+
+ if (el->el_state.lastcmd == el->el_state.thiscmd)
+ what_to_do = '?';
+
+ /* readline's rl_complete() has to be told what we did... */
+ if (completion_type != NULL)
+ *completion_type = what_to_do;
+
+ if (!complet_func)
+ complet_func = fn_filename_completion_function;
+ if (!app_func)
+ app_func = append_char_function;
+
+ /* We now look backwards for the start of a filename/variable word */
+ li = el_line(el);
+ ctemp = (const char *) li->cursor;
+ while (ctemp > li->buffer
+ && !strchr(word_break, ctemp[-1])
+ && (!special_prefixes || !strchr(special_prefixes, ctemp[-1]) ) )
+ ctemp--;
+
+ len = li->cursor - ctemp;
+#if defined(__SSP__) || defined(__SSP_ALL__)
+ temp = malloc(len + 1);
+#else
+ temp = alloca(len + 1);
+#endif
+ (void)strncpy(temp, ctemp, len);
+ temp[len] = '\0';
+
+ /* these can be used by function called in completion_matches() */
+ /* or (*attempted_completion_function)() */
+ if (point != 0)
+ *point = li->cursor - li->buffer;
+ if (end != NULL)
+ *end = li->lastchar - li->buffer;
+
+ if (attempted_completion_function) {
+ int cur_off = li->cursor - li->buffer;
+ matches = (*attempted_completion_function) (temp,
+ (int)(cur_off - len), cur_off);
+ } else
+ matches = 0;
+ if (!attempted_completion_function ||
+ (over != NULL && !*over && !matches))
+ matches = completion_matches(temp, complet_func);
+
+ if (over != NULL)
+ *over = 0;
+
+ if (matches) {
+ int i;
+ int matches_num, maxlen, match_len, match_display=1;
+
+ retval = CC_REFRESH;
+ /*
+ * Only replace the completed string with common part of
+ * possible matches if there is possible completion.
+ */
+ if (matches[0][0] != '\0') {
+ el_deletestr(el, (int) len);
+ el_insertstr(el, matches[0]);
+ }
+
+ if (what_to_do == '?')
+ goto display_matches;
+
+ if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
+ /*
+ * We found exact match. Add a space after
+ * it, unless we do filename completion and the
+ * object is a directory.
+ */
+ el_insertstr(el, (*app_func)(matches[0]));
+ } else if (what_to_do == '!') {
+ display_matches:
+ /*
+ * More than one match and requested to list possible
+ * matches.
+ */
+
+ for(i=1, maxlen=0; matches[i]; i++) {
+ match_len = strlen(matches[i]);
+ if (match_len > maxlen)
+ maxlen = match_len;
+ }
+ matches_num = i - 1;
+
+ /* newline to get on next line from command line */
+ (void)fprintf(el->el_outfile, "\n");
+
+ /*
+ * If there are too many items, ask user for display
+ * confirmation.
+ */
+ if (matches_num > query_items) {
+ (void)fprintf(el->el_outfile,
+ "Display all %d possibilities? (y or n) ",
+ matches_num);
+ (void)fflush(el->el_outfile);
+ if (getc(stdin) != 'y')
+ match_display = 0;
+ (void)fprintf(el->el_outfile, "\n");
+ }
+
+ if (match_display)
+ fn_display_match_list(el, matches, matches_num,
+ maxlen);
+ retval = CC_REDISPLAY;
+ } else if (matches[0][0]) {
+ /*
+ * There was some common match, but the name was
+ * not complete enough. Next tab will print possible
+ * completions.
+ */
+ el_beep(el);
+ } else {
+ /* lcd is not a valid object - further specification */
+ /* is needed */
+ el_beep(el);
+ retval = CC_NORM;
+ }
+
+ /* free elements of array and the array itself */
+ for (i = 0; matches[i]; i++)
+ free(matches[i]);
+ free(matches);
+ matches = NULL;
+ }
+#if defined(__SSP__) || defined(__SSP_ALL__)
+ free(temp);
+#endif
+ return retval;
+}
+
+/*
+ * el-compatible wrapper around rl_complete; needed for key binding
+ */
+/* ARGSUSED */
+unsigned char
+_el_fn_complete(EditLine *el, int ch __attribute__((__unused__)))
+{
+ return (unsigned char)fn_complete(el, NULL, NULL,
+ break_chars, NULL, NULL, 100,
+ NULL, NULL, NULL, NULL);
+}
diff --git a/cmd-line-utils/libedit/fgetln.c b/cmd-line-utils/libedit/filecomplete.h
index 5b95b2f6584..12e0c6f14b0 100644
--- a/cmd-line-utils/libedit/fgetln.c
+++ b/cmd-line-utils/libedit/filecomplete.h
@@ -1,11 +1,11 @@
-/* $NetBSD: fgetln.c,v 1.2 2003/12/10 01:30:27 lukem Exp $ */
+/* $NetBSD: filecomplete.h,v 1.6 2008/04/29 06:53:01 martin Exp $ */
/*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
+ * by Jaromir Dolecek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -35,54 +28,17 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _FILECOMPLETE_H_
+#define _FILECOMPLETE_H_
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
+int fn_complete(EditLine *,
+ char *(*)(const char *, int),
+ char **(*)(const char *, int, int),
+ const char *, const char *, const char *(*)(const char *), int,
+ int *, int *, int *, int *);
+void fn_display_match_list(EditLine *, char **, int, int);
+char *fn_tilde_expand(const char *);
+char *fn_filename_completion_function(const char *, int);
-char *
-fgetln(FILE *fp, size_t *len)
-{
- static char *buf = NULL;
- static size_t bufsiz = 0;
- char *ptr;
-
-
- if (buf == NULL) {
- bufsiz = BUFSIZ;
- if ((buf = malloc(bufsiz)) == NULL)
- return NULL;
- }
-
- if (fgets(buf, bufsiz, fp) == NULL)
- return NULL;
- *len = 0;
-
- while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
- size_t nbufsiz = bufsiz + BUFSIZ;
- char *nbuf = realloc(buf, nbufsiz);
-
- if (nbuf == NULL) {
- int oerrno = errno;
- free(buf);
- errno = oerrno;
- buf = NULL;
- return NULL;
- } else
- buf = nbuf;
-
- *len = bufsiz;
- if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
- return buf;
-
- bufsiz = nbufsiz;
- }
-
- *len = (ptr - buf) + 1;
- return buf;
-}
-
+#endif
diff --git a/cmd-line-utils/libedit/hist.c b/cmd-line-utils/libedit/hist.c
index e8f5c0f39ba..c0b23ee6641 100644
--- a/cmd-line-utils/libedit/hist.c
+++ b/cmd-line-utils/libedit/hist.c
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* hist.c: History access functions
diff --git a/cmd-line-utils/libedit/histedit.h b/cmd-line-utils/libedit/histedit.h
index c58eb62dcfa..37823141c06 100644
--- a/cmd-line-utils/libedit/histedit.h
+++ b/cmd-line-utils/libedit/histedit.h
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.25 2003/12/05 13:37:48 lukem Exp $ */
+/* $NetBSD: histedit.h,v 1.35 2009/02/05 19:15:44 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,11 +41,15 @@
#define _HISTEDIT_H_
#define LIBEDIT_MAJOR 2
-#define LIBEDIT_MINOR 9
+#define LIBEDIT_MINOR 11
#include <sys/types.h>
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* ==== Editing ====
*/
@@ -88,7 +92,7 @@ void el_reset(EditLine *);
*/
const char *el_gets(EditLine *, int *);
int el_getc(EditLine *, char *);
-void el_push(EditLine *, char *);
+void el_push(EditLine *, const char *);
/*
* Beep!
@@ -105,7 +109,8 @@ int el_parse(EditLine *, int, const char **);
* Low level editline access functions
*/
int el_set(EditLine *, int, ...);
-int el_get(EditLine *, int, void *);
+int el_get(EditLine *, int, ...);
+unsigned char _el_fn_complete(EditLine *, int);
/*
* el_set/el_get parameters
@@ -128,8 +133,12 @@ int el_get(EditLine *, int, void *);
#define EL_CLIENTDATA 14 /* , void *); */
#define EL_UNBUFFERED 15 /* , int); */
#define EL_PREP_TERM 16 /* , int); */
+#define EL_GETTC 17 /* , const char *, ..., NULL); */
+#define EL_GETFP 18 /* , int, FILE **); */
+#define EL_SETFP 19 /* , int, FILE *); */
+#define EL_REFRESH 20 /* , void); */
-#define EL_BUILTIN_GETCFN (NULL)
+#define EL_BUILTIN_GETCFN (NULL)
/*
* Source named file or $PWD/.editrc or $HOME/.editrc
@@ -192,6 +201,7 @@ int history(History *, HistEvent *, int, ...);
#define H_CLEAR 19 /* , void); */
#define H_SETUNIQUE 20 /* , int); */
#define H_GETUNIQUE 21 /* , void); */
+#define H_DEL 22 /* , int); */
/*
@@ -211,4 +221,8 @@ int tok_line(Tokenizer *, const LineInfo *,
int tok_str(Tokenizer *, const char *,
int *, const char ***);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _HISTEDIT_H_ */
diff --git a/cmd-line-utils/libedit/history.c b/cmd-line-utils/libedit/history.c
index c0fa7cc717d..3080dd231f6 100644
--- a/cmd-line-utils/libedit/history.c
+++ b/cmd-line-utils/libedit/history.c
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp $ */
+/* $NetBSD: history.c,v 1.33 2009/02/06 14:40:32 sketch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* hist.c: History access functions
@@ -40,7 +46,11 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#ifdef HAVE_VIS_H
#include <vis.h>
+#else
+#include "np/vis.h"
+#endif
#include <sys/stat.h>
static const char hist_cookie[] = "_HiStOrY_V2_\n";
@@ -61,6 +71,7 @@ struct history {
history_gfun_t h_prev; /* Get the previous element */
history_gfun_t h_curr; /* Get the current element */
history_sfun_t h_set; /* Set the current element */
+ history_sfun_t h_del; /* Set the given element */
history_vfun_t h_clear; /* Clear the history list */
history_efun_t h_enter; /* Add an element */
history_efun_t h_add; /* Append to an element */
@@ -75,6 +86,7 @@ struct history {
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
+#define HDEL(h, ev, n) (*(h)->h_del)((h)->h_ref, ev, n)
#define h_strdup(a) strdup(a)
#define h_malloc(a) malloc(a)
@@ -122,16 +134,18 @@ typedef struct history_t {
#define H_UNIQUE 1 /* Store only unique elements */
} history_t;
-private int history_def_first(ptr_t, HistEvent *);
-private int history_def_last(ptr_t, HistEvent *);
private int history_def_next(ptr_t, HistEvent *);
+private int history_def_first(ptr_t, HistEvent *);
private int history_def_prev(ptr_t, HistEvent *);
+private int history_def_last(ptr_t, HistEvent *);
private int history_def_curr(ptr_t, HistEvent *);
-private int history_def_set(ptr_t, HistEvent *, const int n);
+private int history_def_set(ptr_t, HistEvent *, const int);
+private void history_def_clear(ptr_t, HistEvent *);
private int history_def_enter(ptr_t, HistEvent *, const char *);
private int history_def_add(ptr_t, HistEvent *, const char *);
+private int history_def_del(ptr_t, HistEvent *, const int);
+
private int history_def_init(ptr_t *, HistEvent *, int);
-private void history_def_clear(ptr_t, HistEvent *);
private int history_def_insert(history_t *, HistEvent *, const char *);
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
@@ -353,6 +367,24 @@ history_def_add(ptr_t p, HistEvent *ev, const char *str)
}
+/* history_def_del():
+ * Delete element hp of the h list
+ */
+/* ARGSUSED */
+private int
+history_def_del(ptr_t p, HistEvent *ev __attribute__((__unused__)),
+ const int num)
+{
+ history_t *h = (history_t *) p;
+ if (history_def_set(h, ev, num) != 0)
+ return (-1);
+ ev->str = strdup(h->cursor->ev.str);
+ ev->num = h->cursor->ev.num;
+ history_def_delete(h, ev, h->cursor);
+ return (0);
+}
+
+
/* history_def_delete():
* Delete element hp of the h list
*/
@@ -364,6 +396,8 @@ history_def_delete(history_t *h,
HistEventPrivate *evp = (void *)&hp->ev;
if (hp == &h->list)
abort();
+ if (h->cursor == hp)
+ h->cursor = hp->prev;
hp->prev->next = hp->next;
hp->next->prev = hp->prev;
h_free((ptr_t) evp->str);
@@ -497,6 +531,7 @@ history_init(void)
h->h_clear = history_def_clear;
h->h_enter = history_def_enter;
h->h_add = history_def_add;
+ h->h_del = history_def_del;
return (h);
}
@@ -512,6 +547,8 @@ history_end(History *h)
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
+ h_free(h->h_ref);
+ h_free(h);
}
@@ -597,7 +634,7 @@ history_set_fun(History *h, History *nh)
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
- nh->h_ref == NULL) {
+ nh->h_del == NULL || nh->h_ref == NULL) {
if (h->h_next != history_def_next) {
history_def_init(&h->h_ref, &ev, 0);
h->h_first = history_def_first;
@@ -609,6 +646,7 @@ history_set_fun(History *h, History *nh)
h->h_clear = history_def_clear;
h->h_enter = history_def_enter;
h->h_add = history_def_add;
+ h->h_del = history_def_del;
}
return (-1);
}
@@ -625,6 +663,7 @@ history_set_fun(History *h, History *nh)
h->h_clear = nh->h_clear;
h->h_enter = nh->h_enter;
h->h_add = nh->h_add;
+ h->h_del = nh->h_del;
return (0);
}
@@ -676,8 +715,8 @@ history_load(History *h, const char *fname)
(void) strunvis(ptr, line);
line[sz] = c;
if (HENTER(h, &ev, ptr) == -1) {
- i = -1;
- goto oomem;
+ i = -1;
+ goto oomem;
}
}
oomem:
@@ -841,6 +880,10 @@ history(History *h, HistEvent *ev, int fun, ...)
retval = HADD(h, ev, str);
break;
+ case H_DEL:
+ retval = HDEL(h, ev, va_arg(va, const int));
+ break;
+
case H_ENTER:
str = va_arg(va, const char *);
if ((retval = HENTER(h, ev, str)) != -1)
@@ -925,6 +968,7 @@ history(History *h, HistEvent *ev, int fun, ...)
hf.h_clear = va_arg(va, history_vfun_t);
hf.h_enter = va_arg(va, history_efun_t);
hf.h_add = va_arg(va, history_efun_t);
+ hf.h_del = va_arg(va, history_sfun_t);
if ((retval = history_set_fun(h, &hf)) == -1)
he_seterrev(ev, _HE_PARAM_MISSING);
diff --git a/cmd-line-utils/libedit/key.c b/cmd-line-utils/libedit/key.c
index 35fcf0651b2..cda02816861 100644
--- a/cmd-line-utils/libedit/key.c
+++ b/cmd-line-utils/libedit/key.c
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp $ */
+/* $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,14 +32,20 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* key.c: This module contains the procedures for maintaining
* the extended-key map.
*
* An extended-key (key) is a sequence of keystrokes introduced
- * with an sequence introducer and consisting of an arbitrary
+ * with a sequence introducer and consisting of an arbitrary
* number of characters. This module maintains a map (the el->el_key.map)
* to convert these extended-key sequences into input strs
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
@@ -78,12 +84,12 @@ private int node_trav(EditLine *, key_node_t *, char *,
private int node__try(EditLine *, key_node_t *, const char *,
key_value_t *, int);
private key_node_t *node__get(int);
+private void node__free(key_node_t *);
private void node__put(EditLine *, key_node_t *);
private int node__delete(EditLine *, key_node_t **, const char *);
private int node_lookup(EditLine *, const char *, key_node_t *,
int);
private int node_enum(EditLine *, key_node_t *, int);
-private int key__decode_char(char *, int, int);
#define KEY_BUFSIZ EL_BUFSIZ
@@ -103,7 +109,6 @@ key_init(EditLine *el)
return (0);
}
-
/* key_end():
* Free the key maps
*/
@@ -113,8 +118,7 @@ key_end(EditLine *el)
el_free((ptr_t) el->el_key.buf);
el->el_key.buf = NULL;
- /* XXX: provide a function to clear the keys */
- el->el_key.map = NULL;
+ node__free(el->el_key.map);
}
@@ -443,7 +447,7 @@ node__put(EditLine *el, key_node_t *ptr)
/* node__get():
- * Returns pointer to an key_node_t for ch.
+ * Returns pointer to a key_node_t for ch.
*/
private key_node_t *
node__get(int ch)
@@ -461,7 +465,15 @@ node__get(int ch)
return (ptr);
}
-
+private void
+node__free(key_node_t *k)
+{
+ if (k == NULL)
+ return;
+ node__free(k->sibling);
+ node__free(k->next);
+ el_free((ptr_t) k);
+}
/* node_lookup():
* look for the str starting at node ptr.
@@ -483,7 +495,7 @@ node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
/* If match put this char into el->el_key.buf. Recurse */
if (ptr->ch == *str) {
/* match found */
- ncnt = key__decode_char(el->el_key.buf, cnt,
+ ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
(unsigned char) ptr->ch);
if (ptr->next != NULL)
/* not yet at leaf */
@@ -537,7 +549,8 @@ node_enum(EditLine *el, key_node_t *ptr, int cnt)
return (-1);
}
/* put this char at end of str */
- ncnt = key__decode_char(el->el_key.buf, cnt, (unsigned char) ptr->ch);
+ ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
+ (unsigned char)ptr->ch);
if (ptr->next == NULL) {
/* print this key and function */
el->el_key.buf[ncnt + 1] = '"';
@@ -568,9 +581,10 @@ key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
switch (ntype) {
case XK_STR:
case XK_EXE:
- (void) fprintf(el->el_outfile, fmt, key,
- key__decode_str(val->str, unparsbuf,
- ntype == XK_STR ? "\"\"" : "[]"));
+ (void) key__decode_str(val->str, unparsbuf,
+ sizeof(unparsbuf),
+ ntype == XK_STR ? "\"\"" : "[]");
+ (void) fprintf(el->el_outfile, fmt, key, unparsbuf);
break;
case XK_CMD:
for (fp = el->el_map.help; fp->name; fp++)
@@ -595,83 +609,97 @@ key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
}
+#define ADDC(c) \
+ if (b < eb) \
+ *b++ = c; \
+ else \
+ b++
/* key__decode_char():
* Put a printable form of char in buf.
*/
-private int
-key__decode_char(char *buf, int cnt, int ch)
+protected int
+key__decode_char(char *buf, int cnt, int off, int ch)
{
+ char *sb = buf + off;
+ char *eb = buf + cnt;
+ char *b = sb;
if (ch == 0) {
- buf[cnt++] = '^';
- buf[cnt] = '@';
- return (cnt);
+ ADDC('^');
+ ADDC('@');
+ return b - sb;
}
if (iscntrl(ch)) {
- buf[cnt++] = '^';
+ ADDC('^');
if (ch == '\177')
- buf[cnt] = '?';
+ ADDC('?');
else
- buf[cnt] = ch | 0100;
+ ADDC(ch | 0100);
} else if (ch == '^') {
- buf[cnt++] = '\\';
- buf[cnt] = '^';
+ ADDC('\\');
+ ADDC('^');
} else if (ch == '\\') {
- buf[cnt++] = '\\';
- buf[cnt] = '\\';
+ ADDC('\\');
+ ADDC('\\');
} else if (ch == ' ' || (el_isprint(ch) && !isspace(ch))) {
- buf[cnt] = ch;
+ ADDC(ch);
} else {
- buf[cnt++] = '\\';
- buf[cnt++] = (((unsigned int) ch >> 6) & 7) + '0';
- buf[cnt++] = (((unsigned int) ch >> 3) & 7) + '0';
- buf[cnt] = (ch & 7) + '0';
+ ADDC('\\');
+ ADDC((((unsigned int) ch >> 6) & 7) + '0');
+ ADDC((((unsigned int) ch >> 3) & 7) + '0');
+ ADDC((ch & 7) + '0');
}
- return (cnt);
+ return b - sb;
}
/* key__decode_str():
* Make a printable version of the ey
*/
-protected char *
-key__decode_str(const char *str, char *buf, const char *sep)
+protected int
+key__decode_str(const char *str, char *buf, int len, const char *sep)
{
- char *b;
+ char *b = buf, *eb = b + len;
const char *p;
b = buf;
- if (sep[0] != '\0')
- *b++ = sep[0];
- if (*str == 0) {
- *b++ = '^';
- *b++ = '@';
- if (sep[0] != '\0' && sep[1] != '\0')
- *b++ = sep[1];
- *b++ = 0;
- return (buf);
+ if (sep[0] != '\0') {
+ ADDC(sep[0]);
+ }
+ if (*str == '\0') {
+ ADDC('^');
+ ADDC('@');
+ if (sep[0] != '\0' && sep[1] != '\0') {
+ ADDC(sep[1]);
+ }
+ goto done;
}
for (p = str; *p != 0; p++) {
if (iscntrl((unsigned char) *p)) {
- *b++ = '^';
- if (*p == '\177')
- *b++ = '?';
- else
- *b++ = *p | 0100;
+ ADDC('^');
+ if (*p == '\177') {
+ ADDC('?');
+ } else {
+ ADDC(*p | 0100);
+ }
} else if (*p == '^' || *p == '\\') {
- *b++ = '\\';
- *b++ = *p;
+ ADDC('\\');
+ ADDC(*p);
} else if (*p == ' ' || (el_isprint((unsigned char) *p) &&
!isspace((unsigned char) *p))) {
- *b++ = *p;
+ ADDC(*p);
} else {
- *b++ = '\\';
- *b++ = (((unsigned int) *p >> 6) & 7) + '0';
- *b++ = (((unsigned int) *p >> 3) & 7) + '0';
- *b++ = (*p & 7) + '0';
+ ADDC('\\');
+ ADDC((((unsigned int) *p >> 6) & 7) + '0');
+ ADDC((((unsigned int) *p >> 3) & 7) + '0');
+ ADDC((*p & 7) + '0');
}
}
- if (sep[0] != '\0' && sep[1] != '\0')
- *b++ = sep[1];
- *b++ = 0;
- return (buf); /* should check for overflow */
+ if (sep[0] != '\0' && sep[1] != '\0') {
+ ADDC(sep[1]);
+ }
+done:
+ ADDC('\0');
+ if (b - buf >= len)
+ buf[len - 1] = '\0';
+ return b - buf;
}
diff --git a/cmd-line-utils/libedit/key.h b/cmd-line-utils/libedit/key.h
index 39a075c504e..9c6844e6d99 100644
--- a/cmd-line-utils/libedit/key.h
+++ b/cmd-line-utils/libedit/key.h
@@ -1,4 +1,4 @@
-/* $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */
+/* $NetBSD: key.h,v 1.10 2006/03/23 20:22:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -74,6 +74,8 @@ protected int key_delete(EditLine *, const char *);
protected void key_print(EditLine *, const char *);
protected void key_kprint(EditLine *, const char *, key_value_t *,
int);
-protected char *key__decode_str(const char *, char *, const char *);
+protected int key__decode_str(const char *, char *, int,
+ const char *);
+protected int key__decode_char(char *, int, int, int);
#endif /* _h_el_key */
diff --git a/cmd-line-utils/libedit/libedit_term.h b/cmd-line-utils/libedit/libedit_term.h
deleted file mode 100644
index 9f03c549515..00000000000
--- a/cmd-line-utils/libedit/libedit_term.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* $NetBSD: term.h,v 1.12 2001/01/04 15:56:32 christos Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)term.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * el.term.h: Termcap header
- */
-#ifndef _h_el_term
-#define _h_el_term
-
-#include "histedit.h"
-
-typedef struct { /* Symbolic function key bindings */
- const char *name; /* name of the key */
- int key; /* Index in termcap table */
- key_value_t fun; /* Function bound to it */
- int type; /* Type of function */
-} fkey_t;
-
-typedef struct {
- coord_t t_size; /* # lines and cols */
- int t_flags;
-#define TERM_CAN_INSERT 0x001 /* Has insert cap */
-#define TERM_CAN_DELETE 0x002 /* Has delete cap */
-#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */
-#define TERM_CAN_TAB 0x008 /* Can use tabs */
-#define TERM_CAN_ME 0x010 /* Can turn all attrs. */
-#define TERM_CAN_UP 0x020 /* Can move up */
-#define TERM_HAS_META 0x040 /* Has a meta key */
-#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */
-#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */
- char *t_buf; /* Termcap buffer */
- int t_loc; /* location used */
- char **t_str; /* termcap strings */
- int *t_val; /* termcap values */
- char *t_cap; /* Termcap buffer */
- fkey_t *t_fkey; /* Array of keys */
-} el_term_t;
-
-/*
- * fKey indexes
- */
-#define A_K_DN 0
-#define A_K_UP 1
-#define A_K_LT 2
-#define A_K_RT 3
-#define A_K_HO 4
-#define A_K_EN 5
-#define A_K_NKEYS 6
-
-protected void term_move_to_line(EditLine *, int);
-protected void term_move_to_char(EditLine *, int);
-protected void term_clear_EOL(EditLine *, int);
-protected void term_overwrite(EditLine *, const char *, int);
-protected void term_insertwrite(EditLine *, char *, int);
-protected void term_deletechars(EditLine *, int);
-protected void term_clear_screen(EditLine *);
-protected void term_beep(EditLine *);
-protected int term_change_size(EditLine *, int, int);
-protected int term_get_size(EditLine *, int *, int *);
-protected int term_init(EditLine *);
-protected void term_bind_arrow(EditLine *);
-protected void term_print_arrow(EditLine *, const char *);
-protected int term_clear_arrow(EditLine *, const char *);
-protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
-protected void term_end(EditLine *);
-protected int term_set(EditLine *, const char *);
-protected int term_settc(EditLine *, int, const char **);
-protected int term_telltc(EditLine *, int, const char **);
-protected int term_echotc(EditLine *, int, const char **);
-protected int term__putc(int);
-protected void term__flush(void);
-
-/*
- * Easy access macros
- */
-#define EL_FLAGS (el)->el_term.t_flags
-
-#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT)
-#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE)
-#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
-#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
-#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
-#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
-#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
-#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
-
-#endif /* _h_el_term */
diff --git a/cmd-line-utils/libedit/makelist.sh b/cmd-line-utils/libedit/makelist.sh
index f15b3d1eb9f..5d25b4776c9 100644
--- a/cmd-line-utils/libedit/makelist.sh
+++ b/cmd-line-utils/libedit/makelist.sh
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: makelist,v 1.8 2003/03/10 21:21:10 christos Exp $
+# $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -15,11 +15,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
-# This product includes software developed by the University of
-# California, Berkeley and its contributors.
-# 4. Neither the name of the University nor the names of its contributors
+# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
@@ -68,6 +64,7 @@ case $FLAG in
/\(\):/ {
pr = substr($2, 1, 2);
if (pr == "vi" || pr == "em" || pr == "ed") {
+ # XXXMYSQL: support CRLF
name = substr($2, 1, index($2,"(") - 1);
#
# XXX: need a space between name and prototype so that -fc and -fh
@@ -97,6 +94,7 @@ case $FLAG in
/\(\):/ {
pr = substr($2, 1, 2);
if (pr == "vi" || pr == "em" || pr == "ed") {
+ # XXXMYSQL: support CRLF
name = substr($2, 1, index($2,"(") - 1);
uname = "";
fname = "";
@@ -117,13 +115,13 @@ case $FLAG in
printf(" \"");
for (i = 2; i < NF; i++)
printf("%s ", $i);
- sub("\r", "", $i);
+ # XXXMYSQL: support CRLF
+ sub("\r", "", $i);
printf("%s\" },\n", $i);
ok = 0;
}
}
END {
- printf(" { NULL, 0, NULL }\n");
printf("};\n");
printf("\nprotected const el_bindings_t* help__get()");
printf("{ return el_func_help; }\n");
@@ -144,6 +142,7 @@ case $FLAG in
# generate fcns.h from various .h files
#
+# XXXMYSQL: use portable tr syntax
-fh)
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
sort | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | $AWK '
@@ -220,6 +219,7 @@ case $FLAG in
/\(\):/ {
pr = substr($2, 1, 2);
if (pr == "vi" || pr == "em" || pr == "ed") {
+ # XXXMYSQL: support CRLF
name = substr($2, 1, index($2, "(") - 1);
fname = "";
for (i = 1; i <= length(name); i++) {
diff --git a/cmd-line-utils/libedit/map.c b/cmd-line-utils/libedit/map.c
index 6be9279b5e5..693b56c82ba 100644
--- a/cmd-line-utils/libedit/map.c
+++ b/cmd-line-utils/libedit/map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
+/* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* map.c: Editor function definitions
@@ -1118,11 +1124,12 @@ private void
map_print_key(EditLine *el, el_action_t *map, const char *in)
{
char outbuf[EL_BUFSIZ];
- el_bindings_t *bp;
+ el_bindings_t *bp, *ep;
if (in[0] == '\0' || in[1] == '\0') {
- (void) key__decode_str(in, outbuf, "");
- for (bp = el->el_map.help; bp->name != NULL; bp++)
+ (void) key__decode_str(in, outbuf, sizeof(outbuf), "");
+ ep = &el->el_map.help[el->el_map.nfunc];
+ for (bp = el->el_map.help; bp < ep; bp++)
if (bp->func == map[(unsigned char) *in]) {
(void) fprintf(el->el_outfile,
"%s\t->\t%s\n", outbuf, bp->name);
@@ -1139,7 +1146,7 @@ map_print_key(EditLine *el, el_action_t *map, const char *in)
private void
map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
{
- el_bindings_t *bp;
+ el_bindings_t *bp, *ep;
char firstbuf[2], lastbuf[2];
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
@@ -1148,39 +1155,47 @@ map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
lastbuf[0] = last;
lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) {
- if (first == last)
+ if (first == last) {
+ (void) key__decode_str(firstbuf, unparsbuf,
+ sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
- "%-15s-> is undefined\n",
- key__decode_str(firstbuf, unparsbuf, STRQQ));
+ "%-15s-> is undefined\n", unparsbuf);
+ }
return;
}
- for (bp = el->el_map.help; bp->name != NULL; bp++) {
+ ep = &el->el_map.help[el->el_map.nfunc];
+ for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) {
if (first == last) {
+ (void) key__decode_str(firstbuf, unparsbuf,
+ sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, "%-15s-> %s\n",
- key__decode_str(firstbuf, unparsbuf, STRQQ),
- bp->name);
+ unparsbuf, bp->name);
} else {
+ (void) key__decode_str(firstbuf, unparsbuf,
+ sizeof(unparsbuf), STRQQ);
+ (void) key__decode_str(lastbuf, extrabuf,
+ sizeof(extrabuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-4s to %-7s-> %s\n",
- key__decode_str(firstbuf, unparsbuf, STRQQ),
- key__decode_str(lastbuf, extrabuf, STRQQ),
- bp->name);
+ unparsbuf, extrabuf, bp->name);
}
return;
}
}
#ifdef MAP_DEBUG
if (map == el->el_map.key) {
+ (void) key__decode_str(firstbuf, unparsbuf,
+ sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
- "BUG!!! %s isn't bound to anything.\n",
- key__decode_str(firstbuf, unparsbuf, STRQQ));
+ "BUG!!! %s isn't bound to anything.\n", unparsbuf);
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
first, el->el_map.key[first]);
} else {
+ (void) key__decode_str(firstbuf, unparsbuf,
+ sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
- "BUG!!! %s isn't bound to anything.\n",
- key__decode_str(firstbuf, unparsbuf, STRQQ));
+ "BUG!!! %s isn't bound to anything.\n", unparsbuf);
(void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
first, el->el_map.alt[first]);
}
@@ -1237,7 +1252,7 @@ map_bind(EditLine *el, int argc, const char **argv)
char outbuf[EL_BUFSIZ];
const char *in = NULL;
char *out = NULL;
- el_bindings_t *bp;
+ el_bindings_t *bp, *ep;
int cmd;
int key;
@@ -1279,8 +1294,8 @@ map_bind(EditLine *el, int argc, const char **argv)
return (0);
case 'l':
- for (bp = el->el_map.help; bp->name != NULL;
- bp++)
+ ep = &el->el_map.help[el->el_map.nfunc];
+ for (bp = el->el_map.help; bp < ep; bp++)
(void) fprintf(el->el_outfile,
"%s\n\t%s\n",
bp->name, bp->description);
@@ -1367,7 +1382,7 @@ map_bind(EditLine *el, int argc, const char **argv)
break;
default:
- EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype));
+ EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
break;
}
return (0);
@@ -1381,7 +1396,7 @@ protected int
map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
{
void *p;
- int nf = el->el_map.nfunc + 2;
+ int nf = el->el_map.nfunc + 1;
if (name == NULL || help == NULL || func == NULL)
return (-1);
@@ -1400,7 +1415,6 @@ map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
el->el_map.help[nf].name = name;
el->el_map.help[nf].func = nf;
el->el_map.help[nf].description = help;
- el->el_map.help[++nf].name = NULL;
el->el_map.nfunc++;
return (0);
diff --git a/cmd-line-utils/libedit/np/fgetln.c b/cmd-line-utils/libedit/np/fgetln.c
index 93da9914dc8..898abc758dc 100644
--- a/cmd-line-utils/libedit/np/fgetln.c
+++ b/cmd-line-utils/libedit/np/fgetln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetln.c,v 1.1.1.1 1999/04/12 07:43:21 crooksa Exp $ */
+/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -36,17 +29,24 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#else
#include "config.h"
-#include <stdio.h>
+#endif
+
+#if !HAVE_FGETLN
#include <stdlib.h>
+#ifndef HAVE_NBTOOL_CONFIG_H
+/* These headers are required, but included from nbtool_config.h */
+#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#endif
char *
-fgetln(fp, len)
- FILE *fp;
- size_t *len;
+fgetln(FILE *fp, size_t *len)
{
static char *buf = NULL;
static size_t bufsiz = 0;
@@ -61,8 +61,8 @@ fgetln(fp, len)
if (fgets(buf, bufsiz, fp) == NULL)
return NULL;
- *len = 0;
+ *len = 0;
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
size_t nbufsiz = bufsiz + BUFSIZ;
char *nbuf = realloc(buf, nbufsiz);
@@ -76,13 +76,33 @@ fgetln(fp, len)
} else
buf = nbuf;
- *len = bufsiz;
- if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
+ if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
+ buf[bufsiz] = '\0';
+ *len = strlen(buf);
return buf;
+ }
+ *len = bufsiz;
bufsiz = nbufsiz;
}
*len = (ptr - buf) + 1;
return buf;
}
+
+#endif
+
+#ifdef TEST
+int
+main(int argc, char *argv[])
+{
+ char *p;
+ size_t len;
+
+ while ((p = fgetln(stdin, &len)) != NULL) {
+ (void)printf("%zu %s", len, p);
+ free(p);
+ }
+ return 0;
+}
+#endif
diff --git a/cmd-line-utils/libedit/np/strlcat.c b/cmd-line-utils/libedit/np/strlcat.c
index 6c9f1e92d79..4e2897d8f35 100644
--- a/cmd-line-utils/libedit/np/strlcat.c
+++ b/cmd-line-utils/libedit/np/strlcat.c
@@ -1,59 +1,68 @@
+/* $NetBSD: strlcat.c,v 1.3 2007/06/04 18:19:27 christos Exp $ */
+/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
+
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#else
#include "config.h"
+#endif
+
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD: src/lib/libc/string/strlcat.c,v 1.2.4.2 2001/07/09 23:30:06 obrien Exp $";
-#endif
+#ifdef _LIBC
+#include "namespace.h"
+#endif
#include <sys/types.h>
+#include <assert.h>
#include <string.h>
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcat, _strlcat)
+# endif
+#endif
+
+#else
+#include <lib/libkern/libkern.h>
+#endif /* !_KERNEL && !_STANDALONE */
+
+#if !HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
- * Returns strlen(initial dst) + strlen(src); if retval >= siz,
- * truncation occurred.
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
*/
-size_t strlcat(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
+size_t
+strlcat(char *dst, const char *src, size_t siz)
{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
size_t dlen;
+ _DIAGASSERT(dst != NULL);
+ _DIAGASSERT(src != NULL);
+
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
@@ -73,3 +82,4 @@ size_t strlcat(dst, src, siz)
return(dlen + (s - src)); /* count does not include NUL */
}
+#endif
diff --git a/cmd-line-utils/libedit/np/strlcpy.c b/cmd-line-utils/libedit/np/strlcpy.c
index 1f154bcf2ea..092a9757c0f 100644
--- a/cmd-line-utils/libedit/np/strlcpy.c
+++ b/cmd-line-utils/libedit/np/strlcpy.c
@@ -1,59 +1,63 @@
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
+/* $NetBSD: strlcpy.c,v 1.3 2007/06/04 18:19:27 christos Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#else
#include "config.h"
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
#endif
+#if defined(LIBC_SCCS) && !defined(lint)
#endif /* LIBC_SCCS and not lint */
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.2.4.1 2001/07/09 23:30:06 obrien Exp $";
-#endif
+#ifdef _LIBC
+#include "namespace.h"
+#endif
#include <sys/types.h>
+#include <assert.h>
#include <string.h>
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcpy, _strlcpy)
+# endif
+#endif
+#else
+#include <lib/libkern/libkern.h>
+#endif /* !_KERNEL && !_STANDALONE */
+
+
+#if !HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
-size_t strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ _DIAGASSERT(dst != NULL);
+ _DIAGASSERT(src != NULL);
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
@@ -73,3 +77,4 @@ size_t strlcpy(dst, src, siz)
return(s - src - 1); /* count does not include NUL */
}
+#endif
diff --git a/cmd-line-utils/libedit/np/unvis.c b/cmd-line-utils/libedit/np/unvis.c
index 895ff2059ac..3c37c231ceb 100644
--- a/cmd-line-utils/libedit/np/unvis.c
+++ b/cmd-line-utils/libedit/np/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.22 2002/03/23 17:38:27 christos Exp $ */
+/* $NetBSD: unvis.c,v 1.28 2005/09/13 01:44:09 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -34,34 +30,30 @@
*/
#include "config.h"
+
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.22 2002/03/23 17:38:27 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-#define __LIBC12_SOURCE__
-
#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
#include "np/vis.h"
+#endif
#ifdef __weak_alias
__weak_alias(strunvis,_strunvis)
-__weak_alias(unvis,_unvis)
#endif
-#ifdef __warn_references
-__warn_references(unvis,
- "warning: reference to compatibility unvis(); include <vis.h> for correct reference")
-#endif
-
-#if !HAVE_VIS_H
+#if !HAVE_VIS
/*
* decode driven by state machine
*/
@@ -72,30 +64,22 @@ __warn_references(unvis,
#define S_CTRL 4 /* control char started (^) */
#define S_OCTAL2 5 /* octal digit 2 */
#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX1 7 /* hex digit */
-#define S_HEX2 8 /* hex digit 2 */
+#define S_HEX1 7 /* hex digit */
+#define S_HEX2 8 /* hex digit 2 */
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
-int
-unvis(cp, c, astate, flag)
- char *cp;
- int c;
- int *astate, flag;
-{
- return __unvis13(cp, (int)c, astate, flag);
-}
-
/*
* unvis - decode characters previously encoded by vis
*/
int
-__unvis13(cp, c, astate, flag)
+unvis(cp, c, astate, flag)
char *cp;
int c;
int *astate, flag;
{
+ unsigned char uc = (unsigned char)c;
_DIAGASSERT(cp != NULL);
_DIAGASSERT(astate != NULL);
@@ -105,7 +89,7 @@ __unvis13(cp, c, astate, flag)
|| *astate == S_HEX2) {
*astate = S_GROUND;
return (UNVIS_VALID);
- }
+ }
return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
}
@@ -116,7 +100,7 @@ __unvis13(cp, c, astate, flag)
if (c == '\\') {
*astate = S_START;
return (0);
- }
+ }
if ((flag & VIS_HTTPSTYLE) && c == '%') {
*astate = S_HEX1;
return (0);
@@ -193,7 +177,7 @@ __unvis13(cp, c, astate, flag)
}
*astate = S_GROUND;
return (UNVIS_SYNBAD);
-
+
case S_META:
if (c == '-')
*astate = S_META1;
@@ -204,12 +188,12 @@ __unvis13(cp, c, astate, flag)
return (UNVIS_SYNBAD);
}
return (0);
-
+
case S_META1:
*astate = S_GROUND;
*cp |= c;
return (UNVIS_VALID);
-
+
case S_CTRL:
if (c == '?')
*cp |= 0177;
@@ -219,23 +203,23 @@ __unvis13(cp, c, astate, flag)
return (UNVIS_VALID);
case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
+ if (isoctal(uc)) {
+ /*
+ * yes - and maybe a third
*/
*cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
+ *astate = S_OCTAL3;
return (0);
- }
- /*
- * no - done with current sequence, push back passed char
+ }
+ /*
+ * no - done with current sequence, push back passed char
*/
*astate = S_GROUND;
return (UNVIS_VALIDPUSH);
case S_OCTAL3: /* third possible octal digit */
*astate = S_GROUND;
- if (isoctal(c)) {
+ if (isoctal(uc)) {
*cp = (*cp << 3) + (c - '0');
return (UNVIS_VALID);
}
@@ -243,27 +227,30 @@ __unvis13(cp, c, astate, flag)
* we were done, push back passed char
*/
return (UNVIS_VALIDPUSH);
+
case S_HEX1:
- if (isxdigit(c)) {
- *cp = xtod(c);
+ if (isxdigit(uc)) {
+ *cp = xtod(uc);
*astate = S_HEX2;
return (0);
}
- /*
- * no - done with current sequence, push back passed char
+ /*
+ * no - done with current sequence, push back passed char
*/
*astate = S_GROUND;
return (UNVIS_VALIDPUSH);
+
case S_HEX2:
- *astate = S_GROUND;
- if (isxdigit(c)) {
- *cp = xtod(c) | (*cp << 4);
+ *astate = S_GROUND;
+ if (isxdigit(uc)) {
+ *cp = xtod(uc) | (*cp << 4);
return (UNVIS_VALID);
}
- return (UNVIS_VALIDPUSH);
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
+ return (UNVIS_VALIDPUSH);
+
+ default:
+ /*
+ * decoder in unknown state - (probably uninitialized)
*/
*astate = S_GROUND;
return (UNVIS_SYNBAD);
@@ -271,7 +258,7 @@ __unvis13(cp, c, astate, flag)
}
/*
- * strunvis - decode src into dst
+ * strunvis - decode src into dst
*
* Number of chars decoded into dst is returned, -1 on error.
* Dst is null terminated.
@@ -291,8 +278,8 @@ strunvisx(dst, src, flag)
_DIAGASSERT(dst != NULL);
while ((c = *src++) != '\0') {
- again:
- switch (__unvis13(dst, c, &state, flag)) {
+ again:
+ switch (unvis(dst, c, &state, flag)) {
case UNVIS_VALID:
dst++;
break;
@@ -306,7 +293,7 @@ strunvisx(dst, src, flag)
return (-1);
}
}
- if (__unvis13(dst, c, &state, UNVIS_END) == UNVIS_VALID)
+ if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
dst++;
*dst = '\0';
return (dst - start);
diff --git a/cmd-line-utils/libedit/np/vis.c b/cmd-line-utils/libedit/np/vis.c
index e8f5c195f10..2a746274681 100644
--- a/cmd-line-utils/libedit/np/vis.c
+++ b/cmd-line-utils/libedit/np/vis.c
@@ -1,7 +1,6 @@
-/* $NetBSD: vis.c,v 1.22 2002/03/23 17:38:27 christos Exp $ */
+/* $NetBSD: vis.c,v 1.38 2008/09/04 09:41:44 lukem Exp $ */
/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -13,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -34,21 +29,47 @@
* SUCH DAMAGE.
*/
+/*-
+ * Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "config.h"
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.22 2002/03/23 17:38:27 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
+
#include <assert.h>
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
+#include "np/vis.h"
#endif
#include <stdlib.h>
-#include "np/vis.h"
-
#ifdef __weak_alias
__weak_alias(strsvis,_strsvis)
__weak_alias(strsvisx,_strsvisx)
@@ -58,63 +79,61 @@ __weak_alias(svis,_svis)
__weak_alias(vis,_vis)
#endif
-#if !HAVE_VIS_H
+#if !HAVE_VIS || !HAVE_SVIS
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
-#include <assert.h>
+
+static char *do_svis(char *, int, int, int, const char *);
+
#undef BELL
-#if defined(__STDC__)
#define BELL '\a'
-#else
-#define BELL '\007'
-#endif
-#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
+#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
#define xtoa(c) "0123456789abcdef"[c]
-#define MAXEXTRAS 5
-
-
-char *MAKEEXTRALIST(unsigned int flag, const char *orig)
-{
- const char *o = orig;
- char *e, *extra;
- while (*o++)
- continue;
- extra = (char*) malloc((size_t)((o - orig) + MAXEXTRAS));
- assert(extra);
- for (o = orig, e = extra; (*e++ = *o++) != '\0';)
- continue;
- e--;
- if (flag & VIS_SP) *e++ = ' ';
- if (flag & VIS_TAB) *e++ = '\t';
- if (flag & VIS_NL) *e++ = '\n';
- if ((flag & VIS_NOSLASH) == 0) *e++ = '\\';
- *e = '\0';
- return extra;
-}
+#define MAXEXTRAS 5
+#define MAKEEXTRALIST(flag, extra, orig_str) \
+do { \
+ const char *orig = orig_str; \
+ const char *o = orig; \
+ char *e; \
+ while (*o++) \
+ continue; \
+ extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
+ if (!extra) break; \
+ for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
+ continue; \
+ e--; \
+ if (flag & VIS_SP) *e++ = ' '; \
+ if (flag & VIS_TAB) *e++ = '\t'; \
+ if (flag & VIS_NL) *e++ = '\n'; \
+ if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
+ *e = '\0'; \
+} while (/*CONSTCOND*/0)
/*
- * This is HVIS, the macro of vis used to HTTP style (RFC 1808)
+ * This is do_hvis, for HTTP style (RFC 1808)
*/
-#define HVIS(dst, c, flag, nextc, extra) \
-do \
- if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
- *dst++ = '%'; \
- *dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
- *dst++ = xtoa((unsigned int)c & 0xf); \
- } else { \
- SVIS(dst, c, flag, nextc, extra); \
- } \
-while (/*CONSTCOND*/0)
-
+static char *
+do_hvis(char *dst, int c, int flag, int nextc, const char *extra)
+{
+ if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) {
+ *dst++ = '%';
+ *dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
+ *dst++ = xtoa((unsigned int)c & 0xf);
+ } else {
+ dst = do_svis(dst, c, flag, nextc, extra);
+ }
+ return dst;
+}
+
/*
- * This is SVIS, the central macro of vis.
+ * This is do_vis, the central code of vis.
* dst: Pointer to the destination buffer
* c: Character to encode
* flag: Flag word
@@ -122,95 +141,103 @@ while (/*CONSTCOND*/0)
* extra: Pointer to the list of extra characters to be
* backslash-protected.
*/
-#define SVIS(dst, c, flag, nextc, extra) \
-do { \
- int isextra, isc; \
- isextra = strchr(extra, c) != NULL; \
- if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
- ((flag & VIS_SAFE) && issafe(c)))) { \
- *dst++ = c; \
- break; \
- } \
- isc = 0; \
- if (flag & VIS_CSTYLE) { \
- switch (c) { \
- case '\n': \
- isc = 1; *dst++ = '\\'; *dst++ = 'n'; \
- break; \
- case '\r': \
- isc = 1; *dst++ = '\\'; *dst++ = 'r'; \
- break; \
- case '\b': \
- isc = 1; *dst++ = '\\'; *dst++ = 'b'; \
- break; \
- case BELL: \
- isc = 1; *dst++ = '\\'; *dst++ = 'a'; \
- break; \
- case '\v': \
- isc = 1; *dst++ = '\\'; *dst++ = 'v'; \
- break; \
- case '\t': \
- isc = 1; *dst++ = '\\'; *dst++ = 't'; \
- break; \
- case '\f': \
- isc = 1; *dst++ = '\\'; *dst++ = 'f'; \
- break; \
- case ' ': \
- isc = 1; *dst++ = '\\'; *dst++ = 's'; \
- break; \
- case '\0': \
- isc = 1; *dst++ = '\\'; *dst++ = '0'; \
- if (isoctal(nextc)) { \
- *dst++ = '0'; \
- *dst++ = '0'; \
- } \
- } \
- } \
- if (isc) break; \
- if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
- *dst++ = '\\'; \
- *dst++ = (unsigned char)(((unsigned int)(unsigned char)c >> 6) & 03) + '0'; \
- *dst++ = (unsigned char)(((unsigned int)(unsigned char)c >> 3) & 07) + '0'; \
- *dst++ = (c & 07) + '0'; \
- } else { \
- if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
- if (c & 0200) { \
- c &= 0177; *dst++ = 'M'; \
- } \
- if (iscntrl(c)) { \
- *dst++ = '^'; \
- if (c == 0177) \
- *dst++ = '?'; \
- else \
- *dst++ = c + '@'; \
- } else { \
- *dst++ = '-'; *dst++ = c; \
- } \
- } \
-} while (/*CONSTCOND*/0)
+static char *
+do_svis(char *dst, int c, int flag, int nextc, const char *extra)
+{
+ int isextra;
+ isextra = strchr(extra, c) != NULL;
+ if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) ||
+ ((flag & VIS_SAFE) && issafe(c)))) {
+ *dst++ = c;
+ return dst;
+ }
+ if (flag & VIS_CSTYLE) {
+ switch (c) {
+ case '\n':
+ *dst++ = '\\'; *dst++ = 'n';
+ return dst;
+ case '\r':
+ *dst++ = '\\'; *dst++ = 'r';
+ return dst;
+ case '\b':
+ *dst++ = '\\'; *dst++ = 'b';
+ return dst;
+ case BELL:
+ *dst++ = '\\'; *dst++ = 'a';
+ return dst;
+ case '\v':
+ *dst++ = '\\'; *dst++ = 'v';
+ return dst;
+ case '\t':
+ *dst++ = '\\'; *dst++ = 't';
+ return dst;
+ case '\f':
+ *dst++ = '\\'; *dst++ = 'f';
+ return dst;
+ case ' ':
+ *dst++ = '\\'; *dst++ = 's';
+ return dst;
+ case '\0':
+ *dst++ = '\\'; *dst++ = '0';
+ if (isoctal(nextc)) {
+ *dst++ = '0';
+ *dst++ = '0';
+ }
+ return dst;
+ default:
+ if (isgraph(c)) {
+ *dst++ = '\\'; *dst++ = c;
+ return dst;
+ }
+ }
+ }
+ if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
+ *dst++ = '\\';
+ *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
+ *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
+ *dst++ = (c & 07) + '0';
+ } else {
+ if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\';
+ if (c & 0200) {
+ c &= 0177; *dst++ = 'M';
+ }
+ if (iscntrl(c)) {
+ *dst++ = '^';
+ if (c == 0177)
+ *dst++ = '?';
+ else
+ *dst++ = c + '@';
+ } else {
+ *dst++ = '-'; *dst++ = c;
+ }
+ }
+ return dst;
+}
/*
* svis - visually encode characters, also encoding the characters
- * pointed to by `extra'
+ * pointed to by `extra'
*/
char *
-svis(dst, c, flag, nextc, extra)
- char *dst;
- int c, flag, nextc;
- const char *extra;
+svis(char *dst, int c, int flag, int nextc, const char *extra)
{
- char *nextra, *to_be_freed;
+ char *nextra = NULL;
+
_DIAGASSERT(dst != NULL);
_DIAGASSERT(extra != NULL);
- nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (!nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return dst;
+ }
if (flag & VIS_HTTPSTYLE)
- HVIS(dst, c, flag, nextc, nextra);
+ dst = do_hvis(dst, c, flag, nextc, nextra);
else
- SVIS(dst, c, flag, nextc, nextra);
+ dst = do_svis(dst, c, flag, nextc, nextra);
+ free(nextra);
*dst = '\0';
- free(to_be_freed);
- return(dst);
+ return dst;
}
@@ -221,140 +248,146 @@ svis(dst, c, flag, nextc, extra)
* be encoded, too. These functions are useful e. g. to
* encode strings in such a way so that they are not interpreted
* by a shell.
- *
+ *
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
- * is returned.
+ * is returned.
*
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
int
-strsvis(dst, src, flag, extra)
- char *dst;
- const char *src;
- int flag;
- const char *extra;
+strsvis(char *dst, const char *csrc, int flag, const char *extra)
{
- char c;
+ int c;
char *start;
- char *nextra, *to_be_freed;
+ char *nextra = NULL;
+ const unsigned char *src = (const unsigned char *)csrc;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
_DIAGASSERT(extra != NULL);
- nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (!nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return 0;
+ }
if (flag & VIS_HTTPSTYLE) {
for (start = dst; (c = *src++) != '\0'; /* empty */)
- HVIS(dst, c, flag, *src, nextra);
+ dst = do_hvis(dst, c, flag, *src, nextra);
} else {
for (start = dst; (c = *src++) != '\0'; /* empty */)
- SVIS(dst, c, flag, *src, nextra);
+ dst = do_svis(dst, c, flag, *src, nextra);
}
+ free(nextra);
*dst = '\0';
- free(to_be_freed);
return (dst - start);
}
int
-strsvisx(dst, src, len, flag, extra)
- char *dst;
- const char *src;
- size_t len;
- int flag;
- const char *extra;
+strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
{
- char c;
+ unsigned char c;
char *start;
- char *nextra, *to_be_freed;
+ char *nextra = NULL;
+ const unsigned char *src = (const unsigned char *)csrc;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
_DIAGASSERT(extra != NULL);
- nextra= to_be_freed= MAKEEXTRALIST(flag, extra);
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (! nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return 0;
+ }
if (flag & VIS_HTTPSTYLE) {
for (start = dst; len > 0; len--) {
c = *src++;
- HVIS(dst, c, flag, len ? *src : '\0', nextra);
+ dst = do_hvis(dst, c, flag,
+ len > 1 ? *src : '\0', nextra);
}
} else {
for (start = dst; len > 0; len--) {
c = *src++;
- SVIS(dst, c, flag, len ? *src : '\0', nextra);
+ dst = do_svis(dst, c, flag,
+ len > 1 ? *src : '\0', nextra);
}
}
+ free(nextra);
*dst = '\0';
- free(to_be_freed);
return (dst - start);
}
+#endif
-
+#if !HAVE_VIS
/*
* vis - visually encode characters
*/
char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, flag, nextc;
-
+vis(char *dst, int c, int flag, int nextc)
{
- char *extra, *to_be_freed;
+ char *extra = NULL;
+ unsigned char uc = (unsigned char)c;
_DIAGASSERT(dst != NULL);
- extra= to_be_freed= MAKEEXTRALIST(flag, "");
-
+ MAKEEXTRALIST(flag, extra, "");
+ if (! extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return dst;
+ }
if (flag & VIS_HTTPSTYLE)
- HVIS(dst, c, flag, nextc, extra);
+ dst = do_hvis(dst, uc, flag, nextc, extra);
else
- SVIS(dst, c, flag, nextc, extra);
+ dst = do_svis(dst, uc, flag, nextc, extra);
+ free(extra);
*dst = '\0';
- free(to_be_freed);
- return (dst);
+ return dst;
}
/*
* strvis, strvisx - visually encode characters from src into dst
- *
+ *
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
- * is returned.
+ * is returned.
*
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
+strvis(char *dst, const char *src, int flag)
{
- char *extra;
- int tmp;
+ char *extra = NULL;
+ int rv;
- extra= MAKEEXTRALIST(flag, "");
- tmp= strsvis(dst, src, flag, extra);
+ MAKEEXTRALIST(flag, extra, "");
+ if (!extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return 0;
+ }
+ rv = strsvis(dst, src, flag, extra);
free(extra);
- return tmp;
+ return rv;
}
int
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
+strvisx(char *dst, const char *src, size_t len, int flag)
{
- char *extra;
- int tmp;
+ char *extra = NULL;
+ int rv;
- extra= MAKEEXTRALIST(flag, "");
- tmp= strsvisx(dst, src, len, flag, extra);
+ MAKEEXTRALIST(flag, extra, "");
+ if (!extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return 0;
+ }
+ rv = strsvisx(dst, src, len, flag, extra);
free(extra);
- return tmp;
+ return rv;
}
#endif
diff --git a/cmd-line-utils/libedit/np/vis.h b/cmd-line-utils/libedit/np/vis.h
index 1a49c9e3ed2..11f5b740e2d 100644
--- a/cmd-line-utils/libedit/np/vis.h
+++ b/cmd-line-utils/libedit/np/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.12 2002/03/23 17:39:05 christos Exp $ */
+/* $NetBSD: vis.h,v 1.16 2005/09/13 01:44:32 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -38,9 +34,7 @@
#ifndef _VIS_H_
#define _VIS_H_
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+#include <sys/types.h>
/*
* to select alternate encoding format
@@ -78,6 +72,7 @@
*/
#define UNVIS_END 1 /* no more characters */
+__BEGIN_DECLS
char *vis(char *, int, int, int);
char *svis(char *, int, int, int, const char *);
int strvis(char *, const char *, int);
@@ -86,11 +81,7 @@ int strvisx(char *, const char *, size_t, int);
int strsvisx(char *, const char *, size_t, int, const char *);
int strunvis(char *, const char *);
int strunvisx(char *, const char *, int);
-#ifdef __LIBC12_SOURCE__
int unvis(char *, int, int *, int);
-int __unvis13(char *, int, int *, int);
-#else
-int unvis(char *, int, int *, int) __RENAME(__unvis13);
-#endif
+__END_DECLS
#endif /* !_VIS_H_ */
diff --git a/cmd-line-utils/libedit/parse.c b/cmd-line-utils/libedit/parse.c
index 993cf5b752d..5bdefb5a0e4 100644
--- a/cmd-line-utils/libedit/parse.c
+++ b/cmd-line-utils/libedit/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp $ */
+/* $NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* parse.c: parse an editline extended command
@@ -129,7 +135,7 @@ el_parse(EditLine *el, int argc, const char *argv[])
* the appropriate character or -1 if the escape is not valid
*/
protected int
-parse__escape(const char **const ptr)
+parse__escape(const char **ptr)
{
const char *p;
int c;
diff --git a/cmd-line-utils/libedit/parse.h b/cmd-line-utils/libedit/parse.h
index 4b796666b8e..58dced1aeaa 100644
--- a/cmd-line-utils/libedit/parse.h
+++ b/cmd-line-utils/libedit/parse.h
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.h,v 1.5 2003/08/07 16:44:32 agc Exp $ */
+/* $NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
#define _h_el_parse
protected int parse_line(EditLine *, const char *);
-protected int parse__escape(const char ** const);
+protected int parse__escape(const char **);
protected char *parse__string(char *, const char *);
protected int parse_cmd(EditLine *, const char *);
diff --git a/cmd-line-utils/libedit/prompt.c b/cmd-line-utils/libedit/prompt.c
index 455dd60331b..982943afd30 100644
--- a/cmd-line-utils/libedit/prompt.c
+++ b/cmd-line-utils/libedit/prompt.c
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* prompt.c: Prompt printing functions
diff --git a/cmd-line-utils/libedit/read.c b/cmd-line-utils/libedit/read.c
index 51848c2038e..ac768142e79 100644
--- a/cmd-line-utils/libedit/read.c
+++ b/cmd-line-utils/libedit/read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.35 2005/03/09 23:55:02 christos Exp $ */
+/* $NetBSD: read.c,v 1.43 2009/02/05 19:15:44 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* read.c: Clean this junk up! This is horrible code.
@@ -50,6 +56,7 @@ private int read__fixio(int, int);
private int read_preread(EditLine *);
private int read_char(EditLine *, char *);
private int read_getcmd(EditLine *, el_action_t *, char *);
+private void read_pop(c_macro_t *);
/* read_init():
* Initialize the read stuff
@@ -205,7 +212,7 @@ read_preread(EditLine *el)
* Push a macro
*/
public void
-el_push(EditLine *el, char *str)
+el_push(EditLine *el, const char *str)
{
c_macro_t *ma = &el->el_chared.c_macro;
@@ -216,7 +223,7 @@ el_push(EditLine *el, char *str)
ma->level--;
}
term_beep(el);
- term__flush();
+ term__flush(el);
}
@@ -294,6 +301,19 @@ read_char(EditLine *el, char *cp)
return (num_read);
}
+/* read_pop():
+ * Pop a macro from the stack
+ */
+private void
+read_pop(c_macro_t *ma)
+{
+ int i;
+
+ el_free(ma->macro[0]);
+ for (i = ma->level--; i > 0; i--)
+ ma->macro[i - 1] = ma->macro[i];
+ ma->offset = 0;
+}
/* el_getc():
* Read a character
@@ -304,26 +324,28 @@ el_getc(EditLine *el, char *cp)
int num_read;
c_macro_t *ma = &el->el_chared.c_macro;
- term__flush();
+ term__flush(el);
for (;;) {
if (ma->level < 0) {
if (!read_preread(el))
break;
}
+
if (ma->level < 0)
break;
- if (ma->macro[ma->level][ma->offset] == '\0') {
- el_free(ma->macro[ma->level--]);
- ma->offset = 0;
+ if (ma->macro[0][ma->offset] == '\0') {
+ read_pop(ma);
continue;
}
- *cp = ma->macro[ma->level][ma->offset++] & 0377;
- if (ma->macro[ma->level][ma->offset] == '\0') {
+
+ *cp = ma->macro[0][ma->offset++] & 0377;
+
+ if (ma->macro[0][ma->offset] == '\0') {
/* Needed for QuoteMode On */
- el_free(ma->macro[ma->level--]);
- ma->offset = 0;
+ read_pop(ma);
}
+
return (1);
}
@@ -357,11 +379,11 @@ read_prepare(EditLine *el)
we have the wrong size. */
el_resize(el);
re_clear_display(el); /* reset the display stuff */
- ch_reset(el);
+ ch_reset(el, 0);
re_refresh(el); /* print the prompt */
if (el->el_flags & UNBUFFERED)
- term__flush();
+ term__flush(el);
}
protected void
@@ -438,7 +460,7 @@ el_gets(EditLine *el, int *nread)
else
cp = el->el_line.lastchar;
- term__flush();
+ term__flush(el);
while ((*el->el_read.read_char)(el, cp) == 1) {
/* make sure there is space next character */
@@ -478,7 +500,7 @@ el_gets(EditLine *el, int *nread)
#endif /* DEBUG_READ */
break;
}
- if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
+ if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */
#ifdef DEBUG_EDIT
(void) fprintf(el->el_errfile,
"ERROR: illegal command from key 0%o\r\n", ch);
@@ -570,7 +592,7 @@ el_gets(EditLine *el, int *nread)
#endif /* DEBUG_READ */
/* put (real) cursor in a known place */
re_clear_display(el); /* reset the display stuff */
- ch_reset(el); /* reset the input pointers */
+ ch_reset(el, 1); /* reset the input pointers */
re_refresh(el); /* print the prompt again */
break;
@@ -581,7 +603,7 @@ el_gets(EditLine *el, int *nread)
"*** editor ERROR ***\r\n\n");
#endif /* DEBUG_READ */
term_beep(el);
- term__flush();
+ term__flush(el);
break;
}
el->el_state.argument = 1;
@@ -591,7 +613,7 @@ el_gets(EditLine *el, int *nread)
break;
}
- term__flush(); /* flush any buffered output */
+ term__flush(el); /* flush any buffered output */
/* make sure the tty is set up correctly */
if ((el->el_flags & UNBUFFERED) == 0) {
read_finish(el);
diff --git a/cmd-line-utils/libedit/read.h b/cmd-line-utils/libedit/read.h
index 1982f47253b..bd8d4c1f5bb 100644
--- a/cmd-line-utils/libedit/read.h
+++ b/cmd-line-utils/libedit/read.h
@@ -1,4 +1,4 @@
-/* $NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp $ */
+/* $NetBSD: read.h,v 1.6 2008/04/29 06:53:01 martin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/cmd-line-utils/libedit/readline.c b/cmd-line-utils/libedit/readline.c
index 004fcf7d183..1f1b18c97d8 100644
--- a/cmd-line-utils/libedit/readline.c
+++ b/cmd-line-utils/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.49 2005/03/10 19:34:46 christos Exp $ */
+/* $NetBSD: readline.c,v 1.78 2009/02/05 19:15:26 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -36,25 +29,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* AIX requires this to be the first thing in the file. */
-#if defined (_AIX) && !defined (__GNUC__)
- #pragma alloca
-#endif
-
-#include <config.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca(n) __builtin_alloca (n)
-#else
-# ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifndef _AIX
-extern char *alloca ();
-# endif
-# endif
-#endif
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#endif /* not lint && not SCCSID */
#include <sys/types.h>
#include <sys/stat.h>
@@ -68,12 +45,20 @@ extern char *alloca ();
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
+#include <setjmp.h>
+#ifdef HAVE_VIS_H
#include <vis.h>
-
+#else
+#include "np/vis.h"
+#endif
#include "readline/readline.h"
#include "el.h"
#include "fcns.h" /* for EL_NUM_FCNS */
#include "histedit.h"
+#include "filecomplete.h"
+
+void rl_prep_terminal(int);
+void rl_deprep_terminal(void);
/* for rl_complete() */
#define TAB '\r'
@@ -94,9 +79,12 @@ FILE *rl_outstream = NULL;
int rl_point = 0;
int rl_end = 0;
char *rl_line_buffer = NULL;
-VFunction *rl_linefunc = NULL;
+VCPFunction *rl_linefunc = NULL;
int rl_done = 0;
VFunction *rl_event_hook = NULL;
+KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
+ emacs_meta_keymap,
+ emacs_ctlx_keymap;
int history_base = 1; /* probably never subject to change */
int history_length = 0;
@@ -112,21 +100,23 @@ int rl_attempted_completion_over = 0;
char *rl_basic_word_break_characters = break_chars;
char *rl_completer_word_break_characters = NULL;
char *rl_completer_quote_characters = NULL;
-CPFunction *rl_completion_entry_function = NULL;
+Function *rl_completion_entry_function = NULL;
CPPFunction *rl_attempted_completion_function = NULL;
Function *rl_pre_input_hook = NULL;
Function *rl_startup1_hook = NULL;
-Function *rl_getc_function = NULL;
+int (*rl_getc_function)(FILE *) = NULL;
char *rl_terminal_name = NULL;
int rl_already_prompted = 0;
int rl_filename_completion_desired = 0;
int rl_ignore_completion_duplicates = 0;
int rl_catch_signals = 1;
+int readline_echoing_p = 1;
+int _rl_print_completions_horizontally = 0;
VFunction *rl_redisplay_function = NULL;
Function *rl_startup_hook = NULL;
VFunction *rl_completion_display_matches_hook = NULL;
-VFunction *rl_prep_term_function = NULL;
-VFunction *rl_deprep_term_function = NULL;
+VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
+VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
/*
* The current prompt string.
@@ -150,7 +140,7 @@ int rl_completion_query_items = 100;
* in the parsed text when it is passed to the completion function.
* Shell uses this to help determine what kind of completing to do.
*/
-char *rl_special_prefixes = (char *)NULL;
+char *rl_special_prefixes = NULL;
/*
* This is the character appended to the completed words if at the end of
@@ -160,25 +150,21 @@ int rl_completion_append_character = ' ';
/* stuff below is used internally by libedit for readline emulation */
-/* if not zero, non-unique completions always show list of possible matches */
-static int _rl_complete_show_all = 0;
-
static History *h = NULL;
static EditLine *e = NULL;
static Function *map[256];
-static int el_rl_complete_cmdnum = 0;
+static jmp_buf topbuf;
/* internal functions */
static unsigned char _el_rl_complete(EditLine *, int);
static unsigned char _el_rl_tstp(EditLine *, int);
static char *_get_prompt(EditLine *);
+static int _getc_function(EditLine *, char *);
static HIST_ENTRY *_move_history(int);
static int _history_expand_command(const char *, size_t, size_t,
char **);
static char *_rl_compat_sub(const char *, const char *,
const char *, int);
-static int _rl_complete_internal(int);
-static int _rl_qsort_string_compare(const void *, const void *);
static int _rl_event_read_char(EditLine *, char *);
static void _rl_update_pos(void);
@@ -205,17 +191,50 @@ _move_history(int op)
return (HIST_ENTRY *) NULL;
rl_he.line = ev.str;
- rl_he.data = (histdata_t) &(ev.num);
+ rl_he.data = NULL;
return (&rl_he);
}
/*
+ * read one key from user defined input function
+ */
+static int
+/*ARGSUSED*/
+_getc_function(EditLine *el, char *c)
+{
+ int i;
+
+ i = (*rl_getc_function)(NULL);
+ if (i == -1)
+ return 0;
+ *c = i;
+ return 1;
+}
+
+
+/*
* READLINE compatibility stuff
*/
/*
+ * Set the prompt
+ */
+int
+rl_set_prompt(const char *prompt)
+{
+ if (!prompt)
+ prompt = "";
+ if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
+ return 0;
+ if (rl_prompt)
+ free(rl_prompt);
+ rl_prompt = strdup(prompt);
+ return rl_prompt == NULL ? -1 : 0;
+}
+
+/*
* initialize rl compat stuff
*/
int
@@ -223,7 +242,6 @@ rl_initialize(void)
{
HistEvent ev;
const LineInfo *li;
- int i;
int editmode = 1;
struct termios t;
@@ -257,9 +275,12 @@ rl_initialize(void)
max_input_history = INT_MAX;
el_set(e, EL_HIST, history, h);
+ /* setup getc function if valid */
+ if (rl_getc_function)
+ el_set(e, EL_GETCFN, _getc_function);
+
/* for proper prompt printing in readline() */
- rl_prompt = strdup("");
- if (rl_prompt == NULL) {
+ if (rl_set_prompt("") == -1) {
history_end(h);
el_end(e);
return -1;
@@ -291,17 +312,6 @@ rl_initialize(void)
"ReadLine compatible suspend function",
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
-
- /*
- * Find out where the rl_complete function was added; this is
- * used later to detect that lastcmd was also rl_complete.
- */
- for(i=EL_NUM_FCNS; i < e->el_map.nfunc; i++) {
- if (e->el_map.func[i] == _el_rl_complete) {
- el_rl_complete_cmdnum = i;
- break;
- }
- }
/* read settings from configuration file */
el_source(e, NULL);
@@ -327,9 +337,10 @@ rl_initialize(void)
* trailing newline (if there is any)
*/
char *
-readline(const char *prompt)
+readline(const char *p)
{
HistEvent ev;
+ const char * volatile prompt = p;
int count;
const char *ret;
char *buf;
@@ -340,15 +351,11 @@ readline(const char *prompt)
rl_done = 0;
+ (void)setjmp(topbuf);
+
/* update prompt accordingly to what has been passed */
- if (!prompt)
- prompt = "";
- if (strcmp(rl_prompt, prompt) != 0) {
- free(rl_prompt);
- rl_prompt = strdup(prompt);
- if (rl_prompt == NULL)
- return NULL;
- }
+ if (rl_set_prompt(prompt) == -1)
+ return NULL;
if (rl_pre_input_hook)
(*rl_pre_input_hook)(NULL, 0);
@@ -446,7 +453,7 @@ _rl_compat_sub(const char *str, const char *what, const char *with,
} else
*r++ = *s++;
}
- *r = 0;
+ *r = '\0';
return(result);
}
@@ -467,7 +474,7 @@ get_history_event(const char *cmd, int *cindex, int qchar)
return(NULL);
/* find out which event to take */
- if (cmd[idx] == history_expansion_char || cmd[idx] == 0) {
+ if (cmd[idx] == history_expansion_char || cmd[idx] == '\0') {
if (history(h, &ev, H_FIRST) != 0)
return(NULL);
*cindex = cmd[idx]? (idx + 1):idx;
@@ -689,7 +696,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
if (aptr)
free(aptr);
- if (*cmd == 0 || (cmd - (command + offs) >= cmdlen)) {
+ if (*cmd == '\0' || ((size_t)(cmd - (command + offs)) >= cmdlen)) {
*result = tmp;
return(1);
}
@@ -699,7 +706,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
continue;
else if (*cmd == 'h') { /* remove trailing path */
if ((aptr = strrchr(tmp, '/')) != NULL)
- *aptr = 0;
+ *aptr = '\0';
} else if (*cmd == 't') { /* remove leading path */
if ((aptr = strrchr(tmp, '/')) != NULL) {
aptr = strdup(aptr + 1);
@@ -708,7 +715,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
}
} else if (*cmd == 'r') { /* remove trailing suffix */
if ((aptr = strrchr(tmp, '.')) != NULL)
- *aptr = 0;
+ *aptr = '\0';
} else if (*cmd == 'e') { /* remove all but suffix */
if ((aptr = strrchr(tmp, '.')) != NULL) {
aptr = strdup(aptr);
@@ -732,6 +739,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
what = realloc(from, size);
if (what == NULL) {
free(from);
+ free(tmp);
return 0;
}
len = 0;
@@ -744,6 +752,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
(size <<= 1));
if (nwhat == NULL) {
free(what);
+ free(tmp);
return 0;
}
what = nwhat;
@@ -756,10 +765,13 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
free(what);
if (search) {
from = strdup(search);
- if (from == NULL)
+ if (from == NULL) {
+ free(tmp);
return 0;
+ }
} else {
from = NULL;
+ free(tmp);
return (-1);
}
}
@@ -771,6 +783,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
with = realloc(to, size);
if (with == NULL) {
free(to);
+ free(tmp);
return -1;
}
len = 0;
@@ -782,6 +795,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
nwith = realloc(with, size);
if (nwith == NULL) {
free(with);
+ free(tmp);
return -1;
}
with = nwith;
@@ -850,12 +864,14 @@ history_expand(char *str, char **output)
return 0;
}
-#define ADD_STRING(what, len) \
+#define ADD_STRING(what, len, fr) \
{ \
if (idx + len + 1 > size) { \
char *nresult = realloc(result, (size += len + 1));\
if (nresult == NULL) { \
free(*output); \
+ if (/*CONSTCOND*/fr) \
+ free(tmp); \
return 0; \
} \
result = nresult; \
@@ -867,6 +883,7 @@ history_expand(char *str, char **output)
result = NULL;
size = idx = 0;
+ tmp = NULL;
for (i = 0; str[i];) {
int qchar, loop_again;
size_t len, start, j;
@@ -904,13 +921,11 @@ loop:
goto loop;
}
len = i - start;
- tmp = &str[start];
- ADD_STRING(tmp, len);
+ ADD_STRING(&str[start], len, 0);
if (str[i] == '\0' || str[i] != history_expansion_char) {
len = j - i;
- tmp = &str[i];
- ADD_STRING(tmp, len);
+ ADD_STRING(&str[i], len, 0);
if (start == 0)
ret = 0;
else
@@ -920,8 +935,11 @@ loop:
ret = _history_expand_command (str, i, (j - i), &tmp);
if (ret > 0 && tmp) {
len = strlen(tmp);
- ADD_STRING(tmp, len);
+ ADD_STRING(tmp, len, 1);
+ }
+ if (tmp) {
free(tmp);
+ tmp = NULL;
}
i = j;
}
@@ -973,23 +991,23 @@ history_arg_extract(int start, int end, const char *str)
if (start < 0)
start = end;
- if (start < 0 || end < 0 || start > max || end > max || start > end)
+ if (start < 0 || end < 0 || (size_t)start > max || (size_t)end > max || start > end)
return(NULL);
- for (i = start, len = 0; i <= end; i++)
+ for (i = start, len = 0; i <= (size_t)end; i++)
len += strlen(arr[i]) + 1;
len++;
result = malloc(len);
if (result == NULL)
return NULL;
- for (i = start, len = 0; i <= end; i++) {
+ for (i = start, len = 0; i <= (size_t)end; i++) {
(void)strcpy(result + len, arr[i]);
len += strlen(arr[i]);
- if (i < end)
+ if (i < (size_t)end)
result[len++] = ' ';
}
- result[len] = 0;
+ result[len] = '\0';
for (i = 0; arr[i]; i++)
free(arr[i]);
@@ -1152,7 +1170,7 @@ history_get(int num)
return (NULL); /* error */
/* look backwards for event matching specified offset */
- if (history(h, &ev, H_NEXT_EVENT, num))
+ if (history(h, &ev, H_NEXT_EVENT, num + 1))
return (NULL);
she.line = ev.str;
@@ -1185,6 +1203,31 @@ add_history(const char *line)
/*
+ * remove the specified entry from the history list and return it.
+ */
+HIST_ENTRY *
+remove_history(int num)
+{
+ HIST_ENTRY *she;
+ HistEvent ev;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ if (history(h, &ev, H_DEL, num) != 0)
+ return NULL;
+
+ if ((she = malloc(sizeof(*she))) == NULL)
+ return NULL;
+
+ she->line = ev.str;
+ she->data = NULL;
+
+ return she;
+}
+
+
+/*
* clear the history list - delete all entries
*/
void
@@ -1377,172 +1420,18 @@ history_search_pos(const char *str,
/********************************/
/* completion functions */
-/*
- * does tilde expansion of strings of type ``~user/foo''
- * if ``user'' isn't valid user name or ``txt'' doesn't start
- * w/ '~', returns pointer to strdup()ed copy of ``txt''
- *
- * it's callers's responsibility to free() returned string
- */
char *
-tilde_expand(char *txt)
+tilde_expand(char *name)
{
- struct passwd *pass;
- char *temp;
- size_t len = 0;
-
- if (txt[0] != '~')
- return (strdup(txt));
-
- temp = strchr(txt + 1, '/');
- if (temp == NULL) {
- temp = strdup(txt + 1);
- if (temp == NULL)
- return NULL;
- } else {
- len = temp - txt + 1; /* text until string after slash */
- temp = malloc(len);
- if (temp == NULL)
- return NULL;
- (void)strncpy(temp, txt + 1, len - 2);
- temp[len - 2] = '\0';
- }
- pass = getpwnam(temp);
- free(temp); /* value no more needed */
- if (pass == NULL)
- return (strdup(txt));
-
- /* update pointer txt to point at string immedially following */
- /* first slash */
- txt += len;
-
- temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
- if (temp == NULL)
- return NULL;
- (void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
-
- return (temp);
+ return fn_tilde_expand(name);
}
-
-/*
- * return first found file name starting by the ``text'' or NULL if no
- * such file can be found
- * value of ``state'' is ignored
- *
- * it's caller's responsibility to free returned string
- */
char *
-filename_completion_function(const char *text, int state)
+filename_completion_function(const char *name, int state)
{
- static DIR *dir = NULL;
- static char *filename = NULL, *dirname = NULL;
- static size_t filename_len = 0;
- struct dirent *entry;
- char *temp;
- size_t len;
-
- if (state == 0 || dir == NULL) {
- temp = strrchr(text, '/');
- if (temp) {
- char *nptr;
- temp++;
- nptr = realloc(filename, strlen(temp) + 1);
- if (nptr == NULL) {
- free(filename);
- return NULL;
- }
- filename = nptr;
- (void)strcpy(filename, temp);
- len = temp - text; /* including last slash */
- nptr = realloc(dirname, len + 1);
- if (nptr == NULL) {
- free(filename);
- return NULL;
- }
- dirname = nptr;
- (void)strncpy(dirname, text, len);
- dirname[len] = '\0';
- } else {
- if (*text == 0)
- filename = NULL;
- else {
- filename = strdup(text);
- if (filename == NULL)
- return NULL;
- }
- dirname = NULL;
- }
-
- /* support for ``~user'' syntax */
- if (dirname && *dirname == '~') {
- char *nptr;
- temp = tilde_expand(dirname);
- if (temp == NULL)
- return NULL;
- nptr = realloc(dirname, strlen(temp) + 1);
- if (nptr == NULL) {
- free(dirname);
- return NULL;
- }
- dirname = nptr;
- (void)strcpy(dirname, temp); /* safe */
- free(temp); /* no longer needed */
- }
- /* will be used in cycle */
- filename_len = filename ? strlen(filename) : 0;
-
- if (dir != NULL) {
- (void)closedir(dir);
- dir = NULL;
- }
- dir = opendir(dirname ? dirname : ".");
- if (!dir)
- return (NULL); /* cannot open the directory */
- }
- /* find the match */
- while ((entry = readdir(dir)) != NULL) {
- /* skip . and .. */
- if (entry->d_name[0] == '.' && (!entry->d_name[1]
- || (entry->d_name[1] == '.' && !entry->d_name[2])))
- continue;
- if (filename_len == 0)
- break;
- /* otherwise, get first entry where first */
- /* filename_len characters are equal */
- if (entry->d_name[0] == filename[0]
- /* Some dirents have d_namlen, but it is not portable. */
- && strlen(entry->d_name) >= filename_len
- && strncmp(entry->d_name, filename,
- filename_len) == 0)
- break;
- }
-
- if (entry) { /* match found */
-
- struct stat stbuf;
- /* Some dirents have d_namlen, but it is not portable. */
- len = strlen(entry->d_name) +
- ((dirname) ? strlen(dirname) : 0) + 1 + 1;
- temp = malloc(len);
- if (temp == NULL)
- return NULL;
- (void)sprintf(temp, "%s%s",
- dirname ? dirname : "", entry->d_name); /* safe */
-
- /* test, if it's directory */
- if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
- strcat(temp, "/"); /* safe */
- } else {
- (void)closedir(dir);
- dir = NULL;
- temp = NULL;
- }
-
- return (temp);
+ return fn_filename_completion_function(name, state);
}
-
/*
* a completion generator for usernames; returns _first_ username
* which starts with supplied text
@@ -1564,6 +1453,7 @@ username_completion_function(const char *text, int state)
if (state == 0)
setpwent();
+ /* XXXMYSQL: just use non-_r functions for now */
while ((pwd = getpwent()) && text[0] == pwd->pw_name[0]
&& strcmp(text, pwd->pw_name) == 0);
@@ -1576,16 +1466,6 @@ username_completion_function(const char *text, int state)
/*
- * el-compatible wrapper around rl_complete; needed for key binding
- */
-/* ARGSUSED */
-static unsigned char
-_el_rl_complete(EditLine *el __attribute__((__unused__)), int ch)
-{
- return (unsigned char) rl_complete(0, ch);
-}
-
-/*
* el-compatible wrapper to send TSTP on ^Z
*/
/* ARGSUSED */
@@ -1597,272 +1477,35 @@ _el_rl_tstp(EditLine *el __attribute__((__unused__)), int ch __attribute__((__un
}
/*
- * returns list of completions for text given
- */
-char **
-completion_matches(const char *text, CPFunction *genfunc)
-{
- char **match_list = NULL, *retstr, *prevstr;
- size_t match_list_len, max_equal, which, i;
- size_t matches;
-
- if (h == NULL || e == NULL)
- rl_initialize();
-
- matches = 0;
- match_list_len = 1;
- while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
- /* allow for list terminator here */
- if (matches + 3 >= match_list_len) {
- char **nmatch_list;
- while (matches + 3 >= match_list_len)
- match_list_len <<= 1;
- nmatch_list = realloc(match_list,
- match_list_len * sizeof(char *));
- if (nmatch_list == NULL) {
- free(match_list);
- return NULL;
- }
- match_list = nmatch_list;
-
- }
- match_list[++matches] = retstr;
- }
-
- if (!match_list)
- return NULL; /* nothing found */
-
- /* find least denominator and insert it to match_list[0] */
- which = 2;
- prevstr = match_list[1];
- max_equal = strlen(prevstr);
- for (; which <= matches; which++) {
- for (i = 0; i < max_equal &&
- prevstr[i] == match_list[which][i]; i++)
- continue;
- max_equal = i;
- }
-
- retstr = malloc(max_equal + 1);
- if (retstr == NULL) {
- free(match_list);
- return NULL;
- }
- (void)strncpy(retstr, match_list[1], max_equal);
- retstr[max_equal] = '\0';
- match_list[0] = retstr;
-
- /* add NULL as last pointer to the array */
- match_list[matches + 1] = (char *) NULL;
-
- return (match_list);
-}
-
-/*
- * Sort function for qsort(). Just wrapper around strcasecmp().
- */
-static int
-_rl_qsort_string_compare(i1, i2)
- const void *i1, *i2;
-{
- const char *s1 = ((const char * const *)i1)[0];
- const char *s2 = ((const char * const *)i2)[0];
-
- return strcasecmp(s1, s2);
-}
-
-/*
* Display list of strings in columnar format on readline's output stream.
* 'matches' is list of strings, 'len' is number of strings in 'matches',
* 'max' is maximum length of string in 'matches'.
*/
void
-rl_display_match_list (matches, len, max)
- char **matches;
- int len, max;
+rl_display_match_list(char **matches, int len, int max)
{
- int i, idx, limit, count;
- int screenwidth = e->el_term.t_size.h;
- /*
- * Find out how many entries can be put on one line, count
- * with two spaces between strings.
- */
- limit = screenwidth / (max + 2);
- if (limit == 0)
- limit = 1;
-
- /* how many lines of output */
- count = len / limit;
- if (count * limit < len)
- count++;
-
- /* Sort the items if they are not already sorted. */
- qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
- _rl_qsort_string_compare);
-
- idx = 1;
- for(; count > 0; count--) {
- for(i = 0; i < limit && matches[idx]; i++, idx++)
- (void)fprintf(e->el_outfile, "%-*s ", max,
- matches[idx]);
- (void)fprintf(e->el_outfile, "\n");
- }
+ fn_display_match_list(e, matches, len, max);
}
-/*
- * Complete the word at or before point, called by rl_complete()
- * 'what_to_do' says what to do with the completion.
- * `?' means list the possible completions.
- * TAB means do standard completion.
- * `*' means insert all of the possible completions.
- * `!' means to do standard completion, and list all possible completions if
- * there is more than one.
- *
- * Note: '*' support is not implemented
- */
-static int
-_rl_complete_internal(int what_to_do)
+static const char *
+/*ARGSUSED*/
+_rl_completion_append_character_function(const char *dummy
+ __attribute__((__unused__)))
{
- CPFunction *complet_func;
- const LineInfo *li;
- char *temp, **matches;
- const char *ctemp;
- size_t len;
-
- rl_completion_type = what_to_do;
-
- if (h == NULL || e == NULL)
- rl_initialize();
-
- complet_func = rl_completion_entry_function;
- if (!complet_func)
- complet_func = filename_completion_function;
-
- /* We now look backwards for the start of a filename/variable word */
- li = el_line(e);
- ctemp = (const char *) li->cursor;
- while (ctemp > li->buffer
- && !strchr(rl_basic_word_break_characters, ctemp[-1])
- && (!rl_special_prefixes
- || !strchr(rl_special_prefixes, ctemp[-1]) ) )
- ctemp--;
-
- len = li->cursor - ctemp;
- temp = alloca(len + 1);
- (void)strncpy(temp, ctemp, len);
- temp[len] = '\0';
-
- /* these can be used by function called in completion_matches() */
- /* or (*rl_attempted_completion_function)() */
- _rl_update_pos();
-
- if (rl_attempted_completion_function) {
- int end = li->cursor - li->buffer;
- matches = (*rl_attempted_completion_function) (temp, (int)
- (end - len), end);
- } else
- matches = 0;
- if (!rl_attempted_completion_function || !matches)
- matches = completion_matches(temp, complet_func);
-
- if (matches) {
- int i, retval = CC_REFRESH;
- int matches_num, maxlen, match_len, match_display=1;
-
- /*
- * Only replace the completed string with common part of
- * possible matches if there is possible completion.
- */
- if (matches[0][0] != '\0') {
- el_deletestr(e, (int) len);
- el_insertstr(e, matches[0]);
- }
-
- if (what_to_do == '?')
- goto display_matches;
-
- if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
- /*
- * We found exact match. Add a space after
- * it, unless we do filename completion and the
- * object is a directory.
- */
- size_t alen = strlen(matches[0]);
- if ((complet_func != filename_completion_function
- || (alen > 0 && (matches[0])[alen - 1] != '/'))
- && rl_completion_append_character) {
- char buf[2];
- buf[0] = rl_completion_append_character;
- buf[1] = '\0';
- el_insertstr(e, buf);
- }
- } else if (what_to_do == '!') {
- display_matches:
- /*
- * More than one match and requested to list possible
- * matches.
- */
-
- for(i=1, maxlen=0; matches[i]; i++) {
- match_len = strlen(matches[i]);
- if (match_len > maxlen)
- maxlen = match_len;
- }
- matches_num = i - 1;
-
- /* newline to get on next line from command line */
- (void)fprintf(e->el_outfile, "\n");
-
- /*
- * If there are too many items, ask user for display
- * confirmation.
- */
- if (matches_num > rl_completion_query_items) {
- (void)fprintf(e->el_outfile,
- "Display all %d possibilities? (y or n) ",
- matches_num);
- (void)fflush(e->el_outfile);
- if (getc(stdin) != 'y')
- match_display = 0;
- (void)fprintf(e->el_outfile, "\n");
- }
-
- if (match_display)
- rl_display_match_list(matches, matches_num,
- maxlen);
- retval = CC_REDISPLAY;
- } else if (matches[0][0]) {
- /*
- * There was some common match, but the name was
- * not complete enough. Next tab will print possible
- * completions.
- */
- el_beep(e);
- } else {
- /* lcd is not a valid object - further specification */
- /* is needed */
- el_beep(e);
- retval = CC_NORM;
- }
-
- /* free elements of array and the array itself */
- for (i = 0; matches[i]; i++)
- free(matches[i]);
- free(matches), matches = NULL;
-
- return (retval);
- }
- return (CC_NORM);
+ static char buf[2];
+ buf[0] = rl_completion_append_character;
+ buf[1] = '\0';
+ return buf;
}
/*
* complete word at current point
*/
+/* ARGSUSED */
int
-/*ARGSUSED*/
-rl_complete(int ignore, int invoking_key)
+rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
{
if (h == NULL || e == NULL)
rl_initialize();
@@ -1873,15 +1516,26 @@ rl_complete(int ignore, int invoking_key)
arr[1] = '\0';
el_insertstr(e, arr);
return (CC_REFRESH);
- } else if (e->el_state.lastcmd == el_rl_complete_cmdnum)
- return _rl_complete_internal('?');
- else if (_rl_complete_show_all)
- return _rl_complete_internal('!');
- else
- return _rl_complete_internal(TAB);
+ }
+
+ /* Just look at how many global variables modify this operation! */
+ return fn_complete(e,
+ (CPFunction *)rl_completion_entry_function,
+ rl_attempted_completion_function,
+ rl_basic_word_break_characters, rl_special_prefixes,
+ _rl_completion_append_character_function, rl_completion_query_items,
+ &rl_completion_type, &rl_attempted_completion_over,
+ &rl_point, &rl_end);
}
+/* ARGSUSED */
+static unsigned char
+_el_rl_complete(EditLine *el __attribute__((__unused__)), int ch)
+{
+ return (unsigned char)rl_complete(0, ch);
+}
+
/*
* misc other functions
*/
@@ -1989,7 +1643,7 @@ int
rl_add_defun(const char *name, Function *fun, int c)
{
char dest[8];
- if (c >= sizeof(map) / sizeof(map[0]) || c < 0)
+ if ((size_t)c >= sizeof(map) / sizeof(map[0]) || c < 0)
return -1;
map[(unsigned char)c] = fun;
el_set(e, EL_ADDFN, name, name, rl_bind_wrapper);
@@ -2007,11 +1661,7 @@ rl_callback_read_char()
if (buf == NULL || count-- <= 0)
return;
-#ifdef CTRL2 /* _AIX */
- if (count == 0 && buf[0] == CTRL2('d'))
-#else
- if (count == 0 && buf[0] == CTRL('d'))
-#endif
+ if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF])
done = 1;
if (buf[count] == '\n' || buf[count] == '\r')
done = 2;
@@ -2029,14 +1679,12 @@ rl_callback_read_char()
}
void
-rl_callback_handler_install (const char *prompt, VFunction *linefunc)
+rl_callback_handler_install(const char *prompt, VCPFunction *linefunc)
{
if (e == NULL) {
rl_initialize();
}
- if (rl_prompt)
- free(rl_prompt);
- rl_prompt = prompt ? strdup(strchr(prompt, *prompt)) : NULL;
+ (void)rl_set_prompt(prompt);
rl_linefunc = linefunc;
el_set(e, EL_UNBUFFERED, 1);
}
@@ -2045,17 +1693,14 @@ void
rl_callback_handler_remove(void)
{
el_set(e, EL_UNBUFFERED, 0);
+ rl_linefunc = NULL;
}
void
rl_redisplay(void)
{
char a[2];
-#ifdef CTRL2 /* _AIX */
- a[0] = CTRL2('r');
-#else
- a[0] = CTRL('r');
-#endif
+ a[0] = e->el_tty.t_c[TS_IO][C_REPRINT];
a[1] = '\0';
el_push(e, a);
}
@@ -2079,7 +1724,7 @@ rl_prep_terminal(int meta_flag)
}
void
-rl_deprep_terminal()
+rl_deprep_terminal(void)
{
el_set(e, EL_PREP_TERM, 0);
}
@@ -2104,6 +1749,16 @@ rl_parse_and_bind(const char *line)
return (argc ? 1 : 0);
}
+int
+rl_variable_bind(const char *var, const char *value)
+{
+ /*
+ * The proper return value is undocument, but this is what the
+ * readline source seems to do.
+ */
+ return ((el_set(e, EL_BIND, "", var, value) == -1) ? 1 : 0);
+}
+
void
rl_stuff_char(int c)
{
@@ -2119,7 +1774,7 @@ _rl_event_read_char(EditLine *el, char *cp)
{
int n, num_read = 0;
- *cp = 0;
+ *cp = '\0';
while (rl_event_hook) {
(*rl_event_hook)();
@@ -2164,3 +1819,142 @@ _rl_update_pos(void)
rl_point = li->cursor - li->buffer;
rl_end = li->lastchar - li->buffer;
}
+
+void
+rl_get_screen_size(int *rows, int *cols)
+{
+ if (rows)
+ el_get(e, EL_GETTC, "li", rows);
+ if (cols)
+ el_get(e, EL_GETTC, "co", cols);
+}
+
+void
+rl_set_screen_size(int rows, int cols)
+{
+ char buf[64];
+ (void)snprintf(buf, sizeof(buf), "%d", rows);
+ el_set(e, EL_SETTC, "li", buf);
+ (void)snprintf(buf, sizeof(buf), "%d", cols);
+ el_set(e, EL_SETTC, "co", buf);
+}
+
+char **
+rl_completion_matches(const char *str, rl_compentry_func_t *fun)
+{
+ size_t len, max, i, j, min;
+ char **list, *match, *a, *b;
+
+ len = 1;
+ max = 10;
+ if ((list = malloc(max * sizeof(*list))) == NULL)
+ return NULL;
+
+ while ((match = (*fun)(str, (int)(len - 1))) != NULL) {
+ if (len == max) {
+ char **nl;
+ max += 10;
+ if ((nl = realloc(list, max * sizeof(*nl))) == NULL)
+ goto out;
+ list = nl;
+ }
+ list[len++] = match;
+ }
+ if (len == 1)
+ goto out;
+ list[len] = NULL;
+ if (len == 2) {
+ if ((list[0] = strdup(list[1])) == NULL)
+ goto out;
+ return list;
+ }
+ qsort(&list[1], len - 1, sizeof(*list),
+ (int (*)(const void *, const void *)) strcmp);
+ min = SIZE_T_MAX;
+ for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
+ b = list[i + 1];
+ for (j = 0; a[j] && a[j] == b[j]; j++)
+ continue;
+ if (min > j)
+ min = j;
+ }
+ if (min == 0 && *str) {
+ if ((list[0] = strdup(str)) == NULL)
+ goto out;
+ } else {
+ if ((list[0] = malloc(min + 1)) == NULL)
+ goto out;
+ (void)memcpy(list[0], list[1], min);
+ list[0][min] = '\0';
+ }
+ return list;
+
+out:
+ free(list);
+ return NULL;
+}
+
+char *
+rl_filename_completion_function (const char *text, int state)
+{
+ return fn_filename_completion_function(text, state);
+}
+
+void
+rl_forced_update_display(void)
+{
+ el_set(e, EL_REFRESH);
+}
+
+int
+_rl_abort_internal(void)
+{
+ el_beep(e);
+ longjmp(topbuf, 1);
+ /*NOTREACHED*/
+}
+
+int
+_rl_qsort_string_compare(char **s1, char **s2)
+{
+ return strcoll(*s1, *s2);
+}
+
+int
+/*ARGSUSED*/
+rl_kill_text(int from, int to)
+{
+ return 0;
+}
+
+Keymap
+rl_make_bare_keymap(void)
+{
+ return NULL;
+}
+
+Keymap
+rl_get_keymap(void)
+{
+ return NULL;
+}
+
+void
+/*ARGSUSED*/
+rl_set_keymap(Keymap k)
+{
+}
+
+int
+/*ARGSUSED*/
+rl_generic_bind(int type, const char * keyseq, const char * data, Keymap k)
+{
+ return 0;
+}
+
+int
+/*ARGSUSED*/
+rl_bind_key_in_map(int key, Function *fun, Keymap k)
+{
+ return 0;
+}
diff --git a/cmd-line-utils/libedit/readline/readline.h b/cmd-line-utils/libedit/readline/readline.h
index 6b1fa186512..c77b080c439 100644
--- a/cmd-line-utils/libedit/readline/readline.h
+++ b/cmd-line-utils/libedit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.12 2004/09/08 18:15:37 christos Exp $ */
+/* $NetBSD: readline.h,v 1.24 2009/02/05 19:15:26 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -45,14 +38,14 @@
/* typedefs */
typedef int Function(const char *, int);
typedef void VFunction(void);
+typedef void VCPFunction(char *);
typedef char *CPFunction(const char *, int);
typedef char **CPPFunction(const char *, int, int);
-
-typedef void *histdata_t;
+typedef char *rl_compentry_func_t(const char *, int);
typedef struct _hist_entry {
const char *line;
- histdata_t *data;
+ const char *data;
} HIST_ENTRY;
typedef struct _keymap_entry {
@@ -73,7 +66,7 @@ typedef KEYMAP_ENTRY *Keymap;
#ifndef CTRL
#include <sys/ioctl.h>
-#if defined(__GLIBC__) || defined(__MWERKS__)
+#if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
#include <sys/ttydefaults.h>
#endif
#ifndef CTRL
@@ -102,8 +95,9 @@ extern int max_input_history;
extern char *rl_basic_word_break_characters;
extern char *rl_completer_word_break_characters;
extern char *rl_completer_quote_characters;
-extern CPFunction *rl_completion_entry_function;
+extern Function *rl_completion_entry_function;
extern CPPFunction *rl_attempted_completion_function;
+extern int rl_attempted_completion_over;
extern int rl_completion_type;
extern int rl_completion_query_items;
extern char *rl_special_prefixes;
@@ -122,11 +116,13 @@ extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
emacs_ctlx_keymap;
extern int rl_filename_completion_desired;
extern int rl_ignore_completion_duplicates;
-extern Function *rl_getc_function;
+extern int (*rl_getc_function)(FILE *);
extern VFunction *rl_redisplay_function;
extern VFunction *rl_completion_display_matches_hook;
extern VFunction *rl_prep_term_function;
extern VFunction *rl_deprep_term_function;
+extern int readline_echoing_p;
+extern int _rl_print_completions_horizontally;
/* supported functions */
char *readline(const char *);
@@ -141,6 +137,7 @@ int history_is_stifled(void);
int where_history(void);
HIST_ENTRY *current_history(void);
HIST_ENTRY *history_get(int);
+HIST_ENTRY *remove_history(int);
int history_total_bytes(void);
int history_set_pos(int);
HIST_ENTRY *previous_history(void);
@@ -168,7 +165,7 @@ void rl_reset_terminal(const char *);
int rl_bind_key(int, int (*)(int, int));
int rl_newline(int, int);
void rl_callback_read_char(void);
-void rl_callback_handler_install(const char *, VFunction *);
+void rl_callback_handler_install(const char *, VCPFunction *);
void rl_callback_handler_remove(void);
void rl_redisplay(void);
int rl_get_previous_history(int, int);
@@ -176,13 +173,24 @@ void rl_prep_terminal(int);
void rl_deprep_terminal(void);
int rl_read_init_file(const char *);
int rl_parse_and_bind(const char *);
+int rl_variable_bind(const char *, const char *);
void rl_stuff_char(int);
int rl_add_defun(const char *, Function *, int);
+void rl_get_screen_size(int *, int *);
+void rl_set_screen_size(int, int);
+char *rl_filename_completion_function (const char *, int);
+int _rl_abort_internal(void);
+int _rl_qsort_string_compare(char **, char **);
+char **rl_completion_matches(const char *, rl_compentry_func_t *);
+void rl_forced_update_display(void);
+int rl_set_prompt(const char *);
/*
* The following are not implemented
*/
+int rl_kill_text(int, int);
Keymap rl_get_keymap(void);
+void rl_set_keymap(Keymap);
Keymap rl_make_bare_keymap(void);
int rl_generic_bind(int, const char *, const char *, Keymap);
int rl_bind_key_in_map(int, Function *, Keymap);
diff --git a/cmd-line-utils/libedit/refresh.c b/cmd-line-utils/libedit/refresh.c
index 46aca15ef08..5edd1fe78fc 100644
--- a/cmd-line-utils/libedit/refresh.c
+++ b/cmd-line-utils/libedit/refresh.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $ */
+/* $NetBSD: refresh.c,v 1.28 2008/09/10 15:45:37 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* refresh.c: Lower level screen refreshing functions
@@ -49,6 +55,7 @@ private void re_update_line(EditLine *, char *, char *, int);
private void re_insert (EditLine *, char *, int, int, char *, int);
private void re_delete(EditLine *, char *, int, int, int);
private void re_fastputc(EditLine *, int);
+private void re_clear_eol(EditLine *, int, int, int);
private void re__strncopy(char *, char *, size_t);
private void re__copy_and_pad(char *, const char *, size_t);
@@ -315,9 +322,9 @@ re_goto_bottom(EditLine *el)
{
term_move_to_line(el, el->el_refresh.r_oldcv);
- term__putc('\n');
+ term__putc(el, '\n');
re_clear_display(el);
- term__flush();
+ term__flush(el);
}
@@ -340,7 +347,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
ELRE_DEBUG(1,
(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
num, dat, dlen, d));
- ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
+ ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
/* open up the space for num chars */
if (num > 0) {
@@ -353,7 +360,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
ELRE_DEBUG(1, (__F,
"re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
num, dat, dlen, d));
- ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
+ ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
/* copy the characters */
for (a = d + dat; (a < d + dlen) && (num > 0); num--)
@@ -362,7 +369,7 @@ re_insert(EditLine *el __attribute__((__unused__)),
ELRE_DEBUG(1,
(__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
num, dat, dlen, d, s));
- ELRE_DEBUG(1, (__F, "s == \"%s\"n", s));
+ ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s));
}
@@ -411,6 +418,32 @@ re__strncopy(char *a, char *b, size_t n)
*a++ = *b++;
}
+/* re_clear_eol():
+ * Find the number of characters we need to clear till the end of line
+ * in order to make sure that we have cleared the previous contents of
+ * the line. fx and sx is the number of characters inserted or deleted
+ * int the first or second diff, diff is the difference between the
+ * number of characters between the new and old line.
+ */
+private void
+re_clear_eol(EditLine *el, int fx, int sx, int diff)
+{
+
+ ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n",
+ sx, fx, diff));
+
+ if (fx < 0)
+ fx = -fx;
+ if (sx < 0)
+ sx = -sx;
+ if (fx > diff)
+ diff = fx;
+ if (sx > diff)
+ diff = sx;
+
+ ELRE_DEBUG(1, (__F, "re_clear_eol %d\n", diff));
+ term_clear_EOL(el, diff);
+}
/*****************************************************************
re_update_line() is based on finding the middle difference of each line
@@ -626,7 +659,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
fx = (nsb - nfd) - (osb - ofd);
sx = (nls - nse) - (ols - ose);
- ELRE_DEBUG(1, (__F, "\n"));
+ ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx));
ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
ofd - old, osb - old, ose - old, ols - old, oe - old));
ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
@@ -775,9 +808,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
* write (nsb-nfd) chars of new starting at nfd
*/
term_overwrite(el, nfd, (nsb - nfd));
- ELRE_DEBUG(1, (__F,
- "cleareol %d\n", (oe - old) - (ne - new)));
- term_clear_EOL(el, (oe - old) - (ne - new));
+ re_clear_eol(el, fx, sx, (oe - old) - (ne - new));
/*
* Done
*/
@@ -818,10 +849,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
ELRE_DEBUG(1, (__F,
"but with nothing left to save\r\n"));
term_overwrite(el, nse, (nls - nse));
- ELRE_DEBUG(1, (__F,
- "cleareol %d\n", (oe - old) - (ne - new)));
- if ((oe - old) - (ne - new) != 0)
- term_clear_EOL(el, (oe - old) - (ne - new));
+ re_clear_eol(el, fx, sx, (oe - old) - (ne - new));
}
}
/*
@@ -982,7 +1010,7 @@ re_refresh_cursor(EditLine *el)
/* now go there */
term_move_to_line(el, v);
term_move_to_char(el, h);
- term__flush();
+ term__flush(el);
}
@@ -993,7 +1021,7 @@ private void
re_fastputc(EditLine *el, int c)
{
- term__putc(c);
+ term__putc(el, c);
el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
if (el->el_cursor.h >= el->el_term.t_size.h) {
/* if we must overflow */
@@ -1020,12 +1048,12 @@ re_fastputc(EditLine *el, int c)
}
if (EL_HAS_AUTO_MARGINS) {
if (EL_HAS_MAGIC_MARGINS) {
- term__putc(' ');
- term__putc('\b');
+ term__putc(el, ' ');
+ term__putc(el, '\b');
}
} else {
- term__putc('\r');
- term__putc('\n');
+ term__putc(el, '\r');
+ term__putc(el, '\n');
}
}
}
@@ -1065,7 +1093,7 @@ re_fastaddc(EditLine *el)
re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0'));
re_fastputc(el, (c & 7) + '0');
}
- term__flush();
+ term__flush(el);
}
@@ -1104,7 +1132,7 @@ re_clear_lines(EditLine *el)
} else {
term_move_to_line(el, el->el_refresh.r_oldcv);
/* go to last line */
- term__putc('\r'); /* go to BOL */
- term__putc('\n'); /* go to new line */
+ term__putc(el, '\r'); /* go to BOL */
+ term__putc(el, '\n'); /* go to new line */
}
}
diff --git a/cmd-line-utils/libedit/search.c b/cmd-line-utils/libedit/search.c
index 850c5f27140..df50c7e7370 100644
--- a/cmd-line-utils/libedit/search.c
+++ b/cmd-line-utils/libedit/search.c
@@ -32,12 +32,17 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* search.c: History and character search functions
*/
-#include <sys/types.h>
#include <stdlib.h>
#if defined(REGEX)
#include <regex.h>
diff --git a/cmd-line-utils/libedit/sig.c b/cmd-line-utils/libedit/sig.c
index 8e70933d606..5307ee6ec60 100644
--- a/cmd-line-utils/libedit/sig.c
+++ b/cmd-line-utils/libedit/sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.c,v 1.11 2003/08/07 16:44:33 agc Exp $ */
+/* $NetBSD: sig.c,v 1.12 2008/09/10 15:45:37 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* sig.c: Signal handling stuff.
@@ -51,15 +57,15 @@ private const int sighdl[] = {
- 1
};
-private void sig_handler(int);
+private void el_sig_handler(int);
-/* sig_handler():
+/* el_sig_handler():
* This is the handler called for all signals
* XXX: we cannot pass any data so we just store the old editline
* state in a private variable
*/
private void
-sig_handler(int signo)
+el_sig_handler(int signo)
{
int i;
sigset_t nset, oset;
@@ -73,7 +79,7 @@ sig_handler(int signo)
tty_rawmode(sel);
if (ed_redisplay(sel, 0) == CC_REFRESH)
re_refresh(sel);
- term__flush();
+ term__flush(sel);
break;
case SIGWINCH:
@@ -154,7 +160,7 @@ sig_set(EditLine *el)
for (i = 0; sighdl[i] != -1; i++) {
el_signalhandler_t s;
/* This could happen if we get interrupted */
- if ((s = signal(sighdl[i], sig_handler)) != sig_handler)
+ if ((s = signal(sighdl[i], el_sig_handler)) != el_sig_handler)
el->el_signal[i] = s;
}
sel = el;
diff --git a/cmd-line-utils/libedit/sig.h b/cmd-line-utils/libedit/sig.h
index 0bf1fc37e39..2bd3c516d46 100644
--- a/cmd-line-utils/libedit/sig.h
+++ b/cmd-line-utils/libedit/sig.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $ */
+/* $NetBSD: sig.h,v 1.6 2008/07/12 15:27:14 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -51,7 +51,6 @@
#define ALLSIGS \
_DO(SIGINT) \
_DO(SIGTSTP) \
- _DO(SIGSTOP) \
_DO(SIGQUIT) \
_DO(SIGHUP) \
_DO(SIGTERM) \
diff --git a/cmd-line-utils/libedit/strlcpy.c b/cmd-line-utils/libedit/strlcpy.c
deleted file mode 100644
index e38d6cf1c4b..00000000000
--- a/cmd-line-utils/libedit/strlcpy.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* $NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp $ */
-/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
- * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <assert.h>
-#include <string.h>
-
-#ifdef _LIBC
-# ifdef __weak_alias
-__weak_alias(strlcpy, _strlcpy)
-# endif
-#endif
-
-#if !HAVE_STRLCPY
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-#ifdef _LIBC
-_strlcpy(dst, src, siz)
-#else
-strlcpy(dst, src, siz)
-#endif
- char *dst;
- const char *src;
- size_t siz;
-{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(src != NULL);
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-#endif
diff --git a/cmd-line-utils/libedit/strlcpy.h b/cmd-line-utils/libedit/strlcpy.h
deleted file mode 100644
index e4d3a7ffa3f..00000000000
--- a/cmd-line-utils/libedit/strlcpy.h
+++ /dev/null
@@ -1,2 +0,0 @@
-size_t strlcpy(char *dst, const char *src, size_t size);
-size_t strlcat(char *dst, const char *src, size_t size);
diff --git a/cmd-line-utils/libedit/sys.h b/cmd-line-utils/libedit/sys.h
index c8a29dbfb05..a0369affbb0 100644
--- a/cmd-line-utils/libedit/sys.h
+++ b/cmd-line-utils/libedit/sys.h
@@ -48,14 +48,14 @@
# define __attribute__(A)
#endif
-#ifndef __P
-# define __P(x) x
-#endif
-
#ifndef _DIAGASSERT
# define _DIAGASSERT(x)
#endif
+#ifndef SIZE_T_MAX
+# define SIZE_T_MAX UINT_MAX
+#endif
+
#ifndef __BEGIN_DECLS
# ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
@@ -113,6 +113,25 @@ char *fgetln(FILE *fp, size_t *len);
#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */
+#ifdef __SunOS
+extern int tgetent(char *, const char *);
+extern int tgetflag(char *);
+extern int tgetnum(char *);
+extern int tputs(const char *, int, int (*)(int));
+extern char* tgoto(const char*, int, int);
+extern char* tgetstr(char*, char**);
+#endif
+
+/* XXXMYSQL: Bug#10218 Command line recall rolls into segfault */
+#if !HAVE_DECL_TGOTO
+/*
+ 'tgoto' is not declared in the system header files, this causes
+ problems on 64-bit systems. The function returns a 64 bit pointer
+ but caller see it as "int" and it's thus truncated to 32-bit
+*/
+extern char* tgoto(const char*, int, int);
+#endif
+
#ifdef notdef
# undef REGEX
# undef REGEXP
diff --git a/cmd-line-utils/libedit/term.c b/cmd-line-utils/libedit/term.c
index b516d6753c3..488c760da14 100644
--- a/cmd-line-utils/libedit/term.c
+++ b/cmd-line-utils/libedit/term.c
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp $ */
+/* $NetBSD: term.c,v 1.48 2009/02/06 20:08:13 sketch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* term.c: Editor/termcap-curses interface
@@ -44,21 +50,28 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-
+#if 0 /* TODO: do we need this */
+#ifdef HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+#endif
#ifdef HAVE_CURSES_H
-# include <curses.h>
-#elif HAVE_NCURSES_H
-# include <ncurses.h>
+#include <curses.h>
+#endif
+#ifdef HAVE_NCURSES_H
+#include <ncurses.h>
#endif
-
/* Solaris's term.h does horrid things. */
-#if (defined(HAVE_TERM_H) && !defined(_SUNOS))
-# include <term.h>
+#if (defined(HAVE_TERM_H) && !defined(__SunOS))
+#include <term.h>
#endif
-
#include <sys/types.h>
#include <sys/ioctl.h>
+#ifdef _REENTRANT
+#include <pthread.h>
+#endif
+
#include "el.h"
/*
@@ -263,9 +276,13 @@ private int term_alloc_display(EditLine *);
private void term_alloc(EditLine *, const struct termcapstr *, const char *);
private void term_init_arrow(EditLine *);
private void term_reset_arrow(EditLine *);
+private int term_putc(int);
+private void term_tputs(EditLine *, const char *, int);
-
-private FILE *term_outfile = NULL; /* XXX: How do we fix that? */
+#ifdef _REENTRANT
+private pthread_mutex_t term_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+private FILE *term_outfile = NULL;
/* term_setflags():
@@ -313,7 +330,6 @@ term_setflags(EditLine *el)
#endif /* DEBUG_SCREEN */
}
-
/* term_init():
* Initialize the terminal stuff
*/
@@ -339,7 +355,6 @@ term_init(EditLine *el)
if (el->el_term.t_val == NULL)
return (-1);
(void) memset(el->el_term.t_val, 0, T_val * sizeof(int));
- term_outfile = el->el_outfile;
(void) term_set(el, NULL);
term_init_arrow(el);
return (0);
@@ -390,7 +405,8 @@ term_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
* New string is shorter; no need to allocate space
*/
if (clen <= tlen) {
- (void) strcpy(*str, cap); /* XXX strcpy is safe */
+ if (*str)
+ (void) strcpy(*str, cap); /* XXX strcpy is safe */
return;
}
/*
@@ -464,8 +480,12 @@ term_alloc_display(EditLine *el)
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
- if (b[i] == NULL)
+ if (b[i] == NULL) {
+ while (--i >= 0)
+ el_free((ptr_t) b[i]);
+ el_free((ptr_t) b);
return (-1);
+ }
}
b[c->v] = NULL;
el->el_display = b;
@@ -475,8 +495,12 @@ term_alloc_display(EditLine *el)
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
- if (b[i] == NULL)
+ if (b[i] == NULL) {
+ while (--i >= 0)
+ el_free((ptr_t) b[i]);
+ el_free((ptr_t) b);
return (-1);
+ }
}
b[c->v] = NULL;
el->el_vdisplay = b;
@@ -542,12 +566,12 @@ term_move_to_line(EditLine *el, int where)
del--;
} else {
if ((del > 1) && GoodStr(T_DO)) {
- (void) tputs(tgoto(Str(T_DO), del, del),
- del, term__putc);
+ term_tputs(el, tgoto(Str(T_DO), del,
+ del), del);
del = 0;
} else {
for (; del > 0; del--)
- term__putc('\n');
+ term__putc(el, '\n');
/* because the \n will become \r\n */
el->el_cursor.h = 0;
}
@@ -555,12 +579,11 @@ term_move_to_line(EditLine *el, int where)
}
} else { /* del < 0 */
if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up)))
- (void) tputs(tgoto(Str(T_UP), -del, -del), -del,
- term__putc);
+ term_tputs(el, tgoto(Str(T_UP), -del, -del), -del);
else {
if (GoodStr(T_up))
for (; del < 0; del++)
- (void) tputs(Str(T_up), 1, term__putc);
+ term_tputs(el, Str(T_up), 1);
}
}
el->el_cursor.v = where;/* now where is here */
@@ -587,7 +610,7 @@ mc_again:
return;
}
if (!where) { /* if where is first column */
- term__putc('\r'); /* do a CR */
+ term__putc(el, '\r'); /* do a CR */
el->el_cursor.h = 0;
return;
}
@@ -595,12 +618,11 @@ mc_again:
if ((del < -4 || del > 4) && GoodStr(T_ch))
/* go there directly */
- (void) tputs(tgoto(Str(T_ch), where, where), where, term__putc);
+ term_tputs(el, tgoto(Str(T_ch), where, where), where);
else {
if (del > 0) { /* moving forward */
if ((del > 4) && GoodStr(T_RI))
- (void) tputs(tgoto(Str(T_RI), del, del),
- del, term__putc);
+ term_tputs(el, tgoto(Str(T_RI), del, del), del);
else {
/* if I can do tabs, use them */
if (EL_CAN_TAB) {
@@ -611,7 +633,7 @@ mc_again:
(el->el_cursor.h & 0370);
i < (where & 0370);
i += 8)
- term__putc('\t');
+ term__putc(el, '\t');
/* then tab over */
el->el_cursor.h = where & 0370;
}
@@ -631,8 +653,8 @@ mc_again:
}
} else { /* del < 0 := moving backward */
if ((-del > 4) && GoodStr(T_LE))
- (void) tputs(tgoto(Str(T_LE), -del, -del),
- -del, term__putc);
+ term_tputs(el, tgoto(Str(T_LE), -del, -del),
+ -del);
else { /* can't go directly there */
/*
* if the "cost" is greater than the "cost"
@@ -643,12 +665,12 @@ mc_again:
(((unsigned int) where >> 3) +
(where & 07)))
: (-del > where)) {
- term__putc('\r'); /* do a CR */
+ term__putc(el, '\r'); /* do a CR */
el->el_cursor.h = 0;
goto mc_again; /* and try again */
}
for (i = 0; i < -del; i++)
- term__putc('\b');
+ term__putc(el, '\b');
}
}
}
@@ -673,7 +695,7 @@ term_overwrite(EditLine *el, const char *cp, int n)
return;
}
do {
- term__putc(*cp++);
+ term__putc(el, *cp++);
el->el_cursor.h++;
} while (--n);
@@ -689,7 +711,7 @@ term_overwrite(EditLine *el, const char *cp, int n)
!= '\0')
term_overwrite(el, &c, 1);
else
- term__putc(' ');
+ term__putc(el, ' ');
el->el_cursor.h = 1;
}
} else /* no wrap, but cursor stays on screen */
@@ -723,19 +745,18 @@ term_deletechars(EditLine *el, int num)
if (GoodStr(T_DC)) /* if I have multiple delete */
if ((num > 1) || !GoodStr(T_dc)) { /* if dc would be more
* expen. */
- (void) tputs(tgoto(Str(T_DC), num, num),
- num, term__putc);
+ term_tputs(el, tgoto(Str(T_DC), num, num), num);
return;
}
if (GoodStr(T_dm)) /* if I have delete mode */
- (void) tputs(Str(T_dm), 1, term__putc);
+ term_tputs(el, Str(T_dm), 1);
if (GoodStr(T_dc)) /* else do one at a time */
while (num--)
- (void) tputs(Str(T_dc), 1, term__putc);
+ term_tputs(el, Str(T_dc), 1);
if (GoodStr(T_ed)) /* if I have delete mode */
- (void) tputs(Str(T_ed), 1, term__putc);
+ term_tputs(el, Str(T_ed), 1);
}
@@ -764,37 +785,35 @@ term_insertwrite(EditLine *el, char *cp, int num)
if (GoodStr(T_IC)) /* if I have multiple insert */
if ((num > 1) || !GoodStr(T_ic)) {
/* if ic would be more expensive */
- (void) tputs(tgoto(Str(T_IC), num, num),
- num, term__putc);
+ term_tputs(el, tgoto(Str(T_IC), num, num), num);
term_overwrite(el, cp, num);
/* this updates el_cursor.h */
return;
}
if (GoodStr(T_im) && GoodStr(T_ei)) { /* if I have insert mode */
- (void) tputs(Str(T_im), 1, term__putc);
+ term_tputs(el, Str(T_im), 1);
el->el_cursor.h += num;
do
- term__putc(*cp++);
+ term__putc(el, *cp++);
while (--num);
if (GoodStr(T_ip)) /* have to make num chars insert */
- (void) tputs(Str(T_ip), 1, term__putc);
+ term_tputs(el, Str(T_ip), 1);
- (void) tputs(Str(T_ei), 1, term__putc);
+ term_tputs(el, Str(T_ei), 1);
return;
}
do {
if (GoodStr(T_ic)) /* have to make num chars insert */
- (void) tputs(Str(T_ic), 1, term__putc);
- /* insert a char */
+ term_tputs(el, Str(T_ic), 1);
- term__putc(*cp++);
+ term__putc(el, *cp++);
el->el_cursor.h++;
if (GoodStr(T_ip)) /* have to make num chars insert */
- (void) tputs(Str(T_ip), 1, term__putc);
+ term_tputs(el, Str(T_ip), 1);
/* pad the inserted char */
} while (--num);
@@ -810,10 +829,10 @@ term_clear_EOL(EditLine *el, int num)
int i;
if (EL_CAN_CEOL && GoodStr(T_ce))
- (void) tputs(Str(T_ce), 1, term__putc);
+ term_tputs(el, Str(T_ce), 1);
else {
for (i = 0; i < num; i++)
- term__putc(' ');
+ term__putc(el, ' ');
el->el_cursor.h += num; /* have written num spaces */
}
}
@@ -828,14 +847,14 @@ term_clear_screen(EditLine *el)
if (GoodStr(T_cl))
/* send the clear screen code */
- (void) tputs(Str(T_cl), Val(T_li), term__putc);
+ term_tputs(el, Str(T_cl), Val(T_li));
else if (GoodStr(T_ho) && GoodStr(T_cd)) {
- (void) tputs(Str(T_ho), Val(T_li), term__putc); /* home */
+ term_tputs(el, Str(T_ho), Val(T_li)); /* home */
/* clear to bottom of screen */
- (void) tputs(Str(T_cd), Val(T_li), term__putc);
+ term_tputs(el, Str(T_cd), Val(T_li));
} else {
- term__putc('\r');
- term__putc('\n');
+ term__putc(el, '\r');
+ term__putc(el, '\n');
}
}
@@ -848,9 +867,9 @@ term_beep(EditLine *el)
{
if (GoodStr(T_bl))
/* what termcap says we should use */
- (void) tputs(Str(T_bl), 1, term__putc);
+ term_tputs(el, Str(T_bl), 1);
else
- term__putc('\007'); /* an ASCII bell; ^G */
+ term__putc(el, '\007'); /* an ASCII bell; ^G */
}
@@ -862,9 +881,9 @@ protected void
term_clear_to_bottom(EditLine *el)
{
if (GoodStr(T_cd))
- (void) tputs(Str(T_cd), Val(T_li), term__putc);
+ term_tputs(el, Str(T_cd), Val(T_li));
else if (GoodStr(T_ce))
- (void) tputs(Str(T_ce), Val(T_li), term__putc);
+ term_tputs(el, Str(T_ce), Val(T_li));
}
#endif
@@ -936,7 +955,7 @@ term_set(EditLine *el, const char *term)
Val(T_co) = tgetnum("co");
Val(T_li) = tgetnum("li");
for (t = tstr; t->name != NULL; t++) {
- /* XXX: some systems tgetstr needs non const */
+ /* XXX: some systems' tgetstr needs non const */
term_alloc(el, t, tgetstr(strchr(t->name, *t->name),
&area));
}
@@ -1220,26 +1239,62 @@ term_bind_arrow(EditLine *el)
}
}
+/* term_putc():
+ * Add a character
+ */
+private int
+term_putc(int c)
+{
+
+ if (term_outfile == NULL)
+ return -1;
+ return fputc(c, term_outfile);
+}
+
+private void
+term_tputs(EditLine *el, const char *cap, int affcnt)
+{
+#ifdef _REENTRANT
+ pthread_mutex_lock(&term_mutex);
+#endif
+ term_outfile = el->el_outfile;
+ (void)tputs(cap, affcnt, term_putc);
+#ifdef _REENTRANT
+ pthread_mutex_unlock(&term_mutex);
+#endif
+}
/* term__putc():
* Add a character
*/
protected int
-term__putc(int c)
+term__putc(EditLine *el, int c)
{
- return (fputc(c, term_outfile));
+ return fputc(c, el->el_outfile);
}
-
/* term__flush():
* Flush output
*/
protected void
-term__flush(void)
+term__flush(EditLine *el)
{
- (void) fflush(term_outfile);
+ (void) fflush(el->el_outfile);
+}
+
+/* term_writec():
+ * Write the given character out, in a human readable form
+ */
+protected void
+term_writec(EditLine *el, int c)
+{
+ char buf[8];
+ int cnt = key__decode_char(buf, sizeof(buf), 0, c);
+ buf[cnt] = '\0';
+ term_overwrite(el, buf, cnt);
+ term__flush(el);
}
@@ -1269,11 +1324,17 @@ term_telltc(EditLine *el, int argc __attribute__((__unused__)),
(void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
EL_HAS_MAGIC_MARGINS ? "has" : "does not have");
- for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++)
+ for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++) {
+ const char *ub;
+ if (*ts && **ts) {
+ (void) key__decode_str(*ts, upbuf, sizeof(upbuf), "");
+ ub = upbuf;
+ } else {
+ ub = "(empty)";
+ }
(void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
- t->long_name,
- t->name, *ts && **ts ?
- key__decode_str(*ts, upbuf, "") : "(empty)");
+ t->long_name, t->name, ub);
+ }
(void) fputc('\n', el->el_outfile);
return (0);
}
@@ -1292,7 +1353,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
const char *what, *how;
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
- return (-1);
+ return -1;
what = argv[1];
how = argv[2];
@@ -1307,7 +1368,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
if (ts->name != NULL) {
term_alloc(el, ts, how);
term_setflags(el);
- return (0);
+ return 0;
}
/*
* Do the numeric ones second
@@ -1316,46 +1377,100 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
if (strcmp(tv->name, what) == 0)
break;
- if (tv->name != NULL) {
- if (tv == &tval[T_pt] || tv == &tval[T_km] ||
- tv == &tval[T_am] || tv == &tval[T_xn]) {
- if (strcmp(how, "yes") == 0)
- el->el_term.t_val[tv - tval] = 1;
- else if (strcmp(how, "no") == 0)
- el->el_term.t_val[tv - tval] = 0;
- else {
- (void) fprintf(el->el_errfile,
- "settc: Bad value `%s'.\n", how);
- return (-1);
- }
- term_setflags(el);
- if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
- return (-1);
- return (0);
- } else {
- long i;
- char *ep;
+ if (tv->name != NULL)
+ return -1;
- i = strtol(how, &ep, 10);
- if (*ep != '\0') {
- (void) fprintf(el->el_errfile,
- "settc: Bad value `%s'.\n", how);
- return (-1);
- }
- el->el_term.t_val[tv - tval] = (int) i;
- el->el_term.t_size.v = Val(T_co);
- el->el_term.t_size.h = Val(T_li);
- if (tv == &tval[T_co] || tv == &tval[T_li])
- if (term_change_size(el, Val(T_li), Val(T_co))
- == -1)
- return (-1);
- return (0);
+ if (tv == &tval[T_pt] || tv == &tval[T_km] ||
+ tv == &tval[T_am] || tv == &tval[T_xn]) {
+ if (strcmp(how, "yes") == 0)
+ el->el_term.t_val[tv - tval] = 1;
+ else if (strcmp(how, "no") == 0)
+ el->el_term.t_val[tv - tval] = 0;
+ else {
+ (void) fprintf(el->el_errfile,
+ "%s: Bad value `%s'.\n", argv[0], how);
+ return -1;
+ }
+ term_setflags(el);
+ if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
+ return -1;
+ return 0;
+ } else {
+ long i;
+ char *ep;
+
+ i = strtol(how, &ep, 10);
+ if (*ep != '\0') {
+ (void) fprintf(el->el_errfile,
+ "%s: Bad value `%s'.\n", argv[0], how);
+ return -1;
}
+ el->el_term.t_val[tv - tval] = (int) i;
+ el->el_term.t_size.v = Val(T_co);
+ el->el_term.t_size.h = Val(T_li);
+ if (tv == &tval[T_co] || tv == &tval[T_li])
+ if (term_change_size(el, Val(T_li), Val(T_co))
+ == -1)
+ return -1;
+ return 0;
}
- return (-1);
}
+/* term_gettc():
+ * Get the current terminal characteristics
+ */
+protected int
+/*ARGSUSED*/
+term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
+{
+ const struct termcapstr *ts;
+ const struct termcapval *tv;
+ char *what;
+ void *how;
+
+ if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
+ return (-1);
+
+ what = argv[1];
+ how = argv[2];
+
+ /*
+ * Do the strings first
+ */
+ for (ts = tstr; ts->name != NULL; ts++)
+ if (strcmp(ts->name, what) == 0)
+ break;
+
+ if (ts->name != NULL) {
+ *(char **)how = el->el_term.t_str[ts - tstr];
+ return 0;
+ }
+ /*
+ * Do the numeric ones second
+ */
+ for (tv = tval; tv->name != NULL; tv++)
+ if (strcmp(tv->name, what) == 0)
+ break;
+
+ if (tv->name == NULL)
+ return -1;
+
+ if (tv == &tval[T_pt] || tv == &tval[T_km] ||
+ tv == &tval[T_am] || tv == &tval[T_xn]) {
+ static char yes[] = "yes";
+ static char no[] = "no";
+ if (el->el_term.t_val[tv - tval])
+ *(char **)how = yes;
+ else
+ *(char **)how = no;
+ return 0;
+ } else {
+ *(int *)how = el->el_term.t_val[tv - tval];
+ return 0;
+ }
+}
+
/* term_echotc():
* Print the termcap string out with variable substitution
*/
@@ -1441,7 +1556,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
break;
}
if (t->name == NULL) {
- /* XXX: some systems tgetstr needs non const */
+ /* XXX: some systems' tgetstr needs non const */
scap = tgetstr(strchr(*argv, **argv), &area);
}
if (!scap || scap[0] == '\0') {
@@ -1494,7 +1609,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
*argv);
return (-1);
}
- (void) tputs(scap, 1, term__putc);
+ term_tputs(el, scap, 1);
break;
case 1:
argv++;
@@ -1522,7 +1637,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
*argv);
return (-1);
}
- (void) tputs(tgoto(scap, arg_cols, arg_rows), 1, term__putc);
+ term_tputs(el, tgoto(scap, arg_cols, arg_rows), 1);
break;
default:
/* This is wrong, but I will ignore it... */
@@ -1578,8 +1693,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)),
*argv);
return (-1);
}
- (void) tputs(tgoto(scap, arg_cols, arg_rows), arg_rows,
- term__putc);
+ term_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows);
break;
}
return (0);
diff --git a/cmd-line-utils/libedit/tokenizer.c b/cmd-line-utils/libedit/tokenizer.c
index 561b41740f8..5161cdd0a22 100644
--- a/cmd-line-utils/libedit/tokenizer.c
+++ b/cmd-line-utils/libedit/tokenizer.c
@@ -32,7 +32,13 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* tokenize.c: Bourne shell like tokenizer
diff --git a/cmd-line-utils/libedit/tokenizer.h b/cmd-line-utils/libedit/tokenizer.h
deleted file mode 100644
index 7cc7a3346e4..00000000000
--- a/cmd-line-utils/libedit/tokenizer.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $NetBSD: tokenizer.h,v 1.5 2002/03/18 16:01:00 christos Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tokenizer.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * tokenizer.h: Header file for tokenizer routines
- */
-#ifndef _h_tokenizer
-#define _h_tokenizer
-
-typedef struct tokenizer Tokenizer;
-
-Tokenizer *tok_init(const char *);
-void tok_reset(Tokenizer *);
-void tok_end(Tokenizer *);
-int tok_line(Tokenizer *, const char *, int *, const char ***);
-
-#endif /* _h_tokenizer */
diff --git a/cmd-line-utils/libedit/tty.c b/cmd-line-utils/libedit/tty.c
index 6f73fb4f9e7..3706905fc79 100644
--- a/cmd-line-utils/libedit/tty.c
+++ b/cmd-line-utils/libedit/tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $ */
+/* $NetBSD: tty.c,v 1.28 2009/02/06 19:53:23 sketch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,18 +32,25 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* tty.c: tty interface stuff
*/
#include <assert.h>
+#include <errno.h>
#include "tty.h"
#include "el.h"
typedef struct ttymodes_t {
const char *m_name;
- u_int m_value;
+ unsigned int m_value;
int m_type;
} ttymodes_t;
@@ -438,13 +445,12 @@ private const ttymodes_t ttymodes[] = {
-#define tty_getty(el, td) tcgetattr((el)->el_infd, (td))
-#define tty_setty(el, td) tcsetattr((el)->el_infd, TCSADRAIN, (td))
-
#define tty__gettabs(td) ((((td)->c_oflag & TAB3) == TAB3) ? 0 : 1)
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
+private int tty_getty(EditLine *, struct termios *);
+private int tty_setty(EditLine *, int, const struct termios *);
private int tty__getcharindex(int);
private void tty__getchar(struct termios *, unsigned char *);
private void tty__setchar(struct termios *, unsigned char *);
@@ -453,6 +459,29 @@ private int tty_setup(EditLine *);
#define t_qu t_ts
+/* tty_getty():
+ * Wrapper for tcgetattr to handle EINTR
+ */
+private int
+tty_getty(EditLine *el, struct termios *t)
+{
+ int rv;
+ while ((rv = tcgetattr(el->el_infd, t)) == -1 && errno == EINTR)
+ continue;
+ return rv;
+}
+
+/* tty_setty():
+ * Wrapper for tcsetattr to handle EINTR
+ */
+private int
+tty_setty(EditLine *el, int action, const struct termios *t)
+{
+ int rv;
+ while ((rv = tcsetattr(el->el_infd, action, t)) == -1 && errno == EINTR)
+ continue;
+ return rv;
+}
/* tty_setup():
* Get the tty parameters and initialize the editing state
@@ -514,7 +543,7 @@ tty_setup(EditLine *el)
el->el_tty.t_c[TS_IO][rst];
}
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
- if (tty_setty(el, &el->el_tty.t_ex) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile,
"tty_setup: tty_setty: %s\n",
@@ -522,8 +551,11 @@ tty_setup(EditLine *el)
#endif /* DEBUG_TTY */
return (-1);
}
- } else
+ }
+#ifdef notdef
+ else
tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
+#endif
el->el_tty.t_ed.c_iflag &= ~el->el_tty.t_t[ED_IO][MD_INP].t_clrmask;
el->el_tty.t_ed.c_iflag |= el->el_tty.t_t[ED_IO][MD_INP].t_setmask;
@@ -1040,7 +1072,7 @@ tty_rawmode(EditLine *el)
}
}
}
- if (tty_setty(el, &el->el_tty.t_ed) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n",
strerror(errno));
@@ -1065,7 +1097,7 @@ tty_cookedmode(EditLine *el)
if (el->el_flags & EDIT_DISABLED)
return (0);
- if (tty_setty(el, &el->el_tty.t_ex) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile,
"tty_cookedmode: tty_setty: %s\n",
@@ -1101,7 +1133,7 @@ tty_quotemode(EditLine *el)
el->el_tty.t_qu.c_lflag &= ~el->el_tty.t_t[QU_IO][MD_LIN].t_clrmask;
el->el_tty.t_qu.c_lflag |= el->el_tty.t_t[QU_IO][MD_LIN].t_setmask;
- if (tty_setty(el, &el->el_tty.t_qu) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_qu) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n",
strerror(errno));
@@ -1122,7 +1154,7 @@ tty_noquotemode(EditLine *el)
if (el->el_tty.t_mode != QU_IO)
return (0);
- if (tty_setty(el, &el->el_tty.t_ed) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n",
strerror(errno));
@@ -1193,10 +1225,14 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
st = len =
strlen(el->el_tty.t_t[z][m->m_type].t_name);
}
- x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
- ? '+' : '\0';
- x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
- ? '-' : x;
+ if (i != -1) {
+ x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
+ ? '+' : '\0';
+ x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
+ ? '-' : x;
+ } else {
+ x = '\0';
+ }
if (x != '\0' || aflag) {
@@ -1221,7 +1257,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
return (0);
}
while (argv && (s = *argv++)) {
- char *p;
+ const char *p;
switch (*s) {
case '+':
case '-':
@@ -1232,10 +1268,10 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
break;
}
d = s;
- if ((p = strchr(s, '=')) != NULL)
- *p++ = '\0';
+ p = strchr(s, '=');
for (m = ttymodes; m->m_name; m++)
- if (strcmp(m->m_name, d) == 0 &&
+ if ((p ? strncmp(m->m_name, d, (size_t)(p - d)) :
+ strcmp(m->m_name, d)) == 0 &&
(p == NULL || m->m_type == MD_CHAR))
break;
@@ -1246,7 +1282,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
}
if (p) {
int c = ffs((int)m->m_value);
- int v = *p ? parse__escape((const char **const) &p) :
+ int v = *++p ? parse__escape((const char **) &p) :
el->el_tty.t_vdisable;
assert(c-- != 0);
c = tty__getcharindex(c);
@@ -1269,6 +1305,17 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
break;
}
}
+
+ if (el->el_tty.t_mode == z) {
+ if (tty_setty(el, TCSADRAIN, tios) == -1) {
+#ifdef DEBUG_TTY
+ (void) fprintf(el->el_errfile,
+ "tty_stty: tty_setty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+ return (-1);
+ }
+ }
+
return (0);
}
diff --git a/cmd-line-utils/libedit/tty.h b/cmd-line-utils/libedit/tty.h
index cc7c4ad8c66..10e9b98c953 100644
--- a/cmd-line-utils/libedit/tty.h
+++ b/cmd-line-utils/libedit/tty.h
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.h,v 1.10 2003/08/07 16:44:34 agc Exp $ */
+/* $NetBSD: tty.h,v 1.11 2005/06/01 11:37:52 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -450,8 +450,8 @@
typedef struct {
const char *t_name;
- u_int t_setmask;
- u_int t_clrmask;
+ unsigned int t_setmask;
+ unsigned int t_clrmask;
} ttyperm_t[NN_IO][MD_NN];
typedef unsigned char ttychar_t[NN_IO][C_NCC];
diff --git a/cmd-line-utils/libedit/unvis.c b/cmd-line-utils/libedit/unvis.c
deleted file mode 100644
index ffa8ac4251c..00000000000
--- a/cmd-line-utils/libedit/unvis.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/* $NetBSD: unvis.c,v 1.24 2003/08/07 16:42:59 agc Exp $ */
-
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <config.h>
-
-#define __LIBC12_SOURCE__
-
-#include <sys/types.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <vis.h>
-
-#ifdef __weak_alias
-__weak_alias(strunvis,_strunvis)
-__weak_alias(unvis,_unvis)
-#endif
-
-#ifdef __warn_references
-__warn_references(unvis,
- "warning: reference to compatibility unvis(); include <vis.h> for correct reference")
-#endif
-
-#if !HAVE_VIS
-/*
- * decode driven by state machine
- */
-#define S_GROUND 0 /* haven't seen escape char */
-#define S_START 1 /* start decoding special sequence */
-#define S_META 2 /* metachar started (M) */
-#define S_META1 3 /* metachar more, regular char (-) */
-#define S_CTRL 4 /* control char started (^) */
-#define S_OCTAL2 5 /* octal digit 2 */
-#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX1 7 /* hex digit */
-#define S_HEX2 8 /* hex digit 2 */
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
-
-int
-unvis(cp, c, astate, flag)
- char *cp;
- int c;
- int *astate, flag;
-{
- return __unvis13(cp, (int)c, astate, flag);
-}
-
-/*
- * unvis - decode characters previously encoded by vis
- */
-int
-__unvis13(cp, c, astate, flag)
- char *cp;
- int c;
- int *astate, flag;
-{
-
- _DIAGASSERT(cp != NULL);
- _DIAGASSERT(astate != NULL);
-
- if (flag & UNVIS_END) {
- if (*astate == S_OCTAL2 || *astate == S_OCTAL3
- || *astate == S_HEX2) {
- *astate = S_GROUND;
- return (UNVIS_VALID);
- }
- return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
- }
-
- switch (*astate) {
-
- case S_GROUND:
- *cp = 0;
- if (c == '\\') {
- *astate = S_START;
- return (0);
- }
- if ((flag & VIS_HTTPSTYLE) && c == '%') {
- *astate = S_HEX1;
- return (0);
- }
- *cp = c;
- return (UNVIS_VALID);
-
- case S_START:
- switch(c) {
- case '\\':
- *cp = c;
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- *cp = (c - '0');
- *astate = S_OCTAL2;
- return (0);
- case 'M':
- *cp = (char)0200;
- *astate = S_META;
- return (0);
- case '^':
- *astate = S_CTRL;
- return (0);
- case 'n':
- *cp = '\n';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'r':
- *cp = '\r';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'b':
- *cp = '\b';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'a':
- *cp = '\007';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'v':
- *cp = '\v';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 't':
- *cp = '\t';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'f':
- *cp = '\f';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 's':
- *cp = ' ';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'E':
- *cp = '\033';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '\n':
- /*
- * hidden newline
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- case '$':
- /*
- * hidden marker
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- }
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
-
- case S_META:
- if (c == '-')
- *astate = S_META1;
- else if (c == '^')
- *astate = S_CTRL;
- else {
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
- return (0);
-
- case S_META1:
- *astate = S_GROUND;
- *cp |= c;
- return (UNVIS_VALID);
-
- case S_CTRL:
- if (c == '?')
- *cp |= 0177;
- else
- *cp |= c & 037;
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
- */
- *cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
- return (0);
- }
- /*
- * no - done with current sequence, push back passed char
- */
- *astate = S_GROUND;
- return (UNVIS_VALIDPUSH);
-
- case S_OCTAL3: /* third possible octal digit */
- *astate = S_GROUND;
- if (isoctal(c)) {
- *cp = (*cp << 3) + (c - '0');
- return (UNVIS_VALID);
- }
- /*
- * we were done, push back passed char
- */
- return (UNVIS_VALIDPUSH);
- case S_HEX1:
- if (isxdigit(c)) {
- *cp = xtod(c);
- *astate = S_HEX2;
- return (0);
- }
- /*
- * no - done with current sequence, push back passed char
- */
- *astate = S_GROUND;
- return (UNVIS_VALIDPUSH);
- case S_HEX2:
- *astate = S_GROUND;
- if (isxdigit(c)) {
- *cp = xtod(c) | (*cp << 4);
- return (UNVIS_VALID);
- }
- return (UNVIS_VALIDPUSH);
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
- */
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
-}
-
-/*
- * strunvis - decode src into dst
- *
- * Number of chars decoded into dst is returned, -1 on error.
- * Dst is null terminated.
- */
-
-int
-strunvisx(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
-{
- char c;
- char *start = dst;
- int state = 0;
-
- _DIAGASSERT(src != NULL);
- _DIAGASSERT(dst != NULL);
-
- while ((c = *src++) != '\0') {
- again:
- switch (__unvis13(dst, c, &state, flag)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (__unvis13(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strunvis(dst, src)
- char *dst;
- const char *src;
-{
- return strunvisx(dst, src, 0);
-}
-#endif
diff --git a/cmd-line-utils/libedit/vi.c b/cmd-line-utils/libedit/vi.c
index b977ce716c6..00a9f493a9b 100644
--- a/cmd-line-utils/libedit/vi.c
+++ b/cmd-line-utils/libedit/vi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
+/* $NetBSD: vi.c,v 1.28 2009/02/06 13:14:37 sketch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -32,11 +32,17 @@
* SUCH DAMAGE.
*/
-#include <config.h>
+#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
+#else
+#endif
+#endif /* not lint && not SCCSID */
/*
* vi.c: Vi mode commands.
@@ -64,8 +70,10 @@ cv_action(EditLine *el, int c)
el->el_line.lastchar - el->el_line.buffer);
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_vcmd.pos = 0;
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
+ if (!(c & YANK)) {
+ el->el_line.lastchar = el->el_line.buffer;
+ el->el_line.cursor = el->el_line.buffer;
+ }
if (c & INSERT)
el->el_map.current = el->el_map.key;
@@ -82,7 +90,6 @@ cv_action(EditLine *el, int c)
private el_action_t
cv_paste(EditLine *el, int c)
{
- char *ptr;
c_kill_t *k = &el->el_chared.c_kill;
int len = k->last - k->buf;
@@ -96,12 +103,12 @@ cv_paste(EditLine *el, int c)
if (!c && el->el_line.cursor < el->el_line.lastchar)
el->el_line.cursor++;
- ptr = el->el_line.cursor;
c_insert(el, len);
if (el->el_line.cursor + len > el->el_line.lastchar)
return (CC_ERROR);
- (void) memcpy(ptr, k->buf, len +0u);
+ (void) memcpy(el->el_line.cursor, k->buf, len +0u);
+
return (CC_REFRESH);
}
@@ -592,13 +599,12 @@ vi_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_list_or_eof(EditLine *el, int c __attribute__((__unused__)))
+vi_list_or_eof(EditLine *el, int c)
{
if (el->el_line.cursor == el->el_line.lastchar) {
if (el->el_line.cursor == el->el_line.buffer) {
- term_overwrite(el, STReof, 4); /* then do a EOF */
- term__flush();
+ term_writec(el, c); /* then do a EOF */
return (CC_EOF);
} else {
/*
@@ -888,7 +894,7 @@ vi_yank(EditLine *el, int c)
/* vi_comment_out():
* Vi comment out current command
- * [c]
+ * [#]
*/
protected el_action_t
/*ARGSUSED*/
@@ -905,18 +911,19 @@ vi_comment_out(EditLine *el, int c)
/* vi_alias():
* Vi include shell alias
* [@]
- * NB: posix impiles that we should enter insert mode, however
+ * NB: posix implies that we should enter insert mode, however
* this is against historical precedent...
*/
+#if defined(__weak_reference) && !defined(__FreeBSD__)
+extern char *get_alias_text(const char *) __weak_reference(get_alias_text);
+#endif
protected el_action_t
/*ARGSUSED*/
vi_alias(EditLine *el, int c)
{
-#ifdef __weak_extern
+#if defined(__weak_reference) && !defined(__FreeBSD__)
char alias_name[3];
char *alias_text;
- extern char *get_alias_text(const char *);
- __weak_extern(get_alias_text);
if (get_alias_text == 0) {
return CC_ERROR;
@@ -1014,7 +1021,7 @@ vi_histedit(EditLine *el, int c)
return CC_ERROR;
case 0:
close(fd);
- execlp("vi", "vi", tempfile, (char *) NULL);
+ execlp("vi", "vi", tempfile, (char *)NULL);
exit(0);
/*NOTREACHED*/
default:
diff --git a/cmd-line-utils/libedit/vis.c b/cmd-line-utils/libedit/vis.c
deleted file mode 100644
index 127d28733a8..00000000000
--- a/cmd-line-utils/libedit/vis.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* $NetBSD: vis.c,v 1.27 2004/02/26 23:01:15 enami Exp $ */
-
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* AIX requires this to be the first thing in the file. */
-#if defined (_AIX) && !defined (__GNUC__)
- #pragma alloca
-#endif
-
-#include <config.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca(n) __builtin_alloca (n)
-#else
-# ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifndef _AIX
-extern char *alloca ();
-# endif
-# endif
-#endif
-
-#include <sys/types.h>
-
-#include <assert.h>
-#include <vis.h>
-#include <stdlib.h>
-
-#ifdef __weak_alias
-__weak_alias(strsvis,_strsvis)
-__weak_alias(strsvisx,_strsvisx)
-__weak_alias(strvis,_strvis)
-__weak_alias(strvisx,_strvisx)
-__weak_alias(svis,_svis)
-__weak_alias(vis,_vis)
-#endif
-
-#if !HAVE_VIS || !HAVE_SVIS
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-
-#undef BELL
-#define BELL '\a'
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
-#define issafe(c) (c == '\b' || c == BELL || c == '\r')
-#define xtoa(c) "0123456789abcdef"[c]
-
-#define MAXEXTRAS 5
-
-
-#define MAKEEXTRALIST(flag, extra, orig) \
-do { \
- const char *o = orig; \
- char *e; \
- while (*o++) \
- continue; \
- extra = alloca((size_t)((o - orig) + MAXEXTRAS)); \
- for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
- continue; \
- e--; \
- if (flag & VIS_SP) *e++ = ' '; \
- if (flag & VIS_TAB) *e++ = '\t'; \
- if (flag & VIS_NL) *e++ = '\n'; \
- if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
- *e = '\0'; \
-} while (/*CONSTCOND*/0)
-
-
-/*
- * This is HVIS, the macro of vis used to HTTP style (RFC 1808)
- */
-#define HVIS(dst, c, flag, nextc, extra) \
-do \
- if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
- *dst++ = '%'; \
- *dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
- *dst++ = xtoa((unsigned int)c & 0xf); \
- } else { \
- SVIS(dst, c, flag, nextc, extra); \
- } \
-while (/*CONSTCOND*/0)
-
-/*
- * This is SVIS, the central macro of vis.
- * dst: Pointer to the destination buffer
- * c: Character to encode
- * flag: Flag word
- * nextc: The character following 'c'
- * extra: Pointer to the list of extra characters to be
- * backslash-protected.
- */
-#define SVIS(dst, c, flag, nextc, extra) \
-do { \
- int isextra; \
- isextra = strchr(extra, c) != NULL; \
- if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
- ((flag & VIS_SAFE) && issafe(c)))) { \
- *dst++ = c; \
- break; \
- } \
- if (flag & VIS_CSTYLE) { \
- switch (c) { \
- case '\n': \
- *dst++ = '\\'; *dst++ = 'n'; \
- continue; \
- case '\r': \
- *dst++ = '\\'; *dst++ = 'r'; \
- continue; \
- case '\b': \
- *dst++ = '\\'; *dst++ = 'b'; \
- continue; \
- case BELL: \
- *dst++ = '\\'; *dst++ = 'a'; \
- continue; \
- case '\v': \
- *dst++ = '\\'; *dst++ = 'v'; \
- continue; \
- case '\t': \
- *dst++ = '\\'; *dst++ = 't'; \
- continue; \
- case '\f': \
- *dst++ = '\\'; *dst++ = 'f'; \
- continue; \
- case ' ': \
- *dst++ = '\\'; *dst++ = 's'; \
- continue; \
- case '\0': \
- *dst++ = '\\'; *dst++ = '0'; \
- if (isoctal(nextc)) { \
- *dst++ = '0'; \
- *dst++ = '0'; \
- } \
- continue; \
- default: \
- if (isgraph(c)) { \
- *dst++ = '\\'; *dst++ = c; \
- continue; \
- } \
- } \
- } \
- if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
- *dst++ = '\\'; \
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0'; \
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0'; \
- *dst++ = (c & 07) + '0'; \
- } else { \
- if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
- if (c & 0200) { \
- c &= 0177; *dst++ = 'M'; \
- } \
- if (iscntrl(c)) { \
- *dst++ = '^'; \
- if (c == 0177) \
- *dst++ = '?'; \
- else \
- *dst++ = c + '@'; \
- } else { \
- *dst++ = '-'; *dst++ = c; \
- } \
- } \
-} while (/*CONSTCOND*/0)
-
-
-/*
- * svis - visually encode characters, also encoding the characters
- * pointed to by `extra'
- */
-char *
-svis(dst, c, flag, nextc, extra)
- char *dst;
- int c, flag, nextc;
- const char *extra;
-{
- char *nextra;
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
- if (flag & VIS_HTTPSTYLE)
- HVIS(dst, c, flag, nextc, nextra);
- else
- SVIS(dst, c, flag, nextc, nextra);
- *dst = '\0';
- return(dst);
-}
-
-
-/*
- * strsvis, strsvisx - visually encode characters from src into dst
- *
- * Extra is a pointer to a \0-terminated list of characters to
- * be encoded, too. These functions are useful e. g. to
- * encode strings in such a way so that they are not interpreted
- * by a shell.
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NULL,
- * is returned.
- *
- * Strsvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
- */
-int
-strsvis(dst, csrc, flag, extra)
- char *dst;
- const char *csrc;
- int flag;
- const char *extra;
-{
- int c;
- char *start;
- char *nextra;
- const unsigned char *src = (const unsigned char *)csrc;
-
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(src != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
- if (flag & VIS_HTTPSTYLE) {
- for (start = dst; (c = *src++) != '\0'; /* empty */)
- HVIS(dst, c, flag, *src, nextra);
- } else {
- for (start = dst; (c = *src++) != '\0'; /* empty */)
- SVIS(dst, c, flag, *src, nextra);
- }
- *dst = '\0';
- return (dst - start);
-}
-
-
-int
-strsvisx(dst, csrc, len, flag, extra)
- char *dst;
- const char *csrc;
- size_t len;
- int flag;
- const char *extra;
-{
- int c;
- char *start;
- char *nextra;
- const unsigned char *src = (const unsigned char *)csrc;
-
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(src != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
-
- if (flag & VIS_HTTPSTYLE) {
- for (start = dst; len > 0; len--) {
- c = *src++;
- HVIS(dst, c, flag, len ? *src : '\0', nextra);
- }
- } else {
- for (start = dst; len > 0; len--) {
- c = *src++;
- SVIS(dst, c, flag, len ? *src : '\0', nextra);
- }
- }
- *dst = '\0';
- return (dst - start);
-}
-#endif
-
-#if !HAVE_VIS
-/*
- * vis - visually encode characters
- */
-char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, flag, nextc;
-
-{
- char *extra;
-
- _DIAGASSERT(dst != NULL);
-
- MAKEEXTRALIST(flag, extra, "");
- if (flag & VIS_HTTPSTYLE)
- HVIS(dst, c, flag, nextc, extra);
- else
- SVIS(dst, c, flag, nextc, extra);
- *dst = '\0';
- return (dst);
-}
-
-
-/*
- * strvis, strvisx - visually encode characters from src into dst
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NULL,
- * is returned.
- *
- * Strvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
- */
-int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
-{
- char *extra;
-
- MAKEEXTRALIST(flag, extra, "");
- return (strsvis(dst, src, flag, extra));
-}
-
-
-int
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
-{
- char *extra;
-
- MAKEEXTRALIST(flag, extra, "");
- return (strsvisx(dst, src, len, flag, extra));
-}
-#endif
diff --git a/cmd-line-utils/libedit/vis.h b/cmd-line-utils/libedit/vis.h
deleted file mode 100644
index 44f6fc7d785..00000000000
--- a/cmd-line-utils/libedit/vis.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* $NetBSD: vis.h,v 1.15 2005/02/03 04:39:32 perry Exp $ */
-
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)vis.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _VIS_H_
-#define _VIS_H_
-
-#include <config.h>
-
-/*
- * to select alternate encoding format
- */
-#define VIS_OCTAL 0x01 /* use octal \ddd format */
-#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */
-
-/*
- * to alter set of characters encoded (default is to encode all
- * non-graphic except space, tab, and newline).
- */
-#define VIS_SP 0x04 /* also encode space */
-#define VIS_TAB 0x08 /* also encode tab */
-#define VIS_NL 0x10 /* also encode newline */
-#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
-#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
-
-/*
- * other
- */
-#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
-#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
-
-/*
- * unvis return codes
- */
-#define UNVIS_VALID 1 /* character valid */
-#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
-#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
-#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
-#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
-
-/*
- * unvis flags
- */
-#define UNVIS_END 1 /* no more characters */
-
-__BEGIN_DECLS
-char *vis(char *, int, int, int);
-char *svis(char *, int, int, int, const char *);
-int strvis(char *, const char *, int);
-int strsvis(char *, const char *, int, const char *);
-int strvisx(char *, const char *, size_t, int);
-int strsvisx(char *, const char *, size_t, int, const char *);
-int strunvis(char *, const char *);
-int strunvisx(char *, const char *, int);
-#ifdef __LIBC12_SOURCE__
-int unvis(char *, int, int *, int);
-int __unvis13(char *, int, int *, int);
-#else
-int unvis(char *, int, int *, int);
-#endif
-__END_DECLS
-
-#endif /* !_VIS_H_ */
diff --git a/configure.in b/configure.in
index e4336ad0dce..af3d3162b3d 100644
--- a/configure.in
+++ b/configure.in
@@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM
#
# When changing major version number please also check switch statement
# in mysqlbinlog::check_master_version().
-AM_INIT_AUTOMAKE(mysql, 5.1.32-maria-alpha)
+AM_INIT_AUTOMAKE(mysql, 5.1.33-maria-alpha)
AM_CONFIG_HEADER([include/config.h:config.h.in])
PROTOCOL_VERSION=10
@@ -36,6 +36,7 @@ MYSQL_NUMERIC_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|[[a-z]][[a-z0-9]]
MYSQL_BASE_VERSION=`echo $MYSQL_NUMERIC_VERSION | sed -e "s|\.[[^.]]*$||"`
MYSQL_VERSION_ID=`echo $MYSQL_NUMERIC_VERSION | \
awk -F. '{printf "%d%0.2d%0.2d", $1, $2, $3}'`
+MYSQL_COPYRIGHT_YEAR=`date '+%Y'`
# Add previous major version for debian package upgrade path
MYSQL_PREVIOUS_BASE_VERSION=5.0
@@ -70,6 +71,7 @@ AC_SUBST(MYSQL_NO_DASH_VERSION)
AC_SUBST(MYSQL_BASE_VERSION)
AC_SUBST(MYSQL_VERSION_ID)
AC_SUBST(MYSQL_PREVIOUS_BASE_VERSION)
+AC_SUBST(MYSQL_COPYRIGHT_YEAR)
AC_SUBST(PROTOCOL_VERSION)
AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
[mysql client protocol version])
@@ -2048,7 +2050,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
- pthread_key_delete pthread_rwlock_rdlock pthread_setprio pthread_setschedprio \
+ pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
@@ -2071,6 +2073,15 @@ case "$target" in
;;
esac
+case "$mysql_cv_sys_os" in
+ OS400) # i5/OS (OS/400) emits a SIGILL (Function not implemented) when
+ # unsupported priority values are passed to pthread_setschedprio.
+ # Since the only supported value is 1, treat it as inexistent.
+ ;;
+ *) AC_CHECK_FUNCS(pthread_setschedprio)
+ ;;
+esac
+
# Check that isinf() is available in math.h and can be used in both C and C++
# code
AC_MSG_CHECKING(for isinf in <math.h>)
diff --git a/include/my_global.h b/include/my_global.h
index 554b26a1602..93c64647252 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -733,7 +733,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define UNSINT32 /* unsigned int32 */
/* General constants */
-#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
#define FN_LEN 256 /* Max file name len */
#define FN_HEADLEN 253 /* Max length of filepart of file name */
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
diff --git a/include/my_sys.h b/include/my_sys.h
index 07e56f1c91f..44273014066 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -39,8 +39,6 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
#define MY_INIT(name); { my_progname= name; my_init(); }
-#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
-#define NRERRBUFFS (2) /* Buffers for parameters */
#define MY_FILE_ERROR ((size_t) -1)
/* General bitmaps for my_func's */
@@ -212,7 +210,6 @@ extern void my_large_free(uchar * ptr, myf my_flags);
extern int errno; /* declare errno */
#endif
#endif /* #ifndef errno */
-extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */
extern const char *my_progname_short; /* like above but without directory */
diff --git a/include/thr_lock.h b/include/thr_lock.h
index 261f596f911..c523207638f 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -160,7 +160,8 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
void thr_print_locks(void); /* For debugging */
-my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);
+my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
+ enum thr_lock_type new_lock_type);
void thr_downgrade_write_lock(THR_LOCK_DATA *data,
enum thr_lock_type new_lock_type);
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index 9e38a32cd00..45df98d3c04 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -71,17 +71,17 @@ SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README \
valgrind.supp \
$(test_SCRIPTS) \
- $(nobase_test_DATA)
+ $(nobase_test_DATA)
# List of directories containing test + result files and the
# related test data files that should be copied
-TEST_DIRS = t r include std_data std_data/parts \
+TEST_DIRS = t r include std_data std_data/parts collections \
std_data/ndb_backup50 std_data/ndb_backup51 \
std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \
std_data/funcs_1 \
extra/binlog_tests/ extra/rpl_tests \
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
- suite/bugs/data suite/bugs/t suite/bugs/r \
+ suite/bugs suite/bugs/data suite/bugs/t suite/bugs/r \
suite/federated \
suite/funcs_1 suite/funcs_1/bitdata \
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
@@ -90,7 +90,7 @@ TEST_DIRS = t r include std_data std_data/parts \
suite/funcs_2 suite/funcs_2/charset suite/funcs_2/data \
suite/funcs_2/include suite/funcs_2/lib suite/funcs_2/r \
suite/funcs_2/t \
- suite/jp suite/jp/t suite/jp/r suite/jp/std_data \
+ suite/jp suite/jp/t suite/jp/r suite/jp/std_data suite/jp/include \
suite/manual/t suite/manual/r \
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \
diff --git a/mysql-test/collections/README b/mysql-test/collections/README
new file mode 100644
index 00000000000..9af84646a40
--- /dev/null
+++ b/mysql-test/collections/README
@@ -0,0 +1,30 @@
+This directory contains collections of test runs that we run during our
+integration and release testing. Each file contains zero or more lines,
+with one invocation of mysql-test-run.pl on each. These invocations are
+written so that, with the assumption that perl is in your search path,
+any collection can run as a shell script or a batch file, with the parent
+mysql-test directory being the current working directory.
+
+During integration testing, we choose the collection to run by following
+these steps:
+
+1) We choose the extension to look for, based on these rules:
+ - If we're running a per-push test, we choose ".push" as the extension.
+ - If we're running a daily test, we choose ".daily" as the extension.
+ - If we're running a weekly test, we choose ".weekly" as the extension.
+
+2) If there is a collection that has the same name as the branch we're
+ testing plus the extension as determined in step 1, we choose that
+ collection.
+
+3) If the branch is unknown or we have removed all characters from it
+ and still not found a matching collection, we choose the name "default"
+ plus the extension determined in step 1. If there is no such file,
+ we give up and don't test anything at all.
+
+4) If we haven't found a collection yet, we remove the last character from
+ the branch name and go back to step 2.
+
+5) The commands from the collection are run line by line via execv() or
+ similar system calls. They are not run as a shell script. Shell
+ expansions are not guaranteed to work and most likely won't.
diff --git a/mysql-test/collections/README.experimental b/mysql-test/collections/README.experimental
new file mode 100644
index 00000000000..9eee2394423
--- /dev/null
+++ b/mysql-test/collections/README.experimental
@@ -0,0 +1,25 @@
+The .experimental files in this directory contain names of test cases that
+are still in development and whose failures should be considered expected,
+instead of regressions.
+
+These files are to be used with the --experimental option of
+mysql-test-run.pl. Please look at its help screen for usage information.
+
+The syntax is as follows:
+
+1) One line per test case.
+
+2) Empty lines and lines starting with a hash (#) are ignored.
+
+3) If any other line contains a blank followed by a hash (#), the hash
+ and any subsequent characters are ignored.
+
+4) The full test case name including the suite and execution mode
+ must be specified, for example:
+ main.alias 'row' # bug#00000
+
+5) As an exception to item 4, the last character of the test case
+ specification may be an asterisk (*). In that case, all test cases that
+ start with the same characters up to the last letter before the asterisk
+ are considered experimental:
+ main.a* # get rid of main.alias, main.alibaba and main.agliolio
diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily
new file mode 100644
index 00000000000..194cc2aad59
--- /dev/null
+++ b/mysql-test/collections/default.daily
@@ -0,0 +1 @@
+perl mysql-test-run.pl --timer --force --comment=rpl_ndb_row --suite=rpl_ndb,ndb --mysqld=--binlog-format=row --experimental=collections/default.experimental
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
new file mode 100644
index 00000000000..103069f79cf
--- /dev/null
+++ b/mysql-test/collections/default.experimental
@@ -0,0 +1 @@
+funcs_1.charset_collation_1 # depends on compile-time decisions
diff --git a/mysql-test/collections/default.push b/mysql-test/collections/default.push
new file mode 100644
index 00000000000..0879b6fde2c
--- /dev/null
+++ b/mysql-test/collections/default.push
@@ -0,0 +1,5 @@
+perl mysql-test-run.pl --timer --force --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=embedded --embedded --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental
diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/collections/default.weekly
diff --git a/mysql-test/extra/binlog_tests/binlog_truncate.test b/mysql-test/extra/binlog_tests/binlog_truncate.test
new file mode 100644
index 00000000000..dce33b3cef0
--- /dev/null
+++ b/mysql-test/extra/binlog_tests/binlog_truncate.test
@@ -0,0 +1,27 @@
+# BUG #36763: TRUNCATE TABLE fails to replicate when stmt-based
+# binlogging is not supported.
+
+# This should always be logged as a statement, even when executed as a
+# row-by-row deletion.
+
+# $before_truncate A statement to execute (just) before issuing the
+# TRUNCATE TABLE
+
+
+eval CREATE TABLE t1 (a INT) ENGINE=$engine;
+eval CREATE TABLE t2 (a INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1),(2),(3);
+let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
+if (`select length('$before_truncate') > 0`) {
+ eval $before_truncate;
+}
+--echo **** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+
+if (`select length('$before_truncate') > 0`) {
+ eval $before_truncate;
+}
+TRUNCATE TABLE t2;
+source include/show_binlog_events.inc;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
index df0d6cf5045..c426ac1fae8 100644
--- a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
+++ b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
@@ -419,7 +419,7 @@ connection master;
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
- update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+ update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
--echo
--echo ** Delete from Master **
diff --git a/mysql-test/extra/rpl_tests/rpl_truncate.test b/mysql-test/extra/rpl_tests/rpl_truncate.test
index bca53336514..7036ab126e1 100644
--- a/mysql-test/extra/rpl_tests/rpl_truncate.test
+++ b/mysql-test/extra/rpl_tests/rpl_truncate.test
@@ -9,27 +9,8 @@
--source include/master-slave.inc
-let $format = STATEMENT;
-let $stmt = TRUNCATE TABLE;
+let $trunc_stmt = TRUNCATE TABLE;
--source extra/rpl_tests/rpl_truncate_helper.test
-let $format = MIXED;
-let $stmt = TRUNCATE TABLE;
+let $trunc_stmt = DELETE FROM;
--source extra/rpl_tests/rpl_truncate_helper.test
-
-let $format = ROW;
-let $stmt = TRUNCATE TABLE;
---source extra/rpl_tests/rpl_truncate_helper.test
-
-let $format = STATEMENT;
-let $stmt = DELETE FROM;
---source extra/rpl_tests/rpl_truncate_helper.test
-
-let $format = MIXED;
-let $stmt = DELETE FROM;
---source extra/rpl_tests/rpl_truncate_helper.test
-
-let $format = ROW;
-let $stmt = DELETE FROM;
---source extra/rpl_tests/rpl_truncate_helper.test
-
diff --git a/mysql-test/extra/rpl_tests/rpl_truncate_helper.test b/mysql-test/extra/rpl_tests/rpl_truncate_helper.test
index eb0729e4921..cd1ce93177a 100644
--- a/mysql-test/extra/rpl_tests/rpl_truncate_helper.test
+++ b/mysql-test/extra/rpl_tests/rpl_truncate_helper.test
@@ -1,47 +1,35 @@
-connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
-connection master;
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-connection slave;
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-RESET SLAVE;
-START SLAVE;
+source include/reset_master_and_slave.inc;
--echo **** On Master ****
connection master;
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-
-eval SET SESSION BINLOG_FORMAT=$format;
-eval SET GLOBAL BINLOG_FORMAT=$format;
-
eval CREATE TABLE t1 (a INT, b LONG) ENGINE=$engine;
INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
---echo **** On Slave ****
sync_slave_with_master;
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
--echo **** On Master ****
connection master;
-eval $stmt t1;
-SELECT * FROM t1;
---echo **** On Slave ****
+eval $trunc_stmt t1;
sync_slave_with_master;
-# Should be empty
-SELECT * FROM t1;
+
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+--echo ==== Test using a table with delete triggers ====
--echo **** On Master ****
connection master;
-DROP TABLE t1;
-let $SERVER_VERSION=`select version()`;
-source include/show_binlog_events.inc;
+SET @count := 1;
+eval CREATE TABLE t2 (a INT, b LONG) ENGINE=$engine;
+CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
+sync_slave_with_master;
+--echo **** On Master ****
+connection master;
+eval $trunc_stmt t1;
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t2;
+let $diff_table_2=slave:test.t2;
+source include/diff_tables.inc;
connection master;
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
+DROP TABLE t1,t2;
+sync_slave_with_master;
diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test
index 2144957f742..5295dd51a85 100644
--- a/mysql-test/include/check-warnings.test
+++ b/mysql-test/include/check-warnings.test
@@ -26,7 +26,7 @@ create temporary table error_log (
) engine=myisam;
# Get the name of servers error log
-let $log_error= query_get_value(show variables like 'log_error', Value, 1);
+let $log_error= $MTR_LOG_ERROR;
let $log_warning= $log_error.warnings;
# Try tload the warnings into a temporary table,
diff --git a/mysql-test/include/count_sessions.inc b/mysql-test/include/count_sessions.inc
new file mode 100644
index 00000000000..4728e39ce74
--- /dev/null
+++ b/mysql-test/include/count_sessions.inc
@@ -0,0 +1,21 @@
+# include/count_sessions.inc
+#
+# SUMMARY
+#
+# Stores the number of current sessions in $count_sessions.
+#
+#
+# USAGE
+#
+# Please look into include/wait_until_count_sessions.inc
+# for examples of typical usage.
+#
+#
+# EXAMPLE
+# backup.test, grant3.test
+#
+#
+# Created: 2009-01-14 mleich
+#
+
+let $count_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc
index 4cde18b97d1..f66f888261d 100644
--- a/mysql-test/include/ps_modify.inc
+++ b/mysql-test/include/ps_modify.inc
@@ -108,7 +108,6 @@ execute stmt1 using @arg00, @arg01;
select a,b from t1 where a=@arg00;
set @arg00=NULL;
set @arg01=2;
---error 1048
execute stmt1 using @arg00, @arg01;
select a,b from t1 order by a;
set @arg00=0;
diff --git a/mysql-test/include/wait_until_count_sessions.inc b/mysql-test/include/wait_until_count_sessions.inc
new file mode 100644
index 00000000000..36fa9accafe
--- /dev/null
+++ b/mysql-test/include/wait_until_count_sessions.inc
@@ -0,0 +1,112 @@
+# include/wait_until_count_sessions.inc
+#
+# SUMMARY
+#
+# Waits until the passed number ($count_sessions) of concurrent sessions was
+# observed via
+# SHOW STATUS LIKE 'Threads_connected'
+# or the operation times out.
+# Note: Starting with 5.1 we could also use
+# SELECT COUNT(*) FROM information_schema.processlist
+# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
+# runs in all versions 5.0+
+#
+#
+# USAGE
+#
+# let $count_sessions= 3;
+# --source include/wait_until_count_sessions.inc
+#
+# OR typical example of a test which uses more than one session
+# Such a test could harm successing tests if there is no server shutdown
+# and start between.cw
+#
+# If the testing box is slow than the disconnect of sessions belonging to
+# the current test might happen when the successing test gets executed.
+# This means the successing test might see activities like unexpected
+# rows within the general log or the PROCESSLIST.
+# Example from bug http://bugs.mysql.com/bug.php?id=40377
+# --- bzr_mysql-6.0-rpl/.../r/log_state.result
+# +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
+# @@ -25,6 +25,7 @@
+# event_time user_host ... command_type argument
+# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
+# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
+# +TIMESTAMP USER_HOST ... Quit
+# ....
+#
+# What to do?
+# -----------
+# <start of test>
+# # Determine initial number of connections (set $count_sessions)
+# --source include/count_sessions.inc
+# ...
+# connect (con1,.....)
+# ...
+# connection default;
+# ...
+# disconnect con1;
+# ...
+# # Wait until we have reached the initial number of connections
+# # or more than the sleep time above (10 seconds) has passed.
+# # $count_sessions
+# --source include/wait_until_count_sessions.inc
+# <end of test>
+#
+# Important note about tests with unfortunate (= not cooperative
+# to successing tests) architecture:
+# connection con1;
+# send SELECT ..., sleep(10)
+# connection default;
+# ...
+# disconnect con1;
+# <end of test>
+# should be fixed by
+# connection con1;
+# send SELECT ..., sleep(10)
+# connection default;
+# ...
+# connect con1;
+# reap;
+# connection default;
+# disconnect con1;
+# <end of test>
+# and not only by appending include/wait_until_count_sessions.inc etc.
+#
+#
+# EXAMPLE
+#
+# backup.test, grant3.test
+#
+#
+# Created: 2009-01-14 mleich
+#
+
+let $wait_counter= 50;
+if ($wait_timeout)
+{
+ let $wait_counter= `SELECT $wait_timeout * 10`;
+}
+# Reset $wait_timeout so that its value won't be used on subsequent
+# calls, and default will be used instead.
+let $wait_timeout= 0;
+while ($wait_counter)
+{
+ let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
+ let $success= `SELECT $current_sessions = $count_sessions`;
+ if ($success)
+ {
+ let $wait_counter= 0;
+ }
+ if (!$success)
+ {
+ real_sleep 0.1;
+ dec $wait_counter;
+ }
+}
+if (!$success)
+{
+ --echo # Timeout in wait_until_count_sessions.inc
+ --echo # Number of sessions expected: $count_sessions found: $current_sessions
+}
+
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm
index 567a05ac7a1..852f706c858 100644
--- a/mysql-test/lib/My/ConfigFactory.pm
+++ b/mysql-test/lib/My/ConfigFactory.pm
@@ -116,8 +116,8 @@ sub fix_tmpdir {
sub fix_log_error {
my ($self, $config, $group_name, $group)= @_;
- my $dir= dirname($group->value('datadir'));
- return "$dir/mysqld.err";
+ my $dir= $self->{ARGS}->{vardir};
+ return "$dir/log/$group_name.err";
}
sub fix_log {
@@ -203,7 +203,7 @@ my @mysqld_rules=
{ '#host' => \&fix_host },
{ 'port' => \&fix_port },
{ 'socket' => \&fix_socket },
- { 'log-error' => \&fix_log_error },
+ { '#log-error' => \&fix_log_error },
{ 'log' => \&fix_log },
{ 'log-slow-queries' => \&fix_log_slow_queries },
{ '#user' => sub { return shift->{ARGS}->{user} || ""; } },
@@ -389,7 +389,7 @@ sub post_check_embedded_group {
my @no_copy =
(
- 'log-error', # Embedded server writes stderr to mysqltest's log file
+ '#log-error', # Embedded server writes stderr to mysqltest's log file
'slave-net-timeout', # Embedded server are not build with replication
);
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index 3dd5c552b10..69ffdfbb4ce 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -113,8 +113,8 @@ sub check_socket_path_length {
# Create a tempfile name with same length as "path"
my $tmpdir = tempdir( CLEANUP => 0);
- my $len = length($path) - length($tmpdir);
- my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1);
+ my $len = length($path) - length($tmpdir) - 1;
+ my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1);
my $sock;
eval {
$sock= new IO::Socket::UNIX
@@ -126,17 +126,15 @@ sub check_socket_path_length {
die "Could not create UNIX domain socket: $!"
unless defined $sock;
- die "UNIX domain socket patch was truncated"
+ die "UNIX domain socket path was truncated"
unless ($testfile eq $sock->hostpath());
$truncated= 0; # Yes, it worked!
};
- #print "check_socket_path_length, failed: ", $@, '\n' if ($@);
$sock= undef; # Close socket
- unlink($testfile); # Remove the physical file
- rmdir($tmpdir); # Remove the tempdir
+ rmtree($tmpdir); # Remove the tempdir and any socket file created
return $truncated;
}
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 0e3aa968052..5ef3286ad8e 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -117,6 +117,7 @@ sub new {
my $output = delete($opts{'output'});
my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'});
+ my $nocore = delete($opts{'nocore'});
my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'});
my $user_data= delete($opts{'user_data'});
@@ -137,6 +138,7 @@ sub new {
push(@safe_args, $safe_script) if defined $safe_script;
push(@safe_args, "--verbose") if $verbose > 0;
+ push(@safe_args, "--nocore") if $nocore;
# Point the safe_process at the right parent if running on cygwin
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc
index 7932f3fd2d6..6ad45a3226e 100644
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc
@@ -45,6 +45,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/resource.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
@@ -149,7 +150,8 @@ int main(int argc, char* const argv[] )
char* const* child_argv= 0;
pid_t own_pid= getpid();
pid_t parent_pid= getppid();
-
+ bool nocore = false;
+
/* Install signal handlers */
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
@@ -181,6 +183,9 @@ int main(int argc, char* const argv[] )
start++; /* Step past = */
if ((parent_pid= atoi(start)) == 0)
die("Invalid value '%s' passed to --parent-id", start);
+ } else if ( strcmp(arg, "--nocore") == 0 )
+ {
+ nocore = true; // Don't allow the process to dump core
}
else
die("Unknown option: %s", arg);
@@ -218,6 +223,15 @@ int main(int argc, char* const argv[] )
// it and any childs(that hasn't changed group themself)
setpgid(0, 0);
+ if (nocore)
+ {
+ struct rlimit corelim = { 0, 0 };
+ if (setrlimit (RLIMIT_CORE, &corelim) < 0)
+ {
+ message("setrlimit failed, errno=%d", errno);
+ }
+ }
+
// Signal that child is ready
buf= 37;
write(pfd[1], &buf, 1);
diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
index 8aa603a8793..640254875c9 100755
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
@@ -237,12 +237,19 @@ int main(int argc, const char** argv )
/*
Create the process suspended to make sure it's assigned to the
Job before it creates any process of it's own
+
+ Allow the new process to break away from any job that this
+ process is part of so that it can be assigned to the new JobObject
+ we just created. This is safe since the new JobObject is created with
+ the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag, making sure it will be
+ terminated when the last handle to it is closed(which is owned by
+ this process).
*/
if (CreateProcess(NULL, (LPSTR)child_args,
NULL,
NULL,
TRUE, /* inherit handles */
- CREATE_SUSPENDED,
+ CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB,
NULL,
NULL,
&si,
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index f385379cfff..57f3c6bbd75 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -69,6 +69,8 @@ sub _mtr_report_test_name ($) {
print _name(), _timestamp();
printf "%-40s ", $tname;
+
+ return $tname;
}
@@ -105,20 +107,48 @@ sub mtr_report_test_passed ($) {
sub mtr_report_test ($) {
my ($tinfo)= @_;
- _mtr_report_test_name($tinfo);
+ my $test_name = _mtr_report_test_name($tinfo);
my $comment= $tinfo->{'comment'};
my $logfile= $tinfo->{'logfile'};
my $warnings= $tinfo->{'warnings'};
my $result= $tinfo->{'result'};
+ my $retry= $tinfo->{'retries'} ? "retry-" : "";
if ($result eq 'MTR_RES_FAILED'){
my $timest = format_time();
+ my $fail = "fail";
+
+ if ( $::opt_experimental )
+ {
+ # Find out if this test case is an experimental one, so we can treat
+ # the failure as an expected failure instead of a regression.
+ for my $exp ( @$::experimental_test_cases ) {
+ if ( $exp ne $test_name ) {
+ # if the expression is not the name of this test case, but has
+ # an asterisk at the end, determine if the characters up to
+ # but excluding the asterisk are the same
+ if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) {
+ $exp = substr($exp, 0, length($exp) - 1);
+ if ( substr($test_name, 0, length($exp)) ne $exp ) {
+ # no match, try next entry
+ next;
+ }
+ # if yes, fall through to set the exp-fail status
+ } else {
+ # no match, try next entry
+ next;
+ }
+ }
+ $fail = "exp-fail";
+ last;
+ }
+ }
if ( $warnings )
{
- mtr_report("[ fail ] Found warnings/errors in server log file!");
+ mtr_report("[ $retry$fail ] Found warnings/errors in server log file!");
mtr_report(" Test ended at $timest");
mtr_report($warnings);
return;
@@ -126,14 +156,14 @@ sub mtr_report_test ($) {
my $timeout= $tinfo->{'timeout'};
if ( $timeout )
{
- mtr_report("[ fail ] timeout after $timeout seconds");
+ mtr_report("[ $retry$fail ] timeout after $timeout seconds");
mtr_report(" Test ended at $timest");
mtr_report("\n$tinfo->{'comment'}");
return;
}
else
{
- mtr_report("[ fail ]\n Test ended at $timest");
+ mtr_report("[ $retry$fail ]\n Test ended at $timest");
}
if ( $logfile )
@@ -176,7 +206,7 @@ sub mtr_report_test ($) {
{
my $timer_str= $tinfo->{timer} || "";
$tot_real_time += ($timer_str/1000);
- mtr_report("[ pass ] ", sprintf("%5s", $timer_str));
+ mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str));
# Show any problems check-testcase found
if ( defined $tinfo->{'check'} )
diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm
index b4093ab1dce..294a5d7b4d6 100644
--- a/mysql-test/lib/mtr_unique.pm
+++ b/mysql-test/lib/mtr_unique.pm
@@ -28,7 +28,17 @@ sub msg {
# print "### unique($$) - ", join(" ", @_), "\n";
}
-my $file= "/tmp/mysql-test-ports";
+my $file;
+
+if(!IS_WINDOWS)
+{
+ $file= "/tmp/mysql-test-ports";
+}
+else
+{
+ $file= $ENV{'TEMP'}."/mysql-test-ports";
+}
+
my %mtr_unique_ids;
@@ -178,6 +188,8 @@ sub mtr_release_unique_id($) {
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
close SEM;
+
+ delete $mtr_unique_ids{$$};
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index f242df9991e..64bf6f71390 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -45,8 +45,8 @@ BEGIN {
print "=======================================================\n";
print " WARNING: Using mysql-test-run.pl version 1! \n";
print "=======================================================\n";
- require "lib/v1/mysql-test-run.pl";
- exit(1);
+ # Should use exec() here on *nix but this appears not to work on Windows
+ exit(system($^X, "lib/v1/mysql-test-run.pl", @ARGV) >> 8);
}
elsif ( $version == 2 )
{
@@ -107,6 +107,17 @@ our $default_vardir;
our $opt_vardir; # Path to use for var/ dir
my $path_vardir_trace; # unix formatted opt_vardir for trace files
my $opt_tmpdir; # Path to use for tmp/ dir
+my $opt_tmpdir_pid;
+
+END {
+ if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
+ {
+ # Remove the tempdir this process has created
+ mtr_verbose("Removing tmpdir '$opt_tmpdir");
+ rmtree($opt_tmpdir);
+ }
+}
+
my $path_config_file; # The generated config file, var/my.cnf
# Visual Studio produces executables in different sub-directories based on the
@@ -137,7 +148,7 @@ our @opt_extra_mysqltest_opt;
my $opt_compress;
my $opt_ssl;
-my $opt_skip_ssl = 1; # Until bug#42366 has been fixed
+my $opt_skip_ssl;
my $opt_ssl_supported;
my $opt_ps_protocol;
my $opt_sp_protocol;
@@ -174,12 +185,18 @@ our $opt_client_debugger;
my $config; # The currently running config
my $current_config_name; # The currently running config file template
+our $opt_experimental;
+our $experimental_test_cases;
+
my $baseport;
my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
+my $build_thread= 0;
my $opt_record;
my $opt_report_features;
+my $opt_skip_core;
+
our $opt_check_testcases= 1;
my $opt_mark_progress;
@@ -676,14 +693,9 @@ sub run_worker ($) {
report_option('name',"worker[$thread_num]");
# --------------------------------------------------------------------------
- # Use auto build thread in all but first worker
+ # Set different ports per thread
# --------------------------------------------------------------------------
- set_build_thread_ports($thread_num > 1 ? 'auto' : $opt_build_thread);
-
- if (check_ports_free()){
- # Some port was not free(which one has already been printed)
- mtr_error("Some port(s) was not free")
- }
+ set_build_thread_ports($thread_num);
# --------------------------------------------------------------------------
# Turn off verbosity in workers, unless explicitly specified
@@ -803,7 +815,7 @@ sub command_line_setup {
'big-test' => \$opt_big_test,
'combination=s' => \@opt_combinations,
'skip-combinations' => \&collect_option,
-
+ 'experimental=s' => \$opt_experimental,
'skip-im' => \&ignore_option,
# Specify ports
@@ -951,12 +963,12 @@ sub command_line_setup {
}
# Look for language files and charsetsdir, use same share
- my $path_share= mtr_path_exists("$basedir/share/mysql",
- "$basedir/sql/share",
- "$basedir/share");
+ $path_language= mtr_path_exists("$basedir/share/mysql/english",
+ "$basedir/sql/share/english",
+ "$basedir/share/english");
+
-
- $path_language= mtr_path_exists("$path_share/english");
+ my $path_share= dirname($path_language);
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
if (using_extern())
@@ -978,6 +990,33 @@ sub command_line_setup {
mtr_print_thick_line('#');
}
+ if ( $opt_experimental )
+ {
+ # read the list of experimental test cases from the file specified on
+ # the command line
+ open(FILE, "<", $opt_experimental) or mtr_error("Can't read experimental file: $opt_experimental");
+ mtr_report("Using experimental file: $opt_experimental");
+ $experimental_test_cases = [];
+ while(<FILE>) {
+ chomp;
+ # remove comments (# foo) at the beginning of the line, or after a
+ # blank at the end of the line
+ s/( +|^)#.*$//;
+ # remove whitespace
+ s/^ +//;
+ s/ +$//;
+ # if nothing left, don't need to remember this line
+ if ( $_ eq "" ) {
+ next;
+ }
+ # remember what is left as the name of another test case that should be
+ # treated as experimental
+ print " - $_\n";
+ push @$experimental_test_cases, $_;
+ }
+ close FILE;
+ }
+
foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
@@ -1085,8 +1124,11 @@ sub command_line_setup {
" creating a shorter one...");
# Create temporary directory in standard location for temporary files
- $opt_tmpdir= tempdir( TMPDIR => 1, CLEANUP => 1 );
+ $opt_tmpdir= tempdir( TMPDIR => 1, CLEANUP => 0 );
mtr_report(" - using tmpdir: '$opt_tmpdir'\n");
+
+ # Remember pid that created dir so it's removed by correct process
+ $opt_tmpdir_pid= $$;
}
}
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
@@ -1099,6 +1141,14 @@ sub command_line_setup {
}
# --------------------------------------------------------------------------
+ # Check parallel value
+ # --------------------------------------------------------------------------
+ if ($opt_parallel < 1)
+ {
+ mtr_error("0 or negative parallel value makes no sense, use positive number");
+ }
+
+ # --------------------------------------------------------------------------
# Record flag
# --------------------------------------------------------------------------
if ( $opt_record and ! @opt_cases )
@@ -1287,18 +1337,32 @@ sub command_line_setup {
# But a fairly safe range seems to be 5001 - 32767
#
sub set_build_thread_ports($) {
- my $build_thread= shift || 0;
+ my $thread= shift || 0;
- if ( lc($build_thread) eq 'auto' ) {
- #mtr_report("Requesting build thread... ");
- $build_thread= mtr_get_unique_id(250, 299);
- if ( !defined $build_thread ) {
- mtr_error("Could not get a unique build thread id");
+ if ( lc($opt_build_thread) eq 'auto' ) {
+ my $found_free = 0;
+ $build_thread = 250; # Start attempts from here
+ while (! $found_free)
+ {
+ $build_thread= mtr_get_unique_id($build_thread, 299);
+ if ( !defined $build_thread ) {
+ mtr_error("Could not get a unique build thread id");
+ }
+ $found_free= check_ports_free($build_thread);
+ # If not free, release and try from next number
+ mtr_release_unique_id($build_thread++) unless $found_free;
}
- #mtr_report(" - got $build_thread");
+ }
+ else
+ {
+ $build_thread = $opt_build_thread + $thread - 1;
}
$ENV{MTR_BUILD_THREAD}= $build_thread;
- $opt_build_thread= $build_thread;
+
+ if (! check_ports_free($build_thread)) {
+ # Some port was not free(which one has already been printed)
+ mtr_error("Some port(s) was not free")
+ }
# Calculate baseport
$baseport= $build_thread * 10 + 10000;
@@ -1547,8 +1611,8 @@ sub mysql_fix_arguments () {
mtr_init_args(\$args);
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
- mtr_add_arg($args, "--basedir=", $basedir);
- mtr_add_arg($args, "--bindir=", $path_client_bindir);
+ mtr_add_arg($args, "--basedir=%s", $basedir);
+ mtr_add_arg($args, "--bindir=%s", $path_client_bindir);
mtr_add_arg($args, "--verbose");
return mtr_args2str($exe, @$args);
}
@@ -2483,22 +2547,18 @@ sub kill_leftovers ($) {
# Check that all the ports that are going to
# be used are free
#
-sub check_ports_free
+sub check_ports_free ($)
{
- my @ports_to_check;
- for ($baseport..$baseport+9){
- push(@ports_to_check, $_);
- }
- #mtr_report("Checking ports...");
- # print "@ports_to_check\n";
- foreach my $port (@ports_to_check){
- if (mtr_ping_port($port)){
- mtr_report(" - 'localhost:$port' was not free");
- return 1; # One port was not free
+ my $bthread= shift;
+ my $portbase = $bthread * 10 + 10000;
+ for ($portbase..$portbase+9){
+ if (mtr_ping_port($_)){
+ mtr_report(" - 'localhost:$_' was not free");
+ return 0; # One port was not free
}
}
- return 0; # All ports free
+ return 1; # All ports free
}
@@ -3527,7 +3587,10 @@ sub start_check_warnings ($$) {
my $name= "warnings-".$mysqld->name();
- extract_warning_lines($mysqld->value('log-error'));
+ my $log_error= $mysqld->value('#log-error');
+ # To be communicated to the test
+ $ENV{MTR_LOG_ERROR}= $log_error;
+ extract_warning_lines($log_error);
my $args;
mtr_init_args(\$args);
@@ -4004,6 +4067,7 @@ sub mysqld_arguments ($$$) {
mtr_add_arg($args, "%s", $arg);
}
}
+ $opt_skip_core = $found_skip_core;
if ( !$found_skip_core )
{
mtr_add_arg($args, "%s", "--core-file");
@@ -4048,6 +4112,12 @@ sub mysqld_start ($$) {
$path_vardir_trace, $mysqld->name());
}
+ if (IS_WINDOWS)
+ {
+ # Trick the server to send output to stderr, with --console
+ mtr_add_arg($args, "--console");
+ }
+
if ( $opt_gdb || $opt_manual_gdb )
{
gdb_arguments(\$args, \$exe, $mysqld->name());
@@ -4080,7 +4150,7 @@ sub mysqld_start ($$) {
# Remove the old pidfile if any
unlink($mysqld->value('pid-file'));
- my $output= $mysqld->value('log-error');
+ my $output= $mysqld->value('#log-error');
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
@@ -4110,6 +4180,7 @@ sub mysqld_start ($$) {
error => $output,
append => 1,
verbose => $opt_verbose,
+ nocore => $opt_skip_core,
host => undef,
shutdown => sub { mysqld_stop($mysqld) },
);
@@ -4162,12 +4233,6 @@ sub server_need_restart {
return 0;
}
- if ( $opt_embedded_server )
- {
- mtr_verbose_restart($server, "no start or restart for embedded server");
- return 0;
- }
-
if ( $tinfo->{'force_restart'} ) {
mtr_verbose_restart($server, "forced in .opt file");
return 1;
@@ -4397,7 +4462,7 @@ sub start_servers($) {
# Already started
# Write start of testcase to log file
- mark_log($mysqld->value('log-error'), $tinfo);
+ mark_log($mysqld->value('#log-error'), $tinfo);
next;
}
@@ -4456,7 +4521,7 @@ sub start_servers($) {
mkpath($tmpdir) unless -d $tmpdir;
# Write start of testcase to log file
- mark_log($mysqld->value('log-error'), $tinfo);
+ mark_log($mysqld->value('#log-error'), $tinfo);
# Run <tname>-master.sh
if ($mysqld->option('#!run-master-sh') and
@@ -4507,7 +4572,7 @@ sub start_servers($) {
$tinfo->{comment}=
"Failed to start ".$mysqld->name();
- my $logfile= $mysqld->value('log-error');
+ my $logfile= $mysqld->value('#log-error');
if ( defined $logfile and -f $logfile )
{
$tinfo->{logfile}= mtr_fromfile($logfile);
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index a39b424827c..21e6347cb47 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -231,7 +231,8 @@ a b
204 7
delete from t1 where a=0;
update t1 set a=NULL where b=6;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
update t1 set a=300 where b=7;
SET SQL_MODE='';
insert into t1(a,b)values(NULL,8);
@@ -246,7 +247,7 @@ a b
1 1
200 2
201 4
-203 6
+0 6
300 7
301 8
400 9
@@ -262,7 +263,6 @@ a b
1 1
200 2
201 4
-203 6
300 7
301 8
400 9
@@ -273,20 +273,20 @@ a b
405 14
delete from t1 where a=0;
update t1 set a=NULL where b=13;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
update t1 set a=500 where b=14;
select * from t1 order by b;
a b
1 1
200 2
201 4
-203 6
300 7
301 8
400 9
401 10
402 11
-404 13
+0 13
500 14
drop table t1;
create table t1 (a bigint);
diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result
index a31a881051f..de80dba47c1 100644
--- a/mysql-test/r/commit_1innodb.result
+++ b/mysql-test/r/commit_1innodb.result
@@ -687,8 +687,8 @@ SUCCESS
truncate table t2;
call p_verify_status_increment(4, 0, 4, 0);
-SUCCESS
-
+ERROR
+Expected commit increment: 4 actual: 2
commit;
# There is nothing left to commit
call p_verify_status_increment(0, 0, 0, 0);
@@ -854,8 +854,8 @@ SUCCESS
truncate table t3;
call p_verify_status_increment(4, 4, 4, 4);
-SUCCESS
-
+ERROR
+Expected commit increment: 4 actual: 2
create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
diff --git a/mysql-test/r/csv_not_null.result b/mysql-test/r/csv_not_null.result
index 77026b8f056..af583a36837 100644
--- a/mysql-test/r/csv_not_null.result
+++ b/mysql-test/r/csv_not_null.result
@@ -46,8 +46,9 @@ SELECT * FROM t1;
a b
0 new_value
UPDATE t1 set b = NULL where b = 'new_value';
-ERROR 23000: Column 'b' cannot be null
+Warnings:
+Warning 1048 Column 'b' cannot be null
SELECT * FROM t1;
a b
-0 new_value
+0
DROP TABLE t1;
diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
index 65b358615cf..74fbcc86554 100644
--- a/mysql-test/r/delayed.result
+++ b/mysql-test/r/delayed.result
@@ -288,4 +288,30 @@ ERROR 22007: Incorrect date value: '0000-00-00' for column 'f1' at row 1
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
ERROR 22007: Incorrect date value: '2007-00-00' for column 'f1' at row 1
DROP TABLE t1,t2;
+set @old_delayed_updates = @@global.low_priority_updates;
+set global low_priority_updates = 1;
+select @@global.low_priority_updates;
+@@global.low_priority_updates
+1
+drop table if exists t1;
+create table t1 (a int, b int);
+insert into t1 values (1,1);
+lock table t1 read;
+connection: update
+insert delayed into t1 values (2,2);;
+connection: select
+select * from t1;
+a b
+1 1
+connection: default
+select * from t1;
+a b
+1 1
+unlock tables;
+select * from t1;
+a b
+1 1
+2 2
+drop table t1;
+set global low_priority_updates = @old_delayed_updates;
End of 5.1 tests
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index a3df23138e8..3b864cd5804 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -324,6 +324,11 @@ select @my_uuid_date - @my_uuid_synthetic;
@my_uuid_date - @my_uuid_synthetic
0
set @@session.time_zone=@save_tz;
+CREATE TABLE t1 (a DATE);
+SELECT * FROM t1 WHERE a = NAME_CONST('reportDate',
+_binary'2009-01-09' COLLATE 'binary');
+a
+DROP TABLE t1;
End of 5.0 tests
select connection_id() > 0;
connection_id() > 0
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
index 63f9ac71e74..bbc5390895b 100644
--- a/mysql-test/r/func_sapdb.result
+++ b/mysql-test/r/func_sapdb.result
@@ -268,3 +268,17 @@ timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00')
SELECT CAST(time('-73:42:12') AS DECIMAL);
CAST(time('-73:42:12') AS DECIMAL)
-734212
+SELECT TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1Eq,
+TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq1,
+TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq2,
+TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))= '00:00:00' AS 2Eq,
+TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq1,
+TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq2,
+TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME(0) AS 3Eq,
+TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME(0) AS 3NEq1,
+TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME(0) AS 3NEq2,
+TIME(0) AS Time0, TIME('00:00:00') AS Time00, '00:00:00' AS Literal0000,
+TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
+TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
+1Eq 1NEq1 1NEq2 2Eq 2NEq1 2NEq2 3Eq 3NEq1 3NEq2 Time0 Time00 Literal0000 TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')) TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'))
+1 0 0 1 0 0 1 0 0 00:00:00 00:00:00 00:00:00 00:59:00 -00:59:00
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index 0c3bd2f48aa..7c2023127f0 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -367,20 +367,20 @@ drop database TESTDB;
flush privileges;
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
-grant all privileges on test.* to `a@`@localhost;
-grant execute on * to `a@`@localhost;
-create table t2 (s1 int);
-insert into t2 values (1);
-drop function if exists f2;
-create function f2 () returns int
-begin declare v int; select s1 from t2 into v; return v; end//
-select f2();
+GRANT ALL PRIVILEGES ON test.* TO `a@`@localhost;
+GRANT EXECUTE ON * TO `a@`@localhost;
+CREATE TABLE t2 (s1 INT);
+INSERT INTO t2 VALUES (1);
+DROP FUNCTION IF EXISTS f2;
+CREATE FUNCTION f2 () RETURNS INT
+BEGIN DECLARE v INT; SELECT s1 FROM t2 INTO v; RETURN v; END//
+SELECT f2();
f2()
1
-drop function f2;
-drop table t2;
+DROP FUNCTION f2;
+DROP TABLE t2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
-drop user `a@`@localhost;
+DROP USER `a@`@localhost;
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
drop database if exists mysqltest_1;
drop database if exists mysqltest_2;
@@ -438,6 +438,7 @@ SELECT * FROM t2;
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for table 't2'
SELECT * FROM t1 JOIN t2 USING (b);
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
+USE test;
DROP TABLE db1.t1, db1.t2;
DROP USER mysqltest1@localhost;
DROP DATABASE db1;
diff --git a/mysql-test/r/have_outfile.require b/mysql-test/r/have_outfile.require
index 9fc2f8fdb5a..71137a69a91 100644
--- a/mysql-test/r/have_outfile.require
+++ b/mysql-test/r/have_outfile.require
@@ -1,3 +1,3 @@
-load_file(concat(@tmpdir,"/outfile.test"))
+load_file(concat(@tmpdir,'/outfile.test'))
Outfile OK
diff --git a/mysql-test/r/innodb_ignore_builtin.result b/mysql-test/r/innodb_ignore_builtin.result
new file mode 100644
index 00000000000..4694a61b20a
--- /dev/null
+++ b/mysql-test/r/innodb_ignore_builtin.result
@@ -0,0 +1,9 @@
+show variables like 'ignore_builtin_innodb';
+Variable_name Value
+ignore_builtin_innodb ON
+select PLUGIN_NAME from information_schema.plugins
+where PLUGIN_NAME = "InnoDb";
+PLUGIN_NAME
+select ENGINE from information_schema.engines
+where ENGINE = "InnoDB";
+ENGINE
diff --git a/mysql-test/r/lock_tables_lost_commit.result b/mysql-test/r/lock_tables_lost_commit.result
index 22885d93d40..df4b6eff5cf 100644
--- a/mysql-test/r/lock_tables_lost_commit.result
+++ b/mysql-test/r/lock_tables_lost_commit.result
@@ -1,8 +1,8 @@
-drop table if exists t1;
-create table t1(a int) engine=innodb;
-lock tables t1 write;
-insert into t1 values(10);
-select * from t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT) ENGINE=innodb;
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 VALUES(10);
+SELECT * FROM t1;
a
10
-drop table t1;
+DROP TABLE t1;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 7d8f052ef84..1b06c71e4c1 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -990,6 +990,17 @@ m1 CREATE TABLE `m1` (
`a` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, m1;
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a VARCHAR(10));
+CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
+CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
+SELECT * FROM t1;
+a
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM m2;
+a
+DROP TABLE t1, t2, m1, m2;
End of 5.0 tests
create table t1 (c1 int, index(c1));
create table t2 (c1 int, index(c1)) engine=merge union=(t1);
diff --git a/mysql-test/r/mysqlbinlog_row_trans.result b/mysql-test/r/mysqlbinlog_row_trans.result
index 9c3348a9e76..d0180e4a7a3 100644
--- a/mysql-test/r/mysqlbinlog_row_trans.result
+++ b/mysql-test/r/mysqlbinlog_row_trans.result
@@ -215,30 +215,14 @@ COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
-BEGIN
-/*!*/;
-# at #
-#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
-SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
-#010909 4:46:40 server id 1 end_log_pos # Xid = #
-COMMIT/*!*/;
-# at #
-#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
-SET TIMESTAMP=1000000000/*!*/;
-BEGIN
-/*!*/;
-# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
-#010909 4:46:40 server id 1 end_log_pos # Xid = #
-COMMIT/*!*/;
-# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
@@ -347,17 +331,9 @@ COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
-BEGIN
-/*!*/;
-# at #
-#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
-SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
-#010909 4:46:40 server id 1 end_log_pos # Xid = #
-COMMIT/*!*/;
-# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t2
@@ -473,17 +449,9 @@ ROLLBACK
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
-BEGIN
-/*!*/;
-# at #
-#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
-SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
-#010909 4:46:40 server id 1 end_log_pos # Xid = #
-COMMIT/*!*/;
-# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t2
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 83d5ec284c1..c4ed6deec09 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1,6 +1,6 @@
-Bug#37938 - Test "mysqldump" lacks various insert statements
-Turn off concurrent inserts to avoid random errors
-NOTE: We reset the variable back to saved value at the end of test
+# Bug#37938 Test "mysqldump" lacks various insert statements
+# Turn off concurrent inserts to avoid random errors
+# NOTE: We reset the variable back to saved value at the end of test
SET @OLD_CONCURRENT_INSERT = @@GLOBAL.CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT = 0;
DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa, t3;
@@ -8,7 +8,7 @@ drop database if exists mysqldump_test_db;
drop database if exists db1;
drop database if exists db2;
drop view if exists v1, v2, v3;
-CREATE TABLE t1(a int, key (a)) key_block_size=1024;
+CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -29,7 +29,7 @@ INSERT INTO t1 VALUES (1), (2);
</mysqldump>
DROP TABLE t1;
#
-# Bug #2005
+# Bug#2005 Long decimal comparison bug.
#
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
@@ -43,7 +43,7 @@ SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('987654321098765432109876543210987654321.00000000000000000000');
DROP TABLE t1;
#
-# Bug #2055
+# Bug#2055 mysqldump should replace "-inf" numeric field values with "NULL"
#
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
@@ -58,7 +58,7 @@ SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (RES);
DROP TABLE t1;
#
-# Bug #3361 mysqldump quotes DECIMAL values inconsistently
+# Bug#3361 mysqldump quotes DECIMAL values inconsistently
#
CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT);
INSERT INTO t1 VALUES (1.2345, 2.3456);
@@ -170,7 +170,7 @@ INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
</mysqldump>
DROP TABLE t1;
#
-# Bug #1707
+# Bug#1707 mysqldump -X does't quote field and table names
#
CREATE TABLE t1 (`a"b"` char(2));
INSERT INTO t1 VALUES ("1\""), ("\"2");
@@ -192,8 +192,8 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
</mysqldump>
DROP TABLE t1;
#
-# Bug #1994
-# Bug #4261
+# Bug#1994 mysqldump does not correctly dump UCS2 data
+# Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts
#
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
@@ -234,7 +234,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# Bug #2634
+# Bug#2634 mysqldump in --compatible=mysql4
#
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
@@ -292,7 +292,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# Bug #2592 'mysqldump doesn't quote "tricky" names correctly'
+# Bug#2592 mysqldump doesn't quote "tricky" names correctly
#
create table ```a` (i int);
SET @saved_cs_client = @@character_set_client;
@@ -303,7 +303,7 @@ CREATE TABLE ```a` (
SET character_set_client = @saved_cs_client;
drop table ```a`;
#
-# Bug #2591 "mysqldump quotes names inconsistently"
+# Bug#2591 mysqldump quotes names inconsistently
#
create table t1(a int);
@@ -426,7 +426,7 @@ UNLOCK TABLES;
set global sql_mode='';
drop table t1;
#
-# Bug #2705 'mysqldump --tab extra output'
+# Bug#2705 mysqldump --tab extra output
#
create table t1(a int);
insert into t1 values (1),(2),(3);
@@ -460,7 +460,7 @@ SET character_set_client = @saved_cs_client;
3
drop table t1;
#
-# Bug #6101: create database problem
+# Bug#6101 create database problem
#
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
@@ -515,7 +515,7 @@ USE `mysqldump_test_db`;
drop database mysqldump_test_db;
#
-# Bug #7020
+# Bug#7020 mysqldump --compatible=mysql40 should set --skip-set-charset --default-char...
# Check that we don't dump in UTF8 in compatible mode by default,
# but use the default compiled values, or the values given in
# --default-character-set=xxx. However, we should dump in UTF8
@@ -557,8 +557,8 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
#
-# Bug#8063: make test mysqldump [ fail ]
-# We cannot tes this command because its output depends
+# Bug#8063 make test mysqldump [ fail ]
+# We cannot test this command because its output depends
# on --default-character-set incompiled into "mysqldump" program.
# If the future we can move this command into a separate test with
# checking that "mysqldump" is compiled with "latin1"
@@ -643,7 +643,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# WL #2319: Exclude Tables from dump
+# WL#2319 Exclude Tables from dump
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
@@ -686,7 +686,7 @@ UNLOCK TABLES;
DROP TABLE t1;
DROP TABLE t2;
#
-# Bug #8830
+# Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values
#
CREATE TABLE t1 (`b` blob);
INSERT INTO `t1` VALUES (0x602010000280100005E71A);
@@ -728,7 +728,7 @@ DROP TABLE t1;
#
# Test for --insert-ignore
#
-CREATE TABLE t1 (a int) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 VALUES (4),(5),(6);
@@ -799,9 +799,9 @@ INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
DROP TABLE t1;
#
-# Bug #10286: mysqldump -c crashes on table that has many fields with long
-# names
-#
+# Bug#10286 mysqldump -c crashes on table that has many fields with long
+# names
+#
create table t1 (
F_c4ca4238a0b923820dcc509a6f75849b int,
F_c81e728d9d4c2f636f067f89cc14862c int,
@@ -1545,7 +1545,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
+# Bug#9558 mysqldump --no-data db t1 t2 format still dumps data
#
CREATE DATABASE mysqldump_test_db;
USE mysqldump_test_db;
@@ -1650,7 +1650,7 @@ DROP DATABASE mysqldump_test_db;
#
# Testing with tables and databases that don't exists
# or contains illegal characters
-# (Bug #9358 mysqldump crashes if tablename starts with \)
+# (Bug#9358 mysqldump crashes if tablename starts with \)
#
create database mysqldump_test_db;
use mysqldump_test_db;
@@ -1679,7 +1679,7 @@ drop table t1, t2, t3;
drop database mysqldump_test_db;
use test;
#
-# Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly
+# Bug#9657 mysqldump xml ( -x ) does not format NULL fields correctly
#
create table t1 (a int(10));
create table t2 (pk int primary key auto_increment,
@@ -1738,7 +1738,7 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
</mysqldump>
drop table t1, t2;
#
-# BUG #12123
+# Bug#12123 mysqldump --tab results in text file which can't be imported
#
create table t1 (a text character set utf8, b text character set latin1);
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
@@ -1751,11 +1751,11 @@ a b
Osnabrück Köln
drop table t1;
#
-# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
+# Bug#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
#
--fields-optionally-enclosed-by="
#
-# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
+# Bug#19025 mysqldump doesn't correctly dump "auto_increment = [int]"
#
create table `t1` (
t1_name varchar(255) default null,
@@ -1795,7 +1795,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
drop table `t1`;
#
-# Bug #18536: wrong table order
+# Bug#18536 wrong table order
#
create table t1(a int);
create table t2(a int);
@@ -1844,7 +1844,7 @@ SET character_set_client = @saved_cs_client;
drop table t1, t2, t3;
#
-# Bug #21288: mysqldump segmentation fault when using --where
+# Bug#21288 mysqldump segmentation fault when using --where
#
create table t1 (a int);
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
@@ -1880,7 +1880,7 @@ SET character_set_client = @saved_cs_client;
drop table t1;
#
-# BUG#13926: --order-by-primary fails if PKEY contains quote character
+# Bug#13926 --order-by-primary fails if PKEY contains quote character
#
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
@@ -1959,7 +1959,7 @@ UNLOCK TABLES;
DROP TABLE `t1`;
End of 4.1 tests
#
-# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+# Bug#10213 mysqldump crashes when dumping VIEWs(on MacOS X)
#
create database db1;
use db1;
@@ -2036,7 +2036,7 @@ drop view v2;
drop database db1;
use test;
#
-# Bug 10713 mysqldump includes database in create view and referenced tables
+# Bug#10713 mysqldump includes database in create view and referenced tables
#
create database db2;
use db2;
@@ -2067,9 +2067,6 @@ a b
drop table t1, t2;
drop database db1;
use test;
-#
-# dump of view
-#
create table t1(a int);
create view v1 as select * from t1;
@@ -2130,7 +2127,7 @@ SET character_set_client = @saved_cs_client;
drop view v1;
drop table t1;
#
-# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+# Bug#10213 mysqldump crashes when dumping VIEWs(on MacOS X)
#
create database mysqldump_test_db;
use mysqldump_test_db;
@@ -2207,7 +2204,7 @@ drop view v2;
drop database mysqldump_test_db;
use test;
#
-# Bug #9756
+# Bug#9756 mysql client failing on dumps containing certain \ sequences
#
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
@@ -2247,7 +2244,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# Bug #10927 mysqldump: Can't reload dump with view that consist of other view
+# Bug#10927 mysqldump: Can't reload dump with view that consist of other view
#
create table t1(a int, b int, c varchar(30));
insert into t1 values(1, 2, "one"), (2, 4, "two"), (3, 6, "three");
@@ -2620,12 +2617,14 @@ end if;
end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
DROP TABLE t1, t2;
#
-# Bugs #9136, #12917: problems with --defaults-extra-file option
+# Bug#9136 my_print_defaults changed behaviour between 4.1.7 and 4.1.10a
+# Bug#12917 The --defaults-extra-file option is ignored by the 5.0 client binaries
+# (Problems with --defaults-extra-file option)
#
--port=1234
--port=1234
#
-# Test of fix to BUG 12597
+# Test of fix to Bug#12597 mysqldump dumps triggers wrongly
#
DROP TABLE IF EXISTS `test1`;
Warnings:
@@ -2659,7 +2658,7 @@ DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
#
-# BUG#9056 - mysqldump does not dump routines
+# Bug#9056 mysqldump does not dump routines
#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS bug9056_func1;
@@ -2677,9 +2676,9 @@ begin
set f1= concat( 'hello', f1 );
return f1;
end //
-CREATE PROCEDURE bug9056_proc2(OUT a INT)
-BEGIN
-select sum(id) from t1 into a;
+CREATE PROCEDURE bug9056_proc2(OUT a INT)
+BEGIN
+select sum(id) from t1 into a;
END //
set sql_mode='ansi';
create procedure `a'b` () select 1;
@@ -2794,8 +2793,8 @@ DELIMITER ;
/*!50003 SET sql_mode = '' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `bug9056_proc2`(OUT a INT)
-BEGIN
-select sum(id) from t1 into a;
+BEGIN
+select sum(id) from t1 into a;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -2819,7 +2818,7 @@ DROP PROCEDURE bug9056_proc2;
DROP PROCEDURE `a'b`;
drop table t1;
#
-# BUG# 13052 - mysqldump timestamp reloads broken
+# Bug#13052 mysqldump timestamp reloads broken
#
drop table if exists t1;
create table t1 (`d` timestamp, unique (`d`));
@@ -2914,7 +2913,7 @@ drop table t1;
set global time_zone=default;
set time_zone=default;
#
-# Test of fix to BUG 13146 - ansi quotes break loading of triggers
+# Test of fix to Bug#13146 ansi quotes break loading of triggers
#
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
@@ -2993,7 +2992,7 @@ DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
#
-# BUG# 12838 mysqldump -x with views exits with error
+# Bug#12838 mysqldump -x with views exits with error
#
drop table if exists t1;
create table t1 (a int, b varchar(32), c varchar(32));
@@ -3127,7 +3126,7 @@ drop view v0;
drop view v1;
drop table t1;
#
-# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
+# Bug#14554 mysqldump does not separate words "ROW" and "BEGIN"
# for tables with trigger created in the IGNORE_SPACE sql mode.
#
SET @old_sql_mode = @@SQL_MODE;
@@ -3198,8 +3197,8 @@ DELIMITER ;
DROP TRIGGER tr1;
DROP TABLE t1;
#
-# Bug #13318: Bad result with empty field and --hex-blob
-#
+# Bug#13318 Bad result with empty field and --hex-blob
+#
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
@@ -3274,7 +3273,7 @@ UNLOCK TABLES;
drop table t1;
#
-# Bug 14871 Invalid view dump output
+# Bug#14871 Invalid view dump output
#
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
@@ -3303,7 +3302,7 @@ a
drop table t1;
drop view v1, v2, v3, v4, v5;
#
-# Bug #16878 dump of trigger
+# Bug#16878 dump of trigger
#
create table t1 (a int, created datetime);
create table t2 (b int, created datetime);
@@ -3371,7 +3370,7 @@ drop view v2;
drop table t;
#
# Bug#14857 Reading dump files with single statement stored routines fails.
-# fixed by patch for bug#16878
+# fixed by patch for Bug#16878
#
/*!50003 CREATE FUNCTION `f`() RETURNS bigint(20)
return 42 */|
@@ -3388,7 +3387,7 @@ select 42 latin1 latin1_swedish_ci latin1_swedish_ci
drop function f;
drop procedure p;
#
-# Bug #17371 Unable to dump a schema with invalid views
+# Bug#17371 Unable to dump a schema with invalid views
#
create table t1 ( id serial );
create view v1 as select * from t1;
@@ -3399,7 +3398,7 @@ mysqldump {
} mysqldump
drop view v1;
-# BUG#17201 Spurious 'DROP DATABASE' in output,
+# Bug#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
create database mysqldump_test_db;
@@ -3478,7 +3477,7 @@ drop view v1;
drop table t1;
drop database mysqldump_test_db;
#
-# Bug21014 Segmentation fault of mysqldump on view
+# Bug#21014 Segmentation fault of mysqldump on view
#
create database mysqldump_tables;
use mysqldump_tables;
@@ -3530,7 +3529,7 @@ drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
#
-# Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
+# Bug#20221 Dumping of multiple databases containing view(s) yields maleformed dumps
#
create database mysqldump_dba;
use mysqldump_dba;
@@ -3579,10 +3578,10 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1;
drop user mysqltest_1@localhost;
#
-# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
-# information_schema database.
+# Bug#21527 mysqldump incorrectly tries to LOCK TABLES on the
+# information_schema database.
#
-# Bug #21424 mysqldump failing to export/import views
+# Bug#21424 mysqldump failing to export/import views
#
create database mysqldump_myDB;
use mysqldump_myDB;
@@ -3602,8 +3601,8 @@ revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User@localhost;
drop database mysqldump_myDB;
flush privileges;
-# Bug #21424 continues from here.
-# Restore. Flush Privileges test ends.
+# Bug#21424 continues from here.
+# Restore. Flush Privileges test ends.
#
use mysqldump_myDB;
select * from mysqldump_myDB.v1;
@@ -3621,7 +3620,7 @@ drop user myDB_User@localhost;
drop database mysqldump_myDB;
use test;
#
-# Bug #19745: mysqldump --xml produces invalid xml
+# Bug#19745 mysqldump --xml produces invalid xml
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f1 int(10), data MEDIUMBLOB);
@@ -3643,15 +3642,15 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
</mysqldump>
DROP TABLE t1;
#
-# Bug#26346: stack + buffer overrun in mysqldump
+# Bug#26346 stack + buffer overrun in mysqldump
#
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
mysqldump: Input filename too long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
DROP TABLE t1;
-CREATE TABLE t2 (a int) ENGINE=MyISAM;
-CREATE TABLE t3 (a int) ENGINE=MyISAM;
-CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3);
+CREATE TABLE t2 (a INT) ENGINE=MyISAM;
+CREATE TABLE t3 (a INT) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3706,7 +3705,7 @@ UNLOCK TABLES;
DROP TABLE t1, t2, t3;
#
-# Bug #23491: MySQLDump prefix function call in a view by database name
+# Bug#23491 MySQLDump prefix function call in a view by database name
#
create database bug23491_original;
create database bug23491_restore;
@@ -3728,12 +3727,12 @@ v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI
drop database bug23491_original;
drop database bug23491_restore;
use test;
-#
-# Bug 27293: mysqldump crashes when dumping routines
-# defined by a different user
#
-# Bug #22761: mysqldump reports no errors when using
-# --routines without mysql.proc privileges
+# Bug#27293 mysqldump crashes when dumping routines
+# defined by a different user
+#
+# Bug#22761 mysqldump reports no errors when using
+# --routines without mysql.proc privileges
#
create database mysqldump_test_db;
grant all privileges on mysqldump_test_db.* to user1;
@@ -3764,7 +3763,7 @@ drop user user1;
drop user user2;
drop database mysqldump_test_db;
#
-# Bug #28522: buffer overrun by '\0' byte using --hex-blob.
+# Bug#28522 buffer overrun by '\0' byte using --hex-blob.
#
CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
@@ -3778,8 +3777,8 @@ SET character_set_client = @saved_cs_client;
INSERT INTO `t1` VALUES (11,0x7171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171);
DROP TABLE t1;
#
-# Bug #28524: mysqldump --skip-add-drop-table is not
-# compatible with views
+# Bug#28524 mysqldump --skip-add-drop-table is not
+# compatible with views
#
CREATE VIEW v1 AS SELECT 1;
DROP VIEW v1;
@@ -3788,8 +3787,8 @@ SELECT * FROM v1;
1
DROP VIEW v1;
#
-# Bug #29788: mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
-# the SQL_MODE variable after the dumping of triggers.
+# Bug#29788 mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
+# the SQL_MODE variable after the dumping of triggers.
#
CREATE TABLE t1 (c1 INT);
CREATE TRIGGER t1bd BEFORE DELETE ON t1 FOR EACH ROW BEGIN END;
@@ -3810,8 +3809,8 @@ c1
2
DROP TABLE t1,t2;
#
-# Bug#29815: new option for suppressing last line of mysqldump:
-# "Dump completed on"
+# Bug#29815 new option for suppressing last line of mysqldump:
+# "Dump completed on"
#
# --skip-dump-date:
--
@@ -3876,7 +3875,7 @@ UNLOCK TABLES;
DROP TABLE t1;
#
-# BUG# 16853: mysqldump doesn't show events
+# Bug#16853 mysqldump doesn't show events
#
create database first;
use first;
@@ -3916,7 +3915,7 @@ drop database third;
set time_zone = 'SYSTEM';
use test;
#
-# BUG#17201 Spurious 'DROP DATABASE' in output,
+# Bug#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
#
@@ -3996,8 +3995,8 @@ drop view v1;
drop table t1;
drop database mysqldump_test_db;
#
-# Bug #30027: mysqldump does not dump views properly.
-#
+# Bug#30027 mysqldump does not dump views properly.
+#
# Cleanup.
DROP DATABASE IF EXISTS mysqldump_test_db;
@@ -4029,8 +4028,8 @@ set names latin1;
# Cleanup.
DROP DATABASE mysqldump_test_db;
#
-# BUG#29938: wrong behavior of mysqldump --skip-events
-# with --all-databases
+# Bug#29938 wrong behavior of mysqldump --skip-events
+# with --all-databases
#
TRUNCATE mysql.event;
USE test;
@@ -4062,7 +4061,7 @@ drop database `test-database`;
use test;
# -----------------------------------------------------------------
-# -- Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1.
+# -- Bug#30217 Views: changes in metadata behaviour between 5.0 and 5.1.
# -----------------------------------------------------------------
DROP DATABASE IF EXISTS mysqldump_test_db;
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index 64b8aa74af3..1cdc48e6552 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -93,9 +93,11 @@ INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=1/NULL;
-ERROR 23000: Column 'd' cannot be null
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=NULL;
-ERROR 23000: Column 'd' cannot be null
+Warnings:
+Warning 1048 Column 'd' cannot be null
INSERT INTO t1 (a) values (null);
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (1/null);
@@ -130,7 +132,7 @@ Warning 1048 Column 'd' cannot be null
Warning 1048 Column 'd' cannot be null
select * from t1;
a b c d
- 0 0000-00-00 00:00:00 2003
+ 0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
0 0000-00-00 00:00:00 0
diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result
index bbd8088834f..e5f5a53c1f3 100644
--- a/mysql-test/r/outfile.result
+++ b/mysql-test/r/outfile.result
Binary files differ
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 4e732db493e..3fc39be7594 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -1303,11 +1303,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index bddb160189f..4d7e207b8b1 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -1286,11 +1286,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 6072e6e771e..9cde92247d1 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1287,11 +1287,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index fde309d82e4..e50bf886b86 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -1329,11 +1329,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
@@ -4350,11 +4351,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result
index b76109a3d0e..ca815540c29 100644
--- a/mysql-test/r/status.result
+++ b/mysql-test/r/status.result
@@ -196,7 +196,7 @@ create table db37908.t1(f1 int);
insert into db37908.t1 values(1);
grant usage,execute on test.* to mysqltest_1@localhost;
create procedure proc37908() begin select 1; end |
-create function func37908() returns int sql security invoker
+create function func37908() returns int sql security invoker
return (select * from db37908.t1 limit 1)|
select * from db37908.t1;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 7629a1d79a3..19d95acd5c1 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -98,7 +98,8 @@ Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'c' at row 2
alter table t1 add d char(2);
update t1 set a=NULL where a=10;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
update t1 set c='mysql ab' where c='test';
Warnings:
Warning 1265 Data truncated for column 'c' at row 4
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 41c0d6bee21..404b0dc3789 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -1053,4 +1053,15 @@ ExtractValue('<xml xxx "yyy">CharData</xml>', '/xml')
NULL
Warnings:
Warning 1525 Incorrect XML value: 'parse error at line 1 pos 17: STRING unexpected ('>' wanted)'
+set @x=10;
+select extractvalue('<a></a>','$@x/a');
+ERROR HY000: XPATH syntax error: '/a'
+select extractvalue('<a></a>','round(123.4)/a');
+ERROR HY000: XPATH syntax error: '/a'
+select extractvalue('<a></a>','1/a');
+ERROR HY000: XPATH syntax error: '/a'
+select extractvalue('<a></a>','"b"/a');
+ERROR HY000: XPATH syntax error: '/a'
+select extractvalue('<a></a>','(1)/a');
+ERROR HY000: XPATH syntax error: '/a'
End of 5.1 tests
diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
index 0606c223126..4f3bc57e576 100644
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
@@ -379,9 +379,7 @@ master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; COMMIT
-master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
-master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
@@ -401,9 +399,7 @@ master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # use `test`; ROLLBACK
-master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
-master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
index 6d943ed9da1..38488c9331d 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
@@ -346,9 +346,7 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (3,3)
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,4)
-master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
-master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5,5)
master-bin.000001 # Query # # use `test`; DROP TABLE t2
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (6,6)
@@ -356,9 +354,7 @@ master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE t2 (a int, b in
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (7,7)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (8,8)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (9,9)
-master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
-master-bin.000001 # Query # # use `test`; COMMIT
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (10,10)
master-bin.000001 # Query # # use `test`; BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100)
diff --git a/mysql-test/suite/binlog/r/binlog_truncate_innodb.result b/mysql-test/suite/binlog/r/binlog_truncate_innodb.result
new file mode 100644
index 00000000000..ab237898a74
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_truncate_innodb.result
@@ -0,0 +1,63 @@
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1),(2),(3);
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1),(2),(3);
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1),(2),(3);
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1),(2),(3);
+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1),(2),(3);
+SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/binlog/r/binlog_truncate_myisam.result b/mysql-test/suite/binlog/r/binlog_truncate_myisam.result
new file mode 100644
index 00000000000..9f01c015178
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_truncate_myisam.result
@@ -0,0 +1,12 @@
+RESET MASTER;
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+CREATE TABLE t2 (a INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(2),(3);
+**** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
+master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t2
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 1f7b217dc31..7c0980ba77c 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -220,3 +220,10 @@ Warning 1592 Statement is not safe to log in statement format.
Warning 1592 Statement is not safe to log in statement format.
DROP PROCEDURE p1;
DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100));
+INSERT INTO t1 VALUES ('a','b');
+UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
+Warnings:
+Warning 1592 Statement is not safe to log in statement format.
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_truncate_innodb-master.opt b/mysql-test/suite/binlog/t/binlog_truncate_innodb-master.opt
new file mode 100644
index 00000000000..69cc489a969
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_truncate_innodb-master.opt
@@ -0,0 +1 @@
+--loose-innodb \ No newline at end of file
diff --git a/mysql-test/suite/binlog/t/binlog_truncate_innodb.test b/mysql-test/suite/binlog/t/binlog_truncate_innodb.test
new file mode 100644
index 00000000000..be0918a43f0
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_truncate_innodb.test
@@ -0,0 +1,29 @@
+source include/have_log_bin.inc;
+source include/have_innodb.inc;
+
+# It is necessary to reset the master since otherwise the binlog test
+# might show the wrong binary log. The default for SHOW BINLOG EVENTS
+# is to show the first binary log, not the current one (which is
+# actually a better idea).
+
+RESET MASTER;
+
+let $engine = InnoDB;
+source extra/binlog_tests/binlog_truncate.test;
+
+# Under transaction isolation level READ UNCOMMITTED and READ
+# COMMITTED, InnoDB does not permit statement-based replication of
+# row-deleting statement. In these cases, TRUNCATE TABLE should still
+# be replicated as a statement.
+
+let $before_truncate = SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+source extra/binlog_tests/binlog_truncate.test;
+
+let $before_truncate = SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+source extra/binlog_tests/binlog_truncate.test;
+
+let $before_truncate = SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+source extra/binlog_tests/binlog_truncate.test;
+
+let $before_truncate = SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+source extra/binlog_tests/binlog_truncate.test;
diff --git a/mysql-test/suite/binlog/t/binlog_truncate_myisam.test b/mysql-test/suite/binlog/t/binlog_truncate_myisam.test
new file mode 100644
index 00000000000..e0e4673e876
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_truncate_myisam.test
@@ -0,0 +1,11 @@
+source include/have_log_bin.inc;
+
+# It is necessary to reset the master since otherwise the binlog test
+# might show the wrong binary log. The default for SHOW BINLOG EVENTS
+# is to show the first binary log, not the current one (which is
+# actually a better idea).
+
+RESET MASTER;
+
+let $engine = MyISAM;
+source extra/binlog_tests/binlog_truncate.test;
diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test
index 0d7059bc31f..f58233d4fef 100644
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test
@@ -257,3 +257,17 @@ delimiter ;|
CALL p1();
DROP PROCEDURE p1;
DROP TABLE t1;
+
+#
+# Bug#42634: % character in query can cause mysqld signal 11 segfault
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100));
+INSERT INTO t1 VALUES ('a','b');
+UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
+DROP TABLE t1;
+
diff --git a/mysql-test/suite/binlog/t/disabled.def b/mysql-test/suite/binlog/t/disabled.def
index 888298bbb09..0018387de94 100644
--- a/mysql-test/suite/binlog/t/disabled.def
+++ b/mysql-test/suite/binlog/t/disabled.def
@@ -9,3 +9,5 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
+binlog_truncate_innodb : BUG#42643 2009-02-06 mats Changes to InnoDB requires to complete fix for BUG#36763
+
diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_09.result b/mysql-test/suite/funcs_1/r/innodb_trig_09.result
index b2ed4321a8f..986506b4e71 100644
--- a/mysql-test/suite/funcs_1/r/innodb_trig_09.result
+++ b/mysql-test/suite/funcs_1/r/innodb_trig_09.result
@@ -187,7 +187,8 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
-ERROR 23000: Column 'f136' cannot be null
+Warnings:
+Warning 1048 Column 'f136' cannot be null
Update tb3 Set f122='Test 3.5.9.4-trig', f136=0, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
select f118, f121, f122, f136, f151, f163 from tb3
diff --git a/mysql-test/suite/funcs_1/r/memory_trig_09.result b/mysql-test/suite/funcs_1/r/memory_trig_09.result
index aa9d93403dd..0795c3be36f 100644
--- a/mysql-test/suite/funcs_1/r/memory_trig_09.result
+++ b/mysql-test/suite/funcs_1/r/memory_trig_09.result
@@ -188,7 +188,8 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
-ERROR 23000: Column 'f136' cannot be null
+Warnings:
+Warning 1048 Column 'f136' cannot be null
Update tb3 Set f122='Test 3.5.9.4-trig', f136=0, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
select f118, f121, f122, f136, f151, f163 from tb3
diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_09.result b/mysql-test/suite/funcs_1/r/myisam_trig_09.result
index aa9d93403dd..0795c3be36f 100644
--- a/mysql-test/suite/funcs_1/r/myisam_trig_09.result
+++ b/mysql-test/suite/funcs_1/r/myisam_trig_09.result
@@ -188,7 +188,8 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
-ERROR 23000: Column 'f136' cannot be null
+Warnings:
+Warning 1048 Column 'f136' cannot be null
Update tb3 Set f122='Test 3.5.9.4-trig', f136=0, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
select f118, f121, f122, f136, f151, f163 from tb3
diff --git a/mysql-test/suite/funcs_1/r/ndb_trig_09.result b/mysql-test/suite/funcs_1/r/ndb_trig_09.result
index b2ed4321a8f..986506b4e71 100644
--- a/mysql-test/suite/funcs_1/r/ndb_trig_09.result
+++ b/mysql-test/suite/funcs_1/r/ndb_trig_09.result
@@ -187,7 +187,8 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
0 0 0 0 0 0
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
-ERROR 23000: Column 'f136' cannot be null
+Warnings:
+Warning 1048 Column 'f136' cannot be null
Update tb3 Set f122='Test 3.5.9.4-trig', f136=0, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
select f118, f121, f122, f136, f151, f163 from tb3
diff --git a/mysql-test/suite/funcs_1/triggers/triggers_09.inc b/mysql-test/suite/funcs_1/triggers/triggers_09.inc
index c20553a9435..47277afb63c 100644
--- a/mysql-test/suite/funcs_1/triggers/triggers_09.inc
+++ b/mysql-test/suite/funcs_1/triggers/triggers_09.inc
@@ -183,7 +183,6 @@ let $message= Testcase 3.5.9.4:;
@tr_var_af_136, @tr_var_af_151, @tr_var_af_163;
--enable_query_log
---error ER_BAD_NULL_ERROR
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/r/ps_maria.result
index 10172868474..38e69fc0d00 100644
--- a/mysql-test/suite/maria/r/ps_maria.result
+++ b/mysql-test/suite/maria/r/ps_maria.result
@@ -1303,11 +1303,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result
index 1799ac2a203..6a6b0129548 100644
--- a/mysql-test/suite/ndb/r/ps_7ndb.result
+++ b/mysql-test/suite/ndb/r/ps_7ndb.result
@@ -1286,11 +1286,12 @@ a b
set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Column 'a' cannot be null
+Warnings:
+Warning 1048 Column 'a' cannot be null
select a,b from t1 order by a;
a b
+0 two
1 one
-2 two
3 three
4 four
set @arg00=0;
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc
index 5e9ad47aa2e..26375c72c0c 100644
--- a/mysql-test/suite/parts/inc/partition_auto_increment.inc
+++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc
@@ -50,12 +50,7 @@ if (!$skip_update)
UPDATE t1 SET c1 = 40 WHERE c1 = 50;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1';
- -- error 0, ER_BAD_NULL_ERROR
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
-if (!$mysql_errno)
-{
- echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
-}
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
}
@@ -203,12 +198,7 @@ if (!$skip_update)
UPDATE t1 SET c1 = 140 WHERE c1 = 150;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1';
- -- error 0, ER_BAD_NULL_ERROR
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
-if (!$mysql_errno)
-{
- echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
-}
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
}
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
index 1946ebbf978..ac39d038c56 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
@@ -43,7 +43,6 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
1
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
-# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
@@ -192,7 +191,6 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
1
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
-# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result
index a30dfbcbe72..9a23cd4364e 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result
@@ -42,12 +42,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
31
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
10
@@ -215,12 +217,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
141
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
9
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result
index 96925d206f6..77bab79f020 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result
@@ -42,12 +42,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
52
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
10
@@ -214,12 +216,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
152
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
9
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result
index 204c241cfa8..b5b001ec17a 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result
@@ -42,12 +42,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
52
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
10
@@ -214,12 +216,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
152
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
9
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
index 85e226b749b..408f32cce78 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
@@ -43,12 +43,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
52
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
10
@@ -215,12 +217,14 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AUTO_INCREMENT
152
UPDATE t1 SET c1 = NULL WHERE c1 = 4;
+Warnings:
+Warning 1048 Column 'c1' cannot be null
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1;
c1
+0
2
-4
5
6
9
diff --git a/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result b/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
index 86648ba12c3..ad67f96db71 100644
--- a/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result
@@ -454,7 +454,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
@@ -1593,7 +1595,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
@@ -2732,7 +2736,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
diff --git a/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result b/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
index 96d4ca237d1..8859a8e24e3 100644
--- a/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result
@@ -454,7 +454,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
@@ -1593,7 +1595,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
@@ -2732,7 +2736,9 @@ f1 f2 f3 f4
update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1;
-update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
+Warnings:
+Warning 1048 Column 'f3' cannot be null
** Delete from Master **
diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
index 8602718ba46..1e795a85ce1 100644
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
@@ -963,9 +963,7 @@ master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # use `test_rpl`; BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1')
master-bin.000001 # Xid 1 # #
-master-bin.000001 # Query 1 # use `test_rpl`; BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; TRUNCATE t1
-master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # use `test_rpl`; BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1
master-bin.000001 # Xid 1 # #
diff --git a/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result b/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result
index 92e13064856..38fb9e27764 100644
--- a/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result
@@ -4,265 +4,43 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
+**** Resetting master and slave ****
+include/stop_slave.inc
RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=STATEMENT;
-SET GLOBAL BINLOG_FORMAT=STATEMENT;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
-**** On Master ****
-TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
+include/start_slave.inc
**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=MIXED;
-SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
**** On Master ****
TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
+Comparing tables master:test.t1 and slave:test.t1
+==== Test using a table with delete triggers ====
**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=ROW;
-SET GLOBAL BINLOG_FORMAT=ROW;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
+SET @count := 1;
+CREATE TABLE t2 (a INT, b LONG) ENGINE=MyISAM;
+CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
**** On Master ****
TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Query # # use `test`; COMMIT
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
+Comparing tables master:test.t2 and slave:test.t2
+DROP TABLE t1,t2;
+**** Resetting master and slave ****
+include/stop_slave.inc
RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=STATEMENT;
-SET GLOBAL BINLOG_FORMAT=STATEMENT;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
-**** On Master ****
-DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Query # # use `test`; DELETE FROM t1
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
+include/start_slave.inc
**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=MIXED;
-SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
**** On Master ****
DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
+Comparing tables master:test.t1 and slave:test.t1
+==== Test using a table with delete triggers ====
**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Query # # use `test`; DELETE FROM t1
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=ROW;
-SET GLOBAL BINLOG_FORMAT=ROW;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
+SET @count := 1;
+CREATE TABLE t2 (a INT, b LONG) ENGINE=MyISAM;
+CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
**** On Master ****
DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-3 3
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Query # # use `test`; COMMIT
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Query # # use `test`; COMMIT
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
+Comparing tables master:test.t2 and slave:test.t2
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result b/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result
index 94461c33c46..b5e5936834d 100644
--- a/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_truncate_3innodb.result
@@ -4,283 +4,43 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
+**** Resetting master and slave ****
+include/stop_slave.inc
RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=STATEMENT;
-SET GLOBAL BINLOG_FORMAT=STATEMENT;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
-**** On Master ****
-TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
+include/start_slave.inc
**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=MIXED;
-SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
**** On Master ****
TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
+Comparing tables master:test.t1 and slave:test.t1
+==== Test using a table with delete triggers ====
**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=ROW;
-SET GLOBAL BINLOG_FORMAT=ROW;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
+SET @count := 1;
+CREATE TABLE t2 (a INT, b LONG) ENGINE=InnoDB;
+CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
**** On Master ****
TRUNCATE TABLE t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
+Comparing tables master:test.t2 and slave:test.t2
+DROP TABLE t1,t2;
+**** Resetting master and slave ****
+include/stop_slave.inc
RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=STATEMENT;
-SET GLOBAL BINLOG_FORMAT=STATEMENT;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
-**** On Master ****
-DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; DELETE FROM t1
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
+include/start_slave.inc
**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=MIXED;
-SET GLOBAL BINLOG_FORMAT=MIXED;
CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
**** On Master ****
DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
+Comparing tables master:test.t1 and slave:test.t1
+==== Test using a table with delete triggers ====
**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Query # # use `test`; DELETE FROM t1
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
-STOP SLAVE;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t1;
-RESET SLAVE;
-START SLAVE;
-**** On Master ****
-SET @old_session_binlog_format= @@session.binlog_format;
-SET @old_global_binlog_format= @@global.binlog_format;
-SET SESSION BINLOG_FORMAT=ROW;
-SET GLOBAL BINLOG_FORMAT=ROW;
-CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,1), (2,2);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-**** On Slave ****
-INSERT INTO t1 VALUE (3,3);
-SELECT * FROM t1;
-a b
-1 1
-2 2
-3 3
+SET @count := 1;
+CREATE TABLE t2 (a INT, b LONG) ENGINE=InnoDB;
+CREATE TRIGGER trg1 BEFORE DELETE ON t1 FOR EACH ROW SET @count := @count + 1;
**** On Master ****
DELETE FROM t1;
-SELECT * FROM t1;
-a b
-**** On Slave ****
-SELECT * FROM t1;
-a b
-3 3
-**** On Master ****
-DROP TABLE t1;
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; BEGIN
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t1
-RESET MASTER;
-SET @@session.binlog_format= @old_session_binlog_format;
-SET @@global.binlog_format= @old_global_binlog_format;
+Comparing tables master:test.t2 and slave:test.t2
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
index e26e240b5ab..b9ab66165cc 100644
--- a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
+++ b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
@@ -50,7 +50,7 @@ kill @id;
drop table t2,t3;
insert into t4 values (3),(4);
connection master;
---error 0,1053,2013,1048
+--error 0,1053,2013
reap;
connection master1;
save_master_pos;
diff --git a/mysql-test/suite/rpl_ndb/t/disabled.def b/mysql-test/suite/rpl_ndb/t/disabled.def
index 694f7098980..6908269d014 100644
--- a/mysql-test/suite/rpl_ndb/t/disabled.def
+++ b/mysql-test/suite/rpl_ndb/t/disabled.def
@@ -10,7 +10,4 @@
#
##############################################################################
-rpl_ndb_circular : Bug#41183 rpl_ndb_circular, rpl_ndb_circular_simplex need maintenance, crash
-rpl_ndb_circular_simplex : Bug#41183 rpl_ndb_circular, rpl_ndb_circular_simplex need maintenance, crash
-
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 47458c1f054..32f065171f2 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -149,7 +149,6 @@ delete from t1 where a=0;
update t1 set a=0 where b=5;
select * from t1 order by b;
delete from t1 where a=0;
---error 1048
update t1 set a=NULL where b=6;
update t1 set a=300 where b=7;
SET SQL_MODE='';
@@ -165,7 +164,6 @@ delete from t1 where a=0;
update t1 set a=0 where b=12;
select * from t1 order by b;
delete from t1 where a=0;
---error 1048
update t1 set a=NULL where b=13;
update t1 set a=500 where b=14;
select * from t1 order by b;
diff --git a/mysql-test/t/csv_not_null.test b/mysql-test/t/csv_not_null.test
index bb7b412aa49..03ed566fb22 100644
--- a/mysql-test/t/csv_not_null.test
+++ b/mysql-test/t/csv_not_null.test
@@ -93,7 +93,6 @@ SELECT * FROM t1;
UPDATE t1 set b = 'new_value' where a = 0;
--enable_warnings
SELECT * FROM t1;
---error ER_BAD_NULL_ERROR
UPDATE t1 set b = NULL where b = 'new_value';
SELECT * FROM t1;
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index 87d6ab55ee5..b8ab4fe31c0 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -298,4 +298,47 @@ INSERT DELAYED INTO t2 VALUES (0,'0000-00-00');
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
DROP TABLE t1,t2;
+#
+# Bug#40536: SELECT is blocked by INSERT DELAYED waiting on upgrading lock,
+# even with low_priority_updates
+#
+
+set @old_delayed_updates = @@global.low_priority_updates;
+set global low_priority_updates = 1;
+select @@global.low_priority_updates;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int, b int);
+insert into t1 values (1,1);
+lock table t1 read;
+connect (update,localhost,root,,);
+connection update;
+--echo connection: update
+--send insert delayed into t1 values (2,2);
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where command = "Delayed insert" and state = "upgrading lock";
+--source include/wait_condition.inc
+connect (select,localhost,root,,);
+--echo connection: select
+select * from t1;
+connection default;
+--echo connection: default
+select * from t1;
+connection default;
+disconnect update;
+disconnect select;
+unlock tables;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where command = "Delayed insert" and state = "Waiting for INSERT";
+--source include/wait_condition.inc
+select * from t1;
+drop table t1;
+
+set global low_priority_updates = @old_delayed_updates;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 61bf285c364..eb243d38238 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -445,6 +445,15 @@ select @my_uuid_date - @my_uuid_synthetic;
set @@session.time_zone=@save_tz;
+
+#
+# Bug#42014: Crash, name_const with collate
+#
+CREATE TABLE t1 (a DATE);
+SELECT * FROM t1 WHERE a = NAME_CONST('reportDate',
+ _binary'2009-01-09' COLLATE 'binary');
+DROP TABLE t1;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
index f37ee0c39f0..1292c475732 100644
--- a/mysql-test/t/func_sapdb.test
+++ b/mysql-test/t/func_sapdb.test
@@ -151,4 +151,22 @@ select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00');
SELECT CAST(time('-73:42:12') AS DECIMAL);
+
+#
+# Bug#42525 - TIMEDIFF function
+#
+
+SELECT TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1Eq,
+ TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq1,
+ TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq2,
+ TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))= '00:00:00' AS 2Eq,
+ TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq1,
+ TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq2,
+ TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME(0) AS 3Eq,
+ TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME(0) AS 3NEq1,
+ TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME(0) AS 3NEq2,
+ TIME(0) AS Time0, TIME('00:00:00') AS Time00, '00:00:00' AS Literal0000,
+ TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
+ TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
+
# End of 5.0 tests
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 21de3e349cf..54cdf8d6cc1 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -1,6 +1,10 @@
# Grant tests not performed with embedded server
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
SET NAMES binary;
#
@@ -27,7 +31,7 @@ create user mysqltest_2@localhost;
connect (user_a,localhost,mysqltest_1,,);
connection user_a;
grant select on `my\_1`.* to mysqltest_2@localhost;
---error 1132
+--error ER_PASSWORD_NOT_ALLOWED
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
disconnect user_a;
connection default;
@@ -61,7 +65,7 @@ connect (user1,localhost,mysqltest_1,,);
connection user1;
select current_user();
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
#
@@ -72,7 +76,7 @@ select @@sql_mode;
#
# GRANT without IDENTIFIED BY does not create new users
#
---error 1133
+--error ER_PASSWORD_NO_MATCH
grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
with grant option;
@@ -80,7 +84,7 @@ disconnect user1;
connection default;
show grants for mysqltest_1@localhost;
show grants for mysqltest_2@localhost;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_3@localhost;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
@@ -95,7 +99,7 @@ connect (user2,localhost,mysqltest_1,,);
connection user2;
select current_user();
show databases;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
disconnect user2;
connection default;
@@ -106,8 +110,8 @@ drop database mysqltest_1;
flush privileges;
#
-# Bug #6173: One can circumvent missing UPDATE privilege if he has SELECT
-# and INSERT privilege for table with primary key
+# Bug#6173 One can circumvent missing UPDATE privilege if he has SELECT and
+# INSERT privilege for table with primary key
#
create database mysqltest;
grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
@@ -119,10 +123,10 @@ connect (mrbad, localhost, mysqltest_1,,mysqltest);
connection mrbad;
show grants for current_user();
insert into t1 values (1, 'I can''t change it!');
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update t1 set data='I can change it!' where id = 1;
# This should not be allowed since it too require UPDATE privilege.
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';
select * from t1;
disconnect mrbad;
@@ -138,9 +142,9 @@ create table t1 (a int, b int);
grant select (a) on t1 to mysqltest_1@localhost with grant option;
connect (mrugly, localhost, mysqltest_1,,mysqltest);
connection mrugly;
---error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
grant select (a,b) on t1 to mysqltest_2@localhost;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
grant select on t1 to mysqltest_3@localhost;
disconnect mrugly;
@@ -157,7 +161,7 @@ use test;
#
-# Bug #15775: "drop user" command does not refresh acl_check_hosts
+# Bug#15775 "drop user" command does not refresh acl_check_hosts
#
# Create some test users
@@ -188,15 +192,15 @@ disconnect con9;
connection default;
#
-# Bug# 16180 - Setting SQL_LOG_OFF without SUPER privilege is silently ignored
+# Bug#16180 Setting SQL_LOG_OFF without SUPER privilege is silently ignored
#
create database mysqltest_1;
grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost;
connect (con10,localhost,mysqltest_1,,);
connection con10;
---error 1227
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
set sql_log_off = 1;
---error 1227
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
set sql_log_bin = 0;
disconnect con10;
connection default;
@@ -217,7 +221,7 @@ create table t2(c1 int, c2 int);
#
# Three forms of CREATE USER
create user 'mysqltest_1';
---error 1396
+--error ER_CANNOT_USER
create user 'mysqltest_1';
create user 'mysqltest_2' identified by 'Mysqltest-2';
create user 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
@@ -238,7 +242,7 @@ select host,user,password from mysql.user where user like 'mysqltest_%' order by
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
#
# Rename
@@ -249,7 +253,7 @@ select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
show grants for 'mysqltest_1';
drop user 'mysqltest_1', 'mysqltest_3';
---error 1396
+--error ER_CANNOT_USER
drop user 'mysqltest_1';
#
# Cleanup
@@ -258,9 +262,9 @@ drop table t1, t2;
# Add a stray record
insert into mysql.db set user='mysqltest_1', db='%', host='%';
flush privileges;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
---error 1269
+--error ER_REVOKE_GRANTS
revoke all privileges, grant option from 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
@@ -268,7 +272,7 @@ select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,us
# Add a stray record
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
flush privileges;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
@@ -276,7 +280,7 @@ select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1'
# Add a stray record
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
flush privileges;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
@@ -286,23 +290,23 @@ create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';
---error 1396
+--error ER_CANNOT_USER
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';
#
# Let one of multiple users fail
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
---error 1396
+--error ER_CANNOT_USER
create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';
---error 1396
+--error ER_CANNOT_USER
rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
---error 1396
+--error ER_CANNOT_USER
drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';
#
# Obsolete syntax has been dropped
create user 'mysqltest_2' identified by 'Mysqltest-2';
---error 1064
+--error ER_PARSE_ERROR
drop user 'mysqltest_2' identified by 'Mysqltest-2';
drop user 'mysqltest_2';
#
@@ -312,7 +316,7 @@ show grants for '%@b'@'b';
grant select on mysql.* to '%@b'@'b';
show grants for '%@b'@'b';
rename user '%@b'@'b' to '%@a'@'a';
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for '%@b'@'b';
show grants for '%@a'@'a';
drop user '%@a'@'a';
@@ -323,7 +327,7 @@ create user mysqltest_2@localhost;
grant create user on *.* to mysqltest_2@localhost;
connect (user3,localhost,mysqltest_2,,);
connection user3;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
@@ -338,7 +342,7 @@ grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;
connect (user4,localhost,mysqltest_3,,);
connection user4;
show grants;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
insert into mysql.user set host='%', user='mysqltest_B';
create user mysqltest_A@'%';
@@ -349,7 +353,7 @@ disconnect user4;
connection default;
drop user mysqltest_3@localhost;
#
-# Bug #3309: Test IP addresses with netmask
+# Bug#3309 Test IP addresses with netmask
set @@sql_mode='';
create database mysqltest_1;
create table mysqltest_1.t1 (i int);
@@ -367,7 +371,8 @@ flush privileges;
drop table mysqltest_1.t1;
#
-# Bug #12302: 'SET PASSWORD = ...' didn't work if connecting hostname !=
+# Bug#12302 Hostname resolution preventing password changes
+# 'SET PASSWORD = ...' didn't work if connecting hostname !=
# hostname the current user is authenticated as. Note that a test for this
# was also added to the test above.
#
@@ -400,7 +405,7 @@ drop database mysqltest_1;
# But anonymous users can't change their password
connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n5;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
set password = password("changed");
disconnect n5;
connection default;
@@ -408,7 +413,7 @@ connection default;
--source include/delete_anonymous_users.inc
-# Bug #12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in
+# Bug#12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in
# multi-threaded environment". We should be able to execute FLUSH
# PRIVILEGES and SET PASSWORD simultaneously with other account
# management commands (such as GRANT and REVOKE) without causing
@@ -471,12 +476,13 @@ connect (con1,localhost,mysqltest_1,password,TESTDB);
# The user mysqltest_1 should only be allowed access to
# database TESTDB, not TEStdb
-# On system with "lowercase names" we get error "1007: Can't create db..."
---error 1044, 1007
+# On system with "lowercase names" we get error "ER_DB_CREATE_EXISTS: Can't create db..."
+--error ER_DBACCESS_DENIED_ERROR, ER_DB_CREATE_EXISTS
create database TEStdb;
# Clean-up
connection default;
+disconnect con1;
delete from mysql.user;
delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
insert into mysql.user select * from t1;
@@ -485,39 +491,39 @@ drop database TESTDB;
flush privileges;
#
-# BUG#13310 incorrect user parsing by SP
+# Bug#13310 incorrect user parsing by SP
#
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
-grant all privileges on test.* to `a@`@localhost;
-grant execute on * to `a@`@localhost;
+GRANT ALL PRIVILEGES ON test.* TO `a@`@localhost;
+GRANT EXECUTE ON * TO `a@`@localhost;
connect (bug13310,localhost,'a@',,test);
connection bug13310;
-create table t2 (s1 int);
-insert into t2 values (1);
+CREATE TABLE t2 (s1 INT);
+INSERT INTO t2 VALUES (1);
--disable_warnings
-drop function if exists f2;
+DROP FUNCTION IF EXISTS f2;
--enable_warnings
delimiter //;
-create function f2 () returns int
-begin declare v int; select s1 from t2 into v; return v; end//
+CREATE FUNCTION f2 () RETURNS INT
+BEGIN DECLARE v INT; SELECT s1 FROM t2 INTO v; RETURN v; END//
delimiter ;//
-select f2();
-drop function f2;
-drop table t2;
-disconnect bug13310;
+SELECT f2();
+DROP FUNCTION f2;
+DROP TABLE t2;
+disconnect bug13310;
connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
-drop user `a@`@localhost;
+DROP USER `a@`@localhost;
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
#
-# Bug#25578 "CREATE TABLE LIKE does not require any privileges on source table"
+# Bug#25578 CREATE TABLE LIKE does not require any privileges on source table
#
--disable_warnings
drop database if exists mysqltest_1;
@@ -536,7 +542,7 @@ create table t1 (i int);
connect (user1,localhost,mysqltest_u1,,mysqltest_1);
connection user1;
# As expected error is emitted
---error ER_TABLEACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
show create table mysqltest_2.t1;
# This should emit error as well
--error ER_TABLEACCESS_DENIED_ERROR
@@ -551,14 +557,16 @@ create table t1 like mysqltest_2.t1;
# Clean-up
connection default;
+disconnect user1;
use test;
drop database mysqltest_1;
drop database mysqltest_2;
drop user mysqltest_u1@localhost;
+
#
# Bug#18660 Can't grant any privileges on single table in database
-# with underscore char
+# with underscore char
#
grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option;
grant usage on *.* to mysqltest_2@localhost;
@@ -572,7 +580,7 @@ grant create on `mysqltest\_1`.* to mysqltest_2@localhost;
grant select on mysqltest_1.t1 to mysqltest_2@localhost;
connect (con3,localhost,mysqltest_2,,);
connection con3;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
create database mysqltest_3;
use mysqltest_1;
create table t2(f1 int);
@@ -580,6 +588,9 @@ select * from t1;
connection default;
drop database mysqltest_1;
+connection default;
+disconnect con3;
+disconnect con18600_1;
revoke all privileges, grant option from mysqltest_1@localhost;
revoke all privileges, grant option from mysqltest_2@localhost;
drop user mysqltest_1@localhost;
@@ -587,7 +598,7 @@ drop user mysqltest_2@localhost;
#
-# Bug #30468: column level privileges not respected when joining tables
+# Bug#30468 column level privileges not respected when joining tables
#
CREATE DATABASE db1;
@@ -598,7 +609,7 @@ INSERT INTO t1 VALUES (1,1),(2,2);
CREATE TABLE t2 (b INT, c INT);
INSERT INTO t2 VALUES (1,100),(2,200);
-GRANT SELECT ON t1 TO mysqltest1@localhost;
+GRANT SELECT ON t1 TO mysqltest1@localhost;
GRANT SELECT (b) ON t2 TO mysqltest1@localhost;
connect (conn1,localhost,mysqltest1,,);
@@ -613,6 +624,7 @@ SELECT * FROM t1 JOIN t2 USING (b);
connection default;
disconnect conn1;
+USE test;
DROP TABLE db1.t1, db1.t2;
DROP USER mysqltest1@localhost;
DROP DATABASE db1;
@@ -620,3 +632,5 @@ DROP DATABASE db1;
--echo End of 5.0 tests
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test
index 8eceb851c29..9a635048774 100644
--- a/mysql-test/t/grant3.test
+++ b/mysql-test/t/grant3.test
@@ -1,6 +1,10 @@
-# Can't run with embedded server
+# Can't run with embedded server because we use GRANT
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
# Test of GRANT commands
SET NAMES binary;
@@ -23,10 +27,11 @@ grant create user on *.* to mysqltest_1@localhost;
grant select on `my\_1`.* to mysqltest_1@localhost with grant option;
connect (user_a,localhost,mysqltest_1,,);
connection user_a;
---error 1410
+--error ER_CANT_CREATE_USER_WITH_GRANT
grant select on `my\_1`.* to mysqltest_2@localhost;
create user mysqltest_2@localhost;
disconnect user_a;
+disconnect master;
connection default;
delete from mysql.user where user like 'mysqltest\_%';
@@ -36,7 +41,7 @@ delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
#
-# Bug: #19828 Case sensitivity in Grant/Revoke
+# Bug#19828 Case sensitivity in Grant/Revoke
#
grant select on test.* to CUser@localhost;
@@ -137,7 +142,7 @@ DROP USER CUser2@LOCALHOST;
#
-# Bug#31194: Privilege ordering does not order properly for wildcard values
+# Bug#31194 Privilege ordering does not order properly for wildcard values
#
CREATE DATABASE mysqltest_1;
@@ -160,3 +165,6 @@ DROP DATABASE mysqltest_1;
--echo End of 5.0 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/innodb_ignore_builtin-master.opt b/mysql-test/t/innodb_ignore_builtin-master.opt
new file mode 100644
index 00000000000..f7289eed20e
--- /dev/null
+++ b/mysql-test/t/innodb_ignore_builtin-master.opt
@@ -0,0 +1 @@
+--ignore_builtin_innodb
diff --git a/mysql-test/t/innodb_ignore_builtin.test b/mysql-test/t/innodb_ignore_builtin.test
new file mode 100644
index 00000000000..6f987bcf891
--- /dev/null
+++ b/mysql-test/t/innodb_ignore_builtin.test
@@ -0,0 +1,8 @@
+#
+# Bug #42610: Dynamic plugin broken in 5.1.31
+#
+show variables like 'ignore_builtin_innodb';
+select PLUGIN_NAME from information_schema.plugins
+where PLUGIN_NAME = "InnoDb";
+select ENGINE from information_schema.engines
+where ENGINE = "InnoDB";
diff --git a/mysql-test/t/lock_tables_lost_commit.test b/mysql-test/t/lock_tables_lost_commit.test
index d31b4b7dfb5..754c8f3c378 100644
--- a/mysql-test/t/lock_tables_lost_commit.test
+++ b/mysql-test/t/lock_tables_lost_commit.test
@@ -1,24 +1,33 @@
-# This is a test for bug 578
+# Test for Bug#578 mysqlimport -l silently fails when binlog-ignore-db is set
--- source include/have_innodb.inc
+--source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
--disable_warnings
-drop table if exists t1;
-create table t1(a int) engine=innodb;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT) ENGINE=innodb;
--enable_warnings
-lock tables t1 write;
-insert into t1 values(10);
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 VALUES(10);
disconnect con1;
connection con2;
# The bug was that, because of the LOCK TABLES, the handler "forgot" to commit,
# and the other commit when we write to the binlog was not done because of
-# binlog-ignore-db
-select * from t1;
-drop table t1;
+# binlog-ignore-db
+SELECT * FROM t1;
+DROP TABLE t1;
+
+connection default;
+disconnect con2;
# End of 4.1 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 6e5d2aee7fd..1d1c7b3357e 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -617,6 +617,20 @@ ALTER TABLE m1 UNION=(t1);
ALTER TABLE m1 UNION=();
SHOW CREATE TABLE m1;
DROP TABLE t1, m1;
+
+#
+# BUG#32047 - 'Spurious' errors while opening MERGE tables
+#
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a VARCHAR(10));
+CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
+CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
+SELECT * FROM t1;
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE t1, t2, m1, m2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index ae5c27af1d8..48ccfb6e87c 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -5,10 +5,13 @@
# Binlog is required
--source include/have_log_bin.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
---echo Bug#37938 - Test "mysqldump" lacks various insert statements
---echo Turn off concurrent inserts to avoid random errors
---echo NOTE: We reset the variable back to saved value at the end of test
+
+--echo # Bug#37938 Test "mysqldump" lacks various insert statements
+--echo # Turn off concurrent inserts to avoid random errors
+--echo # NOTE: We reset the variable back to saved value at the end of test
SET @OLD_CONCURRENT_INSERT = @@GLOBAL.CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT = 0;
@@ -23,13 +26,13 @@ drop view if exists v1, v2, v3;
# XML output
-CREATE TABLE t1(a int, key (a)) key_block_size=1024;
+CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-create --skip-comments -X test t1
DROP TABLE t1;
--echo #
---echo # Bug #2005
+--echo # Bug#2005 Long decimal comparison bug.
--echo #
CREATE TABLE t1 (a decimal(64, 20));
@@ -39,7 +42,7 @@ INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
DROP TABLE t1;
--echo #
---echo # Bug #2055
+--echo # Bug#2055 mysqldump should replace "-inf" numeric field values with "NULL"
--echo #
CREATE TABLE t1 (a double);
@@ -51,7 +54,7 @@ INSERT INTO t1 VALUES ('-9e999999');
DROP TABLE t1;
--echo #
---echo # Bug #3361 mysqldump quotes DECIMAL values inconsistently
+--echo # Bug#3361 mysqldump quotes DECIMAL values inconsistently
--echo #
CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT);
@@ -65,7 +68,7 @@ INSERT INTO t1 VALUES ("1.2345", 2.3456);
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES';
INSERT INTO t1 VALUES (1.2345, 2.3456);
INSERT INTO t1 VALUES ('1.2345', 2.3456);
---error 1054
+--error ER_BAD_FIELD_ERROR
INSERT INTO t1 VALUES ("1.2345", 2.3456);
SET SQL_MODE=@OLD_SQL_MODE;
@@ -82,7 +85,7 @@ INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
DROP TABLE t1;
--echo #
---echo # Bug #1707
+--echo # Bug#1707 mysqldump -X does't quote field and table names
--echo #
CREATE TABLE t1 (`a"b"` char(2));
@@ -91,8 +94,8 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
DROP TABLE t1;
--echo #
---echo # Bug #1994
---echo # Bug #4261
+--echo # Bug#1994 mysqldump does not correctly dump UCS2 data
+--echo # Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts
--echo #
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
@@ -101,7 +104,7 @@ INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
DROP TABLE t1;
--echo #
---echo # Bug #2634
+--echo # Bug#2634 mysqldump in --compatible=mysql4
--echo #
CREATE TABLE t1 (a int) ENGINE=MYISAM;
@@ -111,7 +114,7 @@ INSERT INTO t1 VALUES (1), (2);
DROP TABLE t1;
--echo #
---echo # Bug #2592 'mysqldump doesn't quote "tricky" names correctly'
+--echo # Bug#2592 mysqldump doesn't quote "tricky" names correctly
--echo #
create table ```a` (i int);
@@ -119,7 +122,7 @@ create table ```a` (i int);
drop table ```a`;
--echo #
---echo # Bug #2591 "mysqldump quotes names inconsistently"
+--echo # Bug#2591 mysqldump quotes names inconsistently
--echo #
create table t1(a int);
@@ -132,7 +135,7 @@ set global sql_mode='';
drop table t1;
--echo #
---echo # Bug #2705 'mysqldump --tab extra output'
+--echo # Bug#2705 mysqldump --tab extra output
--echo #
create table t1(a int);
@@ -148,7 +151,7 @@ insert into t1 values (1),(2),(3);
drop table t1;
--echo #
---echo # Bug #6101: create database problem
+--echo # Bug#6101 create database problem
--echo #
--exec $MYSQL_DUMP --skip-comments --databases test
@@ -158,7 +161,7 @@ create database mysqldump_test_db character set latin2 collate latin2_bin;
drop database mysqldump_test_db;
--echo #
---echo # Bug #7020
+--echo # Bug#7020 mysqldump --compatible=mysql40 should set --skip-set-charset --default-char...
--echo # Check that we don't dump in UTF8 in compatible mode by default,
--echo # but use the default compiled values, or the values given in
--echo # --default-character-set=xxx. However, we should dump in UTF8
@@ -169,8 +172,8 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments test t1
--echo #
---echo # Bug#8063: make test mysqldump [ fail ]
---echo # We cannot tes this command because its output depends
+--echo # Bug#8063 make test mysqldump [ fail ]
+--echo # We cannot test this command because its output depends
--echo # on --default-character-set incompiled into "mysqldump" program.
--echo # If the future we can move this command into a separate test with
--echo # checking that "mysqldump" is compiled with "latin1"
@@ -183,7 +186,7 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
DROP TABLE t1;
--echo #
---echo # WL #2319: Exclude Tables from dump
+--echo # WL#2319 Exclude Tables from dump
--echo #
CREATE TABLE t1 (a int);
@@ -195,7 +198,7 @@ DROP TABLE t1;
DROP TABLE t2;
--echo #
---echo # Bug #8830
+--echo # Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values
--echo #
CREATE TABLE t1 (`b` blob);
@@ -207,7 +210,7 @@ DROP TABLE t1;
--echo # Test for --insert-ignore
--echo #
-CREATE TABLE t1 (a int) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 VALUES (4),(5),(6);
--exec $MYSQL_DUMP --skip-comments --insert-ignore test t1
@@ -215,9 +218,9 @@ INSERT INTO t1 VALUES (4),(5),(6);
DROP TABLE t1;
--echo #
---echo # Bug #10286: mysqldump -c crashes on table that has many fields with long
---echo # names
---echo #
+--echo # Bug#10286 mysqldump -c crashes on table that has many fields with long
+--echo # names
+--echo #
create table t1 (
F_c4ca4238a0b923820dcc509a6f75849b int,
F_c81e728d9d4c2f636f067f89cc14862c int,
@@ -563,7 +566,7 @@ INSERT INTO t1 VALUES (1),(2),(3);
DROP TABLE t1;
--echo #
---echo # Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
+--echo # Bug#9558 mysqldump --no-data db t1 t2 format still dumps data
--echo #
CREATE DATABASE mysqldump_test_db;
@@ -582,7 +585,7 @@ DROP DATABASE mysqldump_test_db;
--echo #
--echo # Testing with tables and databases that don't exists
--echo # or contains illegal characters
---echo # (Bug #9358 mysqldump crashes if tablename starts with \)
+--echo # (Bug#9358 mysqldump crashes if tablename starts with \)
--echo #
create database mysqldump_test_db;
use mysqldump_test_db;
@@ -601,7 +604,7 @@ select '------ Testing with illegal table names ------' as test_sequence ;
--error 6
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\t1" 2>&1
-
+
--error 6
--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\\\t1" 2>&1
@@ -644,7 +647,7 @@ use test;
--echo #
---echo # Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly
+--echo # Bug#9657 mysqldump xml ( -x ) does not format NULL fields correctly
--echo #
create table t1 (a int(10));
@@ -655,8 +658,9 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
--exec $MYSQL_DUMP --skip-comments --xml --no-create-info test
drop table t1, t2;
+
--echo #
---echo # BUG #12123
+--echo # Bug#12123 mysqldump --tab results in text file which can't be imported
--echo #
create table t1 (a text character set utf8, b text character set latin1);
@@ -669,14 +673,15 @@ select * from t1;
drop table t1;
+
--echo #
---echo # BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
+--echo # Bug#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
--echo #
--exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
--echo #
---echo # BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
+--echo # Bug#19025 mysqldump doesn't correctly dump "auto_increment = [int]"
--echo #
create table `t1` (
@@ -704,9 +709,11 @@ select * from t1;
show create table `t1`;
drop table `t1`;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug19025.sql
+
--echo #
---echo # Bug #18536: wrong table order
+--echo # Bug#18536 wrong table order
--echo #
create table t1(a int);
@@ -716,8 +723,9 @@ create table t3(a int);
--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
drop table t1, t2, t3;
+
--echo #
---echo # Bug #21288: mysqldump segmentation fault when using --where
+--echo # Bug#21288 mysqldump segmentation fault when using --where
--echo #
create table t1 (a int);
@@ -725,8 +733,9 @@ create table t1 (a int);
--exec $MYSQL_DUMP --skip-comments --force test t1 --where="xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 2>&1
drop table t1;
+
--echo #
---echo # BUG#13926: --order-by-primary fails if PKEY contains quote character
+--echo # Bug#13926 --order-by-primary fails if PKEY contains quote character
--echo #
--disable_warnings
@@ -746,8 +755,9 @@ DROP TABLE `t1`;
--echo End of 4.1 tests
+
--echo #
---echo # Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+--echo # Bug#10213 mysqldump crashes when dumping VIEWs(on MacOS X)
--echo #
create database db1;
@@ -770,8 +780,9 @@ drop view v2;
drop database db1;
use test;
+
--echo #
---echo # Bug 10713 mysqldump includes database in create view and referenced tables
+--echo # Bug#10713 mysqldump includes database in create view and referenced tables
--echo #
# create table and views in db2
@@ -805,10 +816,11 @@ select * from t2 order by a;
drop table t1, t2;
drop database db1;
use test;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug10713.sql
---echo #
---echo # dump of view
---echo #
+#
+# dump of view
+#
create table t1(a int);
create view v1 as select * from t1;
@@ -816,8 +828,9 @@ create view v1 as select * from t1;
drop view v1;
drop table t1;
+
--echo #
---echo # Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+--echo # Bug#10213 mysqldump crashes when dumping VIEWs(on MacOS X)
--echo #
create database mysqldump_test_db;
@@ -841,7 +854,7 @@ drop database mysqldump_test_db;
use test;
--echo #
---echo # Bug #9756
+--echo # Bug#9756 mysql client failing on dumps containing certain \ sequences
--echo #
CREATE TABLE t1 (a char(10));
@@ -850,7 +863,7 @@ INSERT INTO t1 VALUES ('\'');
DROP TABLE t1;
--echo #
---echo # Bug #10927 mysqldump: Can't reload dump with view that consist of other view
+--echo # Bug#10927 mysqldump: Can't reload dump with view that consist of other view
--echo #
create table t1(a int, b int, c varchar(30));
@@ -922,7 +935,9 @@ show triggers;
DROP TABLE t1, t2;
--echo #
---echo # Bugs #9136, #12917: problems with --defaults-extra-file option
+--echo # Bug#9136 my_print_defaults changed behaviour between 4.1.7 and 4.1.10a
+--echo # Bug#12917 The --defaults-extra-file option is ignored by the 5.0 client binaries
+--echo # (Problems with --defaults-extra-file option)
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp.cnf
@@ -934,7 +949,7 @@ EOF
--remove_file $MYSQLTEST_VARDIR/tmp/tmp.cnf
--echo #
---echo # Test of fix to BUG 12597
+--echo # Test of fix to Bug#12597 mysqldump dumps triggers wrongly
--echo #
DROP TABLE IF EXISTS `test1`;
@@ -970,9 +985,11 @@ SELECT * FROM `test2`;
DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqldump.sql
+
--echo #
---echo # BUG#9056 - mysqldump does not dump routines
+--echo # Bug#9056 mysqldump does not dump routines
--echo #
--disable_warnings
@@ -998,9 +1015,9 @@ begin
return f1;
end //
-CREATE PROCEDURE bug9056_proc2(OUT a INT)
-BEGIN
- select sum(id) from t1 into a;
+CREATE PROCEDURE bug9056_proc2(OUT a INT)
+BEGIN
+ select sum(id) from t1 into a;
END //
DELIMITER ;//
@@ -1009,7 +1026,7 @@ set sql_mode='ansi';
create procedure `a'b` () select 1; # to fix syntax highlighting :')
set sql_mode='';
-# Dump the DB and ROUTINES
+# Dump the DB and ROUTINES
--exec $MYSQL_DUMP --skip-comments --routines --databases test
# ok, now blow it all away
@@ -1020,8 +1037,9 @@ DROP PROCEDURE bug9056_proc2;
DROP PROCEDURE `a'b`;
drop table t1;
+
--echo #
---echo # BUG# 13052 - mysqldump timestamp reloads broken
+--echo # Bug#13052 mysqldump timestamp reloads broken
--echo #
--disable_warnings
@@ -1044,7 +1062,7 @@ set global time_zone=default;
set time_zone=default;
--echo #
---echo # Test of fix to BUG 13146 - ansi quotes break loading of triggers
+--echo # Test of fix to Bug#13146 ansi quotes break loading of triggers
--echo #
--disable_warnings
@@ -1069,7 +1087,7 @@ INSERT INTO `t1 test` VALUES (1);
INSERT INTO `t1 test` VALUES (2);
INSERT INTO `t1 test` VALUES (3);
SELECT * FROM `t2 test`;
-# dump with compatible=ansi. Everything except triggers should be double
+# dump with compatible=ansi. Everything except triggers should be double
# quoted
--exec $MYSQL_DUMP --skip-comments --compatible=ansi --triggers test
@@ -1078,7 +1096,7 @@ DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
--echo #
---echo # BUG# 12838 mysqldump -x with views exits with error
+--echo # Bug#12838 mysqldump -x with views exits with error
--echo #
--disable_warnings
@@ -1095,13 +1113,14 @@ create view v2 as select * from v0;
select * from v2;
--exec $MYSQL_DUMP -x --skip-comments --databases test
+
drop view v2;
drop view v0;
drop view v1;
drop table t1;
--echo #
---echo # BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
+--echo # Bug#14554 mysqldump does not separate words "ROW" and "BEGIN"
--echo # for tables with trigger created in the IGNORE_SPACE sql mode.
--echo #
@@ -1125,8 +1144,8 @@ DROP TRIGGER tr1;
DROP TABLE t1;
--echo #
---echo # Bug #13318: Bad result with empty field and --hex-blob
---echo #
+--echo # Bug#13318 Bad result with empty field and --hex-blob
+--echo #
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
@@ -1135,7 +1154,7 @@ insert into t1 values ('','');
drop table t1;
--echo #
---echo # Bug 14871 Invalid view dump output
+--echo # Bug#14871 Invalid view dump output
--echo #
create table t1 (a int);
@@ -1162,9 +1181,11 @@ select * from v3 order by a;
drop table t1;
drop view v1, v2, v3, v4, v5;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug14871.sql
+
--echo #
---echo # Bug #16878 dump of trigger
+--echo # Bug#16878 dump of trigger
--echo #
create table t1 (a int, created datetime);
@@ -1192,6 +1213,8 @@ show triggers;
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug16878.sql
+
--echo #
--echo # Bug#18462 mysqldump does not dump view structures correctly
@@ -1211,11 +1234,15 @@ create view v2 as select qty from v1;
drop view v1;
drop view v2;
drop table t;
+--remove_file $MYSQLTEST_VARDIR/tmp/v1.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/v2.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/t.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/t.txt
--echo #
--echo # Bug#14857 Reading dump files with single statement stored routines fails.
---echo # fixed by patch for bug#16878
+--echo # fixed by patch for Bug#16878
--echo #
DELIMITER |;
@@ -1230,7 +1257,7 @@ drop function f;
drop procedure p;
--echo #
---echo # Bug #17371 Unable to dump a schema with invalid views
+--echo # Bug#17371 Unable to dump a schema with invalid views
--echo #
create table t1 ( id serial );
@@ -1243,7 +1270,8 @@ drop table t1;
--echo } mysqldump
drop view v1;
---echo # BUG#17201 Spurious 'DROP DATABASE' in output,
+
+--echo # Bug#17201 Spurious 'DROP DATABASE' in output,
--echo # also confusion between tables and views.
--echo # Example code from Markus Popp
@@ -1260,8 +1288,9 @@ drop view v1;
drop table t1;
drop database mysqldump_test_db;
+
--echo #
---echo # Bug21014 Segmentation fault of mysqldump on view
+--echo # Bug#21014 Segmentation fault of mysqldump on view
--echo #
create database mysqldump_tables;
@@ -1280,7 +1309,7 @@ drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
--echo #
---echo # Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
+--echo # Bug#20221 Dumping of multiple databases containing view(s) yields maleformed dumps
--echo #
create database mysqldump_dba;
@@ -1318,6 +1347,7 @@ use mysqldump_dbb;
drop view v1;
drop table t1;
drop database mysqldump_dbb;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug20221_backup
use test;
--echo #
@@ -1364,11 +1394,12 @@ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1;
drop user mysqltest_1@localhost;
+
--echo #
---echo # Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
---echo # information_schema database.
+--echo # Bug#21527 mysqldump incorrectly tries to LOCK TABLES on the
+--echo # information_schema database.
--echo #
---echo # Bug #21424 mysqldump failing to export/import views
+--echo # Bug#21424 mysqldump failing to export/import views
--echo #
# Do as root
@@ -1389,7 +1420,7 @@ create table u1 (f1 int);
insert into u1 values (4);
create view v1 (c1) as select * from t1;
-# Backup should not fail for Bug #21527. Flush priviliges test begins.
+# Backup should not fail for Bug#21527. Flush priviliges test begins.
--exec $MYSQL_DUMP --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql
# Clean up
@@ -1403,8 +1434,9 @@ drop user myDB_User@localhost;
drop database mysqldump_myDB;
flush privileges;
---echo # Bug #21424 continues from here.
---echo # Restore. Flush Privileges test ends.
+
+--echo # Bug#21424 continues from here.
+--echo # Restore. Flush Privileges test ends.
--echo #
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21527.sql
@@ -1417,8 +1449,9 @@ use mysqldump_myDB;
select * from mysqldump_myDB.v1;
select * from mysqldump_myDB.u1;
-#Final cleanup.
+# Final cleanup.
connection root;
+disconnect user1;
use mysqldump_myDB;
drop view v1;
drop table t1;
@@ -1426,10 +1459,14 @@ drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User@localhost;
drop database mysqldump_myDB;
+connection default;
+disconnect root;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug21527.sql
use test;
+
--echo #
---echo # Bug #19745: mysqldump --xml produces invalid xml
+--echo # Bug#19745 mysqldump --xml produces invalid xml
--echo #
--disable_warnings
@@ -1444,9 +1481,8 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
DROP TABLE t1;
-
--echo #
---echo # Bug#26346: stack + buffer overrun in mysqldump
+--echo # Bug#26346 stack + buffer overrun in mysqldump
--echo #
CREATE TABLE t1(a int);
@@ -1468,17 +1504,18 @@ INSERT INTO t1 VALUES (1), (2);
DROP TABLE t1;
#
-# Bug #25993: crashe with a merge table and -c
+# Bug #25993 crashes with a merge table and -c
#
-CREATE TABLE t2 (a int) ENGINE=MyISAM;
-CREATE TABLE t3 (a int) ENGINE=MyISAM;
-CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3);
+CREATE TABLE t2 (a INT) ENGINE=MyISAM;
+CREATE TABLE t3 (a INT) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
--exec $MYSQL_DUMP --skip-comments -c test
DROP TABLE t1, t2, t3;
+
--echo #
---echo # Bug #23491: MySQLDump prefix function call in a view by database name
+--echo # Bug#23491 MySQLDump prefix function call in a view by database name
--echo #
# Setup
@@ -1508,13 +1545,16 @@ show create view bug23491_restore.v3;
drop database bug23491_original;
drop database bug23491_restore;
use test;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql
+
---echo #
---echo # Bug 27293: mysqldump crashes when dumping routines
---echo # defined by a different user
+
+--echo #
+--echo # Bug#27293 mysqldump crashes when dumping routines
+--echo # defined by a different user
--echo #
---echo # Bug #22761: mysqldump reports no errors when using
---echo # --routines without mysql.proc privileges
+--echo # Bug#22761 mysqldump reports no errors when using
+--echo # --routines without mysql.proc privileges
--echo #
create database mysqldump_test_db;
@@ -1535,13 +1575,14 @@ create procedure mysqldump_test_db.sp1() select 'hello';
drop procedure sp1;
connection default;
+disconnect user27293;
drop user user1;
drop user user2;
drop database mysqldump_test_db;
--echo #
---echo # Bug #28522: buffer overrun by '\0' byte using --hex-blob.
+--echo # Bug#28522 buffer overrun by '\0' byte using --hex-blob.
--echo #
CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
@@ -1550,8 +1591,8 @@ INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
DROP TABLE t1;
--echo #
---echo # Bug #28524: mysqldump --skip-add-drop-table is not
---echo # compatible with views
+--echo # Bug#28524 mysqldump --skip-add-drop-table is not
+--echo # compatible with views
--echo #
CREATE VIEW v1 AS SELECT 1;
@@ -1561,10 +1602,12 @@ DROP VIEW v1;
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug28524.sql
SELECT * FROM v1;
DROP VIEW v1;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug28524.sql
+
--echo #
---echo # Bug #29788: mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
---echo # the SQL_MODE variable after the dumping of triggers.
+--echo # Bug#29788 mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
+--echo # the SQL_MODE variable after the dumping of triggers.
--echo #
CREATE TABLE t1 (c1 INT);
@@ -1583,10 +1626,12 @@ SELECT * FROM t2;
SELECT * FROM t2;
DROP TABLE t1,t2;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug29788.sql
+
--echo #
---echo # Bug#29815: new option for suppressing last line of mysqldump:
---echo # "Dump completed on"
+--echo # Bug#29815 new option for suppressing last line of mysqldump:
+--echo # "Dump completed on"
--echo #
--echo # --skip-dump-date:
@@ -1623,7 +1668,7 @@ DROP TABLE t1;
# Added for use-thread option
#
-# THIS PART OF THE TEST IS DISABLED UNTIL BUG#32991 IS FIXED
+# THIS PART OF THE TEST IS DISABLED UNTIL Bug#32991 IS FIXED
if ($bug32991_fixed) {
create table t1 (a text , b text);
@@ -1666,7 +1711,7 @@ drop table words2;
}
--echo #
---echo # BUG# 16853: mysqldump doesn't show events
+--echo # Bug#16853 mysqldump doesn't show events
--echo #
create database first;
@@ -1685,6 +1730,7 @@ use second;
--exec $MYSQL second < $MYSQLTEST_VARDIR/tmp/bug16853-1.sql
show events;
show create event ee1;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug16853-1.sql
## prove three works (with spaces and tabs on the end)
# start with one from the previous restore
@@ -1699,13 +1745,14 @@ use third;
--exec $MYSQL third < $MYSQLTEST_VARDIR/tmp/bug16853-2.sql
show events;
drop database third;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug16853-2.sql
# revert back to normal settings
set time_zone = 'SYSTEM';
use test;
--echo #
---echo # BUG#17201 Spurious 'DROP DATABASE' in output,
+--echo # Bug#17201 Spurious 'DROP DATABASE' in output,
--echo # also confusion between tables and views.
--echo # Example code from Markus Popp
--echo #
@@ -1724,7 +1771,7 @@ drop table t1;
drop database mysqldump_test_db;
#
-# BUG#26121 mysqldump includes LOCK TABLES general_log WRITE
+# Bug#26121 mysqldump includes LOCK TABLES general_log WRITE
#
--exec $MYSQL_DUMP --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql
@@ -1733,8 +1780,8 @@ drop database mysqldump_test_db;
###########################################################################
--echo #
---echo # Bug #30027: mysqldump does not dump views properly.
---echo #
+--echo # Bug#30027 mysqldump does not dump views properly.
+--echo #
--echo
--echo # Cleanup.
@@ -1784,12 +1831,13 @@ set names latin1;
--echo # Cleanup.
DROP DATABASE mysqldump_test_db;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug30027.sql
###########################################################################
--echo #
---echo # BUG#29938: wrong behavior of mysqldump --skip-events
---echo # with --all-databases
+--echo # Bug#29938 wrong behavior of mysqldump --skip-events
+--echo # with --all-databases
--echo #
TRUNCATE mysql.event;
@@ -1802,6 +1850,7 @@ SHOW EVENTS;
TRUNCATE mysql.event;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql
SHOW EVENTS;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug29938.sql
--echo #
@@ -1818,7 +1867,7 @@ use test;
--echo
--echo # -----------------------------------------------------------------
---echo # -- Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1.
+--echo # -- Bug#30217 Views: changes in metadata behaviour between 5.0 and 5.1.
--echo # -----------------------------------------------------------------
--echo
@@ -1863,6 +1912,7 @@ WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
--echo
DROP DATABASE mysqldump_test_db;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug30217.sql
--echo
--echo # -- End of test case for Bug#32538.
@@ -1877,3 +1927,6 @@ SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
--echo #
--echo # End of 5.1 tests
--echo #
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index ddf6b8870fa..2878b54c357 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -61,9 +61,7 @@ drop table t1;
#
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
---error 1048
UPDATE t1 SET d=1/NULL;
---error 1048
UPDATE t1 SET d=NULL;
--error 1048
INSERT INTO t1 (a) values (null);
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index e31e0a6199a..240a977fdca 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -3,6 +3,10 @@
--source include/have_ssl.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -21,38 +25,42 @@ connect (con2,localhost,ssl_user2,,,,,SSL);
connect (con3,localhost,ssl_user3,,,,,SSL);
connect (con4,localhost,ssl_user4,,,,,SSL);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (con5,localhost,ssl_user5,,,,,SSL);
connection con1;
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
select * from t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete from t1;
connection con2;
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
select * from t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete from t1;
connection con3;
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
select * from t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete from t1;
connection con4;
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
select * from t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete from t1;
connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+disconnect con4;
drop user ssl_user1@localhost, ssl_user2@localhost,
ssl_user3@localhost, ssl_user4@localhost, ssl_user5@localhost;
@@ -97,7 +105,7 @@ drop table t1;
--exec $MYSQL_TEST --ssl-cert= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
#
-# BUG#21611 Slave can't connect when master-ssl-cipher specified
+# Bug#21611 Slave can't connect when master-ssl-cipher specified
# - Apparently selecting a cipher doesn't work at all
# - Usa a cipher that both yaSSL and OpenSSL supports
#
@@ -115,7 +123,7 @@ drop table t1;
--echo End of 5.0 tests
#
-# Bug #26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS in
+# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS in
# Event (see also information_schema.test for the other part of test for
# this bug).
#
@@ -171,7 +179,7 @@ SET GLOBAL event_scheduler=0;
--exec $MYSQL_TEST --ssl-cipher=UNKNOWN-CIPHER < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
#
-# Bug #27669 mysqldump: SSL connection error when trying to connect
+# Bug#27669 mysqldump: SSL connection error when trying to connect
#
CREATE TABLE t1(a int);
@@ -190,10 +198,11 @@ INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1
DROP TABLE t1;
+--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
#
-# Bug#39172: Asking for DH+non-RSA key with server set to use other key caused
-# YaSSL to crash the server.
+# Bug#39172 Asking for DH+non-RSA key with server set to use other key caused
+# YaSSL to crash the server.
#
# Common ciphers to openssl and yassl
@@ -231,3 +240,6 @@ select 'is still running; no cipher request crashed the server' as result from d
##
--echo End of 5.1 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
index 57399e16bef..45b13f141f7 100644
--- a/mysql-test/t/outfile.test
+++ b/mysql-test/t/outfile.test
@@ -5,6 +5,10 @@ eval set @tmpdir="../../tmp";
enable_query_log;
-- source include/have_outfile.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
#
# test of into outfile|dumpfile
#
@@ -46,7 +50,7 @@ select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.3
drop table t1;
-# Bug#8191
+# Bug#8191 SELECT INTO OUTFILE insists on FROM clause
disable_query_log;
eval select 1 into outfile "../../tmp/outfile-test.4";
enable_query_log;
@@ -54,11 +58,11 @@ select load_file(concat(@tmpdir,"/outfile-test.4"));
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
#
-# Bug #5382: 'explain select into outfile' crashes the server
+# Bug#5382 'explain select into outfile' crashes the server
#
CREATE TABLE t1 (a INT);
-EXPLAIN
+EXPLAIN
SELECT *
INTO OUTFILE '/tmp/t1.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
@@ -68,7 +72,7 @@ DROP TABLE t1;
# End of 4.1 tests
#
-# Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
+# Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
#
disable_query_log;
eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4"
@@ -114,6 +118,7 @@ from information_schema.schemata
where schema_name like 'mysqltest';
connection default;
+disconnect con28181_1;
grant file on *.* to user_1@localhost;
connect (con28181_2,localhost,user_1,,mysqltest);
@@ -125,9 +130,12 @@ from information_schema.schemata
where schema_name like 'mysqltest';
connection default;
+disconnect con28181_2;
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
use test;
revoke all privileges on *.* from user_1@localhost;
drop user user_1@localhost;
drop database mysqltest;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index f487f0695a3..69ae56ff9a2 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -4,6 +4,9 @@
# embedded server causes different stat
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
# Disable concurrent inserts to avoid sporadic test failures as it might
# affect the the value of variables used throughout the test case.
set @old_concurrent_insert= @@global.concurrent_insert;
@@ -88,7 +91,7 @@ show status like 'last_query_cost';
drop table t1;
#
-# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
+# Test for Bug#15933 max_used_connections is wrong after FLUSH STATUS
# if connections are cached
#
#
@@ -188,7 +191,7 @@ disconnect con1;
#
-# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
+# Bug#30377 EXPLAIN loses last_query_cost when used with UNION
#
CREATE TABLE t1 ( a INT );
@@ -241,7 +244,7 @@ eval select substring_index('$rnd_next2',0x9,-1)-substring_index('$rnd_next',0x9
disconnect con1;
connection default;
-#
+#
# Bug#30252 Com_create_function is not incremented.
#
flush status;
@@ -261,7 +264,7 @@ drop function f1;
show status like 'Com%function';
#
-# Bug#37908: Skipped access right check caused server crash.
+# Bug#37908 Skipped access right check caused server crash.
#
connect (root, localhost, root,,test);
connection root;
@@ -273,20 +276,20 @@ insert into db37908.t1 values(1);
grant usage,execute on test.* to mysqltest_1@localhost;
delimiter |;
create procedure proc37908() begin select 1; end |
-create function func37908() returns int sql security invoker
+create function func37908() returns int sql security invoker
return (select * from db37908.t1 limit 1)|
delimiter ;|
-
+
connect (user1,localhost,mysqltest_1,,test);
connection user1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from db37908.t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show status where variable_name ='uptime' and 2 in (select * from db37908.t1);
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t1);
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show function status where name ='func37908' and 1 in (select func37908());
connection default;
@@ -297,6 +300,8 @@ drop procedure proc37908;
drop function func37908;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
DROP USER mysqltest_1@localhost;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
#
# Bug#41131 "Questions" fails to increment - ignores statements instead stored procs
@@ -339,3 +344,7 @@ DROP FUNCTION f1;
# Restore global concurrent_insert value. Keep in the end of the test file.
--connection default
set @@global.concurrent_insert= @old_concurrent_insert;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 4074317f38a..12421170eba 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -65,7 +65,6 @@ create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
alter table t1 modify c char(4);
alter table t1 add d char(2);
---error 1048
update t1 set a=NULL where a=10;
update t1 set c='mysql ab' where c='test';
update t1 set d=c;
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index d840e14ba5f..74bce8dc962 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -575,5 +575,19 @@ SELECT ExtractValue(@xml, 'html/body');
SELECT ExtractValue('<xml "xxx" "yyy">CharData</xml>', '/xml');
SELECT ExtractValue('<xml xxx "yyy">CharData</xml>', '/xml');
+#
+# Bug#42495 updatexml: Assertion failed: xpath->context, file .\item_xmlfunc.cc, line 2507
+#
+set @x=10;
+--error ER_UNKNOWN_ERROR
+select extractvalue('<a></a>','$@x/a');
+--error ER_UNKNOWN_ERROR
+select extractvalue('<a></a>','round(123.4)/a');
+--error ER_UNKNOWN_ERROR
+select extractvalue('<a></a>','1/a');
+--error ER_UNKNOWN_ERROR
+select extractvalue('<a></a>','"b"/a');
+--error ER_UNKNOWN_ERROR
+select extractvalue('<a></a>','(1)/a');
--echo End of 5.1 tests
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 81abbde96df..7f9850ac94d 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -19,6 +19,10 @@
#include <stdarg.h>
#include <m_ctype.h>
+/* Max length of a error message. Should be kept in sync with MYSQL_ERRMSG_SIZE. */
+#define ERRMSGSIZE (512)
+
+
/* Define some external variables for error handling */
/*
@@ -30,8 +34,6 @@
my_printf_error(ER_CODE, format, MYF(N), ...)
*/
-char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
-
/*
Message texts are registered into a linked list of 'my_err_head' structs.
Each struct contains (1.) an array of pointers to C character strings with
@@ -75,7 +77,7 @@ int my_error(int nr, myf MyFlags, ...)
const char *format;
struct my_err_head *meh_p;
va_list args;
- char ebuff[ERRMSGSIZE + 20];
+ char ebuff[ERRMSGSIZE];
DBUG_ENTER("my_error");
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno));
@@ -112,7 +114,7 @@ int my_error(int nr, myf MyFlags, ...)
int my_printf_error(uint error, const char *format, myf MyFlags, ...)
{
va_list args;
- char ebuff[ERRMSGSIZE+20];
+ char ebuff[ERRMSGSIZE];
DBUG_ENTER("my_printf_error");
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d format: %s",
error, MyFlags, errno, format));
diff --git a/mysys/my_init.c b/mysys/my_init.c
index e05536bf3ea..cfa63f229d7 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -157,9 +157,11 @@ void my_end(int infoflag)
{ /* Test if some file is left open */
if (my_file_opened | my_stream_opened)
{
- sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
- (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
- DBUG_PRINT("error",("%s",errbuff[0]));
+ char ebuff[512];
+ my_snprintf(ebuff, sizeof(ebuff), EE(EE_OPEN_WARNING),
+ my_file_opened, my_stream_opened);
+ my_message_no_curses(EE_OPEN_WARNING, ebuff, ME_BELL);
+ DBUG_PRINT("error", ("%s", ebuff));
my_print_open_files();
}
}
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index 59bc4e73af7..f507a072b69 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -147,7 +147,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
error_handler_hook=fatal_error_handler_hook;
if (MyFlags & (MY_FAE+MY_WME))
{
- char buff[SC_MAXWIDTH];
+ char buff[256];
my_errno=errno;
sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index a9ff1b05881..3eabde85a58 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -1375,7 +1375,8 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
/* Upgrade a WRITE_DELAY lock to a WRITE_LOCK */
-my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
+my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
+ enum thr_lock_type new_lock_type)
{
THR_LOCK *lock=data->lock;
DBUG_ENTER("thr_upgrade_write_delay_lock");
@@ -1388,7 +1389,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
}
check_locks(lock,"before upgrading lock",0);
/* TODO: Upgrade to TL_WRITE_CONCURRENT_INSERT in some cases */
- data->type=TL_WRITE; /* Upgrade lock */
+ data->type= new_lock_type; /* Upgrade lock */
/* Check if someone has given us the lock */
if (!data->cond)
@@ -1427,6 +1428,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
{
THR_LOCK *lock=data->lock;
+ enum thr_lock_type write_lock_type;
DBUG_ENTER("thr_reschedule_write_lock");
pthread_mutex_lock(&lock->mutex);
@@ -1436,6 +1438,7 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
DBUG_RETURN(0);
}
+ write_lock_type= data->type;
data->type=TL_WRITE_DELAYED;
if (lock->update_status)
(*lock->update_status)(data->status_param);
@@ -1454,7 +1457,7 @@ my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
free_all_read_locks(lock,0);
pthread_mutex_unlock(&lock->mutex);
- DBUG_RETURN(thr_upgrade_write_delay_lock(data));
+ DBUG_RETURN(thr_upgrade_write_delay_lock(data, write_lock_type));
}
diff --git a/netware/BUILD/nwbootstrap b/netware/BUILD/nwbootstrap
deleted file mode 100755
index 4dc2ea6fa37..00000000000
--- a/netware/BUILD/nwbootstrap
+++ /dev/null
@@ -1,196 +0,0 @@
-#! /bin/sh
-
-# debug
-#set -x
-
-# stop on errors
-set -e
-
-path=`dirname $0`
-
-# repository direcotry
-repo_dir=`pwd`
-
-# build directory
-build_dir="$HOME/mydev"
-wine_build_dir="F:/mydev"
-
-# doc directory
-doc_dir="$repo_dir/../mysqldoc"
-
-# init
-target_dir=""
-temp_dir=""
-revision=""
-rev=""
-build=""
-suffix=""
-#obsolete mwenv=""
-
-# show usage
-show_usage()
-{
- cat << EOF
-
-usage: nwbootstrap [options]
-
-Exports a revision of the BitKeeper tree (nwbootstrap must be run inside a
-directory of the BitKeeper tree to be used). Creates the ChangeLog file.
-Adds the latest manual.texi from the mysqldoc BitKeeper tree. Builds the
-Linux tools required for cross-platform builds. Optionally, builds the
-binary distributions for NetWare.
-
-options:
-
---build=<opt> Build the binary distributions for NetWare,
- where <opt> is "standard", "debug", or "all"
- (default is to not build a binary distribution)
-
---build-dir=<dir> Export the BitKeeper tree to the <dir> directroy
- (default is "$build_dir")
-
---doc-dir=<dir> Use the mysqldoc BitKeeper tree located in the
- <dir> directory
- (default is parallel to current BitKeeper tree)
-
---help Show this help information
-
---revision=<rev> Export the BitKeeper tree as of revision <rev>
- (default is the latest revision)
-
---wine-build-dir=<dir> Use the WINE directory <dir>, which should
- correspond to the --build-dir directory
- (default is "$wine_build_dir")
-
-examples:
-
- nwbootstrap
-
- nwbootstrap --revision=1.1594 --build=all
-
- nwbootstrap --build-dir=/home/jdoe/dev --wine-build-dir=F:/dev
-
-
-EOF
- exit 0;
-}
-
-# parse arguments
-for arg do
- case "$arg" in
- --build-dir=*) build_dir=`echo "$arg" | sed -e "s;--build-dir=;;"` ;;
- --wine-build-dir=*) wine_build_dir=`echo "$arg" | sed -e "s;--wine-build-dir=;;"` ;;
- --revision=*) revision=`echo "$arg" | sed -e "s;--revision=;;"` ;;
- --build=*) build=`echo "$arg" | sed -e "s;--build=;;"` ;;
- --suffix=*) suffix=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
- --doc-dir=*) doc_dir=`echo "$arg" | sed -e "s;--doc-dir=;;"` ;;
- *) show_usage ;;
- esac
-done
-
-echo "starting build..."
-
-# check for bk and repo_dir
-bzr help > /dev/null
-repo_dir=`bzr root $repo_dir`
-cd $repo_dir
-doc_dir="$repo_dir/../mysqldoc"
-
-# build temporary directory
-temp_dir="$build_dir/mysql-$$.tmp"
-
-# export the bk tree
-command="bzr export";
-if test $revision; then command="$command -r$revision"; fi
-command="$command $temp_dir"
-echo "exporting $repo_dir..."
-$command
-
-# determine version
-version=`grep -e "AM_INIT_AUTOMAKE(mysql, .*)" < $temp_dir/configure.in | sed -e "s/AM_INIT_AUTOMAKE(mysql, \(.*\))/\1/"`
-echo "version: $version"
-
-# build target directory
-target_dir="$build_dir/mysql-$version"
-
-# add suffix
-if test $suffix
-then
- target_dir="$target_dir-$suffix"
-fi
-
-# delete any old target
-if test -d $target_dir.old; then rm -rf $target_dir.old; fi
-
-# rename old target
-if test -d $target_dir; then mv -f $target_dir $target_dir.old; fi
-
-# rename directory to use version
-mv $temp_dir $target_dir
-
-# create ChangeLog
-if test $revision
-then
- rev=`bk changes -r..$revision -t -d':REV:' -n | head -2 | tail -1`
-else
- rev=`bk changes -t -d':REV:' -n | head -1`
-fi
-
-echo "creating ChangeLog..."
-bk changes -v -r$rev..$revision > $target_dir/ChangeLog
-
-# add the latest manual
-if test -d $doc_dir
-then
- echo "adding the latest manual..."
- install -m 644 $doc_dir/Docs/{manual,reservedwords}.texi $target_dir/Docs/
-fi
-
-# make files writeable
-echo "making files writable..."
-cd $target_dir
-chmod -R u+rw,g+rw .
-
-#obsolete # edit the mvenv file
-#obsolete echo "updating the mwenv environment file..."
-#obsolete mwenv="./netware/BUILD/mwenv"
-#obsolete mv -f $mwenv $mwenv.org
-#obsolete sed -e "s;WINE_BUILD_DIR;$wine_build_dir;g" \
-#obsolete -e "s;BUILD_DIR;$build_dir;g" \
-#obsolete -e "s;VERSION;$version;g" $mwenv.org > $mwenv
-#obsolete chmod +rwx $mwenv
-#obsolete
-#obsolete PWD=`pwd`
-#obsolete # This line will catch the default value only, let's hope it is correct
-#obsolete SRC_DIR=`grep "^ *export MYDEV=" $mwenv | cut -d'=' -f2 | \
-#obsolete sed -e 's;";;g' -e "s;^;echo ;g" -e "s;$;/\`basename $PWD\`;g" | /bin/sh`
-
-# edit the def file versions
-echo "updating *.def file versions..."
-nlm_version=`echo "$version" | sed -e "s;\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*;\1, \2, \3;"`
-
-for file in ./netware/*.def
-do
- mv -f $file $file.org
- sed -e "s;VERSION.*;VERSION $nlm_version;g" $file.org > $file
- rm $file.org
-done
-
-# create the libmysql.imp file in netware folder from libmysql/libmysql.def
-# file
-echo "generating libmysql.imp file..."
-awk 'BEGIN{x=0;} END{printf("\n");} x==1 {printf(" %s",$1); x++; next} x>1 {printf(",\n %s", $1);next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp
-# build linux tools
-echo "compiling linux tools..."
-./netware/BUILD/compile-linux-tools
-test -f ./netware/init_db.sql # this must exist
-test -f ./netware/test_db.sql # this must exist
-
-# compile
-if test $build
-then
- echo "compiling $build..."
- ./netware/BUILD/compile-netware-$build
-fi
-
-echo "done"
diff --git a/netware/BUILD/nwbuild b/netware/BUILD/nwbuild
new file mode 100755
index 00000000000..d431f70add8
--- /dev/null
+++ b/netware/BUILD/nwbuild
@@ -0,0 +1,86 @@
+#! /bin/sh
+
+# This script builds a Netware binary from a MySQL source tarball
+
+# debug
+#set -x
+
+# stop on errors
+set -e
+
+# init
+build=""
+
+# show usage
+show_usage()
+{
+ cat << EOF
+
+usage: nwbuild [options]
+
+Build Netware binary from source .tar.gz
+
+options:
+
+--build=<opt> Build the binary distributions for NetWare,
+ where <opt> is "standard", "debug", or "all"
+ (default is to not build a binary distribution)
+
+--help Show this help information
+
+Examples:
+
+ ./netware/BUILD/nwbuild --build=debug
+ ./netware/BUILD/nwbuild --build=standard
+
+EOF
+}
+
+# parse arguments
+for arg do
+ case "$arg" in
+ --build=*) build=`echo "$arg" | sed -e "s;--build=;;"` ;;
+ --help) show_usage; exit 0 ;;
+ *) show_usage >&2; exit 1 ;;
+ esac
+done
+
+# determine version
+version=`grep -e "AM_INIT_AUTOMAKE(mysql, .*)" < configure.in | sed -e "s/AM_INIT_AUTOMAKE(mysql, \(.*\))/\1/"`
+echo "version: $version"
+
+# make files writeable
+echo "making files writable..."
+chmod -R u+rw,g+rw .
+
+# edit the def file versions
+nlm_version=`echo "$version" | sed -e "s;\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*;\1, \2, \3;"`
+echo "updating *.def file versions to $nlm_version..."
+
+for file in ./netware/*.def
+do
+ mv -f $file $file.org
+ sed -e "s;VERSION.*;VERSION $nlm_version;g" $file.org > $file
+ rm $file.org
+done
+
+# create the libmysql.imp file in netware folder from libmysql/libmysql.def
+# file
+echo "generating libmysql.imp file..."
+awk 'BEGIN{x=0;} END{printf("\n");} x==1 {printf(" %s",$1); x++; next} x>1 {printf(",\n %s", $1);next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp
+# build linux tools
+echo "compiling linux tools..."
+./netware/BUILD/compile-linux-tools
+test -f ./netware/init_db.sql # this must exist
+test -f ./netware/test_db.sql # this must exist
+
+# compile
+if test $build
+then
+ echo "compiling $build..."
+ ./netware/BUILD/compile-netware-$build
+else
+ echo "Preparation complete. Use ./netware/BUILD/compile-netware-* to build MySQL."
+fi
+
+echo "done"
diff --git a/netware/Makefile.am b/netware/Makefile.am
index 0b30da17609..3d0402ce714 100644
--- a/netware/Makefile.am
+++ b/netware/Makefile.am
@@ -94,7 +94,7 @@ EXTRA_DIST= $(BUILT_SOURCES) comp_err.def install_test_db.ncf \
BUILD/compile-netware-standard BUILD/create-patch \
BUILD/cron-build BUILD/crontab BUILD/knetware.imp \
BUILD/mwasmnlm BUILD/mwccnlm BUILD/mwenv BUILD/mwldnlm \
- BUILD/nwbootstrap BUILD/openssl.imp BUILD/save-patch
+ BUILD/nwbuild BUILD/openssl.imp BUILD/save-patch
endif
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 339b2a4c219..ee7c36b097d 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -60,13 +60,16 @@ STRIP=1 # Option ignored
SILENT=0
PLATFORM=""
TMP=/tmp
+NEW_NAME="" # Final top directory and TAR package name
SUFFIX=""
+SHORT_PRODUCT_TAG="" # If don't want server suffix in package name
NDBCLUSTER="" # Option ignored
for arg do
case "$arg" in
--tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
--suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
+ --short-product-tag=*) SHORT_PRODUCT_TAG=`echo "$arg" | sed -e "s;--short-product-tag=;;"` ;;
--no-strip) STRIP=0 ;;
--machine=*) machine=`echo "$arg" | sed -e "s;--machine=;;"` ;;
--platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;;
@@ -113,7 +116,11 @@ case $PLATFORM in
esac
# Change the distribution to a long descriptive name
-NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX
+if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then
+ NEW_NAME=mysql-$SHORT_PRODUCT_TAG-@VERSION@-$PLATFORM$SUFFIX
+else
+ NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX
+fi
# ----------------------------------------------------------------------
# Define BASE, and remove the old BASE directory if any
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 3cb4665eb1c..631e1e38cc7 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -293,7 +293,12 @@ sub start_mysqlds()
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
{
+ # Defaults are made explicit parameters to server execution...
@options = defaults_for_group($groups[$i]);
+ # ...so server MUST NOT try to read again from some config file, especially
+ # as the "right" file may be unknown to the server if we are using
+ # --defaults-file=... params in here.
+ unshift(@options,"--no-defaults");
$mysqld_found= 1; # The default
$mysqld_found= 0 if (!length($mysqld));
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index a728086760a..588e518a648 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -47,7 +47,7 @@ $opt_machine=""; $opt_suffix="";
$opt_create_options=undef;
$opt_optimization="None";
$opt_hw="";
-$opt_threads=5;
+$opt_threads=-1;
if (!defined($opt_time_limit))
{
@@ -68,6 +68,11 @@ $limits=merge_limits($server,$opt_cmp);
$date=date();
@estimated=(0.0,0.0,0.0); # For estimated time support
+if ($opt_threads != -1)
+{
+ print "WARNING: Option --threads is deprecated and has no effect\n"
+}
+
if ($opt_hires)
{
eval "use Time::HiRes;";
@@ -560,8 +565,8 @@ All benchmarks takes the following options:
Inform test suite that we are generate random inital values for sequence of
test executions. It should be used for imitation of real conditions.
---threads=# (Default 5)
- Number of threads for multi-user benchmarks.
+--threads=# **DEPRECATED**
+ This option has no effect, and will be removed in a future version.
--tcpip
Inform test suite that we are using TCP/IP to connect to the server. In
diff --git a/sql/item.cc b/sql/item.cc
index f74d8df1045..1ecbecf8615 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1272,13 +1272,26 @@ Item::Type Item_name_const::type() const
valid_args guarantees value_item->basic_const_item(); if type is
FUNC_ITEM, then we have a fudged item_func_neg() on our hands
and return the underlying type.
+ For Item_func_set_collation()
+ e.g. NAME_CONST('name', 'value' COLLATE collation) we return its
+ 'value' argument type.
*/
- return valid_args ?
- (((value_item->type() == FUNC_ITEM) &&
- (((Item_func *) value_item)->functype() == Item_func::NEG_FUNC)) ?
- ((Item_func *) value_item)->key_item()->type() :
- value_item->type()) :
- NULL_ITEM;
+ if (!valid_args)
+ return NULL_ITEM;
+ Item::Type value_type= value_item->type();
+ if (value_type == FUNC_ITEM)
+ {
+ /*
+ The second argument of NAME_CONST('name', 'value') must be
+ a simple constant item or a NEG_FUNC/COLLATE_FUNC.
+ */
+ DBUG_ASSERT(((Item_func *) value_item)->functype() ==
+ Item_func::NEG_FUNC ||
+ ((Item_func *) value_item)->functype() ==
+ Item_func::COLLATE_FUNC);
+ return ((Item_func *) value_item)->key_item()->type();
+ }
+ return value_type;
}
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 94b02d1eaf6..9e3c2e8c89f 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -419,6 +419,7 @@ public:
{
return save_time_in_field(field);
}
+ longlong val_int() { return val_int_from_decimal(); }
bool result_as_longlong() { return TRUE; }
};
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 0e13830a3b1..364b8beb2a0 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -1969,6 +1969,13 @@ my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(MY_XPATH *xpath)
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH))
return 1;
+ if (xpath->item->type() != Item::XPATH_NODESET)
+ {
+ xpath->lasttok= xpath->prevtok;
+ xpath->error= 1;
+ return 0;
+ }
+
my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH);
return my_xpath_parse_RelativeLocationPath(xpath);
}
@@ -1976,7 +1983,6 @@ static int my_xpath_parse_PathExpr(MY_XPATH *xpath)
{
return my_xpath_parse_LocationPath(xpath) ||
my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(xpath);
-
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 250cfd8da4e..139c9ee8dd3 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -53,6 +53,8 @@
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd);
+
static const char *HA_ERR(int i)
{
switch (i) {
@@ -2894,7 +2896,37 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
- const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
+ if (strcmp("COMMIT", query) == 0 && rli->tables_to_lock)
+ {
+ /*
+ Cleaning-up the last statement context:
+ the terminal event of the current statement flagged with
+ STMT_END_F got filtered out in ndb circular replication.
+ */
+ int error;
+ char llbuff[22];
+ if ((error= rows_event_stmt_cleanup(const_cast<Relay_log_info*>(rli), thd)))
+ {
+ const_cast<Relay_log_info*>(rli)->report(ERROR_LEVEL, error,
+ "Error in cleaning up after an event preceeding the commit; "
+ "the group log file/position: %s %s",
+ const_cast<Relay_log_info*>(rli)->group_master_log_name,
+ llstr(const_cast<Relay_log_info*>(rli)->group_master_log_pos,
+ llbuff));
+ }
+ /*
+ Executing a part of rli->stmt_done() logics that does not deal
+ with group position change. The part is redundant now but is
+ future-change-proof addon, e.g if COMMIT handling will start checking
+ invariants like IN_STMT flag must be off at committing the transaction.
+ */
+ const_cast<Relay_log_info*>(rli)->inc_event_relay_log_pos();
+ const_cast<Relay_log_info*>(rli)->clear_flag(Relay_log_info::IN_STMT);
+ }
+ else
+ {
+ const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
+ }
/*
Note: We do not need to execute reset_one_shot_variables() if this
@@ -7406,16 +7438,20 @@ Rows_log_event::do_shall_skip(Relay_log_info *rli)
return Log_event::do_shall_skip(rli);
}
-int
-Rows_log_event::do_update_pos(Relay_log_info *rli)
-{
- DBUG_ENTER("Rows_log_event::do_update_pos");
- int error= 0;
-
- DBUG_PRINT("info", ("flags: %s",
- get_flags(STMT_END_F) ? "STMT_END_F " : ""));
+/**
+ The function is called at Rows_log_event statement commit time,
+ normally from Rows_log_event::do_update_pos() and possibly from
+ Query_log_event::do_apply_event() of the COMMIT.
+ The function commits the last statement for engines, binlog and
+ releases resources have been allocated for the statement.
+
+ @retval 0 Ok.
+ @retval non-zero Error at the commit.
+ */
- if (get_flags(STMT_END_F))
+static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD * thd)
+{
+ int error;
{
/*
This is the end of a statement or transaction, so close (and
@@ -7457,14 +7493,39 @@ Rows_log_event::do_update_pos(Relay_log_info *rli)
thd->reset_current_stmt_binlog_row_based();
- rli->cleanup_context(thd, 0);
- if (error == 0)
+ const_cast<Relay_log_info*>(rli)->cleanup_context(thd, 0);
+ }
+ return error;
+}
+
+/**
+ The method either increments the relay log position or
+ commits the current statement and increments the master group
+ possition if the event is STMT_END_F flagged and
+ the statement corresponds to the autocommit query (i.e replicated
+ without wrapping in BEGIN/COMMIT)
+
+ @retval 0 Success
+ @retval non-zero Error in the statement commit
+ */
+int
+Rows_log_event::do_update_pos(Relay_log_info *rli)
+{
+ DBUG_ENTER("Rows_log_event::do_update_pos");
+ int error= 0;
+
+ DBUG_PRINT("info", ("flags: %s",
+ get_flags(STMT_END_F) ? "STMT_END_F " : ""));
+
+ if (get_flags(STMT_END_F))
+ {
+ if ((error= rows_event_stmt_cleanup(rli, thd)) == 0)
{
/*
Indicate that a statement is finished.
Step the group log position if we are not in a transaction,
otherwise increase the event log position.
- */
+ */
rli->stmt_done(log_pos, when);
/*
@@ -7478,11 +7539,13 @@ Rows_log_event::do_update_pos(Relay_log_info *rli)
thd->clear_error();
}
else
+ {
rli->report(ERROR_LEVEL, error,
"Error in %s event: commit of row events failed, "
"table `%s`.`%s`",
get_type_str(), m_table->s->db.str,
m_table->s->table_name.str);
+ }
}
else
{
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 42131340d6d..e90e2e4c027 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1954,6 +1954,7 @@ extern my_bool opt_log, opt_slow_log;
extern ulong log_output_options;
extern my_bool opt_log_queries_not_using_indexes;
extern bool opt_disable_networking, opt_skip_show_db;
+extern bool opt_ignore_builtin_innodb;
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress;
extern uint volatile thread_count, thread_running, global_read_lock;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4df499bf978..2b996301a73 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -380,7 +380,7 @@ static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
/* Global variables */
-bool opt_update_log, opt_bin_log;
+bool opt_update_log, opt_bin_log, opt_ignore_builtin_innodb= 0;
my_bool opt_log, opt_slow_log;
ulong log_output_options;
my_bool opt_log_queries_not_using_indexes= 0;
@@ -5666,7 +5666,8 @@ enum options_mysqld
OPT_DEADLOCK_TIMEOUT_SHORT,
OPT_DEADLOCK_TIMEOUT_LONG,
OPT_GENERAL_LOG_FILE,
- OPT_SLOW_QUERY_LOG_FILE
+ OPT_SLOW_QUERY_LOG_FILE,
+ OPT_IGNORE_BUILTIN_INNODB
};
@@ -5897,6 +5898,9 @@ Disable with --skip-large-pages.",
(uchar**) &opt_large_pages, (uchar**) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
#endif
+ {"ignore-builtin-innodb", OPT_IGNORE_BUILTIN_INNODB ,
+ "Disable initialization of builtin InnoDB plugin",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection",
(uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -7599,6 +7603,7 @@ static int mysql_init_variables(void)
log_output_options= find_bit_type(log_output_str, &log_output_typelib);
opt_bin_log= 0;
opt_disable_networking= opt_skip_show_db=0;
+ opt_ignore_builtin_innodb= 0;
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
opt_secure_auth= 0;
@@ -7907,6 +7912,9 @@ mysqld_get_one_option(int optid,
case (int) OPT_BIG_TABLES:
thd_startup_options|=OPTION_BIG_TABLES;
break;
+ case (int) OPT_IGNORE_BUILTIN_INNODB:
+ opt_ignore_builtin_innodb= 1;
+ break;
case (int) OPT_ISAM_LOG:
opt_myisam_log=1;
break;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index da2c8b9cfd8..66d4db2d9b2 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -288,6 +288,11 @@ static sys_var_const sys_ft_query_expansion_limit(&vars,
static sys_var_const sys_ft_stopword_file(&vars, "ft_stopword_file",
OPT_GLOBAL, SHOW_CHAR_PTR,
(uchar*) &ft_stopword_file);
+
+static sys_var_const sys_ignore_builtin_innodb(&vars, "ignore_builtin_innodb",
+ OPT_GLOBAL, SHOW_BOOL,
+ (uchar*) &opt_ignore_builtin_innodb);
+
sys_var_str sys_init_connect(&vars, "init_connect", 0,
sys_update_init_connect,
sys_default_init_connect,0);
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index fd75fee9737..befd064e3e3 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -571,30 +571,30 @@ ER_ERROR_ON_READ
swe "Fick fel vid läsning av '%-.200s' (Felkod %d)"
ukr "îÅ ÍÏÖÕ ÐÒÏÞÉÔÁÔÉ ÆÁÊÌ '%-.200s' (ÐÏÍÉÌËÁ: %d)"
ER_ERROR_ON_RENAME
- cze "Chyba p-Bøi pøejmenování '%-.150s' na '%-.150s' (chybový kód: %d)"
- dan "Fejl ved omdøbning af '%-.150s' til '%-.150s' (Fejlkode: %d)"
- nla "Fout bij het hernoemen van '%-.150s' naar '%-.150s' (Errcode: %d)"
- eng "Error on rename of '%-.150s' to '%-.150s' (errno: %d)"
- jps "'%-.150s' ‚ð '%-.150s' ‚É rename ‚Å‚«‚Ü‚¹‚ñ (errno: %d)",
- est "Viga faili '%-.150s' ümbernimetamisel '%-.150s'-ks (veakood: %d)"
- fre "Erreur en renommant '%-.150s' en '%-.150s' (Errcode: %d)"
- ger "Fehler beim Umbenennen von '%-.150s' in '%-.150s' (Fehler: %d)"
- greek "Ðñüâëçìá êáôÜ ôçí ìåôïíïìáóßá ôïõ áñ÷åßïõ '%-.150s' to '%-.150s' (êùäéêüò ëÜèïõò: %d)"
- hun "Hiba a '%-.150s' file atnevezesekor '%-.150s'. (hibakod: %d)"
- ita "Errore durante la rinominazione da '%-.150s' a '%-.150s' (errno: %d)"
- jpn "'%-.150s' ¤ò '%-.150s' ¤Ë rename ¤Ç¤­¤Þ¤»¤ó (errno: %d)"
- kor "'%-.150s'¸¦ '%-.150s'·Î À̸§ º¯°æÁß ¿¡·¯ (¿¡·¯¹øÈ£: %d)"
- nor "Feil ved omdøping av '%-.150s' til '%-.150s' (Feilkode: %d)"
- norwegian-ny "Feil ved omdøyping av '%-.150s' til '%-.150s' (Feilkode: %d)"
- pol "B³?d podczas zmieniania nazwy '%-.150s' na '%-.150s' (Kod b³êdu: %d)"
- por "Erro ao renomear '%-.150s' para '%-.150s' (erro no. %d)"
- rum "Eroare incercind sa renumesc '%-.150s' in '%-.150s' (errno: %d)"
- rus "ïÛÉÂËÁ ÐÒÉ ÐÅÒÅÉÍÅÎÏ×ÁÎÉÉ '%-.150s' × '%-.150s' (ÏÛÉÂËÁ: %d)"
- serbian "Greška pri promeni imena '%-.150s' na '%-.150s' (errno: %d)"
- slo "Chyba pri premenovávaní '%-.150s' na '%-.150s' (chybový kód: %d)"
- spa "Error en el renombrado de '%-.150s' a '%-.150s' (Error: %d)"
- swe "Kan inte byta namn från '%-.150s' till '%-.150s' (Felkod: %d)"
- ukr "îÅ ÍÏÖÕ ÐÅÒÅÊÍÅÎÕ×ÁÔÉ '%-.150s' Õ '%-.150s' (ÐÏÍÉÌËÁ: %d)"
+ cze "Chyba p-Bøi pøejmenování '%-.210s' na '%-.210s' (chybový kód: %d)"
+ dan "Fejl ved omdøbning af '%-.210s' til '%-.210s' (Fejlkode: %d)"
+ nla "Fout bij het hernoemen van '%-.210s' naar '%-.210s' (Errcode: %d)"
+ eng "Error on rename of '%-.210s' to '%-.210s' (errno: %d)"
+ jps "'%-.210s' ‚ð '%-.210s' ‚É rename ‚Å‚«‚Ü‚¹‚ñ (errno: %d)",
+ est "Viga faili '%-.210s' ümbernimetamisel '%-.210s'-ks (veakood: %d)"
+ fre "Erreur en renommant '%-.210s' en '%-.210s' (Errcode: %d)"
+ ger "Fehler beim Umbenennen von '%-.210s' in '%-.210s' (Fehler: %d)"
+ greek "Ðñüâëçìá êáôÜ ôçí ìåôïíïìáóßá ôïõ áñ÷åßïõ '%-.210s' to '%-.210s' (êùäéêüò ëÜèïõò: %d)"
+ hun "Hiba a '%-.210s' file atnevezesekor '%-.210s'. (hibakod: %d)"
+ ita "Errore durante la rinominazione da '%-.210s' a '%-.210s' (errno: %d)"
+ jpn "'%-.210s' ¤ò '%-.210s' ¤Ë rename ¤Ç¤­¤Þ¤»¤ó (errno: %d)"
+ kor "'%-.210s'¸¦ '%-.210s'·Î À̸§ º¯°æÁß ¿¡·¯ (¿¡·¯¹øÈ£: %d)"
+ nor "Feil ved omdøping av '%-.210s' til '%-.210s' (Feilkode: %d)"
+ norwegian-ny "Feil ved omdøyping av '%-.210s' til '%-.210s' (Feilkode: %d)"
+ pol "B³?d podczas zmieniania nazwy '%-.210s' na '%-.210s' (Kod b³êdu: %d)"
+ por "Erro ao renomear '%-.210s' para '%-.210s' (erro no. %d)"
+ rum "Eroare incercind sa renumesc '%-.210s' in '%-.210s' (errno: %d)"
+ rus "ïÛÉÂËÁ ÐÒÉ ÐÅÒÅÉÍÅÎÏ×ÁÎÉÉ '%-.210s' × '%-.210s' (ÏÛÉÂËÁ: %d)"
+ serbian "Greška pri promeni imena '%-.210s' na '%-.210s' (errno: %d)"
+ slo "Chyba pri premenovávaní '%-.210s' na '%-.210s' (chybový kód: %d)"
+ spa "Error en el renombrado de '%-.210s' a '%-.210s' (Error: %d)"
+ swe "Kan inte byta namn från '%-.210s' till '%-.210s' (Felkod: %d)"
+ ukr "îÅ ÍÏÖÕ ÐÅÒÅÊÍÅÎÕ×ÁÔÉ '%-.210s' Õ '%-.210s' (ÐÏÍÉÌËÁ: %d)"
ER_ERROR_ON_WRITE
cze "Chyba p-Bøi zápisu do souboru '%-.200s' (chybový kód: %d)"
dan "Fejl ved skriving av filen '%-.200s' (Fejlkode: %d)"
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 13d3af1b8d1..695bb2d07e5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5121,8 +5121,15 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables)
{
if (mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG))
{
- handler::Table_flags flags_some_set= handler::Table_flags();
- handler::Table_flags flags_all_set= ~handler::Table_flags();
+ /*
+ Compute the starting vectors for the computations by creating a
+ set with all the capabilities bits set and one with no
+ capabilities bits set.
+ */
+ handler::Table_flags flags_some_set= 0;
+ handler::Table_flags flags_all_set=
+ HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE;
+
my_bool multi_engine= FALSE;
void* prev_ht= NULL;
for (TABLE_LIST *table= tables; table; table= table->next_global)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index af62961c65f..125a4ceea2f 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3649,16 +3649,14 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
if (lex->is_stmt_unsafe() &&
variables.binlog_format == BINLOG_FORMAT_STMT)
{
- DBUG_ASSERT(this->query != NULL);
push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_BINLOG_UNSAFE_STATEMENT,
ER(ER_BINLOG_UNSAFE_STATEMENT));
if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
{
- char warn_buf[MYSQL_ERRMSG_SIZE];
- my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s",
- ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
- sql_print_warning(warn_buf);
+ sql_print_warning("%s Statement: %.*s",
+ ER(ER_BINLOG_UNSAFE_STATEMENT),
+ MYSQL_ERRMSG_SIZE, query_arg);
binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
}
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 74867398a35..eefe6b9b31a 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -51,6 +51,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
THD::killed_state killed_status= THD::NOT_KILLED;
DBUG_ENTER("mysql_delete");
+ THD::enum_binlog_query_type query_type=
+ thd->lex->sql_command == SQLCOM_TRUNCATE ?
+ THD::STMT_QUERY_TYPE :
+ THD::ROW_QUERY_TYPE;
+
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
if (!(table= table_list->table))
@@ -135,6 +140,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_PRINT("debug", ("Trying to use delete_all_rows()"));
if (!(error=table->file->ha_delete_all_rows()))
{
+ /*
+ If delete_all_rows() is used, it is not possible to log the
+ query in row format, so we have to log it in statement format.
+ */
+ query_type= THD::STMT_QUERY_TYPE;
error= -1; // ok
deleted= maybe_deleted;
goto cleanup;
@@ -374,6 +384,11 @@ cleanup:
{
if (mysql_bin_log.is_open())
{
+ bool const is_trans=
+ thd->lex->sql_command == SQLCOM_TRUNCATE ?
+ FALSE :
+ transactional_table;
+
if (error < 0)
thd->clear_error();
/*
@@ -381,10 +396,13 @@ cleanup:
storage engine does not inject the rows itself, we replicate
statement-based; otherwise, 'ha_delete_row()' was used to
delete specific rows which we might log row-based.
+
+ Note that TRUNCATE TABLE is not transactional and should
+ therefore be treated as a DDL.
*/
- int log_result= thd->binlog_query(THD::ROW_QUERY_TYPE,
+ int log_result= thd->binlog_query(query_type,
thd->query, thd->query_length,
- transactional_table, FALSE, killed_status);
+ is_trans, FALSE, killed_status);
if (log_result && transactional_table)
{
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 79da1936eb9..bd8f9469571 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -177,7 +177,7 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
uint code, const char *format, ...)
{
va_list args;
- char warning[ERRMSGSIZE+20];
+ char warning[MYSQL_ERRMSG_SIZE];
DBUG_ENTER("push_warning_printf");
DBUG_PRINT("enter",("warning: %u", code));
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 2344724818f..61b8490f9be 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1715,6 +1715,7 @@ public:
class Delayed_insert :public ilink {
uint locks_in_memory;
+ thr_lock_type delayed_lock;
public:
THD thd;
TABLE *table;
@@ -1757,6 +1758,8 @@ public:
pthread_cond_init(&cond_client,NULL);
VOID(pthread_mutex_lock(&LOCK_thread_count));
delayed_insert_threads++;
+ delayed_lock= global_system_variables.low_priority_updates ?
+ TL_WRITE_LOW_PRIORITY : TL_WRITE;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
}
~Delayed_insert()
@@ -2568,7 +2571,7 @@ bool Delayed_insert::handle_inserts(void)
table->use_all_columns();
thd_proc_info(&thd, "upgrading lock");
- if (thr_upgrade_write_delay_lock(*thd.lock->locks))
+ if (thr_upgrade_write_delay_lock(*thd.lock->locks, delayed_lock))
{
/*
This can happen if thread is killed either by a shutdown
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ae9ac38d39f..8536f2308c9 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5475,9 +5475,10 @@ bool check_stack_overrun(THD *thd, long margin,
if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >=
(long) (my_thread_stack_size - margin))
{
- sprintf(errbuff[0],ER(ER_STACK_OVERRUN_NEED_MORE),
- stack_used,my_thread_stack_size,margin);
- my_message(ER_STACK_OVERRUN_NEED_MORE,errbuff[0],MYF(0));
+ char ebuff[MYSQL_ERRMSG_SIZE];
+ my_snprintf(ebuff, sizeof(ebuff), ER(ER_STACK_OVERRUN_NEED_MORE),
+ stack_used, my_thread_stack_size, margin);
+ my_message(ER_STACK_OVERRUN_NEED_MORE, ebuff, MYF(ME_FATALERROR));
thd->fatal_error();
return 1;
}
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index e73e65dc38f..221f42e041d 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1138,6 +1138,9 @@ int plugin_init(int *argc, char **argv, int flags)
{
for (plugin= *builtins; plugin->info; plugin++)
{
+ if (opt_ignore_builtin_innodb &&
+ !my_strcasecmp(&my_charset_latin1, plugin->name, "InnoDB"))
+ continue;
/* by default, ndbcluster and federated are disabled */
def_enabled=
my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0 &&
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0e3856240ca..658064db899 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -92,7 +92,6 @@ static store_key *get_store_key(THD *thd,
KEYUSE *keyuse, table_map used_tables,
KEY_PART_INFO *key_part, uchar *key_buff,
uint maybe_null);
-static bool make_simple_join(JOIN *join,TABLE *tmp_table);
static void make_outerjoin_info(JOIN *join);
static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item);
static void make_join_readinfo(JOIN *join, ulonglong options);
@@ -1897,7 +1896,7 @@ JOIN::exec()
/* Free first data from old join */
curr_join->join_free();
- if (make_simple_join(curr_join, curr_tmp_table))
+ if (curr_join->make_simple_join(this, curr_tmp_table))
DBUG_VOID_RETURN;
calc_group_buffer(curr_join, group_list);
count_field_types(select_lex, &curr_join->tmp_table_param,
@@ -2020,7 +2019,7 @@ JOIN::exec()
curr_join->select_distinct=0;
}
curr_tmp_table->reginfo.lock_type= TL_UNLOCK;
- if (make_simple_join(curr_join, curr_tmp_table))
+ if (curr_join->make_simple_join(this, curr_tmp_table))
DBUG_VOID_RETURN;
calc_group_buffer(curr_join, curr_join->group_list);
count_field_types(select_lex, &curr_join->tmp_table_param,
@@ -5708,48 +5707,42 @@ store_val_in_field(Field *field, Item *item, enum_check_fields check_flag)
}
-static bool
-make_simple_join(JOIN *join,TABLE *tmp_table)
+/**
+ @details Initialize a JOIN as a query execution plan
+ that accesses a single table via a table scan.
+
+ @param parent contains JOIN_TAB and TABLE object buffers for this join
+ @param tmp_table temporary table
+
+ @retval FALSE success
+ @retval TRUE error occurred
+*/
+bool
+JOIN::make_simple_join(JOIN *parent, TABLE *tmp_table)
{
- TABLE **tableptr;
- JOIN_TAB *join_tab;
- DBUG_ENTER("make_simple_join");
+ DBUG_ENTER("JOIN::make_simple_join");
/*
Reuse TABLE * and JOIN_TAB if already allocated by a previous call
to this function through JOIN::exec (may happen for sub-queries).
*/
- if (!join->table_reexec)
- {
- if (!(join->table_reexec= (TABLE**) join->thd->alloc(sizeof(TABLE*))))
- DBUG_RETURN(TRUE); /* purecov: inspected */
- if (join->tmp_join)
- join->tmp_join->table_reexec= join->table_reexec;
- }
- if (!join->join_tab_reexec)
- {
- if (!(join->join_tab_reexec=
- (JOIN_TAB*) join->thd->alloc(sizeof(JOIN_TAB))))
- DBUG_RETURN(TRUE); /* purecov: inspected */
- if (join->tmp_join)
- join->tmp_join->join_tab_reexec= join->join_tab_reexec;
- }
- tableptr= join->table_reexec;
- join_tab= join->join_tab_reexec;
-
- join->join_tab=join_tab;
- join->table=tableptr; tableptr[0]=tmp_table;
- join->tables=1;
- join->const_tables=0;
- join->const_table_map=0;
- join->tmp_table_param.field_count= join->tmp_table_param.sum_func_count=
- join->tmp_table_param.func_count=0;
- join->tmp_table_param.copy_field=join->tmp_table_param.copy_field_end=0;
- join->first_record=join->sort_and_group=0;
- join->send_records=(ha_rows) 0;
- join->group=0;
- join->row_limit=join->unit->select_limit_cnt;
- join->do_send_rows = (join->row_limit) ? 1 : 0;
+ if (!parent->join_tab_reexec &&
+ !(parent->join_tab_reexec= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
+ DBUG_RETURN(TRUE); /* purecov: inspected */
+
+ join_tab= parent->join_tab_reexec;
+ table= &parent->table_reexec[0]; parent->table_reexec[0]= tmp_table;
+ tables= 1;
+ const_tables= 0;
+ const_table_map= 0;
+ tmp_table_param.field_count= tmp_table_param.sum_func_count=
+ tmp_table_param.func_count= 0;
+ tmp_table_param.copy_field= tmp_table_param.copy_field_end=0;
+ first_record= sort_and_group=0;
+ send_records= (ha_rows) 0;
+ group= 0;
+ row_limit= unit->select_limit_cnt;
+ do_send_rows= row_limit ? 1 : 0;
join_tab->cache.buff=0; /* No caching */
join_tab->table=tmp_table;
@@ -5766,7 +5759,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
join_tab->ref.key = -1;
join_tab->not_used_in_distinct=0;
join_tab->read_first_record= join_init_read_record;
- join_tab->join=join;
+ join_tab->join= this;
join_tab->ref.key_parts= 0;
bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record));
tmp_table->status=0;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index eacd3d39905..43e26a6b4b2 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -402,9 +402,12 @@ public:
cleared only at the end of the execution of the whole query and not caching
allocations that occur in repetition at execution time will result in
excessive memory usage.
+ Note: make_simple_join always creates an execution plan that accesses
+ a single table, thus it is sufficient to have a one-element array for
+ table_reexec.
*/
SORT_FIELD *sortorder; // make_unireg_sortorder()
- TABLE **table_reexec; // make_simple_join()
+ TABLE *table_reexec[1]; // make_simple_join()
JOIN_TAB *join_tab_reexec; // make_simple_join()
/* end of allocation caching storage */
@@ -434,7 +437,7 @@ public:
exec_tmp_table1= 0;
exec_tmp_table2= 0;
sortorder= 0;
- table_reexec= 0;
+ table_reexec[0]= 0;
join_tab_reexec= 0;
thd= thd_arg;
sum_funcs= sum_funcs2= 0;
@@ -527,6 +530,8 @@ public:
return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
select_lex == unit->fake_select_lex));
}
+private:
+ bool make_simple_join(JOIN *join, TABLE *tmp_table);
};
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a7443e1bd9b..e17432e0689 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4444,8 +4444,8 @@ send_result_message:
switch (result_code) {
case HA_ADMIN_NOT_IMPLEMENTED:
{
- char buf[ERRMSGSIZE+20];
- uint length=my_snprintf(buf, ERRMSGSIZE,
+ char buf[MYSQL_ERRMSG_SIZE];
+ uint length=my_snprintf(buf, sizeof(buf),
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
@@ -4454,8 +4454,8 @@ send_result_message:
case HA_ADMIN_NOT_BASE_TABLE:
{
- char buf[ERRMSGSIZE+20];
- uint length= my_snprintf(buf, ERRMSGSIZE,
+ char buf[MYSQL_ERRMSG_SIZE];
+ uint length= my_snprintf(buf, sizeof(buf),
ER(ER_BAD_TABLE_ERROR), table_name);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
@@ -4582,11 +4582,12 @@ send_result_message:
case HA_ADMIN_NEEDS_UPGRADE:
case HA_ADMIN_NEEDS_ALTER:
{
- char buf[ERRMSGSIZE];
+ char buf[MYSQL_ERRMSG_SIZE];
uint length;
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
- length=my_snprintf(buf, ERRMSGSIZE, ER(ER_TABLE_NEEDS_UPGRADE), table->table_name);
+ length=my_snprintf(buf, sizeof(buf), ER(ER_TABLE_NEEDS_UPGRADE),
+ table->table_name);
protocol->store(buf, length, system_charset_info);
fatal_error=1;
break;
@@ -4594,8 +4595,8 @@ send_result_message:
default: // Probably HA_ADMIN_INTERNAL_ERROR
{
- char buf[ERRMSGSIZE+20];
- uint length=my_snprintf(buf, ERRMSGSIZE,
+ char buf[MYSQL_ERRMSG_SIZE];
+ uint length=my_snprintf(buf, sizeof(buf),
"Unknown - internal error %d during operation",
result_code);
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 181ff82f0fe..eb7ccd75a75 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -526,9 +526,11 @@ int mysql_update(THD *thd,
init_read_record(&info, thd, table, select, 0, 1, FALSE);
updated= found= 0;
- /* Generate an error when trying to set a NOT NULL field to NULL. */
- thd->count_cuted_fields= ignore ? CHECK_FIELD_WARN
- : CHECK_FIELD_ERROR_FOR_NULL;
+ /*
+ Generate an error (in TRADITIONAL mode) or warning
+ when trying to set a NOT NULL field to NULL.
+ */
+ thd->count_cuted_fields= CHECK_FIELD_WARN;
thd->cuted_fields=0L;
thd_proc_info(thd, "Updating");
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 502a1da7b4d..ad12600a51e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -3587,7 +3587,8 @@ ha_innobase::write_row(
/* out: error code */
uchar* record) /* in: a row in MySQL format */
{
- int error = 0;
+ ulint error = 0;
+ int error_result= 0;
ibool auto_inc_used= FALSE;
ulint sql_command;
trx_t* trx = thd_to_trx(user_thd);
@@ -3703,6 +3704,7 @@ no_commit:
}
/* MySQL errors are passed straight back. */
+ error_result = (int) error;
goto func_exit;
}
@@ -3796,7 +3798,7 @@ set_max_autoinc:
err = innobase_set_max_autoinc(auto_inc);
if (err != DB_SUCCESS) {
- error = (int) err;
+ error = err;
}
}
break;
@@ -3806,12 +3808,12 @@ set_max_autoinc:
innodb_srv_conc_exit_innodb(prebuilt->trx);
report_error:
- error = convert_error_code_to_mysql(error, user_thd);
+ error_result = convert_error_code_to_mysql((int) error, user_thd);
func_exit:
innobase_active_small();
- DBUG_RETURN(error);
+ DBUG_RETURN(error_result);
}
/**************************************************************************
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index efcfca5bd62..1fe084d751b 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1574,7 +1574,7 @@ int ha_maria::preload_keys(THD * thd, HA_CHECK_OPT *check_opt)
if ((error= maria_preload(file, map, table_list->ignore_leaves)))
{
- char buf[ERRMSGSIZE+20];
+ char buf[MYSQL_ERRMSG_SIZE+20];
const char *errmsg;
switch (error) {
@@ -1585,7 +1585,7 @@ int ha_maria::preload_keys(THD * thd, HA_CHECK_OPT *check_opt)
errmsg= "Failed to allocate buffer";
break;
default:
- my_snprintf(buf, ERRMSGSIZE,
+ my_snprintf(buf, sizeof(buf),
"Failed to read from index file (errno: %d)", my_errno);
errmsg= buf;
}
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index a6e6d4ea9cb..fdc43a3fc30 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1272,7 +1272,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
ulonglong map;
TABLE_LIST *table_list= table->pos_in_table_list;
my_bool ignore_leaves= table_list->ignore_leaves;
- char buf[ERRMSGSIZE+20];
+ char buf[MYSQL_ERRMSG_SIZE];
DBUG_ENTER("ha_myisam::preload_keys");
@@ -1300,7 +1300,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
errmsg= "Failed to allocate buffer";
break;
default:
- my_snprintf(buf, ERRMSGSIZE,
+ my_snprintf(buf, sizeof(buf),
"Failed to read from index file (errno: %d)", my_errno);
errmsg= buf;
}
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index b5002116164..64b4be2b7ca 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -47,6 +47,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
MI_INFO *isam=0;
uint found_merge_insert_method= 0;
size_t name_buff_length;
+ my_bool bad_children= FALSE;
DBUG_ENTER("myrg_open");
LINT_INIT(key_parts);
@@ -97,13 +98,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
fn_format(buff, buff, "", "", 0);
if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
{
- my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR)
{
myrg_print_wrong_table(buff);
+ bad_children= TRUE;
continue;
}
- goto err;
+ goto bad_children;
}
if (!m_info) /* First file */
{
@@ -128,13 +129,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
files++;
if (m_info->reclength != isam->s->base.reclength)
{
- my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR)
{
myrg_print_wrong_table(buff);
+ bad_children= TRUE;
continue;
}
- goto err;
+ goto bad_children;
}
m_info->options|= isam->s->options;
m_info->records+= isam->state->records;
@@ -147,8 +148,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->tables);
}
- if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF)
- goto err;
+ if (bad_children)
+ goto bad_children;
if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
@@ -178,12 +179,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
pthread_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info);
+bad_children:
+ my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
err:
save_errno=my_errno;
switch (errpos) {
case 3:
while (files)
- mi_close(m_info->open_tables[--files].table);
+ (void) mi_close(m_info->open_tables[--files].table);
my_free((char*) m_info,MYF(0));
/* Fall through */
case 2:
@@ -392,6 +395,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
uint child_nr;
uint key_parts;
uint min_keys;
+ my_bool bad_children= FALSE;
DBUG_ENTER("myrg_attach_children");
DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking));
@@ -441,13 +445,13 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
DBUG_PRINT("error", ("definition mismatch table: '%s' repair: %d",
myisam->filename,
(handle_locking & HA_OPEN_FOR_REPAIR)));
- my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR)
{
myrg_print_wrong_table(myisam->filename);
+ bad_children= TRUE;
continue;
}
- goto err;
+ goto bad_children;
}
m_info->options|= myisam->s->options;
@@ -462,6 +466,9 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
child_nr++;
}
+ if (bad_children)
+ goto bad_children;
+ /* Note: callback() resets my_errno, so it is safe to check it here */
if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF)
goto err;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
@@ -477,6 +484,8 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
pthread_mutex_unlock(&m_info->mutex);
DBUG_RETURN(0);
+bad_children:
+ my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
err:
save_errno= my_errno;
switch (errpos) {
diff --git a/support-files/Makefile.am b/support-files/Makefile.am
index a6001e635e6..77eddea3227 100644
--- a/support-files/Makefile.am
+++ b/support-files/Makefile.am
@@ -119,6 +119,7 @@ SUFFIXES = .sh
-e 's!@''SHARED_LIB_VERSION''@!@SHARED_LIB_VERSION@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
-e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
+ -e 's!@''MYSQL_COPYRIGHT_YEAR''@!@MYSQL_COPYRIGHT_YEAR@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-e 's!@''PERL_DBI_VERSION''@!@PERL_DBI_VERSION@!' \
-e 's!@''PERL_DBD_VERSION''@!@PERL_DBD_VERSION@!' \
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index a1a0ad50358..6b58b0080e3 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -46,7 +46,7 @@
%else
%define release 0.glibc23
%endif
-%define license GPL
+%define mysql_license GPL
%define mysqld_user mysql
%define mysqld_group mysql
%define server_suffix -standard
@@ -80,7 +80,7 @@ Summary: MySQL: a very fast and reliable SQL database server
Group: Applications/Databases
Version: @MYSQL_NO_DASH_VERSION@
Release: %{release}
-License: Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Under %{license} license as shown in the Description field.
+License: Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Under %{mysql_license} license as shown in the Description field.
Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz
URL: http://www.mysql.com/
Packager: Sun Microsystems, Inc. Product Engineering Team <build@mysql.com>
@@ -101,7 +101,7 @@ is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.
-Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved.
+Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
@@ -125,7 +125,7 @@ is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.
-Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved.
+Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
@@ -392,9 +392,9 @@ CXXFLAGS="$CXXFLAGS" \
BuildMySQL "\
--with-debug \
%if %{MARIA_BUILD}
- --with-comment=\"MySQL Community Server - Debug [Maria] (%{license})\" \
+ --with-comment=\"MySQL Community Server - Debug [Maria] (%{mysql_license})\" \
%else
- --with-comment=\"MySQL Community Server - Debug (%{license})\" \
+ --with-comment=\"MySQL Community Server - Debug (%{mysql_license})\" \
%endif
")
@@ -418,9 +418,9 @@ CXXFLAGS="$CXXFLAGS" \
BuildMySQL "\
--with-embedded-server \
%if %{MARIA_BUILD}
- --with-comment=\"MySQL Community Server [Maria] (%{license})\" \
+ --with-comment=\"MySQL Community Server [Maria] (%{mysql_license})\" \
%else
- --with-comment=\"MySQL Community Server (%{license})\" \
+ --with-comment=\"MySQL Community Server (%{mysql_license})\" \
%endif
")
# We might want to save the config log file