summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c13
-rw-r--r--sql-common/conf_to_src.c144
-rw-r--r--sql-common/errmsg.c129
-rw-r--r--sql-common/my_time.c3
4 files changed, 282 insertions, 7 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index c900ec6800f..858e9ec4b5b 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1005,11 +1005,6 @@ enum option_id {
static TYPELIB option_types={array_elements(default_options)-1,
"options",default_options, NULL};
-const char *sql_protocol_names_lib[] =
-{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS };
-TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
- sql_protocol_names_lib, NULL};
-
static int add_init_command(struct st_mysql_options *options, const char *cmd)
{
char *tmp;
@@ -4776,3 +4771,11 @@ mysql_get_socket(const MYSQL *mysql)
return vio_fd(mysql->net.vio);
return INVALID_SOCKET;
}
+
+
+int STDCALL mysql_cancel(MYSQL *mysql)
+{
+ if (mysql->net.vio)
+ return vio_shutdown(mysql->net.vio, SHUT_RDWR);
+ return -1;
+}
diff --git a/sql-common/conf_to_src.c b/sql-common/conf_to_src.c
new file mode 100644
index 00000000000..0e92388c93c
--- /dev/null
+++ b/sql-common/conf_to_src.c
@@ -0,0 +1,144 @@
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation.
+
+ There are special exceptions to the terms and conditions of the GPL as it
+ is applied to this software.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
+
+/* can't use -lmysys because this prog is used to create -lstrings */
+
+
+#include <my_global.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+
+#define CHARSETS_SUBDIR "sql/share/charsets"
+#define CTYPE_TABLE_SIZE 257
+#define TO_LOWER_TABLE_SIZE 256
+#define TO_UPPER_TABLE_SIZE 256
+#define SORT_ORDER_TABLE_SIZE 256
+#define ROW_LEN 16
+
+void print_arrays_for(char *set);
+
+char *prog;
+char buf[1024], *p, *endptr;
+
+int
+main(int argc, char **argv)
+{
+ prog = *argv;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s source-dir [charset [, charset]]\n", prog);
+ exit(EXIT_FAILURE);
+ }
+
+ --argc; ++argv; /* skip program name */
+
+ if (chdir(*argv) != 0) {
+ fprintf(stderr, "%s: can't cd to %s\n", prog, *argv);
+ exit(EXIT_FAILURE);
+ }
+ --argc; ++argv;
+
+ if (chdir(CHARSETS_SUBDIR) != 0) {
+ fprintf(stderr, "%s: can't cd to %s\n", prog, CHARSETS_SUBDIR);
+ exit(EXIT_FAILURE);
+ }
+
+ while (argc--)
+ print_arrays_for(*argv++);
+
+ exit(EXIT_SUCCESS);
+}
+
+void
+print_array(FILE *f, const char *set, const char *name, int n)
+{
+ int i;
+ char val[100];
+
+ printf("uchar %s_%s[] = {\n", name, set);
+
+ p = buf;
+ *buf = '\0';
+ for (i = 0; i < n; ++i)
+ {
+ /* get a word from f */
+ endptr = p;
+ for (;;)
+ {
+ while (isspace(*endptr))
+ ++endptr;
+ if (*endptr && *endptr != '#') /* not comment */
+ break;
+ if ((fgets(buf, sizeof(buf), f)) == NULL)
+ return; /* XXX: break silently */
+ endptr = buf;
+ }
+
+ p = val;
+ while (!isspace(*endptr))
+ *p++ = *endptr++;
+ *p = '\0';
+ p = endptr;
+
+ /* write the value out */
+
+ if (i == 0 || i % ROW_LEN == n % ROW_LEN)
+ printf(" ");
+
+ printf("%3d", (unsigned char) strtol(val, (char **) NULL, 16));
+
+ if (i < n - 1)
+ printf(",");
+
+ if ((i+1) % ROW_LEN == n % ROW_LEN)
+ printf("\n");
+ }
+
+ printf("};\n\n");
+}
+
+void
+print_arrays_for(char *set)
+{
+ FILE *f;
+
+ snprintf(buf, sizeof(buf), "%s.conf", set);
+
+ if ((f = fopen(buf, "r")) == NULL) {
+ fprintf(stderr, "%s: can't read conf file for charset %s\n", prog, set);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("\
+/* The %s character set. Generated automatically by configure and\n\
+ * the %s program\n\
+ */\n\n",
+ set, prog);
+
+ /* it would be nice if this used the code in mysys/charset.c, but... */
+ print_array(f, set, "ctype", CTYPE_TABLE_SIZE);
+ print_array(f, set, "to_lower", TO_LOWER_TABLE_SIZE);
+ print_array(f, set, "to_upper", TO_UPPER_TABLE_SIZE);
+ print_array(f, set, "sort_order", SORT_ORDER_TABLE_SIZE);
+ printf("\n");
+
+ fclose(f);
+
+ return;
+}
diff --git a/sql-common/errmsg.c b/sql-common/errmsg.c
new file mode 100644
index 00000000000..fc5a6a07e11
--- /dev/null
+++ b/sql-common/errmsg.c
@@ -0,0 +1,129 @@
+/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation.
+
+ There are special exceptions to the terms and conditions of the GPL as it
+ is applied to this software.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+/* Error messages for MySQL clients */
+/* (Error messages for the daemon are in share/language/errmsg.sys) */
+
+#include <my_global.h>
+#include <my_sys.h>
+#include "errmsg.h"
+
+const char *client_errors[]=
+{
+ "Unknown MySQL error",
+ "Can't create UNIX socket (%d)",
+ "Can't connect to local MySQL server through socket '%-.100s' (%M)",
+ "Can't connect to MySQL server on '%-.100s' (%M)",
+ "Can't create TCP/IP socket (%M)",
+ "Unknown MySQL server host '%-.100s' (%d)",
+ "MySQL server has gone away",
+ "Protocol mismatch; server version = %d, client version = %d",
+ "MySQL client ran out of memory",
+ "Wrong host info",
+ "Localhost via UNIX socket",
+ "%-.100s via TCP/IP",
+ "Error in server handshake",
+ "Lost connection to MySQL server during query",
+ "Commands out of sync; you can't run this command now",
+ "Named pipe: %-.32s",
+ "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)",
+ "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
+ "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
+ "Can't initialize character set %-.32s (path: %-.100s)",
+ "Got packet bigger than 'max_allowed_packet' bytes",
+ "Embedded server",
+ "Error on SHOW SLAVE STATUS:",
+ "Error on SHOW SLAVE HOSTS:",
+ "Error connecting to slave:",
+ "Error connecting to master:",
+ "SSL connection error: %-.100s",
+ "Malformed packet",
+ "This client library is licensed only for use with MySQL servers having '%s' license",
+ "Invalid use of null pointer",
+ "Statement not prepared",
+ "No data supplied for parameters in prepared statement",
+ "Data truncated",
+ "No parameters exist in the statement",
+ "Invalid parameter number",
+ "Can't send long data for non-string/non-binary data types (parameter: %d)",
+ "Using unsupported buffer type: %d (parameter: %d)",
+ "Shared memory: %-.100s",
+ "Can't open shared memory; client could not create request event (%lu)",
+ "Can't open shared memory; no answer event received from server (%lu)",
+ "Can't open shared memory; server could not allocate file mapping (%lu)",
+ "Can't open shared memory; server could not get pointer to file mapping (%lu)",
+ "Can't open shared memory; client could not allocate file mapping (%lu)",
+ "Can't open shared memory; client could not get pointer to file mapping (%lu)",
+ "Can't open shared memory; client could not create %s event (%lu)",
+ "Can't open shared memory; no answer from server (%lu)",
+ "Can't open shared memory; cannot send request event to server (%lu)",
+ "Wrong or unknown protocol",
+ "Invalid connection handle",
+ "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)",
+ "Row retrieval was canceled by mysql_stmt_close() call",
+ "Attempt to read column without prior row fetch",
+ "Prepared statement contains no metadata",
+ "Attempt to read a row while there is no result set associated with the statement",
+ "This feature is not implemented yet",
+ "Lost connection to MySQL server at '%s', system error: %M",
+ "Statement closed indirectly because of a preceding %s() call",
+ "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+ "This handle is already connected. Use a separate handle for each connection.",
+ "Authentication plugin '%s' cannot be loaded: %s",
+ "There is an attribute with the same name already",
+ "Authentication plugin '%s' reported error: %s",
+ ""
+};
+
+const char** get_client_errmsgs(int nr __attribute__((unused)))
+{
+ return client_errors;
+}
+
+/*
+ Register client error messages for use with my_error().
+
+ SYNOPSIS
+ init_client_errs()
+
+ RETURN
+ void
+*/
+
+void init_client_errs(void)
+{
+ compile_time_assert(array_elements(client_errors) ==
+ (CR_ERROR_LAST - CR_ERROR_FIRST + 2));
+ (void) my_error_register(get_client_errmsgs, CR_ERROR_FIRST, CR_ERROR_LAST);
+}
+
+
+/*
+ Unregister client error messages.
+
+ SYNOPSIS
+ finish_client_errs()
+
+ RETURN
+ void
+*/
+
+void finish_client_errs(void)
+{
+ (void) my_error_unregister(CR_ERROR_FIRST, CR_ERROR_LAST);
+}
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 7cf8692a3f6..88f28e1d44a 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -20,7 +20,7 @@
#include <m_ctype.h>
/* Windows version of localtime_r() is declared in my_ptrhead.h */
#include <my_pthread.h>
-#include <mysqld_error.h>
+
ulonglong log_10_int[20]=
{
@@ -777,7 +777,6 @@ long calc_daynr(uint year,uint month,uint day)
DBUG_RETURN(delsum+(int) y/4-temp);
} /* calc_daynr */
-
/*
Convert time in MYSQL_TIME representation in system time zone to its
my_time_t form (number of seconds in UTC since begginning of Unix Epoch).