summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2008-10-02 13:10:06 +0500
committerRamil Kalimullin <ramil@mysql.com>2008-10-02 13:10:06 +0500
commit1ce81aac15f0e7a89aef78f8e25ec7976f37972c (patch)
tree0c7ed2ea227afd90471853f9cc4cc08c79549230 /sql
parentd3e317d16befe9e6d7ade3e0527dca10609577ad (diff)
parent652565d3622d2c6a81313aa6faf5e44fd2c9d57b (diff)
downloadmariadb-git-1ce81aac15f0e7a89aef78f8e25ec7976f37972c.tar.gz
merge
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc12
-rw-r--r--sql/field.h10
-rw-r--r--sql/parse_file.cc24
-rw-r--r--sql/parse_file.h5
-rw-r--r--sql/sp_head.cc6
-rw-r--r--sql/sql_class.cc13
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_db.cc17
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_view.cc4
-rw-r--r--sql/stacktrace.c67
11 files changed, 145 insertions, 18 deletions
diff --git a/sql/field.cc b/sql/field.cc
index d840034f8dc..3d3f698f912 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6992,8 +6992,18 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
return 0;
}
- if (from == value.ptr())
+ /*
+ If the 'from' address is in the range of the temporary 'value'-
+ object we need to copy the content to a different location or it will be
+ invalidated when the 'value'-object is reallocated to make room for
+ the new character set.
+ */
+ if (from >= value.ptr() && from <= value.ptr()+value.length())
{
+ /*
+ If content of the 'from'-address is cached in the 'value'-object
+ it is possible that the content needs a character conversion.
+ */
uint32 dummy_offset;
if (!String::needs_conversion(length, cs, field_charset, &dummy_offset))
{
diff --git a/sql/field.h b/sql/field.h
index 7b2dda77095..2975719a591 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1213,8 +1213,16 @@ public:
class Field_blob :public Field_longstr {
protected:
+ /**
+ The number of bytes used to represent the length of the blob.
+ */
uint packlength;
- String value; // For temporaries
+
+ /**
+ The 'value'-object is a cache fronting the storage engine.
+ */
+ String value;
+
public:
Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index aa352433141..2b947fcac4f 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -21,6 +21,9 @@
#include <my_sys.h>
#include <my_dir.h>
+/* from sql_db.cc */
+extern long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
+
/*
write string with escaping
@@ -265,8 +268,9 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
DBUG_RETURN(TRUE);
}
- // archive copies management
path[path_end]='\0';
+#ifdef FRM_ARCHIVE
+ // archive copies management: disabled unused feature (see bug #17823).
if (!access(path, F_OK))
{
if (old_version != ULONGLONG_MAX && max_versions != 0)
@@ -313,6 +317,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
}
}
}
+#endif//FRM_ARCHIVE
{
// rename temporary file
@@ -337,6 +342,7 @@ err_w_file:
SYNOPSIS
rename_in_schema_file
+ thd thread handler
schema name of given schema
old_name original file name
new_name new file name
@@ -348,7 +354,8 @@ err_w_file:
1 - Error (only if renaming of frm failed)
*/
-my_bool rename_in_schema_file(const char *schema, const char *old_name,
+my_bool rename_in_schema_file(THD *thd,
+ const char *schema, const char *old_name,
const char *new_name, ulonglong revision,
uint num_view_backups)
{
@@ -365,10 +372,11 @@ my_bool rename_in_schema_file(const char *schema, const char *old_name,
if (my_rename(old_path, new_path, MYF(MY_WME)))
return 1;
- /* check if arc_dir exists */
+ /* check if arc_dir exists: disabled unused feature (see bug #17823). */
strxnmov(arc_path, FN_REFLEN, mysql_data_home, "/", schema, "/arc", NullS);
(void) unpack_filename(arc_path, arc_path);
+#ifdef FRM_ARCHIVE
if (revision > 0 && !access(arc_path, F_OK))
{
ulonglong limit= ((revision > num_view_backups) ?
@@ -384,6 +392,16 @@ my_bool rename_in_schema_file(const char *schema, const char *old_name,
my_rename(old_path, new_path, MYF(0));
}
}
+#else//FRM_ARCHIVE
+ { // remove obsolete 'arc' directory and files if any
+ MY_DIR *new_dirp;
+ if ((new_dirp = my_dir(arc_path, MYF(MY_DONT_SORT))))
+ {
+ DBUG_PRINT("my",("Archive subdir found: %s", arc_path));
+ (void) mysql_rm_arc_files(thd, new_dirp, arc_path);
+ }
+ }
+#endif//FRM_ARCHIVE
return 0;
}
diff --git a/sql/parse_file.h b/sql/parse_file.h
index ab8b34561fe..ec920b58667 100644
--- a/sql/parse_file.h
+++ b/sql/parse_file.h
@@ -82,8 +82,9 @@ my_bool
sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
const LEX_STRING *type,
gptr base, File_option *parameters, uint versions);
-my_bool rename_in_schema_file(const char *schema, const char *old_name,
- const char *new_name, ulonglong revision,
+my_bool rename_in_schema_file(THD *thd,
+ const char *schema, const char *old_name,
+ const char *new_name, ulonglong revision,
uint num_view_backups);
class File_parser: public Sql_alloc
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 8245e8bee89..3ec6dd5cf06 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1765,7 +1765,11 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
we'll leave it here.
*/
if (!thd->in_sub_stmt)
- close_thread_tables(thd, 0, 0);
+ {
+ thd->lex->unit.cleanup();
+ close_thread_tables(thd);
+ thd->rollback_item_tree_changes();
+ }
DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str));
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6fd11e340be..883291ec460 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -974,6 +974,12 @@ sql_exchange::sql_exchange(char *name,bool flag)
cs= NULL;
}
+bool sql_exchange::escaped_given(void)
+{
+ return escaped != &default_escaped;
+}
+
+
bool select_send::send_fields(List<Item> &list, uint flags)
{
bool res;
@@ -1234,8 +1240,11 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
exchange->line_term=exchange->field_term; // Use this if it exists
field_sep_char= (exchange->enclosed->length() ?
(int) (uchar) (*exchange->enclosed)[0] : field_term_char);
- escape_char= (exchange->escaped->length() ?
- (int) (uchar) (*exchange->escaped)[0] : -1);
+ if (exchange->escaped->length() && (exchange->escaped_given() ||
+ !(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)))
+ escape_char= (int) (uchar) (*exchange->escaped)[0];
+ else
+ escape_char= -1;
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char));
line_sep_char= (exchange->line_term->length() ?
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 77ef868a5c6..a9700c9e91b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1896,6 +1896,7 @@ public:
ulong skip_lines;
CHARSET_INFO *cs;
sql_exchange(char *name,bool dumpfile_flag);
+ bool escaped_given(void);
};
#include "log_event.h"
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index e25ede1be03..8fbb407555a 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -35,7 +35,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
const char *db, const char *path, uint level,
TABLE_LIST **dropped_tables);
-static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
+long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error);
/* Database options hash */
static HASH dboptions;
@@ -906,7 +906,11 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
else if (file->name[0] == 'a' && file->name[1] == 'r' &&
file->name[2] == 'c' && file->name[3] == '\0')
{
- /* .frm archive */
+ /* .frm archive:
+ Those archives are obsolete, but following code should
+ exist to remove existent "arc" directories.
+ See #ifdef FRM_ARCHIVE directives for obsolete code.
+ */
char newpath[FN_REFLEN];
MY_DIR *new_dirp;
strxmov(newpath, org_path, "/", "arc", NullS);
@@ -1061,9 +1065,13 @@ static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error)
RETURN
> 0 number of removed files
-1 error
+
+ NOTE
+ A support of "arc" directories is obsolete, however this
+ function should exist to remove existent "arc" directories.
+ See #ifdef FRM_ARCHIVE directives for obsolete code.
*/
-static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp,
- const char *org_path)
+long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
{
long deleted= 0;
ulong found_other_files= 0;
@@ -1105,6 +1113,7 @@ static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp,
{
goto err;
}
+ deleted++;
}
if (thd->killed)
goto err;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index e9fd04dff15..5477610bb05 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -325,7 +325,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
bzero((char*) &info,sizeof(info));
info.ignore= ignore;
info.handle_duplicates=handle_duplicates;
- info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
+ info.escape_char= (escaped->length() && (ex->escaped_given() ||
+ !(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)))
+ ? (*escaped)[0] : INT_MAX;
READ_INFO read_info(file,tot_length,
ex->cs ? ex->cs : thd->variables.collation_database,
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 3b5fd6a085b..dffad0cc575 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1858,7 +1858,7 @@ mysql_rename_view(THD *thd,
goto err;
/* rename view and it's backups */
- if (rename_in_schema_file(view->db, view->table_name, new_name,
+ if (rename_in_schema_file(thd, view->db, view->table_name, new_name,
view_def.revision - 1, num_view_backups))
goto err;
@@ -1877,7 +1877,7 @@ mysql_rename_view(THD *thd,
num_view_backups))
{
/* restore renamed view in case of error */
- rename_in_schema_file(view->db, new_name, view->table_name,
+ rename_in_schema_file(thd, view->db, new_name, view->table_name,
view_def.revision - 1, num_view_backups);
goto err;
}
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index ce91d63d3f7..4e6ad68c172 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -261,6 +261,7 @@ void write_core(int sig)
#else /* __WIN__*/
#include <dbghelp.h>
+#include <tlhelp32.h>
/*
Stack tracing on Windows is implemented using Debug Helper library(dbghelp.dll)
@@ -349,6 +350,68 @@ void set_exception_pointers(EXCEPTION_POINTERS *ep)
exception_ptrs = ep;
}
+
+/*
+ Get symbol path - semicolon-separated list of directories to search for debug
+ symbols. We expect PDB in the same directory as corresponding exe or dll,
+ so the path is build from directories of the loaded modules. If environment
+ variable _NT_SYMBOL_PATH is set, it's value appended to the symbol search path
+*/
+static void get_symbol_path(char *path, size_t size)
+{
+ HANDLE hSnap;
+ char *envvar;
+
+ path[0]= '\0';
+ /*
+ Enumerate all modules, and add their directories to the path.
+ Avoid duplicate entries.
+ */
+ hSnap= CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
+ if (hSnap != INVALID_HANDLE_VALUE)
+ {
+ BOOL ret;
+ MODULEENTRY32 mod;
+ mod.dwSize= sizeof(MODULEENTRY32);
+ for (ret= Module32First(hSnap, &mod); ret; ret= Module32Next(hSnap, &mod))
+ {
+ char *module_dir= mod.szExePath;
+ char *p= strrchr(module_dir,'\\');
+ if (!p)
+ {
+ /*
+ Path separator was not found. Not known to happen, if ever happens,
+ will indicate current directory.
+ */
+ module_dir[0]= '.';
+ p= module_dir + 1;
+ }
+ *p++= ';';
+ *p= '\0';
+
+ if (!strstr(path, module_dir))
+ {
+ size_t dir_len = strlen(module_dir);
+ if (size > dir_len)
+ {
+ strncat(path, module_dir, size-1);
+ size -= dir_len;
+ }
+ }
+ }
+ CloseHandle(hSnap);
+ }
+
+ /* Add _NT_SYMBOL_PATH, if present. */
+ envvar= getenv("_NT_SYMBOL_PATH");
+ if(envvar && size)
+ {
+ strncat(path, envvar, size-1);
+ }
+}
+
+#define MAX_SYMBOL_PATH 32768
+
/* Platform SDK in VS2003 does not have definition for SYMOPT_NO_PROMPTS*/
#ifndef SYMOPT_NO_PROMPTS
#define SYMOPT_NO_PROMPTS 0
@@ -365,6 +428,7 @@ void print_stacktrace(gptr unused1, ulong unused2)
int i;
CONTEXT context;
STACKFRAME64 frame={0};
+ static char symbol_path[MAX_SYMBOL_PATH];
if(!exception_ptrs || !init_dbghelp_functions())
return;
@@ -373,7 +437,8 @@ void print_stacktrace(gptr unused1, ulong unused2)
context = *(exception_ptrs->ContextRecord);
/*Initialize symbols.*/
pSymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_NO_PROMPTS|SYMOPT_DEFERRED_LOADS|SYMOPT_DEBUG);
- pSymInitialize(hProcess,NULL,TRUE);
+ get_symbol_path(symbol_path, sizeof(symbol_path));
+ pSymInitialize(hProcess, symbol_path, TRUE);
/*Prepare stackframe for the first StackWalk64 call*/
frame.AddrFrame.Mode= frame.AddrPC.Mode= frame.AddrStack.Mode= AddrModeFlat;