| 441 | } |
| 442 | |
| 443 | static void _ASTClause_BuildReferenceMap(AST *ast, const cypher_astnode_t *clause) { |
| 444 | if(!clause) return; |
| 445 | |
| 446 | cypher_astnode_type_t type = cypher_astnode_type(clause); |
| 447 | if(type == CYPHER_AST_RETURN) { |
| 448 | // add referenced aliases for RETURN projections |
| 449 | uint projectionCount = cypher_ast_return_nprojections(clause); |
| 450 | for(uint i = 0 ; i < projectionCount; i ++) { |
| 451 | _AST_MapProjectionAlias(ast, cypher_ast_return_get_projection(clause, i)); |
| 452 | } |
| 453 | // add referenced aliases for RETURN's ORDER BY entities |
| 454 | const cypher_astnode_t *order_by = cypher_ast_return_get_order_by(clause); |
| 455 | if(order_by) _AST_MapOrderByReferences(ast, order_by); |
| 456 | } else if(type == CYPHER_AST_WITH) { |
| 457 | // add referenced aliases for WITH projections |
| 458 | uint projectionCount = cypher_ast_with_nprojections(clause); |
| 459 | for(uint i = 0 ; i < projectionCount; i ++) { |
| 460 | _AST_MapProjectionAlias(ast, cypher_ast_with_get_projection(clause, i)); |
| 461 | } |
| 462 | // add referenced aliases for WITH's ORDER BY entities |
| 463 | const cypher_astnode_t *order_by = cypher_ast_with_get_order_by(clause); |
| 464 | if(order_by) _AST_MapOrderByReferences(ast, order_by); |
| 465 | } else if(type == CYPHER_AST_MATCH) { |
| 466 | // add referenced aliases from MATCH clause |
| 467 | // inline filtered and explicit WHERE filter |
| 468 | _AST_MapMatchClauseReferences(ast, clause); |
| 469 | } else if(type == CYPHER_AST_CREATE) { |
| 470 | // add referenced aliases for CREATE clause |
| 471 | _AST_MapCreateClauseReferences(ast, clause); |
| 472 | } else if(type == CYPHER_AST_MERGE) { |
| 473 | // add referenced aliases for MERGE clause |
| 474 | // inline filtered and modified entities |
| 475 | _AST_MapMergeClauseReference(ast, clause); |
| 476 | } else if(type == CYPHER_AST_SET) { |
| 477 | // add referenced aliases for SET clause |
| 478 | _AST_MapSetClauseReferences(ast, clause); |
| 479 | } else if(type == CYPHER_AST_DELETE) { |
| 480 | // add referenced aliases for DELETE clause |
| 481 | _AST_MapDeleteClauseReferences(ast, clause); |
| 482 | } else if(type == CYPHER_AST_REMOVE) { |
| 483 | // add referenced aliases for REMOVE clause |
| 484 | _AST_MapRemoveClauseReferences(ast, clause); |
| 485 | } else if(type == CYPHER_AST_UNWIND) { |
| 486 | // add referenced aliases for UNWIND clause |
| 487 | _AST_MapUnwindClauseReferences(ast, clause); |
| 488 | } else if(type == CYPHER_AST_FOREACH) { |
| 489 | // add referenced aliases for a FOREACH clause |
| 490 | _AST_MapForeachClauseReferences(ast, clause); |
| 491 | } else if(type == CYPHER_AST_CALL_SUBQUERY) { |
| 492 | // add referenced aliases for a CALL {} clause |
| 493 | _AST_MapCallSubqueryReferences(ast, clause); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | // Map the referred aliases (LHS) in entities projected by a WITH or RETURN clause. |
| 498 | static void _AST_MapProjectionClause(AST *ast_segment, const cypher_astnode_t *projection) { |
no test coverage detected