sql: enable storage parameter syntax for primary key#75971
Conversation
|
pkg/sql/create_table.go, line 2691 at r1 (raw file):
I didn't put these validations into the param observer pattern because right now we don't call |
2adb407 to
686ab41
Compare
postamar
left a comment
There was a problem hiding this comment.
I did a superficial review and couldn't find anything obviously wrong, this looks good enough to me.
Reviewed 15 of 18 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @chengxiong-ruan)
pkg/sql/paramparse/validation.go, line 23 at r2 (raw file):
func ValidateUniqueConstraintParams(params tree.StorageParams, isPK bool) error { // TODO (issue 75243): add `bucket_count` as a valid param. Current dummy // implementation is just for a proof of concept and make golint happy.
Shouldn't bucket_count only be valid if USING HASH is present, though? Perhaps I'm wrong but the validation of the params seems like it will be more context-dependent than this function lets on. You already need an isPK bool arg to describe the context, perhaps it's worth wrapping it in a struct which describes this context.
Perhaps I'm getting ahead of myself here.
pkg/sql/paramparse/validation.go, line 30 at r2 (raw file):
return pgerror.Newf(pgcode.InvalidParameterValue, "invalid storage param %q on Primary Key", params[0].Key) } return pgerror.Newf(pgcode.InvalidParameterValue, "invalid storage param %q on Unique Index", params[0].Key)
nit: no need to capitalize "unique index".
chengxiong-ruan
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @postamar)
pkg/sql/paramparse/validation.go, line 23 at r2 (raw file):
Previously, postamar (Marius Posta) wrote…
Shouldn't
bucket_countonly be valid ifUSING HASHis present, though? Perhaps I'm wrong but the validation of the params seems like it will be more context-dependent than this function lets on. You already need anisPK boolarg to describe the context, perhaps it's worth wrapping it in a struct which describes this context.Perhaps I'm getting ahead of myself here.
You're definitely another man ahead of time! Yes, bucket_count should only exists if USING HASH is present. I'm having a follow up pr to actually add this validation. I planned to have this validation outside of here, but I think you brought a good point to wrap more (just one more) context in, will add it in my next pr if you are ok with that.
pkg/sql/paramparse/validation.go, line 30 at r2 (raw file):
Previously, postamar (Marius Posta) wrote…
nit: no need to capitalize "unique index".
sg, will fix this
686ab41 to
814d219
Compare
|
pkg/sql/paramparse/validation.go, line 23 at r2 (raw file): Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
Actually, validation of |
This is a prerequisite to support `WITH (bucket_count=...)` syntax for hash sharded index. Release note (sql change): Previously, `WITH (param=value)` syntax is not allowed for primary key. However, that does not align with postgresql. Also, to support `WITH (bucket_count=...)` syntax for hash sharded index, we need to enable it as well. This pr also adds extra validation to prevent existing storage params from being applied to primary keys. Which means, even the syntax is accepted by the parser, none of existing storage param for inverted index is allowed on primary key. We don't actually set those params on top of PKs internally, but we need to tell user which param is supprted or not. Eventually, when we add support for `bucket_count` param, a param white list will be maintained for PKs.
814d219 to
350354f
Compare
|
thanks for the review! |
|
Build succeeded: |
A follow up of pr cockroachdb#75971 . Will send another pr to update `SHOW CREATE` output. Release note (sql change): `bucket_count` storage parameter is added. To create hash sharded index, now we may use the new syntax: `USING HASH WITH (bucket_count=xxx)`. `bucket_count` storage param can only be use together with `USING HASH`. The old `WITH BUCKET_COUNT=xxx` syntax is still supported for backward compatibility. However, only either the old or new syntax can be used, but not both. Err is returned for clause like `USING HASH WITH BUCKET_COUNT=5 WITH (bucket_count=5).
A follow up of pr cockroachdb#75971 . Will send another pr to update `SHOW CREATE` output. Release note (sql change): `bucket_count` storage parameter is added. To create hash sharded index, now we may use the new syntax: `USING HASH WITH (bucket_count=xxx)`. `bucket_count` storage param can only be use together with `USING HASH`. The old `WITH BUCKET_COUNT=xxx` syntax is still supported for backward compatibility. However, only either the old or new syntax can be used, but not both. Err is returned for clause like `USING HASH WITH BUCKET_COUNT=5 WITH (bucket_count=5).
A follow up of pr cockroachdb#75971 . Will send another pr to update `SHOW CREATE` output. Release note (sql change): `bucket_count` storage parameter is added. To create hash sharded index, now we may use the new syntax: `USING HASH WITH (bucket_count=xxx)`. `bucket_count` storage param can only be use together with `USING HASH`. The old `WITH BUCKET_COUNT=xxx` syntax is still supported for backward compatibility. However, only either the old or new syntax can be used, but not both. Err is returned for clause like `USING HASH WITH BUCKET_COUNT=5 WITH (bucket_count=5).
76068: sql: support bucket_count storage parameter r=chengxiong-ruan a=chengxiong-ruan A follow up of pr #75971 . Will send another pr to update `SHOW CREATE` output. Release note (sql change): `bucket_count` storage parameter is added. To create hash sharded index, now we may use the new syntax: `USING HASH WITH (bucket_count=xxx)`. `bucket_count` storage param can only be use together with `USING HASH`. The old `WITH BUCKET_COUNT=xxx` syntax is still supported for backward compatibility. However, only either the old or new syntax can be used, but not both. Err is returned for clause like `USING HASH WITH BUCKET_COUNT=5 WITH (bucket_count=5). Co-authored-by: Chengxiong Ruan <chengxiongruan@gmail.com>
This is a prerequisite to support
WITH (bucket_count=...)syntaxfor hash sharded index.
Release note (sql change): Previously,
WITH (param=value)syntaxis not allowed for primary key. However, that does not align with
postgresql. Also, to support
WITH (bucket_count=...)syntax for hashsharded index, we need to enable it as well. This pr also adds
extra validation to prevent existing storage params from being
applied to primary keys. Which means, even the syntax is accepted
by the parser, none of existing storage param for inverted index
is allowed on primary key. We don't actually set those params
on top of PKs internally, but we need to tell user which param is
supprted or not. Eventually, when we add support for
bucket_countparam, a param white list will be maintained for PKs.