anchor.diff:  decode_query_permissions(#riak_sql_v1{'FROM'=Bucket}) ->
       {"riak_kv.ts_query", Bucket}.
   
  +%%
  +-spec missing_helper_module(Bucket::binary(), 
  +                            BucketProps::{error,any()} | [proplists:property()]) -> #rpberrorresp{}.
  +missing_helper_module(Bucket, {error, _}) ->
  +    missing_type_response(Bucket);
  +missing_helper_module(Bucket, BucketProps) when is_binary(Bucket), is_list(BucketProps) ->
  +    case lists:keymember(ddl, 1, BucketProps) of
  +        true  -> missing_table_module_response(Bucket);
  +        false -> not_timeseries_type_response(Bucket)
  +    end.
  +
  +%%
  +-spec missing_type_response(Bucket::binary()) -> #rpberrorresp{}.
  +missing_type_response(Bucket) ->
  +    make_rpberrresp(
  +        ?E_MISSING_TYPE, 
  +        io_lib:format("Failed to put records, bucket type ~s is missing.", [Bucket])).
  +
  +%%
  +-spec not_timeseries_type_response(Bucket::binary()) -> #rpberrorresp{}.
  +not_timeseries_type_response(Bucket) ->
  +    make_rpberrresp(
  +        ?E_NOT_TS_TYPE, 
  +        io_lib:format("Attempt to put Time Series data to non Time Series bucket ~s.", [Bucket])).
  +
  +-spec missing_table_module_response(Bucket::binary()) -> #rpberrorresp{}.
  +missing_table_module_response(Bucket) ->
  +    make_rpberrresp(
  +        ?E_MISSING_TS_MODULE,
  +        io_lib:format("The compiled module for Time Series bucket ~s cannot be loaded.", [Bucket])).
  +
  +to_string(X) ->
  +    io_lib:format("~p", [X]).
   
   %% ---------------------------------------------------
   % functions supporting INSERT
  
positive.code:         true ->
              %% however, prevent bad data to crash us
              try
                  case put_data(Data, Table, Mod) of
                      0 ->
                          {reply, #tsputresp{}, State};
                      ErrorCount ->
  
negative.code:     Remaining = lists:nthtail(RSize, RR),
      assemble_records_(
        Remaining, RSize, [lists:sublist(RR, RSize) | Acc]).
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  
  missing_helper_module_missing_type_test() ->
      ?assertMatch(
          #rpberrorresp{errcode = ?E_MISSING_TYPE },
          missing_helper_module(<<"mytype">>, {error, any})
      ).
  
  missing_helper_module_not_ts_type_test() ->
      ?assertMatch(
          #rpberrorresp{errcode = ?E_NOT_TS_TYPE },
          missing_helper_module(<<"mytype">>, []) % no ddl property
      ).
  
  %% if the bucket properties exist and they contain a ddl property then
  %% the bucket properties are in the correct state but the module is still
  %% missing.
  missing_helper_module_test() ->
      ?assertMatch(
          #rpberrorresp{errcode = ?E_MISSING_TS_MODULE },
          missing_helper_module(<<"mytype">>, [{ddl, #ddl_v1{}}])
      ).
  
  -endif.