mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
merge with 4.1
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
This commit is contained in:
113
sql/sql_show.cc
113
sql/sql_show.cc
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
/* Copyright (C) 2000-2004 MySQL AB
|
||||
|
||||
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
|
||||
@@ -34,7 +34,7 @@ static const char *grant_names[]={
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **),
|
||||
"grant_types",
|
||||
grant_names};
|
||||
grant_names, NULL};
|
||||
#endif
|
||||
|
||||
static int
|
||||
@@ -407,6 +407,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
|
||||
if (wild && !wild[0])
|
||||
wild=0;
|
||||
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
|
||||
if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0)))))
|
||||
@@ -419,27 +420,23 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
{ /* Return databases */
|
||||
#ifdef USE_SYMDIR
|
||||
char *ext;
|
||||
char buff[FN_REFLEN];
|
||||
if (my_use_symdir && !strcmp(ext=fn_ext(file->name), ".sym"))
|
||||
{
|
||||
/* Only show the sym file if it points to a directory */
|
||||
char buff[FN_REFLEN], *end;
|
||||
MY_STAT status;
|
||||
char *end;
|
||||
*ext=0; /* Remove extension */
|
||||
unpack_dirname(buff, file->name);
|
||||
end= strend(buff);
|
||||
if (end != buff && end[-1] == FN_LIBCHAR)
|
||||
end[-1]= 0; // Remove end FN_LIBCHAR
|
||||
if (!my_stat(buff, &status, MYF(0)) ||
|
||||
!MY_S_ISDIR(status.st_mode))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (!my_stat(buff, file->mystat, MYF(0)))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat->st_mode) ||
|
||||
(wild && wild_compare(file->name,wild,0)))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -478,6 +475,9 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
}
|
||||
DBUG_PRINT("info",("found: %d files", files->elements));
|
||||
my_dirend(dirp);
|
||||
|
||||
VOID(ha_find_files(thd,db,path,wild,dir,files));
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@@ -761,10 +761,11 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
|
||||
protocol->store(field->has_charset() ? field->charset()->name : "NULL",
|
||||
system_charset_info);
|
||||
/*
|
||||
Although TIMESTAMP fields can't contain NULL as its value they
|
||||
Even if TIMESTAMP field can't contain NULL as its value it
|
||||
will accept NULL if you will try to insert such value and will
|
||||
convert it to current TIMESTAMP. So YES here means that NULL
|
||||
is allowed for assignment but can't be returned.
|
||||
convert NULL value to current TIMESTAMP. So YES here means
|
||||
that NULL is allowed for assignment (but may be won't be
|
||||
returned).
|
||||
*/
|
||||
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
|
||||
field->type() != FIELD_TYPE_TIMESTAMP ?
|
||||
@@ -1240,51 +1241,33 @@ static const char *require_quotes(const char *name, uint name_length)
|
||||
}
|
||||
|
||||
|
||||
static void append_quoted_simple_identifier(String *packet, char quote_char,
|
||||
const char *name, uint length)
|
||||
{
|
||||
packet->append("e_char, 1, system_charset_info);
|
||||
packet->append(name, length, system_charset_info);
|
||||
packet->append("e_char, 1, system_charset_info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
append_identifier(THD *thd, String *packet, const char *name, uint length)
|
||||
{
|
||||
const char *name_end;
|
||||
char quote_char;
|
||||
int q= get_quote_char_for_identifier(thd, name, length);
|
||||
|
||||
if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
|
||||
quote_char= '\"';
|
||||
else
|
||||
quote_char= '`';
|
||||
|
||||
if (is_keyword(name,length))
|
||||
if (q == EOF)
|
||||
{
|
||||
append_quoted_simple_identifier(packet, quote_char, name, length);
|
||||
packet->append(name, length, system_charset_info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!require_quotes(name, length))
|
||||
{
|
||||
if (!(thd->options & OPTION_QUOTE_SHOW_CREATE))
|
||||
packet->append(name, length, system_charset_info);
|
||||
else
|
||||
append_quoted_simple_identifier(packet, quote_char, name, length);
|
||||
return;
|
||||
}
|
||||
|
||||
/* The identifier must be quoted as it includes a quote character */
|
||||
/*
|
||||
The identifier must be quoted as it includes a quote character or
|
||||
it's a keyword
|
||||
*/
|
||||
|
||||
packet->reserve(length*2 + 2);
|
||||
quote_char= (char) q;
|
||||
packet->append("e_char, 1, system_charset_info);
|
||||
|
||||
for (name_end= name+length ; name < name_end ; name+= length)
|
||||
{
|
||||
char chr= *name;
|
||||
uchar chr= (uchar) *name;
|
||||
length= my_mbcharlen(system_charset_info, chr);
|
||||
if (length == 1 && chr == quote_char)
|
||||
if (length == 1 && chr == (uchar) quote_char)
|
||||
packet->append("e_char, 1, system_charset_info);
|
||||
packet->append(name, length, packet->charset());
|
||||
}
|
||||
@@ -1292,15 +1275,46 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Get the quote character for displaying an identifier.
|
||||
|
||||
SYNOPSIS
|
||||
get_quote_char_for_identifier()
|
||||
thd Thread handler
|
||||
name name to quote
|
||||
length length of name
|
||||
|
||||
IMPLEMENTATION
|
||||
If name is a keyword or includes a special character, then force
|
||||
quoting.
|
||||
Otherwise identifier is quoted only if the option OPTION_QUOTE_SHOW_CREATE
|
||||
is set.
|
||||
|
||||
RETURN
|
||||
EOF No quote character is needed
|
||||
# Quote character
|
||||
*/
|
||||
|
||||
int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
|
||||
{
|
||||
if (!is_keyword(name,length) &&
|
||||
!require_quotes(name, length) &&
|
||||
!(thd->options & OPTION_QUOTE_SHOW_CREATE))
|
||||
return EOF;
|
||||
if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
|
||||
return '"';
|
||||
return '`';
|
||||
}
|
||||
|
||||
|
||||
/* Append directory name (if exists) to CREATE INFO */
|
||||
|
||||
static void append_directory(THD *thd, String *packet, const char *dir_type,
|
||||
const char *filename)
|
||||
{
|
||||
uint length;
|
||||
if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
|
||||
{
|
||||
length= dirname_length(filename);
|
||||
uint length= dirname_length(filename);
|
||||
packet->append(' ');
|
||||
packet->append(dir_type);
|
||||
packet->append(" DIRECTORY='", 12);
|
||||
@@ -1362,6 +1376,8 @@ store_create_info(THD *thd, TABLE *table, String *packet)
|
||||
// check for surprises from the previous call to Field::sql_type()
|
||||
if (type.ptr() != tmp)
|
||||
type.set(tmp, sizeof(tmp), system_charset_info);
|
||||
else
|
||||
type.set_charset(system_charset_info);
|
||||
|
||||
field->sql_type(type);
|
||||
packet->append(type.ptr(), type.length(), system_charset_info);
|
||||
@@ -1386,7 +1402,14 @@ store_create_info(THD *thd, TABLE *table, String *packet)
|
||||
|
||||
if (flags & NOT_NULL_FLAG)
|
||||
packet->append(" NOT NULL", 9);
|
||||
|
||||
else if (field->type() == FIELD_TYPE_TIMESTAMP)
|
||||
{
|
||||
/*
|
||||
TIMESTAMP field require explicit NULL flag, because unlike
|
||||
all other fields they are treated as NOT NULL by default.
|
||||
*/
|
||||
packet->append(" NULL", 5);
|
||||
}
|
||||
|
||||
/*
|
||||
Again we are using CURRENT_TIMESTAMP instead of NOW because it is
|
||||
|
||||
Reference in New Issue
Block a user