Check if table reference is recursive i.e. its name is equal to the name of current processing CTE.
| 1007 | |
| 1008 | // Check if table reference is recursive i.e. its name is equal to the name of current processing CTE. |
| 1009 | bool DsqlCompilerScratch::pass1RelProcIsRecursive(RecordSourceNode* input) |
| 1010 | { |
| 1011 | MetaName relName; |
| 1012 | string relAlias; |
| 1013 | |
| 1014 | if (auto procNode = nodeAs<ProcedureSourceNode>(input)) |
| 1015 | { |
| 1016 | relName = procNode->dsqlName.identifier; |
| 1017 | relAlias = procNode->alias; |
| 1018 | } |
| 1019 | else if (auto relNode = nodeAs<RelationSourceNode>(input)) |
| 1020 | { |
| 1021 | relName = relNode->dsqlName; |
| 1022 | relAlias = relNode->alias; |
| 1023 | } |
| 1024 | //// TODO: LocalTableSourceNode |
| 1025 | else |
| 1026 | return false; |
| 1027 | |
| 1028 | fb_assert(currCtes.hasData()); |
| 1029 | const SelectExprNode* currCte = currCtes.object(); |
| 1030 | const bool recursive = currCte->alias == relName.c_str(); |
| 1031 | |
| 1032 | if (recursive) |
| 1033 | addCTEAlias(relAlias.hasData() ? relAlias.c_str() : relName.c_str()); |
| 1034 | |
| 1035 | return recursive; |
| 1036 | } |
| 1037 | |
| 1038 | // Check if join have recursive members. If found remove this member from join and return its |
| 1039 | // boolean (to be added into WHERE clause). |