1 /* 2 * Copyright (c) 2024 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 #ifndef OHOS_DISTRIBUTED_DATA_RELATIONAL_STORE_FRAMEWORKS_NATIVE_RDB_INCLUDE_STATEMENT_H 17 #define OHOS_DISTRIBUTED_DATA_RELATIONAL_STORE_FRAMEWORKS_NATIVE_RDB_INCLUDE_STATEMENT_H 18 #include <functional> 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "value_object.h" 24 #include "values_bucket.h" 25 namespace OHOS::NativeRdb { 26 struct SharedBlockInfo; 27 class Statement { 28 public: 29 static constexpr int32_t COLUMN_TYPE_INVALID = 0; 30 static constexpr int32_t COLUMN_TYPE_ASSET = 1000; 31 static constexpr int32_t COLUMN_TYPE_ASSETS = 1001; 32 static constexpr int32_t COLUMN_TYPE_FLOATS = 1002; 33 static constexpr int32_t COLUMN_TYPE_BIGINT = 1003; 34 35 virtual ~Statement() = default; 36 virtual int32_t Prepare(const std::string &sql) = 0; 37 virtual int32_t Bind(const std::vector<ValueObject> &args = {}) = 0; 38 virtual std::pair<int32_t, int32_t> Count() = 0; 39 virtual int32_t Step() = 0; 40 virtual int32_t Reset() = 0; 41 virtual int32_t Finalize() = 0; 42 virtual int32_t Execute(const std::vector<ValueObject> &args = {}) = 0; 43 virtual int32_t Execute(const std::vector<std::reference_wrapper<ValueObject>> &args) = 0; 44 45 virtual std::pair<int, ValueObject> ExecuteForValue(const std::vector<ValueObject> &args = {}) = 0; 46 virtual int32_t Changes() const = 0; 47 virtual int64_t LastInsertRowId() const = 0; 48 49 virtual int32_t GetColumnCount() const = 0; 50 virtual std::pair<int32_t, std::string> GetColumnName(int32_t index) const = 0; 51 virtual std::pair<int32_t, int32_t> GetColumnType(int32_t index) const = 0; 52 virtual std::pair<int32_t, size_t> GetSize(int32_t index) const = 0; 53 virtual std::pair<int32_t, ValueObject> GetColumn(int32_t index) const = 0; 54 virtual std::pair<int32_t, std::vector<ValuesBucket>> GetRows(uint32_t maxCount = 1024) = 0; 55 virtual bool ReadOnly() const = 0; 56 virtual bool SupportBlockInfo() const = 0; 57 virtual int32_t FillBlockInfo(SharedBlockInfo *info) const = 0; ModifyLockStatus(const std::string & table,const std::vector<std::vector<uint8_t>> & hashKeys,bool isLock)58 virtual int ModifyLockStatus( 59 const std::string &table, const std::vector<std::vector<uint8_t>> &hashKeys, bool isLock) 60 { 61 return 0; 62 } 63 64 static constexpr int INVALID_COUNT = -1; 65 }; 66 } // namespace OHOS::NativeRdb 67 #endif // OHOS_DISTRIBUTED_DATA_RELATIONAL_STORE_FRAMEWORKS_NATIVE_RDB_INCLUDE_STATEMENT_H 68