* exprLocation - * returns the parse location of an expression tree, for error reports * * -1 is returned if the location can't be determined. * * For expressions larger than a single token, the intent here is to * return the location of the expression's leftmost token, not necessarily * the topmost Node's location field. For example, an OpExpr's location * field will point at the opera
| 1295 | * known and unknown locations in a tree. |
| 1296 | */ |
| 1297 | int |
| 1298 | exprLocation(const Node *expr) |
| 1299 | { |
| 1300 | int loc; |
| 1301 | |
| 1302 | if (expr == NULL) |
| 1303 | return -1; |
| 1304 | switch (nodeTag(expr)) |
| 1305 | { |
| 1306 | case T_RangeVar: |
| 1307 | loc = ((const RangeVar *) expr)->location; |
| 1308 | break; |
| 1309 | case T_TableFunc: |
| 1310 | loc = ((const TableFunc *) expr)->location; |
| 1311 | break; |
| 1312 | case T_Var: |
| 1313 | loc = ((const Var *) expr)->location; |
| 1314 | break; |
| 1315 | case T_Const: |
| 1316 | loc = ((const Const *) expr)->location; |
| 1317 | break; |
| 1318 | case T_Param: |
| 1319 | loc = ((const Param *) expr)->location; |
| 1320 | break; |
| 1321 | case T_Aggref: |
| 1322 | /* function name should always be the first thing */ |
| 1323 | loc = ((const Aggref *) expr)->location; |
| 1324 | break; |
| 1325 | case T_GroupingFunc: |
| 1326 | loc = ((const GroupingFunc *) expr)->location; |
| 1327 | break; |
| 1328 | case T_GroupId: |
| 1329 | loc = ((const GroupId *) expr)->location; |
| 1330 | break; |
| 1331 | case T_GroupingSetId: |
| 1332 | loc = ((const GroupingSetId *) expr)->location; |
| 1333 | break; |
| 1334 | case T_WindowFunc: |
| 1335 | /* function name should always be the first thing */ |
| 1336 | loc = ((const WindowFunc *) expr)->location; |
| 1337 | break; |
| 1338 | case T_SubscriptingRef: |
| 1339 | /* just use container argument's location */ |
| 1340 | loc = exprLocation((Node *) ((const SubscriptingRef *) expr)->refexpr); |
| 1341 | break; |
| 1342 | case T_FuncExpr: |
| 1343 | { |
| 1344 | const FuncExpr *fexpr = (const FuncExpr *) expr; |
| 1345 | |
| 1346 | /* consider both function name and leftmost arg */ |
| 1347 | loc = leftmostLoc(fexpr->location, |
| 1348 | exprLocation((Node *) fexpr->args)); |
| 1349 | } |
| 1350 | break; |
| 1351 | case T_NamedArgExpr: |
| 1352 | { |
| 1353 | const NamedArgExpr *na = (const NamedArgExpr *) expr; |
| 1354 |
no test coverage detected