/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pg_select_index.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_SELECT_INDEX_H_ |
16 | | #define YB_YQL_PGGATE_PG_SELECT_INDEX_H_ |
17 | | |
18 | | #include "yb/yql/pggate/pg_select.h" |
19 | | |
20 | | namespace yb { |
21 | | namespace pggate { |
22 | | |
23 | | //-------------------------------------------------------------------------------------------------- |
24 | | // SELECT FROM Secondary Index Table |
25 | | //-------------------------------------------------------------------------------------------------- |
26 | | |
27 | | class PgSelectIndex : public PgSelect { |
28 | | public: |
29 | | PgSelectIndex(PgSession::ScopedRefPtr pg_session, |
30 | | const PgObjectId& table_id, |
31 | | const PgObjectId& index_id, |
32 | | const PgPrepareParameters *prepare_params); |
33 | | |
34 | | // Prepare NESTED query for secondary index. This function is called when Postgres layer is |
35 | | // accessing the IndexTable via an outer select (Sequential or primary scans) |
36 | | CHECKED_STATUS PrepareSubquery(std::shared_ptr<PgsqlReadRequestPB> read_req); |
37 | | |
38 | | Result<PgTableDescPtr> LoadTable() override; |
39 | | |
40 | | bool UseSecondaryIndex() const override; |
41 | | |
42 | | // The output parameter "ybctids" are pointer to the data buffer in "ybctid_batch_". |
43 | | virtual Result<bool> FetchYbctidBatch(const vector<Slice> **ybctids); |
44 | | |
45 | | // Get next batch of ybctids from either PgGate::cache or server. |
46 | | Result<bool> GetNextYbctidBatch(); |
47 | | |
48 | 151k | void set_is_executed(bool value) { |
49 | 151k | is_executed_ = value; |
50 | 151k | } |
51 | | |
52 | 278k | bool is_executed() { |
53 | 278k | return is_executed_; |
54 | 278k | } |
55 | | |
56 | | private: |
57 | | // This secondary query should be executed just one time. |
58 | | bool is_executed_ = false; |
59 | | }; |
60 | | |
61 | | } // namespace pggate |
62 | | } // namespace yb |
63 | | |
64 | | #endif // YB_YQL_PGGATE_PG_SELECT_INDEX_H_ |