Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GH-4: Fix set_multi with single arrayref

Previously set_multi would crash when a single arrayref was used as part
of the list. This fixes that issue
  • Loading branch information...
commit 69d3c3578c56447848fb969c1da8a84bf486df11 1 parent e3c9f9f
@mnunberg authored
Showing with 19 additions and 6 deletions.
  1. +8 −0 lib/Couchbase/Test/ClientSync.pm
  2. +11 −6 xs/Client_multi.xs
View
8 lib/Couchbase/Test/ClientSync.pm
@@ -259,6 +259,14 @@ sub T06_multi :Test(no_plan) {
"all keys have been decremented");
}
+sub T06_multi_GH4 :Test(no_plan) {
+ my $self = shift;
+ my $o = $self->cbo;
+ my $rv = $o->set_multi(['single_key', 'single_value']);
+ ok($rv->{"single_key"}->is_ok, "Single arrayref on setmulti does not fail");
+}
+
+
sub T07_stats :Test(no_plan) {
my $self = shift;
my $o = $self->cbo;
View
17 xs/Client_multi.xs
@@ -434,20 +434,25 @@ static int arith_cmd_map[] = {
-#define _MAYBE_MULTI_ARG(array) \
- if(items == 2) { \
- array = (AV*)ST(1); warn("Using second stack item for AV"); \
+#define _MAYBE_MULTI_ARG2(array, always_wrap) \
+ if(items == 2 && always_wrap == 0) { \
+ array = (AV*)ST(1); \
if( (SvROK((SV*)array)) && (array = (AV*)SvRV((SV*)array))) { \
if(SvTYPE(array) < SVt_PVAV) { \
die("Expected ARRAY reference for arguments"); \
} \
} \
- } else if (items > 2) { \
+ } else if (items > 2 || items == 2 && always_wrap == 1) { \
array = (AV*)sv_2mortal((SV*)av_make(items - 1, (SP - items + 2))); \
} else { \
die("Usage: %s(self, args)", GvNAME(GvCV(cv))); \
}
+
+#define _MAYBE_MULTI_ARG(array) \
+ _MAYBE_MULTI_ARG2(array, 0)
+
+
MODULE = Couchbase::Client_multi PACKAGE = Couchbase::Client PREFIX = PLCB_
PROTOTYPES: DISABLE
@@ -489,7 +494,7 @@ PLCB_set_multi(self, ...)
CODE:
cmd = set_cmd_map[ix];
- _MAYBE_MULTI_ARG(args);
+ _MAYBE_MULTI_ARG2(args, 1);
RETVAL = PLCB_multi_set_common(self, args, cmd);
OUTPUT:
@@ -531,4 +536,4 @@ PLCB_remove_multi(self, ...)
OUTPUT:
RETVAL
-
+
Please sign in to comment.
Something went wrong with that request. Please try again.