Fixes for returning better error in parser if namespace is invoked twice.
[awesomized/libmemcached] / libmemcached / csl / parser.yy
index 08441987e9b9e7412a447d1e13338b937e1c681d..332d323e823b9c915568c1afd91326f0432d52e4 100644 (file)
@@ -250,48 +250,53 @@ expression:
 behaviors:
           NAMESPACE string
           {
+            if (memcached_callback_get(context->memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL))
+            {
+              parser_abort(context, "--NAMESPACE can only be called once");
+            }
+
             if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, memcached_last_error_message(context->memc));
             }
           }
         | DISTRIBUTION distribution
           {
             if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, memcached_last_error_message(context->memc));;
             }
           }
         | DISTRIBUTION distribution ',' hash
           {
             if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, NULL);
             }
             if ((context->rc= memcached_behavior_set_distribution_hash(context->memc, $4)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, NULL);
             }
           }
         | HASH hash
           {
             if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_HASH, $2)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);; 
+              parser_abort(context, NULL); 
             }
           }
         | behavior_number NUMBER
           {
             if ((context->rc= memcached_behavior_set(context->memc, $1, $2)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, NULL);
             }
           }
         | behavior_boolean
           {
             if ((context->rc= memcached_behavior_set(context->memc, $1, true)) != MEMCACHED_SUCCESS)
             {
-              parser_abort(context, NULL);;
+              parser_abort(context, NULL);
             }
           }
         |  USER_DATA