@@ -14,45 +14,45 @@ This document explains in detail how the `ALTER INDEX ... UNUSABLE` feature in I
1414The implementation of `ALTER INDEX ... UNUSABLE` is divided into five layers:
1515
1616```
17- ┌───────────────────────────────────┐
18- │ Layer 1: Oracle Parser (ora_gram.y + ora_kwlist.h) │
19- │ ─ Adds the UNUSABLE keyword (UNRESERVED_KEYWORD, BARE_LABEL) │
20- │ ─ ALTER INDEX qualified_name UNUSABLE → OraAlterIndexUnusableStmt │
21- └───────────────────────────────────┘
22-
23- ┌───────────────────────────────────┐
24- │ Layer 2: Statement Dispatch (tcop/utility.c) │
25- │ ─ T_OraAlterIndexUnusableStmt appears alongside the existing │
26- │ T_OraAlterIndexRebuildStmt in 4 places: read-only transaction │
27- │ classification / ProcessUtilitySlow / CreateCommandTag / │
28- │ GetCommandLogLevel │
29- └───────────────────────────────────┘
30-
31- ┌───────────────────────────────────┐
32- │ Layer 3: Execution Layer (commands/indexcmds.c) │
33- │ ─ ExecOraAlterIndexUnusable(): permission check, resolves and │
34- │ locks the target index, rejects partitioned indexes, calls │
35- │ index_set_unusable(indexOid, true) │
36- └───────────────────────────────────┘
37-
38- ┌───────────────────────────────────┐
17+ ┌─────────────────────────────────────────────────────────────────────── ┐
18+ │ Layer 1: Oracle Parser (ora_gram.y + ora_kwlist.h) │
19+ │ ─ Adds the UNUSABLE keyword (UNRESERVED_KEYWORD, BARE_LABEL) │
20+ │ ─ ALTER INDEX qualified_name UNUSABLE → OraAlterIndexUnusableStmt │
21+ └─────────────────────────────────────────────────────────────────────── ┘
22+
23+ ┌─────────────────────────────────────────────────────────────────────── ┐
24+ │ Layer 2: Statement Dispatch (tcop/utility.c) │
25+ │ ─ T_OraAlterIndexUnusableStmt appears alongside the existing │
26+ │ T_OraAlterIndexRebuildStmt in 4 places: read-only transaction │
27+ │ classification / ProcessUtilitySlow / CreateCommandTag / │
28+ │ GetCommandLogLevel │
29+ └─────────────────────────────────────────────────────────────────────── ┘
30+
31+ ┌─────────────────────────────────────────────────────────────────────── ┐
32+ │ Layer 3: Execution Layer (commands/indexcmds.c) │
33+ │ ─ ExecOraAlterIndexUnusable(): permission check, resolves and │
34+ │ locks the target index, rejects partitioned indexes, calls │
35+ │ index_set_unusable(indexOid, true) │
36+ └─────────────────────────────────────────────────────────────────────── ┘
37+
38+ ┌───────────────────────────────────────────────────────────────────────── ┐
3939│ Layer 4: Catalog Layer (catalog/index.c + include/catalog/pg_index.h) │
40- │ ─ Adds the pg_index.indisunusable column │
41- │ ─ index_set_unusable(): a standalone catalog update function │
42- │ structurally mirroring index_set_state_flags() │
43- │ ─ index_create()'s values[] array is extended with an initial │
44- │ value (false) for this column │
45- │ ─ reindex_index() clears this flag as part of its existing │
46- │ "repair index state" branch │
47- └───────────────────────────────────┘
48-
49- ┌───────────────────────────────────┐
50- │ Layer 5: Planner / Executor (plancat.c + BuildIndexInfo) │
51- │ ─ get_relation_info() skips indexes with indisunusable set │
52- │ ─ BuildIndexInfo() makes ii_ReadyForInserts reflect this flag as │
53- │ well, so the existing skip logic in execIndexing.c naturally │
54- │ covers it — no changes to the executor itself are needed │
55- └───────────────────────────────────┘
40+ │ ─ Adds the pg_index.indisunusable column │
41+ │ ─ index_set_unusable(): a standalone catalog update function │
42+ │ structurally mirroring index_set_state_flags() │
43+ │ ─ index_create()'s values[] array is extended with an initial │
44+ │ value (false) for this column │
45+ │ ─ reindex_index() clears this flag as part of its existing │
46+ │ "repair index state" branch │
47+ └───────────────────────────────────────────────────────────────────────── ┘
48+
49+ ┌─────────────────────────────────────────────────────────────────────── ┐
50+ │ Layer 5: Planner / Executor (plancat.c + BuildIndexInfo) │
51+ │ ─ get_relation_info() skips indexes with indisunusable set │
52+ │ ─ BuildIndexInfo() makes ii_ReadyForInserts reflect this flag as │
53+ │ well, so the existing skip logic in execIndexing.c naturally │
54+ │ covers it — no changes to the executor itself are needed │
55+ └─────────────────────────────────────────────────────────────────────── ┘
5656```
5757
5858=== Grammar and Parsing
0 commit comments