EvalShardBucketCount evaluates and checks the integer argument to a `USING HASH WITH BUCKET_COUNT` index creation query.
(shardBuckets Expr)
| 836 | // EvalShardBucketCount evaluates and checks the integer argument to a `USING HASH WITH |
| 837 | // BUCKET_COUNT` index creation query. |
| 838 | func EvalShardBucketCount(shardBuckets Expr) (int32, error) { |
| 839 | const invalidBucketCountMsg = `BUCKET_COUNT must be a strictly positive integer value` |
| 840 | cst, ok := shardBuckets.(*NumVal) |
| 841 | if !ok { |
| 842 | return 0, pgerror.New(pgcode.InvalidParameterValue, invalidBucketCountMsg) |
| 843 | } |
| 844 | buckets, err := cst.AsInt32() |
| 845 | if err != nil || buckets <= 0 { |
| 846 | if err != nil { |
| 847 | return 0, pgerror.Wrap(err, pgcode.InvalidParameterValue, invalidBucketCountMsg) |
| 848 | } |
| 849 | return 0, pgerror.New(pgcode.InvalidParameterValue, invalidBucketCountMsg) |
| 850 | } |
| 851 | return buckets, nil |
| 852 | } |
| 853 | |
| 854 | // Format implements the NodeFormatter interface. |
| 855 | func (node *ShardedIndexDef) Format(ctx *FmtCtx) { |