Skip to content

Commit

Permalink
Cleanup non-null pointer args, increase const correctness (facebook#1311
Browse files Browse the repository at this point in the history
)

Summary:
Various minor cleanups

All done or noticed in the native DD prototype work, are independent from it,
and will help to reduce its diff.

- `ha_rocksdb::create_key_defs` had non-null attribute for the 2nd and 3rd
  argument. It seems that the attribute non-null arg indexes got desynced,
  because the 3rd argument is a reference, and by usage the 1st and the 2nd args
  are pointers that cannot be `nullptr`. Instead of fixing the attribute indexes,
  convert pointers to references, which cannot be null by design.
- Do the same for `ha_rocksdb::create_cfs`. At the same time make `tbl_def_arg`
  `const`, which previously was not, and make the function return `bool`, as it only
  returns two values for success and error. Convert it from
  `DBUG_ENTER_FUNC`/`DBUG_RETURN` to a newer (and lighter) `DBUG_TRACE`.
- `ha_rocksdb::create_table` made `private`, pointer args converted to reference
  args.
- Added missing error checking for RocksDB `WriteBatch::SingleDelete` calls
- `ha_rocksdb::has_hidden_pk` made `static`, args changed from pointers to
  references, removed redundant `nonnull` attribute.
- `ha_rocksdb::pk_index` args changed from pointers to references, removed
  redundant `nonnull` attribute.
- `ha_rocksdb::set_last_rowkey` argument was marked unused even though it was used
- `ha_rocksdb::check_and_lock_sk`, `ha_rocksdb::check_uniqueness_and_lock`,
  `ha_rocksdb::update_write_row`, `ha_rocksdb::reset`,
  `ha_rocksdb::calc_updated_indexes`: added asserts for relationships between
  arguments and `table->record[0]`/`table->record[1]`
- `ha_rocksdb::adjust_handler_stats_sst_and_memtable`: reduce scope of two local
  vars
- `Rdb_key_def`: introduce invalid index ID constant based on
  `dd::INVALID_OBJECT_ID`. Check it on construction and in the index ID getter.
  Replace direct field accesses with the getter call.
- `Rdb_key_def::table_has_hidden_pk` arg changed from pointer to reference.
- Replace `warn_unused_result` attribute with the standard `[[nodiscard]]` for all
  the touched signatures.

Pull Request resolved: facebook#1311

Differential Revision: D46075453
  • Loading branch information
laurynas-biveinis authored and inikep committed Jul 30, 2024
1 parent fbfd605 commit 677d9b6
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 157 deletions.
Loading

0 comments on commit 677d9b6

Please sign in to comment.