diff options
author | antony@ppcg5.local <> | 2007-03-02 08:43:45 -0800 |
---|---|---|
committer | antony@ppcg5.local <> | 2007-03-02 08:43:45 -0800 |
commit | dc24473cb20a13b8af79aa8327b0e0fb253ff239 (patch) | |
tree | 23fe49e9ab83f6badb4e173587f9e194490a3859 /mysys/hash.c | |
parent | 83a5eac0a43dfd7ca4ac4d01926c4dfc668a46e4 (diff) | |
download | mariadb-git-dc24473cb20a13b8af79aa8327b0e0fb253ff239.tar.gz |
WL#2936
"Server Variables for Plugins"
Implement support for plugins to declare server variables.
Demonstrate functionality by removing InnoDB specific code from sql/*
New feature for HASH - HASH_UNIQUE flag
New feature for DYNAMIC_ARRAY - initializer accepts preallocated ptr.
Completed support for plugin reference counting.
Diffstat (limited to 'mysys/hash.c')
-rw-r--r-- | mysys/hash.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 60168e01e20..ab875848989 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -315,6 +315,10 @@ my_bool my_hash_insert(HASH *info,const byte *record) LINT_INIT(gpos); LINT_INIT(gpos2); LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2); + if (HASH_UNIQUE & info->flags && + hash_search(info, hash_key(info, record, &idx, 1), idx)) + return(TRUE); /* Duplicate entry */ + flag=0; if (!(empty=(HASH_LINK*) alloc_dynamic(&info->array))) return(TRUE); /* No more memory */ @@ -530,6 +534,19 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length) uint idx,new_index,new_pos_index,blength,records,empty; HASH_LINK org_link,*data,*previous,*pos; DBUG_ENTER("hash_update"); + + if (HASH_UNIQUE & hash->flags) + { + HASH_SEARCH_STATE state; + byte *found, *new_key= hash_key(hash, record, &idx, 1); + if ((found= hash_first(hash, new_key, idx, &state))) + do + { + if (found != record) + DBUG_RETURN(1); /* Duplicate entry */ + } + while ((found= hash_next(hash, new_key, idx, &state))); + } data=dynamic_element(&hash->array,0,HASH_LINK*); blength=hash->blength; records=hash->records; |