summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-02-27 03:44:44 +0200
committerunknown <monty@narttu.mysql.fi>2003-02-27 03:44:44 +0200
commit669cbe6e5fffb715e117a96273db9c95e229b3a9 (patch)
treee734507eb0df4722e03a80a37b7b9a4c53728c3e /sql
parenta7e3ba1df50e4be9148baa2396a0d19f4fe73b8e (diff)
downloadmariadb-git-669cbe6e5fffb715e117a96273db9c95e229b3a9.tar.gz
Portability fixes
Don't define crc32 if we are not linking with gzip cmd-line-utils/libedit/libedit_term.h: Rename: cmd-line-utils/libedit/term.h -> cmd-line-utils/libedit/libedit_term.h BitKeeper/etc/ignore: added scripts/make_win_src_distribution client/connect_test.c: Removed wrong include file (my_global.h should never be included by an external client) client/insert_test.c: Removed wrong include file (my_global.h should never be included by an external client) client/select_test.c: Removed wrong include file (my_global.h should never be included by an external client) cmd-line-utils/libedit/Makefile.am: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/el.h: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/key.h: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/makelist: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/read.c: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/readline.c: Portability fixes (for HPUX11 and AIX) cmd-line-utils/libedit/readline/readline.h: Systems that has sys/cdefs may not have __BEGIN_DECLS cmd-line-utils/libedit/sig.c: sig_t is not portable cmd-line-utils/libedit/sig.h: sig_t is not portable cmd-line-utils/libedit/term.c: Portablity fixes Fixed core dump when using a terminal without arrow key definitions heap/_check.c: Portability fix heap/hp_hash.c: Portability fix heap/hp_rkey.c: Portability fix include/my_global.h: Portability fixes for HPUX11 libmysql/libmysql.c: Removed wrong cast mysql-test/r/union.result: New union tests mysql-test/t/union.test: New union tests sql/gen_lex_hash.cc: Fixed portability bug. sql/gstream.h: Portablity fix sql/item_create.cc: Don't define crc32 if we are not linking with gzip sql/item_create.h: Don't define crc32 if we are not linking with gzip sql/item_func.cc: Don't define crc32 if we are not linking with gzip sql/item_func.h: Don't define crc32 if we are not linking with gzip sql/lex.h: Don't define crc32 if we are not linking with gzip sql/sql_show.cc: Name can't be NULL
Diffstat (limited to 'sql')
-rw-r--r--sql/gen_lex_hash.cc80
-rw-r--r--sql/gstream.h2
-rw-r--r--sql/item_create.cc3
-rw-r--r--sql/item_create.h2
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/item_func.h4
-rw-r--r--sql/lex.h2
-rw-r--r--sql/sql_show.cc1
8 files changed, 71 insertions, 28 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 7ae28e0ce77..1c6f124aac7 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -93,7 +93,7 @@ static struct my_option my_long_options[] =
struct hash_lex_struct
{
- char first_char;
+ int first_char;
char last_char;
union{
hash_lex_struct *char_tails;
@@ -121,18 +121,20 @@ void insert_into_hash(hash_lex_struct *root, const char *name,
{
hash_lex_struct *end, *cur, *tails;
- if (!root->first_char){
+ if (!root->first_char)
+ {
root->first_char= -1;
root->iresult= index;
return;
}
- if (root->first_char==-1){
+ if (root->first_char == -1)
+ {
int index2= root->iresult;
- const char *name2=
- (index2<0 ? sql_functions[-index2-1] : symbols[index2]).name + len_from_begin;
- root->first_char= name2[0];
- root->last_char= root->first_char;
+ const char *name2= (index2 < 0 ? sql_functions[-index2-1] :
+ symbols[index2]).name + len_from_begin;
+ root->first_char= (int) (uchar) name2[0];
+ root->last_char= (char) root->first_char;
tails= (hash_lex_struct*)malloc(sizeof(hash_lex_struct));
root->char_tails= tails;
tails->first_char= -1;
@@ -141,7 +143,8 @@ void insert_into_hash(hash_lex_struct *root, const char *name,
size_t real_size= (root->last_char-root->first_char+1);
- if (root->first_char>(*name)){
+ if (root->first_char>(*name))
+ {
size_t new_size= root->last_char-(*name)+1;
if (new_size<real_size) printf("error!!!!\n");
tails= root->char_tails;
@@ -152,10 +155,11 @@ void insert_into_hash(hash_lex_struct *root, const char *name,
end= tails + new_size - real_size;
for (cur= tails; cur<end; cur++)
cur->first_char= 0;
- root->first_char= (*name);
+ root->first_char= (int) (uchar) *name;
}
- if (root->last_char<(*name)){
+ if (root->last_char<(*name))
+ {
size_t new_size= (*name)-root->first_char+1;
if (new_size<real_size) printf("error!!!!\n");
tails= root->char_tails;
@@ -168,10 +172,11 @@ void insert_into_hash(hash_lex_struct *root, const char *name,
root->last_char= (*name);
}
- insert_into_hash (root->char_tails+(*name)-root->first_char,
- name+1,len_from_begin+1,index,function);
+ insert_into_hash(root->char_tails+(*name)-root->first_char,
+ name+1,len_from_begin+1,index,function);
}
+
hash_lex_struct *root_by_len= 0;
int max_len=0;
@@ -235,20 +240,22 @@ void add_struct_to_map(hash_lex_struct *st)
st->ithis= size_hash_map/4;
size_hash_map+= 4;
hash_map= (char*)realloc((char*)hash_map,size_hash_map);
- hash_map[size_hash_map-4]= st->first_char==-1 ? 0 : st->first_char;
- hash_map[size_hash_map-3]=
- st->first_char==-1 || st->first_char==0 ? 0 : st->last_char;
- if (st->first_char==-1)
+ hash_map[size_hash_map-4]= (char) (st->first_char == -1 ? 0 :
+ st->first_char);
+ hash_map[size_hash_map-3]= (char) (st->first_char == -1 ||
+ st->first_char == 0 ? 0 : st->last_char);
+ if (st->first_char == -1)
{
hash_map[size_hash_map-2]= ((unsigned int)(int16)st->iresult)&255;
hash_map[size_hash_map-1]= ((unsigned int)(int16)st->iresult)>>8;
}
- else if (st->first_char==0)
+ else if (st->first_char == 0)
{
hash_map[size_hash_map-2]= ((unsigned int)(int16)array_elements(symbols))&255;
hash_map[size_hash_map-1]= ((unsigned int)(int16)array_elements(symbols))>>8;
}
-};
+}
+
void add_structs_to_map(hash_lex_struct *st, int len)
{
@@ -256,28 +263,36 @@ void add_structs_to_map(hash_lex_struct *st, int len)
for (cur= st; cur<end; cur++)
add_struct_to_map(cur);
for (cur= st; cur<end; cur++)
- if (cur->first_char && cur->first_char!=-1)
+ {
+ if (cur->first_char && cur->first_char != -1)
add_structs_to_map(cur->char_tails,cur->last_char-cur->first_char+1);
+ }
}
void set_links(hash_lex_struct *st, int len)
{
hash_lex_struct *cur, *end= st+len;
for (cur= st; cur<end; cur++)
- if (cur->first_char!=0 && cur->first_char!=-1){
+ {
+ if (cur->first_char != 0 && cur->first_char != -1)
+ {
int ilink= cur->char_tails->ithis;
hash_map[cur->ithis*4+2]= ilink%256;
hash_map[cur->ithis*4+3]= ilink/256;
set_links(cur->char_tails,cur->last_char-cur->first_char+1);
}
+ }
}
+
void print_hash_map(const char *name)
{
- printf("uchar %s[%d]= {\n",name,size_hash_map);
char *cur;
int i;
- for (i=0, cur= hash_map; i<size_hash_map; i++, cur++){
+
+ printf("uchar %s[%d]= {\n",name,size_hash_map);
+ for (i=0, cur= hash_map; i<size_hash_map; i++, cur++)
+ {
switch(i%4){
case 0: case 1:
if (!*cur)
@@ -292,6 +307,7 @@ void print_hash_map(const char *name)
printf("};\n");
}
+
void print_find_structs()
{
add_structs_to_map(root_by_len,max_len);
@@ -308,9 +324,10 @@ void print_find_structs()
print_hash_map("symbols_map");
}
+
static void usage(int version)
{
- printf("%s Ver 3.5 Distrib %s, for %s (%s)\n",
+ printf("%s Ver 3.6 Distrib %s, for %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version)
return;
@@ -322,6 +339,7 @@ and you are welcome to modify and redistribute it under the GPL license\n");
my_print_help(my_long_options);
}
+
extern "C" my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
@@ -338,6 +356,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
return 0;
}
+
static int get_options(int argc, char **argv)
{
int ho_error;
@@ -353,6 +372,7 @@ static int get_options(int argc, char **argv)
return(0);
}
+
int check_dup_symbols(SYMBOL *s1, SYMBOL *s2)
{
if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length))
@@ -367,6 +387,7 @@ your lex.h has duplicate definition for a symbol \"%s\"\n\n";
return 1;
}
+
int check_duplicates()
{
SYMBOL *cur1, *cur2, *s_end, *f_end;
@@ -377,21 +398,29 @@ int check_duplicates()
for (cur1= symbols; cur1<s_end; cur1++)
{
for (cur2= cur1+1; cur2<s_end; cur2++)
+ {
if (check_dup_symbols(cur1,cur2))
return 1;
+ }
for (cur2= sql_functions; cur2<f_end; cur2++)
+ {
if (check_dup_symbols(cur1,cur2))
return 1;
+ }
}
for (cur1= sql_functions; cur1<f_end; cur1++)
+ {
for (cur2= cur1+1; cur2< f_end; cur2++)
+ {
if (check_dup_symbols(cur1,cur2))
return 1;
-
+ }
+ }
return 0;
}
+
int main(int argc,char **argv)
{
MY_INIT(argv[0]);
@@ -443,7 +472,8 @@ int main(int argc,char **argv)
for(;;){\n\
register uchar first_char= (uchar)cur_struct;\n\
\n\
- if (first_char==0){\n\
+ if (first_char == 0)\n\
+ {\n\
register int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
register SYMBOL *res;\n\
diff --git a/sql/gstream.h b/sql/gstream.h
index f26ef8899f8..a3914a534dd 100644
--- a/sql/gstream.h
+++ b/sql/gstream.h
@@ -26,7 +26,7 @@ public:
numeric,
l_bra,
r_bra,
- comma,
+ comma
};
GTextReadStream(const char *buffer, int size)
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 5c37abb230f..8b2cf52f660 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -103,10 +103,13 @@ Item *create_func_cot(Item* a)
new Item_func_tan(a));
}
+
+#ifdef HAVE_COMPRESS
Item *create_func_crc32(Item* a)
{
return new Item_func_crc32(a);
}
+#endif
Item *create_func_date_format(Item* a,Item *b)
{
diff --git a/sql/item_create.h b/sql/item_create.h
index 0c51886180f..f7542a7b29f 100644
--- a/sql/item_create.h
+++ b/sql/item_create.h
@@ -32,7 +32,9 @@ Item *create_func_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c);
Item *create_func_cos(Item* a);
Item *create_func_cot(Item* a);
+#ifdef HAVE_COMPRESS
Item *create_func_crc32(Item* a);
+#endif
Item *create_func_date_format(Item* a,Item *b);
Item *create_func_dayname(Item* a);
Item *create_func_dayofmonth(Item* a);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3954b53c063..14ceca25af5 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -27,7 +27,9 @@
#include <hash.h>
#include <time.h>
#include <ft_global.h>
+#ifdef HAVE_COMPRESS
#include <zlib.h>
+#endif
/* return TRUE if item is a constant */
@@ -965,6 +967,8 @@ longlong Item_func_min_max::val_int()
return value;
}
+
+#ifdef HAVE_COMPRESS
longlong Item_func_crc32::val_int()
{
String *res=args[0]->val_str(&value);
@@ -976,6 +980,7 @@ longlong Item_func_crc32::val_int()
null_value=0;
return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
}
+#endif /* HAVE_COMPRESS */
longlong Item_func_length::val_int()
diff --git a/sql/item_func.h b/sql/item_func.h
index 68804b83d26..33bfc993b5f 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -549,6 +549,8 @@ public:
const char *func_name() const { return "greatest"; }
};
+
+#ifdef HAVE_COMPRESS
class Item_func_crc32 :public Item_int_func
{
String value;
@@ -558,7 +560,7 @@ public:
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
};
-
+#endif
class Item_func_length :public Item_int_func
{
diff --git a/sql/lex.h b/sql/lex.h
index 287439a9fe7..4e6689ca2d3 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -448,7 +448,9 @@ static SYMBOL sql_functions[] = {
{ "COUNT", SYM(COUNT_SYM),0,0},
{ "COS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cos)},
{ "COT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cot)},
+#ifdef HAVE_COMPRESS
{ "CRC32", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_crc32)},
+#endif
{ "CROSSES", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_crosses)},
{ "CURDATE", SYM(CURDATE),0,0},
{ "CURTIME", SYM(CURTIME),0,0},
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 888aecebd8d..18a11cb2c4b 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -483,7 +483,6 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
(void) sprintf(path,"%s/%s",mysql_data_home,db);
(void) unpack_dirname(path,path);
field_list.push_back(item=new Item_empty_string("Name",NAME_LEN));
- item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("Type",10));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("Row_format",10));