]> granicus.if.org Git - ejabberd/commitdiff
Nidx may be integer or binary, so use jlib:i2l instead
authorBadlop <badlop@process-one.net>
Thu, 20 Oct 2016 19:56:19 +0000 (21:56 +0200)
committerBadlop <badlop@process-one.net>
Thu, 20 Oct 2016 19:56:19 +0000 (21:56 +0200)
As reported in
https://www.ejabberd.im/forum/28580/erlang-function-integertobinary1-throwing-badargs-exception

src/node_flat_sql.erl

index 15cf9b37a0153f2c396d6e0e729572fc6fd37bc6..61156ee064b74c649655a45d3b32c2c5fef2e3a7 100644 (file)
@@ -688,7 +688,7 @@ get_items(Nidx, _From,
             before -> {<<">">>, <<"asc">>};
             _ -> {<<"is not">>, <<"desc">>}
     end,
-    SNidx = integer_to_binary(Nidx),
+    SNidx = jlib:i2l(Nidx),
     [AttrName, Id] = case I of
        undefined when IncIndex =/= undefined ->
            case catch
@@ -790,7 +790,7 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
 
 get_last_items(Nidx, _From, Count) ->
     Limit = jlib:i2l(Count),
-    SNidx = integer_to_binary(Nidx),
+    SNidx = jlib:i2l(Nidx),
     Query = fun(mssql, _) ->
                    ejabberd_sql:sql_query_t(
                      [<<"select top ">>, Limit,
@@ -890,7 +890,7 @@ del_items(Nidx, [ItemId]) ->
     del_item(Nidx, ItemId);
 del_items(Nidx, ItemIds) ->
     I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
-    SNidx = integer_to_binary(Nidx),
+    SNidx = jlib:i2l(Nidx),
     catch
     ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
            I, <<") and nodeid='">>, SNidx, <<"';">>]).