Clarified return type for prefix key in cases where it is too long.
author <brian@gir-3.local> <>
Mon, 30 Jun 2008 16:01:46 +0000 (09:01 -0700)
committer <brian@gir-3.local> <>
Mon, 30 Jun 2008 16:01:46 +0000 (09:01 -0700)
ChangeLog
docs/memcached_callback.pod
libmemcached/memcached_callback.c
tests/function.c

index 50d087720e1dbd18f052bad7a631d125bf8e7b10..d5c8734fc2976936267895c0b6c047d168b86d51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+  * Fixed bugs in stats output (thread output was wrong)
+  * Clarified MEMCACHED_BAD_KEY_PROVIDED is return for bad prefix key.
+
 0.22
   * Found a bug in Flags return (Jacek Ostrowski)
   * Fixed issue with compiling on Visual Studio
 0.22
   * Found a bug in Flags return (Jacek Ostrowski)
   * Fixed issue with compiling on Visual Studio
index e1b2fb16d9e058bf2a7e546733b6997dce35c9ae..1858302cbb487fac62be51b8eee6b29570a755d5 100755 (executable)
@@ -51,9 +51,10 @@ point of its execution all connections have been closed.
 
 You can set a value which will be used to create a domain for your keys.
 The value specified here will be prefixed to each of your keys. The value can not
 
 You can set a value which will be used to create a domain for your keys.
 The value specified here will be prefixed to each of your keys. The value can not
-be greater then MEMCACHED_PREFIX_KEY_MAX_SIZE and will reduce MEMCACHED_MAX_KEY by
+be greater then MEMCACHED_PREFIX_KEY_MAX_SIZE - 1 and will reduce MEMCACHED_MAX_KEY by
 the value of your key. The prefix key is only applied to the primary key,
 the value of your key. The prefix key is only applied to the primary key,
-not the master key.
+not the master key. MEMCACHED_FAILURE will be returned if no key is set. In the case
+of a key which is too long MEMCACHED_BAD_KEY_PROVIDED will be returned.
 
 =item MEMCACHED_CALLBACK_USER_DATA
 
 
 =item MEMCACHED_CALLBACK_USER_DATA
 
index c231716d9b8ca9a35dab5fe67519b27d8b24cd4b..ad1ce2b1e65bb4d2bb81478201d1a76320c1231f 100644 (file)
@@ -101,8 +101,16 @@ void *memcached_callback_get(memcached_st *ptr,
   {
   case MEMCACHED_CALLBACK_PREFIX_KEY:
     {
   {
   case MEMCACHED_CALLBACK_PREFIX_KEY:
     {
-      *error= ptr->prefix_key[0] != 0  ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE;
-      return (void *)ptr->prefix_key;
+      if (ptr->prefix_key[0] == 0)
+      {
+        *error= MEMCACHED_FAILURE;
+        return NULL;
+      }
+      else
+      {
+        *error= MEMCACHED_SUCCESS;
+        return (void *)ptr->prefix_key;
+      }
     }
   case MEMCACHED_CALLBACK_USER_DATA:
     {
     }
   case MEMCACHED_CALLBACK_USER_DATA:
     {
index 015fa49ca377353dd05fb17eaf040977f1efba74..fb2f4bca42cd7caff2c898f7988f6296172e2f9e 100644 (file)
@@ -2006,7 +2006,6 @@ test_return user_supplied_bug15(memcached_st *memc)
 /* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */
 test_return user_supplied_bug16(memcached_st *memc)
 {
 /* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */
 test_return user_supplied_bug16(memcached_st *memc)
 {
-  uint32_t x;
   memcached_return rc;
   char *key= "mykey";
   char *value;
   memcached_return rc;
   char *key= "mykey";
   char *value;
@@ -2523,6 +2522,20 @@ memcached_return set_prefix(memcached_st *memc)
   assert(rc == MEMCACHED_SUCCESS);
   assert(memcmp(value, key, 4) == 0);
 
   assert(rc == MEMCACHED_SUCCESS);
   assert(memcmp(value, key, 4) == 0);
 
+  /* Set to Zero, and then Set to something too large */
+  {
+    char *long_key= "This is more then the allotted number of characters";
+    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL);
+    assert(rc == MEMCACHED_SUCCESS);
+
+    value= memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc);
+    assert(rc == MEMCACHED_FAILURE);
+    assert(value == NULL);
+
+    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
+    assert(rc == MEMCACHED_BAD_KEY_PROVIDED);
+  }
+
   return MEMCACHED_SUCCESS;
 }
 
   return MEMCACHED_SUCCESS;
 }