summaryrefslogtreecommitdiff
path: root/heap/hp_hash.c
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2003-12-15 17:58:15 +0200
committerunknown <monty@mysql.com>2003-12-15 17:58:15 +0200
commit9000046c22fce85340a3507458658a8e1fd69f7c (patch)
treec239203a39c21349557d871ff1f29dd16ab0a5bc /heap/hp_hash.c
parente0daf11201dd6e81af73c1c74270039e73845a24 (diff)
downloadmariadb-git-9000046c22fce85340a3507458658a8e1fd69f7c.tar.gz
Added missing timeout function for named pipes and shared memory (fixes core dump on windows)
Signed auto_increment keys for HASH tables (like for MyISAM tables in 4.0) nitialize system_charset_info() early. Fixes core dump when starting windows service heap/hp_hash.c: Signed auto_increment keys for HASH tables (like for MyISAM tables in 4.0) mysql-test/r/create.result: More test for type returned by if_null() mysql-test/t/create.test: More test for type returned by if_null() sql/field.h: Remove not needed functions sql/item.cc: Use normal field create function instead of special functions just made for tmp_table_field_from_field_type sql/mysqld.cc: Initialize system_charset_info() early. Fixes core dump when starting windows service vio/vio.c: Added missing timeouts for named pipes and shared memory (fixes core dump on windows) vio/vio_priv.h: Added missing timeout function for named pipes and shared memory (fixes core dump on windows) vio/viosocket.c: Added missing timeout function for named pipes and shared memory (fixes core dump on windows)
Diffstat (limited to 'heap/hp_hash.c')
-rw-r--r--heap/hp_hash.c63
1 files changed, 50 insertions, 13 deletions
diff --git a/heap/hp_hash.c b/heap/hp_hash.c
index 2843407f3fe..4fdbfa16586 100644
--- a/heap/hp_hash.c
+++ b/heap/hp_hash.c
@@ -566,50 +566,87 @@ my_bool hp_if_null_in_key(HP_KEYDEF *keydef, const byte *record)
return 0;
}
+
+/*
+ Update auto_increment info
+
+ SYNOPSIS
+ update_auto_increment()
+ info MyISAM handler
+ record Row to update
+
+ IMPLEMENTATION
+ Only replace the auto_increment value if it is higher than the previous
+ one. For signed columns we don't update the auto increment value if it's
+ less than zero.
+*/
+
void heap_update_auto_increment(HP_INFO *info, const byte *record)
{
- ulonglong value;
+ ulonglong value= 0; /* Store unsigned values here */
+ longlong s_value= 0; /* Store signed values here */
+
HA_KEYSEG *keyseg= info->s->keydef[info->s->auto_key - 1].seg;
const uchar *key= (uchar*) record + keyseg->start;
switch (info->s->auto_key_type) {
case HA_KEYTYPE_INT8:
+ s_value= (longlong) *(char*)key;
+ break;
case HA_KEYTYPE_BINARY:
- value= (ulonglong) *(uchar*) key;
+ value=(ulonglong) *(uchar*) key;
break;
case HA_KEYTYPE_SHORT_INT:
+ s_value= (longlong) sint2korr(key);
+ break;
case HA_KEYTYPE_USHORT_INT:
- value= (ulonglong) uint2korr(key);
+ value=(ulonglong) uint2korr(key);
break;
case HA_KEYTYPE_LONG_INT:
+ s_value= (longlong) sint4korr(key);
+ break;
case HA_KEYTYPE_ULONG_INT:
- value= (ulonglong) uint4korr(key);
+ value=(ulonglong) uint4korr(key);
break;
case HA_KEYTYPE_INT24:
+ s_value= (longlong) sint3korr(key);
+ break;
case HA_KEYTYPE_UINT24:
- value= (ulonglong) uint3korr(key);
+ value=(ulonglong) uint3korr(key);
break;
- case HA_KEYTYPE_FLOAT: /* This shouldn't be used */
+ case HA_KEYTYPE_FLOAT: /* This shouldn't be used */
{
float f_1;
- float4get(f_1, key);
- value= (ulonglong) f_1;
+ float4get(f_1,key);
+ /* Ignore negative values */
+ value = (f_1 < (float) 0.0) ? 0 : (ulonglong) f_1;
break;
}
- case HA_KEYTYPE_DOUBLE: /* This shouldn't be used */
+ case HA_KEYTYPE_DOUBLE: /* This shouldn't be used */
{
double f_1;
- float8get(f_1, key);
- value= (ulonglong) f_1;
+ float8get(f_1,key);
+ /* Ignore negative values */
+ value = (f_1 < 0.0) ? 0 : (ulonglong) f_1;
break;
}
case HA_KEYTYPE_LONGLONG:
+ s_value= sint8korr(key);
+ break;
case HA_KEYTYPE_ULONGLONG:
value= uint8korr(key);
break;
default:
- value= 0; /* Error */
+ DBUG_ASSERT(0);
+ value=0; /* Error */
break;
}
- set_if_bigger(info->s->auto_increment, value);
+
+ /*
+ The following code works becasue if s_value < 0 then value is 0
+ and if s_value == 0 then value will contain either s_value or the
+ correct value.
+ */
+ set_if_bigger(info->s->auto_increment,
+ (s_value > 0) ? (ulonglong) s_value : value);
}