| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/function/table/table_scan.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/function/table_function.hpp" |
| 12 | #include "duckdb/common/atomic.hpp" |
| 13 | #include "duckdb/function/built_in_functions.hpp" |
| 14 | |
| 15 | namespace duckdb { |
| 16 | class DuckTableEntry; |
| 17 | class TableCatalogEntry; |
| 18 | |
| 19 | struct TableScanBindData : public TableFunctionData { |
| 20 | explicit TableScanBindData(DuckTableEntry &table) : table(table), is_index_scan(false), is_create_index(false) { |
| 21 | } |
| 22 | |
| 23 | //! The table to scan |
| 24 | DuckTableEntry &table; |
| 25 | |
| 26 | //! Whether or not the table scan is an index scan |
| 27 | bool is_index_scan; |
| 28 | //! Whether or not the table scan is for index creation |
| 29 | bool is_create_index; |
| 30 | //! The row ids to fetch (in case of an index scan) |
| 31 | vector<row_t> result_ids; |
| 32 | |
| 33 | public: |
| 34 | bool Equals(const FunctionData &other_p) const override { |
| 35 | auto &other = (const TableScanBindData &)other_p; |
| 36 | return &other.table == &table && result_ids == other.result_ids; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | //! The table scan function represents a sequential scan over one of DuckDB's base tables. |
| 41 | struct TableScanFunction { |
| 42 | static void RegisterFunction(BuiltinFunctions &set); |
| 43 | static TableFunction GetFunction(); |
| 44 | static TableFunction GetIndexScanFunction(); |
| 45 | static optional_ptr<TableCatalogEntry> GetTableEntry(const TableFunction &function, |
| 46 | const optional_ptr<FunctionData> bind_data); |
| 47 | }; |
| 48 | |
| 49 | } // namespace duckdb |
| 50 |