mysql 32k 限制_技术分享 | MySQL 字段长度限制的计算方法

1./* 下面是函数 dict_index_too_big_for_tree 中关于 rec_max_size 计算部分的内容 */

2./* 涉及到的辅助函数,下面也有相关说明 */

3.

4.rec_max_size = comp /* comp 为 true */

5.? REC_N_NEW_EXTRA_BYTES /* rem0rec.h:52:#define REC_N_NEW_EXTRA_BYTES 5 */

6.: REC_N_OLD_EXTRA_BYTES; /* rem0rec.h:49:#define REC_N_OLD_EXTRA_BYTES 6 */

7.

8.rec_max_size += UT_BITS_IN_BYTES(new_index->n_nullable);

9.

10./*

11.这个宏的实现如下:

12.

13.ut0ut.h:222

14.#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)

15.

16.即 (允许为空的字段个数 + 7) / 8

17.*/

18.

19.for (i = 0; i < new_index->n_fields; i++) {

20.const dict_field_t* field

21.= dict_index_get_nth_field(new_index, i);

22.const dict_col_t* col

23.= dict_field_get_col(field);

24.ulint field_max_size;

25.ulint field_ext_max_size;

26.

27./* In dtuple_convert_big_rec(), variable-length columns

28.that are longer than BTR_EXTERN_LOCAL_STORED_MAX_SIZE

29.may be chosen for external storage.

30.

31.Fixed-length columns, and all columns of secondary

32.index records are always stored inline. */

33.

34./* Determine the maximum length of the index field.

35.The field_ext_max_size should be computed as the worst

36.case in rec_get_converted_size_comp() for

37.REC_STATUS_ORDINARY records. */

38.

39.field_max_size = dict_col_get_fixed_size(col, comp);

40.

41./* 本质上是判断是否定长,并获得定长字段的字节数*/

42.

43./*如果是定长,则直接 goto add_field_size 进行求值*/

44.

45.if (field_max_size && field->fixed_len != 0) {

46./* dict_index_add_col() should guarantee this */

47.ut_ad(!field->prefix_len</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值