Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: expose KV range metadata to SQL for "experienced" admins #8990

Closed
knz opened this issue Aug 31, 2016 · 7 comments
Closed

sql: expose KV range metadata to SQL for "experienced" admins #8990

knz opened this issue Aug 31, 2016 · 7 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) E-easy Easy issue to tackle, requires little or no CockroachDB experience help wanted Help is requested / needed by the one who filed the issue to fix it.
Milestone

Comments

@knz
Copy link
Contributor

knz commented Aug 31, 2016

This is a follow-up to #8938, a proposal to implement two new functions:

  • crdb_encode_pkey(table_or_index_name, expr...), returning bytea, with table_or_index_name a string or identifier (string would be more easy and would create an opportunity to play with the virtual schema). This would compute and return the KV-level key encoding for the primary key of the specified table/index using the values given in the other arguments.
  • crdb_current_range_bounds(pkey), where pkey is a bytea, returning a tuple of two bytea, with the two values are the current known range bounds for the range containing pkey.

The two functions in combinations can then be used to estimate "distance" between two rows in a table, in the sense of whether they belong to the same range or not, and can be used as a follow-up to #8938 to check that a split requested with "ALTER TABLE ... SPLIT" was actually processed.

The function names are just proposals.

cc @mjibson

@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) help wanted Help is requested / needed by the one who filed the issue to fix it. E-easy Easy issue to tackle, requires little or no CockroachDB experience labels Aug 31, 2016
@knz knz mentioned this issue Aug 31, 2016
@knz knz changed the title sql: expose KV range to SQL for "experienced" admins sql: expose KV range metadata to SQL for "experienced" admins Aug 31, 2016
@knz
Copy link
Contributor Author

knz commented Aug 31, 2016

Once this is available the SPLIT AT syntax can be simplified to take a simple bytea expression that is the result of the encode_pkey function.

@a6802739
Copy link
Contributor

a6802739 commented Sep 9, 2016

@knz, please give me some more reference and I have time to fix it now.

@knz
Copy link
Contributor Author

knz commented Sep 9, 2016

@a6802739 Please review #8938 and the discussion that accompanied the PR to see if you understand what this feature is about. Then we can discuss if you have questions.

@a6802739
Copy link
Contributor

@knz , I start to fix this issue.

about crdb_encode_pkey(table_or_index_name, expr...), do you mean wee add this function to encode primary key value to kv value which is used in kv level. it should be like /Table/TableID/PrimaryID/Value, so how can we map the table name or the index name to the specified id?

about crdb_current_range_bounds(pkey), do you mean to find the correct range contains the key?it seems in testutils/serverutils/test_server_shim.go , it already has function LookupRange.

@knz
Copy link
Contributor Author

knz commented Oct 27, 2016

For the first point you need to investigate the table/index descriptors.

For the second point yes the solution will need LookupRange.

@petermattis
Copy link
Collaborator

@knz Now that we have SHOW TESTING_RANGES, is there anything left to do here?

@knz
Copy link
Contributor Author

knz commented Jun 1, 2017

No indeed

@knz knz closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) E-easy Easy issue to tackle, requires little or no CockroachDB experience help wanted Help is requested / needed by the one who filed the issue to fix it.
Projects
None yet
Development

No branches or pull requests

3 participants