summaryrefslogtreecommitdiff
path: root/storage/ndb/src/kernel/blocks/dbdict/CreateIndex.txt
blob: 3d11e501c071a062551c2855dd0757da7b0ed0f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Unique Hash Index
=================

unique hash index X on T(A1,...,An) becomes:
table X with primary key A1,...,An and extra attribute NDB$PK

NDB$PK is primary key of T concatenated at 4-byte boundaries

Protocols:

U - user, initiator of protocol
C - coordinator
P - participants, including coordinator node

RT_ - request type, current state

P always replies to C with current RT_ (initially RT_DICT_PREPARE)
C replies to U at the end

CREATE INDEX
------------

U: RT_USER

C: forward request to P's
P: check and reply

C: invoke CREATE TABLE for index table

C: invoke ALTER INDEX online

C: send RT_DICT_COMMIT to P's
P: reply

C: reply to U

DROP INDEX
----------

[ todo ]

ALTER INDEX online
------------------

U: RT_USER, RT_CREATE_INDEX, RT_NODERESTART, RT_SYSTEMRESTART

C: forward request to P's
P: check and reply

C: send RT_DICT_TC to P's
P: create index in local TC, and reply

C: invoke CREATE TRIGGER for insert/update/delete triggers

C: invoke BUILD INDEX

C: send RT_DICT_COMMIT to P's
P: reply

C: reply to U

ALTER INDEX offline
-------------------

[ todo ]

BUILD INDEX
-----------

U: RT_USER, RT_ALTER_INDEX

C: forward request to P's
P: check and reply

C: invoke CREATE TRIGGER for read-only constraint on NDB$PK

C: send RT_DICT_TRIX to P's
P: build index via local TRIX, and reply

C: invoke DROP TRIGGER for read-only constraint on NDB$PK

C: send RT_DICT_TC to P's
P: online index in local TC, and reply

CREATE TRIGGER
--------------

U: RT_USER, RT_ALTER_INDEX, RT_BUILD_INDEX

C: forward request to P's
P: check and reply

C: seize trigger id and send RT_DICT_CREATE to P's
P: create trigger in DICT (also connect to index record), and reply

C: invoke ALTER TRIGGER online [ not if subscription trigger ]

C: send RT_DICT_COMMIT to P's
P: reply

C: reply to U

DROP TRIGGER
------------

[ todo ]

ALTER TRIGGER online
--------------------

U: RT_USER, RT_CREATE_TRIGGER

C: forward request to P's
P: check and reply

C: send RT_DICT_TC to P's
P: create trigger in local TC, and reply

C: send RT_DICT_LQH to P's
P: create trigger in local LQH (which just forwards to TUP), and reply

C: send RT_DICT_COMMIT to P's
P: reply

C: reply to U

ALTER TRIGGER offline
---------------------

[ todo ]

Ordered Index  << under work >>
=============

created as DICT table, as before, to reuse the code

keep NDB$PK as last attribute (not used but logically correct)

create fragments and attributes must be modified

global metadata?  implemented but will use signals anyway

create (after-) insert/update/delete triggers as DICT objects, as before

skip following:
- create index in TC
- create triggers in TC
- read-only constraint on NDB$PK

create (before-) commit trigger in TUP

alter online (in TUX, instead of TC) is needed