diff --git a/include/tdi/common/tdi_utils.hpp b/include/tdi/common/tdi_utils.hpp index 5a5cc41..0ad963b 100644 --- a/include/tdi/common/tdi_utils.hpp +++ b/include/tdi/common/tdi_utils.hpp @@ -285,7 +285,9 @@ static inline tdi_status_t keyFieldSafeGet( ); return TDI_INVALID_ARG; } - if ((*key_field)->isPtrGet() && field_value->size_ < 64) { + /* If field size less than or equal to 8 and is_ptr is true, + * should use byte arrays */ + if ((*key_field)->isPtrGet() && field_value->size_ <= 8) { LOG_ERROR( "%s:%d Field size is greater than 64 bits. Please use byte arrays in " "the KeyFieldValue for field %d", diff --git a/src/tdi_json_parser/tdi_info_parser.cpp b/src/tdi_json_parser/tdi_info_parser.cpp index 0b708cf..b49aa7c 100644 --- a/src/tdi_json_parser/tdi_info_parser.cpp +++ b/src/tdi_json_parser/tdi_info_parser.cpp @@ -219,7 +219,7 @@ std::unique_ptr TdiInfoParser::parseKeyField( default_fl_value, default_str_value, checkIsFieldSlice(table_key_cjson), - false, + width>64, false); if (tmp == nullptr) { LOG_ERROR("%s:%d Error forming key_field %d", diff --git a/tdi_python/tdiTable.py b/tdi_python/tdiTable.py index 6cdbe09..14cb8f4 100644 --- a/tdi_python/tdiTable.py +++ b/tdi_python/tdiTable.py @@ -713,6 +713,7 @@ def _init_key(self): return sts for field_id in field_ids: field_name = c_char_p() + logging.debug("field_id={} field_name={}".format(field_id, field_name)) sts = self._cintf.get_driver().tdi_key_field_name_get(self._info_handle, field_id, byref(field_name)) if not sts == 0: print("CLI Error: get key field name for {} failed. [{}]".format(self.name, self._cintf.err_str(sts))) @@ -931,6 +932,9 @@ def _set_key_fields(self, content, key_handle): sts = -1 if name not in content.keys(): continue + logging.debug("info:info.type {}, info.data_type {} \n" + "info.is_ptr {}".format(self.key_match_type_cls.key_match_type_str(info.type), + self.data_type_cls.data_type_str(info.data_type), info.is_ptr)) if self.key_match_type_cls.key_match_type_str(info.type) == "EXACT": if self.data_type_cls.data_type_str(info.data_type) == "STRING": value = c_char_p(content[name].encode('ascii')) @@ -940,6 +944,7 @@ def _set_key_fields(self, content, key_handle): sts = self._cintf.get_driver().tdi_key_field_set_value(key_handle, info.id, value) else: value, bytes_ = self.fill_c_byte_arr(content[name], info.size) + logging.debug("value={} bytes_ {}".format(bytes(value).hex(),bytes_)) sts = self._cintf.get_driver().tdi_key_field_set_value_ptr(key_handle, info.id, value, bytes_) elif self.key_match_type_cls.key_match_type_str(info.type) == "TERNARY": if not info.is_ptr: