From cfca7ab5d6ed2013e17ebb7726bacaeffd63ab37 Mon Sep 17 00:00:00 2001 From: Ewout Date: Sat, 20 Jan 2018 12:31:10 +0100 Subject: [PATCH] Fix parsing Prepared response in V4 protocol. According to the spec, the format of Prepared metadata is: [...][?...] * pk_index_i is a short. * pk_index_i come before col_spec_i. * The NO_METADATA flag is not applicable. Signed-off-by: Ewout Van Troostenberghe --- src/Database/CQL/Protocol/Response.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Database/CQL/Protocol/Response.hs b/src/Database/CQL/Protocol/Response.hs index b005ac8..8fecf85 100644 --- a/src/Database/CQL/Protocol/Response.hs +++ b/src/Database/CQL/Protocol/Response.hs @@ -290,12 +290,11 @@ decodePreparedV4 = do f <- decodeInt n <- decodeInt pkCount <- decodeInt - if hasNoMetaData f - then return $ MetaData n Nothing [] [] - else MetaData n Nothing <$> decodeSpecs n (hasGlobalSpec f) <*> replicateM (fromIntegral pkCount) decodeInt + pkis <- replicateM (fromIntegral pkCount) decodeShort + specs <- decodeSpecs n (hasGlobalSpec f) + return $ MetaData n Nothing specs (fromIntegral <$> pkis) where hasGlobalSpec f = f `testBit` 0 - hasNoMetaData f = f `testBit` 2 decodeSpecs n True = do k <- decodeKeyspace -- GitLab