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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//! Catalog planner IR rows.
use selene_core::DbString;
use crate::{DropBehavior, EdgeEndpointSpec, GqlType, SourceSpan, ValidationMode};
use super::ProjectExpr;
/// Catalog operation produced by DDL lowering.
#[derive(Clone, Debug, PartialEq)]
pub enum CatalogOp {
/// Create an open graph.
CreateGraph {
/// Graph name.
name: DbString,
/// Whether `OR REPLACE` was requested.
or_replace: bool,
/// Whether `IF NOT EXISTS` was requested.
if_not_exists: bool,
/// Source span.
span: SourceSpan,
},
/// Drop a graph.
DropGraph {
/// Graph name.
name: DbString,
/// Whether `IF EXISTS` was requested.
if_exists: bool,
/// Source span.
span: SourceSpan,
},
/// Create a node type.
CreateNodeType {
/// Node label.
label: DbString,
/// Resolved key label set in source order (ISO/IEC 39075:2024 §18.2 SR5,
/// Feature GG21). Empty means the bare `:Name` element-type-name form
/// whose singleton key label set is implied (Feature GG20) — the
/// executor then keys on `LabelSet::single(label)`. A non-empty vector is
/// an explicit `<node type key label set>` already validated against the
/// IL003 cardinality cap at lowering.
key_labels: Vec<DbString>,
/// Whether `OR REPLACE` was requested.
or_replace: bool,
/// Whether `IF NOT EXISTS` was requested.
if_not_exists: bool,
/// Optional parent type.
extends: Option<DbString>,
/// Property definitions.
properties: Vec<PlannedTypePropertyDef>,
/// Optional validation mode.
validation_mode: Option<ValidationMode>,
/// Source span.
span: SourceSpan,
},
/// Create an edge type.
CreateEdgeType {
/// Edge label.
label: DbString,
/// Resolved key label set in source order (ISO/IEC 39075:2024 §18.3 SR6,
/// Feature GG21). Empty means the bare `:Name` form whose singleton key
/// label set is implied (Feature GG20). A non-empty vector is an explicit
/// `<edge type key label set>` already validated against the IL003
/// cardinality cap at lowering.
key_labels: Vec<DbString>,
/// Whether `OR REPLACE` was requested.
or_replace: bool,
/// Whether `IF NOT EXISTS` was requested.
if_not_exists: bool,
/// Optional parent type.
extends: Option<DbString>,
/// Optional endpoint declaration.
endpoints: Option<EdgeEndpointSpec>,
/// Property definitions.
properties: Vec<PlannedTypePropertyDef>,
/// Optional validation mode.
validation_mode: Option<ValidationMode>,
/// Source span.
span: SourceSpan,
},
/// Drop a node type.
DropNodeType {
/// Node label.
label: DbString,
/// Whether `IF EXISTS` was requested.
if_exists: bool,
/// `RESTRICT` (default) or `CASCADE` drop behavior.
behavior: DropBehavior,
/// Source span.
span: SourceSpan,
},
/// Drop an edge type.
DropEdgeType {
/// Edge label.
label: DbString,
/// Whether `IF EXISTS` was requested.
if_exists: bool,
/// `RESTRICT` (default) or `CASCADE` drop behavior.
behavior: DropBehavior,
/// Source span.
span: SourceSpan,
},
/// Truncate (bulk-delete instances of) a node type (`IM_TRUNCATE`).
TruncateNodeType {
/// Node label whose instances are removed.
label: DbString,
/// Source span.
span: SourceSpan,
},
/// Truncate (bulk-delete instances of) an edge type (`IM_TRUNCATE`).
TruncateEdgeType {
/// Edge label whose instances are removed.
label: DbString,
/// Source span.
span: SourceSpan,
},
/// Create a named property index.
CreateIndex {
/// Catalog index name.
name: DbString,
/// Node label.
label: DbString,
/// Property names in source order.
properties: Vec<DbString>,
/// Whether `IF NOT EXISTS` was requested.
if_not_exists: bool,
/// Source span.
span: SourceSpan,
},
/// Drop a named property index.
DropIndex {
/// Catalog index name.
name: DbString,
/// Whether `IF EXISTS` was requested.
if_exists: bool,
/// Source span.
span: SourceSpan,
},
/// Show node types.
ShowNodeTypes(SourceSpan),
/// Show edge types.
ShowEdgeTypes(SourceSpan),
/// Show built-in property indexes.
ShowIndexes(SourceSpan),
/// Show registered procedures.
ShowProcedures(SourceSpan),
}
/// Planner-side type property definition.
#[derive(Clone, Debug, PartialEq)]
pub struct PlannedTypePropertyDef {
/// Property name.
pub name: DbString,
/// Declared GQL type.
pub gql_type: GqlType,
/// Planned constraints.
pub constraints: Vec<PlannedTypePropertyConstraint>,
/// Source span.
pub span: SourceSpan,
}
/// Planner-side type property constraint.
#[derive(Clone, Debug, PartialEq)]
pub enum PlannedTypePropertyConstraint {
/// `NOT NULL`.
NotNull(SourceSpan),
/// `DEFAULT expr`.
Default(ProjectExpr, SourceSpan),
/// `IMMUTABLE`.
Immutable(SourceSpan),
/// `UNIQUE`.
Unique(SourceSpan),
/// `INDEXED [AS name]`.
Indexed {
/// Optional explicit index name.
name: Option<DbString>,
/// Source span.
span: SourceSpan,
},
}