diff options
author | unknown <monty@mishka.local> | 2004-10-20 01:28:42 +0300 |
---|---|---|
committer | unknown <monty@mishka.local> | 2004-10-20 01:28:42 +0300 |
commit | da02110dae49d1e9546d27f13ad6a8e9a97a4d81 (patch) | |
tree | 1919e7f3a6a68e36dbbcf1dd8b6cd8729a975e36 /sql/sql_show.cc | |
parent | 9bc6c0827272ca6a5585090e696193754d22a0a6 (diff) | |
download | mariadb-git-da02110dae49d1e9546d27f13ad6a8e9a97a4d81.tar.gz |
Review of all code pushed since last review
Simple optimzations and cleanups
Removed compiler warnings and fixed portability issues
Added client functions 'mysql_embedded()' to allow client to check if we are using embedded server
Fixes for purify
client/mysqlimport.c:
Remove not used variable
client/mysqltest.c:
Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN)
Simplified code
Remove usage of sprintf("%llu") as this is not portable
include/mysql.h:
Added mysql_embedded() to be able to easily check if we are using the embedded server
innobase/srv/srv0start.c:
Don't use memcmp() when using purify (to avoid false warnings)
libmysql/libmysql.c:
Added mysql_embedded() to be able to easily check if we are using the embedded server
libmysql/libmysql.def:
Added mysql_embedded() to be able to easily check if we are using the embedded server
myisam/myisam_ftdump.c:
Remove compiler warning
myisam/myisamchk.c:
Remove compiler warning
myisam/rt_test.c:
#ifdef not used code
mysys/hash.c:
Remove compiler warning (from last push)
mysys/my_gethwaddr.c:
Remove compiler warning
ndb/src/ndbapi/ndberror.c:
#ifdef not used code
regex/regcomp.c:
Remove not used code
regex/regcomp.ih:
Remove not used code (to remove compiler warnings)
sql-common/client.c:
Remove compiler warnings
sql/field.cc:
Simple optimization
sql/ha_innodb.cc:
Rename mysql_embedded -> mysqld_embedded
sql/item.cc:
Fix comments
Move variables first on block
Remove else after return
Simple optimizations
(no logic changes)
sql/item_cmpfunc.cc:
Added comment
sql/mysql_priv.h:
Rename mysql_embedded -> mysqld_embedded
sql/mysqld.cc:
Rename mysql_embedded -> mysqld_embedded
sql/sql_acl.cc:
Added comments
simple optimization
Fixed 'very unlikely' bug when doing REVOKE ALL PRIVILEGES
sql/sql_select.cc:
More comments
Simple optimization
sql/sql_show.cc:
Simple changes to make similar code similar
More comments
sql/sql_string.cc:
Trivial optimization and better code layout
strings/Makefile.am:
Change xml.c to use bcmp to avoid warnings from purify
strings/xml.c:
Change xml.c to use bcmp to avoid warnings from purify
tests/client_test.c:
Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN)
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c5cd2860e03..e030db2caf7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1136,7 +1136,7 @@ static const char *require_quotes(const char *name, uint name_length) for ( ; name < end ; name++) { uchar chr= (uchar) *name; - length= my_mbcharlen(system_charset_info, (uchar) chr); + length= my_mbcharlen(system_charset_info, chr); if (length == 1 && !system_charset_info->ident_map[chr]) return name; } @@ -1148,25 +1148,29 @@ 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 (q == EOF) { + if (q == EOF) + { packet->append(name, length, system_charset_info); return; } - char quote_char= q; - - /* 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; - length= my_mbcharlen(system_charset_info, (uchar) chr); - if (length == 1 && chr == quote_char) + uchar chr= (uchar) *name; + length= my_mbcharlen(system_charset_info, chr); + if (length == 1 && chr == (uchar) quote_char) packet->append("e_char, 1, system_charset_info); packet->append(name, length, packet->charset()); } @@ -1174,8 +1178,25 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) } -/* Get the quote character for displaying an identifier. - If no quote character is needed, return EOF. */ +/* + 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) { @@ -1183,10 +1204,9 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length) !require_quotes(name, length) && !(thd->options & OPTION_QUOTE_SHOW_CREATE)) return EOF; - else if (thd->variables.sql_mode & MODE_ANSI_QUOTES) + if (thd->variables.sql_mode & MODE_ANSI_QUOTES) return '"'; - else - return '`'; + return '`'; } @@ -1195,10 +1215,9 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length) 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); |