1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "rdb_general_ut.h"
17 #include "sqlite_relational_utils.h"
18 #include "virtual_sqlite_relational_store.h"
19 namespace DistributedDB {
20 using namespace testing::ext;
21 using namespace DistributedDB;
22 using namespace DistributedDBUnitTest;
23
24 class DistributedDBRDBDropTableTest : public RDBGeneralUt {
25 public:
26 void SetUp() override;
27 protected:
28 void PrepareEnv(const StoreInfo &info, bool createTracker = false, bool createDistributedTable = false);
29 static UtDateBaseSchemaInfo GetDefaultSchema();
30 static UtDateBaseSchemaInfo GetUniqueSchema();
31 static UtTableSchemaInfo GetTableSchema(const std::string &table, bool isPkUuid);
32 static constexpr const char *DEVICE_SYNC_TABLE = "DEVICE_SYNC_TABLE";
33 static constexpr const char *DEVICE_A = "DEVICE_A";
34 static constexpr const char *DEVICE_B = "DEVICE_B";
35 StoreInfo info1_ = {USER_ID, APP_ID, STORE_ID_1};
36 StoreInfo info2_ = {USER_ID, APP_ID, STORE_ID_2};
37 };
38
SetUp()39 void DistributedDBRDBDropTableTest::SetUp()
40 {
41 RDBGeneralUt::SetUp();
42 RelationalStoreDelegate::Option option;
43 option.tableMode = DistributedTableMode::COLLABORATION;
44 SetOption(option);
45 }
46
PrepareEnv(const StoreInfo & info,bool createTracker,bool createDistributedTable)47 void DistributedDBRDBDropTableTest::PrepareEnv(const StoreInfo &info, bool createTracker, bool createDistributedTable)
48 {
49 ASSERT_EQ(ExecuteSQL("CREATE TABLE IF NOT EXISTS"
50 " DEVICE_SYNC_TABLE(id INTEGER PRIMARY KEY AUTOINCREMENT, uuid INTEGER UNIQUE, value INTEGER)", info), E_OK);
51 if (createTracker) {
52 ASSERT_EQ(SetTrackerTables(info, {DEVICE_SYNC_TABLE}), E_OK);
53 }
54 if (createDistributedTable) {
55 ASSERT_EQ(SetDistributedTables(info, {DEVICE_SYNC_TABLE}), E_OK);
56 }
57 }
58
GetDefaultSchema()59 UtDateBaseSchemaInfo DistributedDBRDBDropTableTest::GetDefaultSchema()
60 {
61 UtDateBaseSchemaInfo info;
62 info.tablesInfo.push_back(GetTableSchema(DEVICE_SYNC_TABLE, false));
63 return info;
64 }
65
GetUniqueSchema()66 UtDateBaseSchemaInfo DistributedDBRDBDropTableTest::GetUniqueSchema()
67 {
68 UtDateBaseSchemaInfo info;
69 info.tablesInfo.push_back(GetTableSchema(DEVICE_SYNC_TABLE, true));
70 return info;
71 }
72
GetTableSchema(const std::string & table,bool isPkUuid)73 UtTableSchemaInfo DistributedDBRDBDropTableTest::GetTableSchema(const std::string &table, bool isPkUuid)
74 {
75 UtTableSchemaInfo tableSchema;
76 tableSchema.name = table;
77 UtFieldInfo field;
78 field.field.type = TYPE_INDEX<int64_t>;
79 field.field.primary = isPkUuid;
80 field.field.colName = "uuid";
81 tableSchema.fieldInfo.push_back(field);
82 field.field.primary = false;
83 field.field.colName = "value";
84 tableSchema.fieldInfo.push_back(field);
85 return tableSchema;
86 }
87
88 /**
89 * @tc.name: SyncAfterDrop001
90 * @tc.desc: Test sync success after drop table.
91 * @tc.type: FUNC
92 * @tc.author: zqq
93 */
94 HWTEST_F(DistributedDBRDBDropTableTest, SyncAfterDrop001, TestSize.Level0)
95 {
96 /**
97 * @tc.steps: step1. Create table and set distributed tables.
98 * @tc.expected: step1. Ok
99 */
100 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
101 SetSchemaInfo(info1_, GetDefaultSchema());
102 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true));
103 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
104 EXPECT_EQ(CountTableData(info1_, DEVICE_SYNC_TABLE, "id=1"), 1);
105 ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
106 SetSchemaInfo(info2_, GetUniqueSchema());
107 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info2_, true, true));
108 /**
109 * @tc.steps: step2. Recreate table and set distributed tables.
110 * @tc.expected: step2. Ok
111 */
112 EXPECT_EQ(ExecuteSQL("DROP TABLE DEVICE_SYNC_TABLE", info1_), E_OK);
113 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_));
114 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
115 SetSchemaInfo(info1_, GetUniqueSchema());
116 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true, true));
117 /**
118 * @tc.steps: step3. Sync.
119 * @tc.expected: step3. Ok
120 */
121 BlockSync(info1_, info2_, DEVICE_SYNC_TABLE, SyncMode::SYNC_MODE_PUSH_ONLY, OK);
122 }
123
124 /**
125 * @tc.name: SyncAfterDrop002
126 * @tc.desc: Test sync success after drop table.
127 * @tc.type: FUNC
128 * @tc.author: zqq
129 */
130 HWTEST_F(DistributedDBRDBDropTableTest, SyncAfterDrop002, TestSize.Level0)
131 {
132 /**
133 * @tc.steps: step1. Create table and set distributed tables.
134 * @tc.expected: step1. Ok
135 */
136 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
137 SetSchemaInfo(info1_, GetDefaultSchema());
138 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true));
139 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
140 ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
141 SetSchemaInfo(info2_, GetUniqueSchema());
142 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info2_, true, true));
143 /**
144 * @tc.steps: step2. Recreate table and set distributed tables and insert dirty data.
145 * @tc.expected: step2. Ok
146 */
147 EXPECT_EQ(ExecuteSQL("DROP TABLE DEVICE_SYNC_TABLE", info1_), E_OK);
148 std::string sql = "INSERT OR REPLACE INTO " + DBCommon::GetLogTableName(DEVICE_SYNC_TABLE) +
149 "(data_key, timestamp, wtimestamp, flag, hash_key, extend_field) "
150 "VALUES(1, 1, 1, 0x02, 'error_hash1', '100')";
151 EXPECT_EQ(ExecuteSQL(sql, info1_), E_OK);
152 sql = "INSERT OR REPLACE INTO " + DBCommon::GetLogTableName(DEVICE_SYNC_TABLE) +
153 "(data_key, timestamp, wtimestamp, flag, hash_key, extend_field) "
154 "VALUES(1, 2, 2, 0x02, 'error_hash2', 200)";
155 EXPECT_EQ(ExecuteSQL(sql, info1_), E_OK);
156 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_));
157 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
158 SetSchemaInfo(info1_, GetUniqueSchema());
159 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, false, true));
160 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true, false));
161 /**
162 * @tc.steps: step3. Sync.
163 * @tc.expected: step3. Ok
164 */
165 BlockSync(info1_, info2_, DEVICE_SYNC_TABLE, SyncMode::SYNC_MODE_PUSH_ONLY, OK);
166 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key='error_hash1'"), 0);
167 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key='error_hash2'"), 0);
168 }
169
170 /**
171 * @tc.name: SetTrackerAfterDrop001
172 * @tc.desc: Test set tracker success after drop table.
173 * @tc.type: FUNC
174 * @tc.author: zqq
175 */
176 HWTEST_F(DistributedDBRDBDropTableTest, SetTrackerAfterDrop001, TestSize.Level0)
177 {
178 /**
179 * @tc.steps: step1. Create table and set tracker table.
180 * @tc.expected: step1. Ok
181 */
182 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
183 SetSchemaInfo(info1_, GetDefaultSchema());
184 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true));
185 /**
186 * @tc.steps: step2. Recreate table and set tracker table with force.
187 * @tc.expected: step2. Ok
188 */
189 EXPECT_EQ(ExecuteSQL("DROP TABLE DEVICE_SYNC_TABLE", info1_), E_OK);
190 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_));
191 ASSERT_EQ(SetTrackerTables(info1_, {DEVICE_SYNC_TABLE}, true), E_OK);
192 }
193
194 /**
195 * @tc.name: InvalidCleanTracker001
196 * @tc.desc: Test clean tracker with invalid obj.
197 * @tc.type: FUNC
198 * @tc.author: zqq
199 */
200 HWTEST_F(DistributedDBRDBDropTableTest, InvalidCleanTracker001, TestSize.Level0)
201 {
202 VirtualSqliteRelationalStore store;
203 auto schemaObj = store.CallGetSchemaObj();
204 EXPECT_FALSE(schemaObj.IsSchemaValid());
205 TrackerSchema schema;
206 TableInfo info;
207 bool isNoTableInSchema = false;
208 bool isFirstCreate = false;
209 RelationalDBProperties properties;
210 auto engine = std::make_shared<SQLiteSingleRelationalStorageEngine>(properties);
211 store.SetStorageEngine(engine);
212 engine->SetEngineState(EngineState::ENGINE_BUSY);
213 EXPECT_EQ(store.CallCheckTrackerTable(schema, info, isNoTableInSchema, isFirstCreate), -E_BUSY);
214 EXPECT_FALSE(isNoTableInSchema);
215 EXPECT_TRUE(isFirstCreate);
216 store.CallCleanDirtyLogIfNeed(DEVICE_SYNC_TABLE);
217 }
218
219 /**
220 * @tc.name: CleanDirtyLog001
221 * @tc.desc: Test clean dirty log by utils.
222 * @tc.type: FUNC
223 * @tc.author: zqq
224 */
225 HWTEST_F(DistributedDBRDBDropTableTest, CleanDirtyLog001, TestSize.Level0)
226 {
227 /**
228 * @tc.steps: step1. Create table and set distributed tables.
229 * @tc.expected: step1. Ok
230 */
231 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
232 SetSchemaInfo(info1_, GetUniqueSchema());
233 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true, true));
234 /**
235 * @tc.steps: step2. Execute sql with invalid db.
236 * @tc.expected: step2. Fail
237 */
238 auto res = SQLiteRelationalUtils::CheckExistDirtyLog(nullptr, DEVICE_SYNC_TABLE);
239 EXPECT_EQ(res.first, -E_INVALID_DB);
240 EXPECT_FALSE(res.second);
241 EXPECT_EQ(SQLiteRelationalUtils::ExecuteSql(nullptr, "", nullptr), -E_INVALID_DB);
242 /**
243 * @tc.steps: step3. Check dirty log with no exist table.
244 * @tc.expected: step3. No exist dirty log
245 */
246 auto handle = GetSqliteHandle(info1_);
247 ASSERT_NE(handle, nullptr);
248 res = SQLiteRelationalUtils::CheckExistDirtyLog(handle, "NO_EXISTS_TABLE");
249 EXPECT_EQ(res.first, E_OK);
250 EXPECT_FALSE(res.second);
251 /**
252 * @tc.steps: step4. Insert data and dirty log.
253 * @tc.expected: step4. Ok
254 */
255 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
256 std::string sql = "INSERT OR REPLACE INTO " + DBCommon::GetLogTableName(DEVICE_SYNC_TABLE) +
257 "(data_key, timestamp, wtimestamp, flag, hash_key, extend_field) "
258 "VALUES(1, 1, 1, 0x02, 'error_hash1', '100')";
259 EXPECT_EQ(ExecuteSQL(sql, info1_), E_OK);
260 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key='error_hash1'"), 1);
261 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "data_key='1'"), 2); // 2 log
262 /**
263 * @tc.steps: step5. Clean dirty log.
264 * @tc.expected: step5. Ok and no exist dirty log
265 */
266 RelationalSchemaObject obj;
267 EXPECT_EQ(SQLiteRelationalUtils::CleanDirtyLog(handle, DEVICE_SYNC_TABLE, obj), E_OK);
268 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key='error_hash1'"), 1);
269 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "data_key='1'"), 2); // 2 log
270 obj.SetDistributedSchema(RDBDataGenerator::ParseSchema(GetSchema(info1_)));
271 EXPECT_EQ(SQLiteRelationalUtils::CleanDirtyLog(handle, DEVICE_SYNC_TABLE, obj), E_OK);
272 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key='error_hash1'"), 0);
273 EXPECT_EQ(CountTableData(info1_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "data_key='1'"), 1);
274 /**
275 * @tc.steps: step6. Clean no exist table dirty log.
276 * @tc.expected: step6. Fail
277 */
278 EXPECT_EQ(ExecuteSQL("DROP TABLE DEVICE_SYNC_TABLE", info1_), E_OK);
279 EXPECT_EQ(SQLiteRelationalUtils::CleanDirtyLog(handle, DEVICE_SYNC_TABLE, obj), -1); // -1 is default error
280 }
281
282 /**
283 * @tc.name: SyncWithDirtyLog001
284 * @tc.desc: Test sync success when remote data log is dirty.
285 * @tc.type: FUNC
286 * @tc.author: zqq
287 */
288 HWTEST_F(DistributedDBRDBDropTableTest, SyncWithDirtyLog001, TestSize.Level1)
289 {
290 /**
291 * @tc.steps: step1. Create table and set distributed tables.
292 * @tc.expected: step1. Ok
293 */
294 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
295 ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
296 SetSchemaInfo(info1_, GetUniqueSchema());
297 SetSchemaInfo(info2_, GetUniqueSchema());
298 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true, true));
299 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info2_, true, true));
300 /**
301 * @tc.steps: step2. Create table and set distributed tables.
302 * @tc.expected: step2. Ok
303 */
304 EXPECT_EQ(ExecuteSQL("INSERT OR REPLACE INTO DEVICE_SYNC_TABLE VALUES(1, 100, 0)", info1_), E_OK);
305 EXPECT_EQ(CountTableData(info1_, DEVICE_SYNC_TABLE, "id = 1"), 1);
306 /**
307 * @tc.steps: step3. DEV_A sync to DEV_B.
308 * @tc.expected: step3. Ok
309 */
310 BlockSync(info1_, info2_, DEVICE_SYNC_TABLE, SYNC_MODE_PUSH_ONLY, OK);
311 EXPECT_EQ(CountTableData(info1_, DEVICE_SYNC_TABLE, "id = 1"), 1);
312 /**
313 * @tc.steps: step4. Update log and set hash_key is dirty.
314 * @tc.expected: step4. Ok
315 */
316 std::string sql = "UPDATE " + DBCommon::GetLogTableName(DEVICE_SYNC_TABLE) + " SET hash_key=x'12'";
317 EXPECT_EQ(ExecuteSQL(sql, info2_), E_OK);
318 ASSERT_EQ(CountTableData(info2_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), "hash_key=x'12'"), 1);
319 /**
320 * @tc.steps: step5. Update log and set hash_key is dirty.
321 * @tc.expected: step5. Ok
322 */
323 EXPECT_EQ(ExecuteSQL("UPDATE DEVICE_SYNC_TABLE SET value = 200 WHERE uuid = 100", info1_), E_OK);
324 ASSERT_EQ(CountTableData(info1_, DEVICE_SYNC_TABLE, "value = 200"), 1);
325 BlockSync(info1_, info2_, DEVICE_SYNC_TABLE, SYNC_MODE_PUSH_ONLY, OK);
326 ASSERT_EQ(CountTableData(info2_, DEVICE_SYNC_TABLE, "value = 200"), 1);
327 }
328
329 /**
330 * @tc.name: GetLocalLog001
331 * @tc.desc: Test get local log.
332 * @tc.type: FUNC
333 * @tc.author: zqq
334 */
335 HWTEST_F(DistributedDBRDBDropTableTest, GetLocalLog001, TestSize.Level0)
336 {
337 /**
338 * @tc.steps: step1. Get local log by invalid dataItem.
339 * @tc.expected: step1. -E_NOT_FOUND
340 */
341 ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
342 SetSchemaInfo(info1_, GetUniqueSchema());
343 ASSERT_NO_FATAL_FAILURE(PrepareEnv(info1_, true, true));
344 auto handle = GetSqliteHandle(info1_);
345 ASSERT_NE(handle, nullptr);
346 sqlite3_stmt *stmt = nullptr;
347 ASSERT_EQ(SQLiteUtils::GetStatement(handle, "SELECT * FROM DEVICE_SYNC_TABLE", stmt), E_OK);
348 ASSERT_NE(stmt, nullptr);
349 DataItem dataItem;
350 RelationalSyncDataInserter inserter;
351 LogInfo logInfo;
352 EXPECT_EQ(SQLiteRelationalUtils::GetLocalLog(dataItem, inserter, stmt, logInfo), -E_PARSE_FAIL);
353 dataItem.flag = DataItem::DELETE_FLAG;
354 EXPECT_EQ(SQLiteRelationalUtils::GetLocalLog(dataItem, inserter, stmt, logInfo), -E_NOT_FOUND);
355 dataItem.flag = DataItem::REMOTE_DEVICE_DATA_MISS_QUERY;
356 EXPECT_EQ(SQLiteRelationalUtils::GetLocalLog(dataItem, inserter, stmt, logInfo), -E_NOT_FOUND);
357 dataItem.flag = DataItem::DELETE_FLAG | DataItem::REMOTE_DEVICE_DATA_MISS_QUERY;
358 EXPECT_EQ(SQLiteRelationalUtils::GetLocalLog(dataItem, inserter, stmt, logInfo), -E_NOT_FOUND);
359 int ret = E_OK;
360 SQLiteUtils::ResetStatement(stmt, true, ret);
361 EXPECT_EQ(ret, E_OK);
362 EXPECT_TRUE(SQLiteRelationalUtils::GetDistributedPk(dataItem, inserter).second.empty());
363 dataItem.value.resize(Parcel::GetUInt64Len());
364 Parcel parcel(dataItem.value.data(), dataItem.value.size());
365 parcel.WriteUInt64(0);
366 /**
367 * @tc.steps: step2. Get distributed pk when field is diff.
368 * @tc.expected: step2. Get empty pk
369 */
370 std::vector<FieldInfo> remote;
371 FieldInfo field;
372 field.SetFieldName("field1");
373 remote.push_back(field);
374 field.SetFieldName("field2");
375 remote.push_back(field);
376 inserter.SetRemoteFields(remote);
377 TableInfo table;
378 table.AddField(field);
379 inserter.SetLocalTable(table);
380 DistributedTable distributedTable;
381 DistributedField distributedField;
382 distributedField.isP2pSync = true;
383 distributedField.isSpecified = true;
384 distributedField.colName = "field1";
385 distributedTable.fields.push_back(distributedField);
386 distributedField.colName = "field2";
387 distributedTable.fields.push_back(distributedField);
388 table.SetDistributedTable(distributedTable);
389 inserter.SetLocalTable(table);
390 EXPECT_TRUE(SQLiteRelationalUtils::GetDistributedPk(dataItem, inserter).second.empty());
391 dataItem.value = {};
392 EXPECT_TRUE(SQLiteRelationalUtils::GetDistributedPk(dataItem, inserter).second.empty());
393 }
394
395 /**
396 * @tc.name: GetLocalLog002
397 * @tc.desc: Test get local log by invalid pk.
398 * @tc.type: FUNC
399 * @tc.author: zqq
400 */
401 HWTEST_F(DistributedDBRDBDropTableTest, GetLocalLog002, TestSize.Level0)
402 {
403 RelationalSyncDataInserter inserter;
404 VBucket distributedPk;
405 TableInfo tableInfo;
406 DistributedTable distributedTable;
407 DistributedField field;
408 field.isP2pSync = true;
409 field.isSpecified = true;
410 field.colName = "field";
411 distributedTable.fields.push_back(field);
412 tableInfo.SetDistributedTable(distributedTable);
413 inserter.SetLocalTable(tableInfo);
414 EXPECT_EQ(SQLiteRelationalUtils::BindDistributedPk(nullptr, inserter, distributedPk), -E_INTERNAL_ERROR);
415 FieldInfo fieldInfo;
416 fieldInfo.SetFieldName(field.colName);
417 tableInfo.AddField(fieldInfo);
418 inserter.SetLocalTable(tableInfo);
419 EXPECT_EQ(SQLiteRelationalUtils::BindDistributedPk(nullptr, inserter, distributedPk), -E_INTERNAL_ERROR);
420 }
421
422 /**
423 * @tc.name: BindOneField001
424 * @tc.desc: Test bind one field by invalid args.
425 * @tc.type: FUNC
426 * @tc.author: zqq
427 */
428 HWTEST_F(DistributedDBRDBDropTableTest, BindOneField001, TestSize.Level0)
429 {
430 FieldInfo fieldInfo;
431 VBucket distributedPk;
432 fieldInfo.SetStorageType(StorageType::STORAGE_TYPE_INTEGER);
433 EXPECT_EQ(SQLiteRelationalUtils::BindOneField(nullptr, 0, fieldInfo, distributedPk), -SQLITE_MISUSE);
434 fieldInfo.SetStorageType(StorageType::STORAGE_TYPE_BLOB);
435 EXPECT_EQ(SQLiteRelationalUtils::BindOneField(nullptr, 0, fieldInfo, distributedPk), -SQLITE_MISUSE);
436 fieldInfo.SetStorageType(StorageType::STORAGE_TYPE_TEXT);
437 EXPECT_EQ(SQLiteRelationalUtils::BindOneField(nullptr, 0, fieldInfo, distributedPk), -SQLITE_MISUSE);
438 fieldInfo.SetStorageType(StorageType::STORAGE_TYPE_REAL);
439 EXPECT_EQ(SQLiteRelationalUtils::BindOneField(nullptr, 0, fieldInfo, distributedPk), -SQLITE_MISUSE);
440 }
441 }