Skip to content

Commit 408fbe9

Browse files
authored
fix: read default for the data insert before first instant (#48)
1 parent 8994acb commit 408fbe9

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

devtools/create_instant_table.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,13 @@
3737
conn.exec_driver_sql('''
3838
alter table test_for_instant add column drop1 int(11) not null default '99'
3939
''')
40-
40+
conn.exec_driver_sql('''
41+
insert into test_for_instant (name, drop1, drop2, add2) values ('insert after first add', 23, 'drop2 after first add', 'add2')
42+
''')
43+
conn.exec_driver_sql('''
44+
alter table test_for_instant add column add3 varchar(255) not null
45+
''')
46+
conn.exec_driver_sql('''
47+
insert into test_for_instant (name, drop1, drop2, add2, add3) values ('insert after second add', 23, 'drop2 after second add', 'add2', 'add3')
48+
''')
49+
conn.commit()

src/pyinnodb/disk_struct/index.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def value_parser(rh: MRecordHeader, f):
132132
if rh.instant == 1:
133133
f.seek(-1, 1)
134134
extra_byte = int.from_bytes(f.read(1), "big")
135+
cols_disk_layout = cols_disk_layout[:extra_byte]
135136
logger.debug("instant col extra byte is %s, &0x80 is %s, len(cols) is %d", hex(extra_byte), extra_byte & 0x80,
136137
len(cols_disk_layout))
137-
cols_disk_layout = cols_disk_layout[:extra_byte]
138138

139139
nullable_cols = [d[0] for d in cols_disk_layout if d[1] == 4294967295 and d[0].is_nullable]
140140

@@ -143,8 +143,8 @@ def value_parser(rh: MRecordHeader, f):
143143

144144

145145
if rh.instant == 0 and rh.instant_version == 0:
146-
nullable_cols = [c for c in nullable_cols if "default_null" not in c.se_private_data]
147-
cols_disk_layout = [d for d in cols_disk_layout if "default_null" not in d[0].se_private_data]
146+
nullable_cols = [c for c in nullable_cols if not c.is_instant_col_80017]
147+
cols_disk_layout = [d for d in cols_disk_layout if not d[0].is_instant_col_80017]
148148

149149
nullcol_bitmask_size = int((len(nullable_cols) + 7) / 8)
150150
f.seek(-nullcol_bitmask_size - rh.instant_version - rh.instant, 1)

src/pyinnodb/sdi/table.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ def is_hidden_from_user(self):
169169
@cache
170170
def is_instant_col(self):
171171
return "version_added" in self.private_data or "version_dropped" in self.private_data
172-
#return "default_null" in self.private_data or "default" in self.private_data
172+
173+
@property
174+
@cache
175+
def is_instant_col_80017(self):
176+
return "default_null" in self.private_data or "default" in self.private_data
173177

174178
def get_instant_default(self):
175179
# if self.default_value_utf8_null:

0 commit comments

Comments
 (0)