CALL db.constraints()
| 169 | |
| 170 | // CALL db.constraints() |
| 171 | ProcedureResult Proc_ConstraintsInvoke |
| 172 | ( |
| 173 | ProcedureCtx *ctx, |
| 174 | const SIValue *args, |
| 175 | const char **yield |
| 176 | ) { |
| 177 | |
| 178 | ASSERT(ctx != NULL); |
| 179 | ASSERT(args != NULL); |
| 180 | ASSERT(yield != NULL); |
| 181 | |
| 182 | // TODO: introduce invoke validation, similar to arithmetic expressions |
| 183 | // expecting no arguments |
| 184 | uint arg_count = array_len((SIValue *)args); |
| 185 | if(arg_count != 0) return PROCEDURE_ERR; |
| 186 | |
| 187 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 188 | |
| 189 | ConstraintsContext *pdata = rm_malloc(sizeof(ConstraintsContext)); |
| 190 | |
| 191 | pdata->gc = gc; |
| 192 | pdata->out = array_new(SIValue, 5); |
| 193 | pdata->constraints = array_new(Constraint, 0); |
| 194 | |
| 195 | _process_yield(pdata, yield); |
| 196 | |
| 197 | ctx->privateData = pdata; |
| 198 | |
| 199 | //-------------------------------------------------------------------------- |
| 200 | // collect constraints |
| 201 | //-------------------------------------------------------------------------- |
| 202 | |
| 203 | SchemaType schema_types[2] = {SCHEMA_NODE, SCHEMA_EDGE}; |
| 204 | |
| 205 | // foreach schema type |
| 206 | for(int i = 0; i < 2; i++) { |
| 207 | SchemaType schema_type = schema_types[i]; |
| 208 | ushort n = GraphContext_SchemaCount(gc, schema_type); |
| 209 | |
| 210 | // foreach schema |
| 211 | for(ushort j = 0; j < n; j++) { |
| 212 | Schema *s = GraphContext_GetSchemaByID(gc, j, schema_type); |
| 213 | const Constraint *cs = Schema_GetConstraints(s); |
| 214 | // foreach schema's constraint |
| 215 | |
| 216 | for(uint32_t k = 0; k < array_len((Constraint*)cs); k++) { |
| 217 | array_append(pdata->constraints, cs[k]); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return PROCEDURE_OK; |
| 223 | } |
| 224 | |
| 225 | ProcedureResult Proc_ConstraintsFree |
| 226 | ( |
nothing calls this directly
no test coverage detected