|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
| 15 | +use std::sync::LazyLock; |
| 16 | + |
15 | 17 | use risingwave_common::catalog::PG_CATALOG_SCHEMA_NAME;
|
16 |
| -use risingwave_common::error::Result; |
17 |
| -use risingwave_common::row::OwnedRow; |
18 | 18 | use risingwave_common::types::DataType;
|
19 | 19 |
|
20 |
| -use crate::catalog::system_catalog::{BuiltinTable, SysCatalogReaderImpl}; |
| 20 | +use crate::catalog::system_catalog::{infer_dummy_view_sql, BuiltinView, SystemCatalogColumnsDef}; |
| 21 | + |
| 22 | +pub const PG_LOCKS_COLUMNS: &[SystemCatalogColumnsDef<'_>] = &[ |
| 23 | + (DataType::Varchar, "locktype"), |
| 24 | + (DataType::Int32, "database"), // oid |
| 25 | + (DataType::Int32, "relation"), // oid |
| 26 | + (DataType::Int32, "page"), |
| 27 | + (DataType::Int16, "tuple"), |
| 28 | + (DataType::Varchar, "virtualxid"), |
| 29 | + (DataType::Int32, "transactionid"), // xid |
| 30 | + (DataType::Int32, "classid"), // oid |
| 31 | + (DataType::Int32, "objid"), // oid |
| 32 | + (DataType::Int16, "objsubid"), |
| 33 | + (DataType::Varchar, "virtualtransaction"), |
| 34 | + (DataType::Int32, "pid"), |
| 35 | + (DataType::Varchar, "mode"), |
| 36 | + (DataType::Boolean, "granted"), |
| 37 | + (DataType::Boolean, "fastpath"), |
| 38 | + (DataType::Timestamptz, "waitstart"), |
| 39 | +]; |
21 | 40 |
|
22 | 41 | /// The catalog `pg_locks` provides access to information about the locks held by active processes
|
23 | 42 | /// within the database server.
|
24 | 43 | /// Reference: [`https://www.postgresql.org/docs/current/view-pg-locks.html`].
|
25 | 44 | /// Currently, we don't have any type of lock.
|
26 |
| -pub const PG_LOCKS: BuiltinTable = BuiltinTable { |
| 45 | +pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView { |
27 | 46 | name: "pg_locks",
|
28 | 47 | schema: PG_CATALOG_SCHEMA_NAME,
|
29 |
| - columns: &[ |
30 |
| - (DataType::Varchar, "locktype"), |
31 |
| - (DataType::Int32, "database"), // oid |
32 |
| - (DataType::Int32, "relation"), // oid |
33 |
| - (DataType::Int32, "page"), |
34 |
| - (DataType::Int16, "tuple"), |
35 |
| - (DataType::Varchar, "virtualxid"), |
36 |
| - (DataType::Int32, "transactionid"), // xid |
37 |
| - (DataType::Int32, "classid"), // oid |
38 |
| - (DataType::Int32, "objid"), // oid |
39 |
| - (DataType::Int16, "objsubid"), |
40 |
| - (DataType::Varchar, "virtualtransaction"), |
41 |
| - (DataType::Int32, "pid"), |
42 |
| - (DataType::Varchar, "mode"), |
43 |
| - (DataType::Boolean, "granted"), |
44 |
| - (DataType::Boolean, "fastpath"), |
45 |
| - (DataType::Timestamptz, "waitstart"), |
46 |
| - ], |
47 |
| - pk: &[], |
48 |
| -}; |
49 |
| - |
50 |
| -impl SysCatalogReaderImpl { |
51 |
| - pub fn read_locks_info(&self) -> Result<Vec<OwnedRow>> { |
52 |
| - Ok(vec![]) |
53 |
| - } |
54 |
| -} |
| 48 | + columns: PG_LOCKS_COLUMNS, |
| 49 | + sql: infer_dummy_view_sql(PG_LOCKS_COLUMNS), |
| 50 | +}); |
0 commit comments