/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pg_insert.h
Line | Count | Source |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. 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 distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | //-------------------------------------------------------------------------------------------------- |
14 | | |
15 | | #ifndef YB_YQL_PGGATE_PG_INSERT_H_ |
16 | | #define YB_YQL_PGGATE_PG_INSERT_H_ |
17 | | |
18 | | #include "yb/yql/pggate/pg_dml_write.h" |
19 | | |
20 | | namespace yb { |
21 | | namespace pggate { |
22 | | |
23 | | //-------------------------------------------------------------------------------------------------- |
24 | | // INSERT |
25 | | //-------------------------------------------------------------------------------------------------- |
26 | | |
27 | | class PgInsert : public PgDmlWrite { |
28 | | public: |
29 | | PgInsert(PgSession::ScopedRefPtr pg_session, const PgObjectId& table_id, bool is_single_row_txn) |
30 | 5.59M | : PgDmlWrite(std::move(pg_session), table_id, is_single_row_txn) {} |
31 | | |
32 | 12.9M | StmtOp stmt_op() const override { return StmtOp::STMT_INSERT; } |
33 | | |
34 | 953k | void SetUpsertMode() { |
35 | 953k | write_req_->set_stmt_type(PgsqlWriteRequestPB::PGSQL_UPSERT); |
36 | 953k | } |
37 | | |
38 | 371k | void SetIsBackfill(const bool is_backfill) { |
39 | 371k | write_req_->set_is_backfill(is_backfill); |
40 | 371k | } |
41 | | |
42 | | private: |
43 | 5.59M | PgsqlWriteRequestPB::PgsqlStmtType stmt_type() const override { |
44 | 5.59M | return PgsqlWriteRequestPB::PGSQL_INSERT; |
45 | 5.59M | } |
46 | | }; |
47 | | |
48 | | } // namespace pggate |
49 | | } // namespace yb |
50 | | |
51 | | #endif // YB_YQL_PGGATE_PG_INSERT_H_ |