MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _index_operation_delete

Function _index_operation_delete

src/commands/cmd_query.c:127–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127static bool _index_operation_delete
128(
129 GraphContext *gc,
130 AST *ast
131) {
132 Schema *s = NULL;
133 SchemaType schema_type = SCHEMA_NODE;
134 const cypher_astnode_t *index_op = ast->root;
135
136 // retrieve strings from AST node
137 const char *label = cypher_ast_label_get_name(
138 cypher_ast_drop_props_index_get_label(index_op));
139 const char *attr = cypher_ast_prop_name_get_value(
140 cypher_ast_drop_props_index_get_prop_name(index_op, 0));
141
142 Attribute_ID attr_id = GraphContext_GetAttributeID(gc, attr);
143
144 // try deleting a NODE EXACT-MATCH index
145
146 // lock
147 QueryCtx_LockForCommit();
148
149 s = GraphContext_GetSchema(gc, label, SCHEMA_NODE);
150 if(s != NULL) {
151 if(Schema_GetIndex(s, &attr_id, 1, IDX_EXACT_MATCH, true) != NULL) {
152 // try deleting an exact match node index
153 return GraphContext_DeleteIndex(gc, SCHEMA_NODE, label, attr, IDX_EXACT_MATCH);
154 }
155 }
156
157 // try removing from an edge schema
158 s = GraphContext_GetSchema(gc, label, SCHEMA_EDGE);
159 if(s != NULL) {
160 if(Schema_GetIndex(s, &attr_id, 1, IDX_EXACT_MATCH, true) != NULL) {
161 // try deleting an exact match edge index
162 return GraphContext_DeleteIndex(gc, SCHEMA_EDGE, label, attr, IDX_EXACT_MATCH);
163 }
164 }
165
166 // no matching index
167 ErrorCtx_SetError("ERR Unable to drop index on :%s(%s): no such index.",
168 label, attr);
169
170 return false;
171}
172
173// create index structure
174static void _index_operation_create

Callers 1

_index_operationFunction · 0.85

Calls 6

QueryCtx_LockForCommitFunction · 0.85
GraphContext_GetSchemaFunction · 0.85
Schema_GetIndexFunction · 0.85
GraphContext_DeleteIndexFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected