Skip to content

Commit 474c6a7

Browse files
Jupyung Lee (JP)Jupyung Lee
authored andcommitted
[Bypass RPC] Respect null values when using rpc protocol
Summary: This diff fixes a bug, in which null values were not returned as null values when using rpc protocol. We also added a new test of reading a column (`is_deleted`) which is null by default. Test Plan: ~/mysql/tools/mysqltest.sh bypass_rpc_scenarios.test Reviewers: luqun, jkedgar, yoshinori, abalsara, #mysql_eng, #mysql_gateway Reviewed By: luqun Subscribers: webscalesql-eng@fb.com Differential Revision: https://phabricator.intern.facebook.com/D40747049
1 parent 615ece1 commit 474c6a7

File tree

4 files changed

+26
-97
lines changed

4 files changed

+26
-97
lines changed

mysql-test/suite/rocksdb/r/bypass_rpc_scenarios.result

Lines changed: 2 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -94,41 +94,11 @@ Warning 1681 Integer display width is deprecated and will be removed in a future
9494
Warning 1681 Integer display width is deprecated and will be removed in a future release.
9595
Warning 1681 Integer display width is deprecated and will be removed in a future release.
9696
Warning 1681 Integer display width is deprecated and will be removed in a future release.
97-
# Bloom filter with complete SK but shorter than bloom filter
98-
CREATE TABLE `id_table_bloom` (
99-
`id1` bigint(20) NOT NULL DEFAULT '0',
100-
`id2` bigint(20) NOT NULL DEFAULT '0',
101-
`id3` bigint(11) NOT NULL DEFAULT '0',
102-
`val` bigint(20) NOT NULL DEFAULT '0',
103-
PRIMARY KEY (`id1`, `id2`),
104-
KEY `id3` (`id3`) COMMENT 'cf_link',
105-
UNIQUE KEY `unique_id3` (`id3`) COMMENT 'cf_link'
106-
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
107-
KEY_BLOCK_SIZE=8;
108-
Warnings:
97+
Warnings:
10998
Warning 1681 Integer display width is deprecated and will be removed in a future release.
11099
Warning 1681 Integer display width is deprecated and will be removed in a future release.
111100
Warning 1681 Integer display width is deprecated and will be removed in a future release.
112101
Warning 1681 Integer display width is deprecated and will be removed in a future release.
113-
INSERT INTO id_table_bloom values (1, 1, 1, 101);
114-
INSERT INTO id_table_bloom values (1, 2, 2, 102);
115-
INSERT INTO id_table_bloom values (1, 3, 3, 103);
116-
INSERT INTO id_table_bloom values (1, 4, 4, 104);
117-
CREATE TABLE `link_table7` (
118-
`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
119-
`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
120-
`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
121-
`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
122-
`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
123-
`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
124-
`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
125-
`time` int(10) unsigned NOT NULL DEFAULT '0' ,
126-
`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
127-
PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
128-
KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
129-
COMMENT 'rev:cf_link_id1_type'
130-
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
131-
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
132102
Warnings:
133103
Warning 1681 Integer display width is deprecated and will be removed in a future release.
134104
Warning 1681 Integer display width is deprecated and will be removed in a future release.
@@ -138,36 +108,6 @@ Warning 1681 Integer display width is deprecated and will be removed in a future
138108
Warning 1681 Integer display width is deprecated and will be removed in a future release.
139109
Warning 1681 Integer display width is deprecated and will be removed in a future release.
140110
Warning 1681 Integer display width is deprecated and will be removed in a future release.
141-
insert into link_table7 values (9223372036854775807, 100, 9223372036854775801,
142-
100, 9223372036854775807, 0,
143-
'data1', 1234561, 9223372036854775801);
144-
insert into link_table7 values (9223372036854775807, 100, 1223372036854775802,
145-
100, 9223372036854775807, 0,
146-
'0123456789012345678901234567890123456789012345678901234567890123456789'
147-
'0123456789012345678901234567890123456789012345678901234567890123456789'
148-
'0123456789012345678901234567890123456789012345678901234567890123456789'
149-
'0123456789012345678901234567890', 1234562, 9223372036854775802);
150-
insert into link_table7 values (9223372036854775807, 100, 1223372036854775803,
151-
100, 9223372036854775807, 0,
152-
'0123456789012345678901234567890123456789012345678901234567890123456789'
153-
'0123456789012345678901234567890123456789012345678901234567890123456789'
154-
'0123456789012345678901234567890123456789012345678901234567890123456789'
155-
'0123456789012345678901234567890', 1234563, 9223372036854775803);
156-
CREATE TABLE `link_table8` (
157-
`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
158-
`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
159-
`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
160-
`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
161-
`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
162-
`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
163-
`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
164-
`time` int(10) unsigned NOT NULL DEFAULT '0' ,
165-
`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
166-
PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
167-
KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
168-
COMMENT 'rev:cf_link_id1_type'
169-
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
170-
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
171111
Warnings:
172112
Warning 1681 Integer display width is deprecated and will be removed in a future release.
173113
Warning 1681 Integer display width is deprecated and will be removed in a future release.
@@ -177,31 +117,6 @@ Warning 1681 Integer display width is deprecated and will be removed in a future
177117
Warning 1681 Integer display width is deprecated and will be removed in a future release.
178118
Warning 1681 Integer display width is deprecated and will be removed in a future release.
179119
Warning 1681 Integer display width is deprecated and will be removed in a future release.
180-
insert into link_table8 values (1, 0x03030303, 1, 0, 100, 0, 'data1', 0, 0);
181-
CREATE TABLE `meta_table` (
182-
`lvid` int(10) unsigned NOT NULL DEFAULT '0',
183-
`mt_object_type` int(10) unsigned NOT NULL DEFAULT '0',
184-
`id` bigint(20) unsigned NOT NULL DEFAULT '0',
185-
`mt_object_cookie` bigint(20) unsigned NOT NULL DEFAULT '0',
186-
`mt_alt_key_data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
187-
`mt_total_size` bigint(20) unsigned NOT NULL DEFAULT '0',
188-
`mt_object_type2` int(10) unsigned NOT NULL DEFAULT '0',
189-
`mt_object_state` smallint(5) unsigned NOT NULL DEFAULT '0',
190-
`context` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
191-
`mt_ref` bigint(20) DEFAULT NULL,
192-
`mt_key` varbinary(80) DEFAULT NULL,
193-
`mt_ctime` int(10) NOT NULL DEFAULT '0',
194-
`mt_rtime` int(10) NOT NULL DEFAULT '0',
195-
`policy_id` tinyint(3) unsigned DEFAULT NULL,
196-
`policy` bigint(20) unsigned DEFAULT NULL,
197-
`parent_id` bigint(20) unsigned NOT NULL DEFAULT '0',
198-
`ttl` int(10) DEFAULT NULL,
199-
`mt_last_update` int(10) unsigned NOT NULL DEFAULT '0',
200-
PRIMARY KEY (`lvid`,`id`),
201-
KEY `key1` (`lvid`,`mt_object_state`,`mt_key`(1)),
202-
KEY `key2` (`lvid`,`mt_last_update`)
203-
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
204-
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
205120
Warnings:
206121
Warning 1681 Integer display width is deprecated and will be removed in a future release.
207122
Warning 1681 Integer display width is deprecated and will be removed in a future release.
@@ -218,19 +133,10 @@ Warning 1681 Integer display width is deprecated and will be removed in a future
218133
Warning 1681 Integer display width is deprecated and will be removed in a future release.
219134
Warning 1681 Integer display width is deprecated and will be removed in a future release.
220135
Warning 1681 Integer display width is deprecated and will be removed in a future release.
221-
INSERT INTO meta_table VALUES (100, 0, 1, 0, 'data1', 1, 2, 3, 'context1',
222-
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
223-
INSERT INTO meta_table VALUES (100, 0, 2, 0, 'data2', 1, 2, 3, 'context2',
224-
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
225-
INSERT INTO meta_table VALUES (100, 0, 3, 0, 'data3', 1, 2, 3, 'context3',
226-
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
227-
INSERT INTO meta_table VALUES (100, 0, 4, 0, 'data4', 1, 2, 3, 'context4',
228-
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
229-
INSERT INTO meta_table VALUES (101, 0, 1, 0, 'data1', 1, 2, 3, 'context1',
230-
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
231136
INSTALL PLUGIN test_bypass_rpc_plugin_info SONAME 'TEST_BYPASS_RPC_PLUGIN';
232137
UNINSTALL PLUGIN test_bypass_rpc_plugin_info;
233138
DROP TABLE id_table_bloom;
234139
DROP TABLE link_table7;
235140
DROP TABLE link_table8;
236141
DROP TABLE meta_table;
142+
DROP TABLE obj_info;

mysql-test/suite/rocksdb/t/bypass_rpc_scenarios.test

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
66
--source ../include/bypass_create_table.inc
77

8-
--echo # Bloom filter with complete SK but shorter than bloom filter
8+
--disable_query_log
99
CREATE TABLE `id_table_bloom` (
1010
`id1` bigint(20) NOT NULL DEFAULT '0',
1111
`id2` bigint(20) NOT NULL DEFAULT '0',
@@ -106,6 +106,19 @@ INSERT INTO meta_table VALUES (100, 0, 4, 0, 'data4', 1, 2, 3, 'context4',
106106
INSERT INTO meta_table VALUES (101, 0, 1, 0, 'data1', 1, 2, 3, 'context1',
107107
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
108108

109+
CREATE TABLE `obj_info` (
110+
`id` bigint unsigned NOT NULL DEFAULT '0',
111+
`type` int unsigned NOT NULL DEFAULT '0',
112+
`version` bigint unsigned NOT NULL DEFAULT '0',
113+
`update_time` int unsigned NOT NULL DEFAULT '0',
114+
`is_deleted` tinyint DEFAULT NULL,
115+
PRIMARY KEY (`type`, `id`),
116+
KEY `id` (`id`)
117+
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
118+
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
119+
120+
INSERT INTO obj_info (id, type, version, update_time) VALUES (100, 1, 2, 3);
121+
--enable_query_log
109122

110123
--write_file $MYSQLD_DATADIR/test_bypass_rpc_plugin_input.txt
111124
# Bloom filter with complete SK but shorter than bloom filter
@@ -179,6 +192,8 @@ SELECT /*+ bypass */ id2,version,data FROM test.link_varchar FORCE INDEX (PRIMAR
179192
# Uncovered TEXT/VARCHAR in SK
180193
SELECT /*+ bypass */ id2,version,data FROM test.link_text FORCE INDEX (id1_type) WHERE id1=1 and link_type=3 and visibility=4 and time>=10;
181194
SELECT /*+ bypass */ id2,version,data FROM test.link_varchar FORCE INDEX (id1_type) WHERE id1=1 and link_type=3 and visibility=4 and time>=10;
195+
# Read a column which is null by default
196+
SELECT /*+ bypass */ id,type,version,is_deleted,update_time FROM test.obj_info WHERE id=100;
182197
EOF
183198

184199
--replace_result $TEST_BYPASS_RPC_PLUGIN TEST_BYPASS_RPC_PLUGIN
@@ -195,5 +210,6 @@ DROP TABLE id_table_bloom;
195210
DROP TABLE link_table7;
196211
DROP TABLE link_table8;
197212
DROP TABLE meta_table;
213+
DROP TABLE obj_info;
198214

199215
--source ../include/bypass_drop_table.inc

plugin/test_bypass_rpc_plugin/test_bypass_rpc_plugin_info.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ static void send_row(void * /* unused */, myrocks_columns *values,
137137
fprintf(outfile_rpc, "null ");
138138
}
139139
}
140+
} else {
141+
fprintf(outfile_rpc, "<null> ");
140142
}
141143
}
142144
fprintf(outfile_rpc, "\n");
@@ -178,6 +180,7 @@ static ulong sql_get_client_capabilities(void *) {
178180

179181
static int sql_get_null(void *) {
180182
DBUG_TRACE;
183+
fprintf(outfile_sql, "<null> ");
181184
return false;
182185
}
183186

storage/rocksdb/nosql_access.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ class rpc_protocol : public base_protocol {
152152
int idx = 0;
153153
for (const auto field : *m_field_list) {
154154
auto rpcbuf = &m_columns->at(idx++);
155+
if (field->is_null()) {
156+
rpcbuf->isNull = true;
157+
continue;
158+
}
155159
switch (field->real_type()) {
156160
case MYSQL_TYPE_LONGLONG: {
157161
pack_integer<8>(rpcbuf, field->field_ptr(),

0 commit comments

Comments
 (0)