risingwave_frontend/catalog/system_catalog/pg_catalog/
pg_index.rs1use risingwave_common::types::Fields;
16use risingwave_frontend_macro::system_catalog;
17
18#[system_catalog(
21 view,
22 "pg_catalog.pg_index",
23 "SELECT id AS indexrelid,
24 primary_table_id AS indrelid,
25 ARRAY_LENGTH(key_columns || include_columns)::smallint AS indnatts,
26 ARRAY_LENGTH(key_columns)::smallint AS indnkeyatts,
27 false AS indisunique,
28 key_columns || include_columns AS indkey,
29 ARRAY[]::smallint[] as indoption,
30 NULL AS indexprs,
31 NULL AS indpred,
32 FALSE AS indisprimary,
33 ARRAY[]::int[] AS indclass,
34 false AS indisexclusion,
35 true AS indimmediate,
36 false AS indisclustered,
37 true AS indisvalid,
38 false AS indcheckxmin,
39 true AS indisready,
40 true AS indislive,
41 false AS indisreplident
42 FROM rw_catalog.rw_indexes
43 UNION ALL
44 SELECT c.relation_id AS indexrelid,
45 c.relation_id AS indrelid,
46 COUNT(*)::smallint AS indnatts,
47 COUNT(*)::smallint AS indnkeyatts,
48 true AS indisunique,
49 ARRAY_AGG(c.position)::smallint[] AS indkey,
50 ARRAY[]::smallint[] as indoption,
51 NULL AS indexprs,
52 NULL AS indpred,
53 TRUE AS indisprimary,
54 ARRAY[]::int[] AS indclass,
55 false AS indisexclusion,
56 true AS indimmediate,
57 false AS indisclustered,
58 true AS indisvalid,
59 false AS indcheckxmin,
60 true AS indisready,
61 true AS indislive,
62 false AS indisreplident
63 FROM rw_catalog.rw_columns c
64 WHERE c.is_primary_key = true AND c.is_hidden = false
65 AND c.relation_id IN (
66 SELECT id
67 FROM rw_catalog.rw_tables
68 )
69 GROUP BY c.relation_id"
70)]
71#[derive(Fields)]
72struct PgIndex {
73 indexrelid: i32,
74 indrelid: i32,
75 indnatts: i16,
76 indnkeyatts: i16,
77 indisunique: bool,
79 indkey: Vec<i16>,
80 indoption: Vec<i16>,
81 indexprs: Option<String>,
83 indpred: Option<String>,
85 indisprimary: bool,
87 indclass: Vec<i32>,
89
90 indisexclusion: bool,
92 indimmediate: bool,
93 indisclustered: bool,
94 indisvalid: bool,
95 indcheckxmin: bool,
96 indisready: bool,
97 indislive: bool,
98 indisreplident: bool,
99}