| Line | Hits | Source | Commit |
|---|---|---|---|
| 42 | - | exprType(const Node *expr) | - |
| 43 | - | { | - |
| 44 | - | Oid type; | - |
| 45 | - | - | |
| 46 | - | if (!expr) | - |
| 47 | - | return InvalidOid; | - |
| 48 | - | - | |
| 49 | - | switch (nodeTag(expr)) | - |
| 50 | - | { | - |
| 51 | - | case T_Var: | - |
| 52 | - | type = ((const Var *) expr)->vartype; | - |
| 53 | - | break; | - |
| 54 | - | case T_Const: | - |
| 55 | - | type = ((const Const *) expr)->consttype; | - |
| 56 | - | break; | - |
| 57 | - | case T_Param: | - |
| 58 | - | type = ((const Param *) expr)->paramtype; | - |
| 59 | - | break; | - |
| 60 | - | case T_Aggref: | - |
| 61 | - | type = ((const Aggref *) expr)->aggtype; | - |
| 62 | - | break; | - |
| 63 | - | case T_GroupingFunc: | - |
| 64 | - | type = INT4OID; | - |
| 65 | - | break; | - |
| 66 | - | case T_WindowFunc: | - |
| 67 | - | type = ((const WindowFunc *) expr)->wintype; | - |
| 68 | - | break; | - |
| 69 | - | case T_MergeSupportFunc: | - |
| 70 | - | type = ((const MergeSupportFunc *) expr)->msftype; | - |
| 71 | - | break; | - |
| 72 | - | case T_SubscriptingRef: | - |
| 73 | - | type = ((const SubscriptingRef *) expr)->refrestype; | - |
| 74 | - | break; | - |
| 75 | - | case T_FuncExpr: | - |
| 76 | - | type = ((const FuncExpr *) expr)->funcresulttype; | - |
| 77 | - | break; | - |
| 78 | - | case T_NamedArgExpr: | - |
| 79 | - | type = exprType((Node *) ((const NamedArgExpr *) expr)->arg); | - |
| 80 | - | break; | - |
| 81 | - | case T_OpExpr: | - |
| 82 | - | type = ((const OpExpr *) expr)->opresulttype; | - |
| 83 | - | break; | - |
| 84 | - | case T_DistinctExpr: | - |
| 85 | - | type = ((const DistinctExpr *) expr)->opresulttype; | - |
| 86 | - | break; | - |
| 87 | - | case T_NullIfExpr: | - |
| 88 | - | type = ((const NullIfExpr *) expr)->opresulttype; | - |
| 89 | - | break; | - |
| 90 | - | case T_ScalarArrayOpExpr: | - |
| 91 | - | type = BOOLOID; | - |
| 92 | - | break; | - |
| 93 | - | case T_BoolExpr: | - |
| 94 | - | type = BOOLOID; | - |
| 95 | - | break; | - |
| 96 | - | case T_SubLink: | - |
| 97 | - | { | - |
| 98 | - | const SubLink *sublink = (const SubLink *) expr; | - |
| 99 | - | - | |
| 100 | - | if (sublink->subLinkType == EXPR_SUBLINK || | - |
| 101 | - | sublink->subLinkType == ARRAY_SUBLINK) | - |
| 102 | - | { | - |
| 103 | - | /* get the type of the subselect's first target column */ | - |
| 104 | - | Query *qtree = (Query *) sublink->subselect; | - |
| 105 | - | TargetEntry *tent; | - |
| 106 | - | - | |
| 107 | - | if (!qtree || !IsA(qtree, Query)) | - |
| 108 | - | elog(ERROR, "cannot get type for untransformed sublink"); | - |
| 109 | - | tent = linitial_node(TargetEntry, qtree->targetList); | - |
| 110 | - | Assert(!tent->resjunk); | - |
| 111 | - | type = exprType((Node *) tent->expr); | - |
| 112 | - | if (sublink->subLinkType == ARRAY_SUBLINK) | - |
| 113 | - | { | - |
| 114 | - | type = get_promoted_array_type(type); | - |
| 115 | - | if (!OidIsValid(type)) | - |
| 116 | - | ereport(ERROR, | - |
| 117 | - | (errcode(ERRCODE_UNDEFINED_OBJECT), | - |
| 118 | - | errmsg("could not find array type for data type %s", | - |
| 119 | - | format_type_be(exprType((Node *) tent->expr))))); | - |
| 120 | - | } | - |
| 121 | - | } | - |
| 122 | - | else if (sublink->subLinkType == MULTIEXPR_SUBLINK) | - |
| 123 | - | { | - |
| 124 | - | /* MULTIEXPR is always considered to return RECORD */ | - |
| 125 | - | type = RECORDOID; | - |
| 126 | - | } | - |
| 127 | - | else | - |
| 128 | - | { | - |
| 129 | - | /* for all other sublink types, result is boolean */ | - |
| 130 | - | type = BOOLOID; | - |
| 131 | - | } | - |
| 132 | - | } | - |
| 133 | - | break; | - |
| 134 | - | case T_SubPlan: | - |
| 135 | - | { | - |
| 136 | - | const SubPlan *subplan = (const SubPlan *) expr; | - |
| 137 | - | - | |
| 138 | - | if (subplan->subLinkType == EXPR_SUBLINK || | - |
| 139 | - | subplan->subLinkType == ARRAY_SUBLINK) | - |
| 140 | - | { | - |
| 141 | - | /* get the type of the subselect's first target column */ | - |
| 142 | - | type = subplan->firstColType; | - |
| 143 | - | if (subplan->subLinkType == ARRAY_SUBLINK) | - |
| 144 | - | { | - |
| 145 | - | type = get_promoted_array_type(type); | - |
| 146 | - | if (!OidIsValid(type)) | - |
| 147 | - | ereport(ERROR, | - |
| 148 | - | (errcode(ERRCODE_UNDEFINED_OBJECT), | - |
| 149 | - | errmsg("could not find array type for data type %s", | - |
| 150 | - | format_type_be(subplan->firstColType)))); | - |
| 151 | - | } | - |
| 152 | - | } | - |
| 153 | - | else if (subplan->subLinkType == MULTIEXPR_SUBLINK) | - |
| 154 | - | { | - |
| 155 | - | /* MULTIEXPR is always considered to return RECORD */ | - |
| 156 | - | type = RECORDOID; | - |
| 157 | - | } | - |
| 158 | - | else | - |
| 159 | - | { | - |
| 160 | - | /* for all other subplan types, result is boolean */ | - |
| 161 | - | type = BOOLOID; | - |
| 162 | - | } | - |
| 163 | - | } | - |
| 164 | - | break; | - |
| 165 | - | case T_AlternativeSubPlan: | - |
| 166 | - | { | - |
| 167 | - | const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr; | - |
| 168 | - | - | |
| 169 | - | /* subplans should all return the same thing */ | - |
| 170 | - | type = exprType((Node *) linitial(asplan->subplans)); | - |
| 171 | - | } | - |
| 172 | - | break; | - |
| 173 | - | case T_FieldSelect: | - |
| 174 | - | type = ((const FieldSelect *) expr)->resulttype; | - |
| 175 | - | break; | - |
| 176 | - | case T_FieldStore: | - |
| 177 | - | type = ((const FieldStore *) expr)->resulttype; | - |
| 178 | - | break; | - |
| 179 | - | case T_RelabelType: | - |
| 180 | - | type = ((const RelabelType *) expr)->resulttype; | - |
| 181 | - | break; | - |
| 182 | - | case T_CoerceViaIO: | - |
| 183 | - | type = ((const CoerceViaIO *) expr)->resulttype; | - |
| 184 | - | break; | - |
| 185 | - | case T_ArrayCoerceExpr: | - |
| 186 | - | type = ((const ArrayCoerceExpr *) expr)->resulttype; | - |
| 187 | - | break; | - |
| 188 | - | case T_ConvertRowtypeExpr: | - |
| 189 | - | type = ((const ConvertRowtypeExpr *) expr)->resulttype; | - |
| 190 | - | break; | - |
| 191 | - | case T_CollateExpr: | - |
| 192 | - | type = exprType((Node *) ((const CollateExpr *) expr)->arg); | - |
| 193 | - | break; | - |
| 194 | - | case T_CaseExpr: | - |
| 195 | - | type = ((const CaseExpr *) expr)->casetype; | - |
| 196 | - | break; | - |
| 197 | - | case T_CaseTestExpr: | - |
| 198 | - | type = ((const CaseTestExpr *) expr)->typeId; | - |
| 199 | - | break; | - |
| 200 | - | case T_ArrayExpr: | - |
| 201 | - | type = ((const ArrayExpr *) expr)->array_typeid; | - |
| 202 | - | break; | - |
| 203 | - | case T_RowExpr: | - |
| 204 | - | type = ((const RowExpr *) expr)->row_typeid; | - |
| 205 | - | break; | - |
| 206 | - | case T_RowCompareExpr: | - |
| 207 | - | type = BOOLOID; | - |
| 208 | - | break; | - |
| 209 | - | case T_CoalesceExpr: | - |
| 210 | - | type = ((const CoalesceExpr *) expr)->coalescetype; | - |
| 211 | - | break; | - |
| 212 | - | case T_MinMaxExpr: | - |
| 213 | - | type = ((const MinMaxExpr *) expr)->minmaxtype; | - |
| 214 | - | break; | - |
| 215 | - | case T_SQLValueFunction: | - |
| 216 | - | type = ((const SQLValueFunction *) expr)->type; | - |
| 217 | - | break; | - |
| 218 | - | case T_XmlExpr: | - |
| 219 | - | if (((const XmlExpr *) expr)->op == IS_DOCUMENT) | - |
| 220 | - | type = BOOLOID; | - |
| 221 | - | else if (((const XmlExpr *) expr)->op == IS_XMLSERIALIZE) | - |
| 222 | - | type = TEXTOID; | - |
| 223 | - | else | - |
| 224 | - | type = XMLOID; | - |
| 225 | - | break; | - |
| 226 | - | case T_JsonValueExpr: | - |
| 227 | - | { | - |
| 228 | - | const JsonValueExpr *jve = (const JsonValueExpr *) expr; | - |
| 229 | - | - | |
| 230 | - | type = exprType((Node *) jve->formatted_expr); | - |
| 231 | - | } | - |
| 232 | - | break; | - |
| 233 | - | case T_JsonConstructorExpr: | - |
| 234 | - | type = ((const JsonConstructorExpr *) expr)->returning->typid; | - |
| 235 | - | break; | - |
| 236 | - | case T_JsonIsPredicate: | - |
| 237 | - | type = BOOLOID; | - |
| 238 | - | break; | - |
| 239 | - | case T_JsonExpr: | - |
| 240 | - | { | - |
| 241 | - | const JsonExpr *jexpr = (const JsonExpr *) expr; | - |
| 242 | - | - | |
| 243 | - | type = jexpr->returning->typid; | - |
| 244 | - | break; | - |
| 245 | - | } | - |
| 246 | - | case T_JsonBehavior: | - |
| 247 | - | { | - |
| 248 | - | const JsonBehavior *behavior = (const JsonBehavior *) expr; | - |
| 249 | - | - | |
| 250 | - | type = exprType(behavior->expr); | - |
| 251 | - | break; | - |
| 252 | - | } | - |
| 253 | - | case T_NullTest: | - |
| 254 | - | type = BOOLOID; | - |
| 255 | - | break; | - |
| 256 | - | case T_BooleanTest: | - |
| 257 | - | type = BOOLOID; | - |
| 258 | - | break; | - |
| 259 | - | case T_CoerceToDomain: | - |
| 260 | - | type = ((const CoerceToDomain *) expr)->resulttype; | - |
| 261 | - | break; | - |
| 262 | - | case T_CoerceToDomainValue: | - |
| 263 | - | type = ((const CoerceToDomainValue *) expr)->typeId; | - |
| 264 | - | break; | - |
| 265 | - | case T_SetToDefault: | - |
| 266 | - | type = ((const SetToDefault *) expr)->typeId; | - |
| 267 | - | break; | - |
| 268 | - | case T_CurrentOfExpr: | - |
| 269 | - | type = BOOLOID; | - |
| 270 | - | break; | - |
| 271 | - | case T_NextValueExpr: | - |
| 272 | - | type = ((const NextValueExpr *) expr)->typeId; | - |
| 273 | - | break; | - |
| 274 | - | case T_InferenceElem: | - |
| 275 | - | { | - |
| 276 | - | const InferenceElem *n = (const InferenceElem *) expr; | - |
| 277 | - | - | |
| 278 | - | type = exprType((Node *) n->expr); | - |
| 279 | - | } | - |
| 280 | - | break; | - |
| 281 | - | case T_ReturningExpr: | - |
| 282 | - | type = exprType((Node *) ((const ReturningExpr *) expr)->retexpr); | - |
| 283 | - | break; | - |
| 284 | - | case T_PlaceHolderVar: | - |
| 285 | - | type = exprType((Node *) ((const PlaceHolderVar *) expr)->phexpr); | - |
| 286 | - | break; | - |
| 287 | 1155 | case T_GraphPropertyRef: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 288 | 1155 | type = ((const GraphPropertyRef *) expr)->typeId; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 289 | 1155 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 290 | - | default: | - |
| 291 | - | elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr)); | - |
| 292 | - | type = InvalidOid; /* keep compiler quiet */ | - |
| 293 | - | break; | - |
| 294 | - | } | - |
| 295 | - | return type; | - |
| 296 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 304 | - | exprTypmod(const Node *expr) | - |
| 305 | - | { | - |
| 306 | - | if (!expr) | - |
| 307 | - | return -1; | - |
| 308 | - | - | |
| 309 | - | switch (nodeTag(expr)) | - |
| 310 | - | { | - |
| 311 | - | case T_Var: | - |
| 312 | - | return ((const Var *) expr)->vartypmod; | - |
| 313 | - | case T_Const: | - |
| 314 | - | return ((const Const *) expr)->consttypmod; | - |
| 315 | - | case T_Param: | - |
| 316 | - | return ((const Param *) expr)->paramtypmod; | - |
| 317 | - | case T_SubscriptingRef: | - |
| 318 | - | return ((const SubscriptingRef *) expr)->reftypmod; | - |
| 319 | - | case T_FuncExpr: | - |
| 320 | - | { | - |
| 321 | - | int32 coercedTypmod; | - |
| 322 | - | - | |
| 323 | - | /* Be smart about length-coercion functions... */ | - |
| 324 | - | if (exprIsLengthCoercion(expr, &coercedTypmod)) | - |
| 325 | - | return coercedTypmod; | - |
| 326 | - | } | - |
| 327 | - | break; | - |
| 328 | - | case T_NamedArgExpr: | - |
| 329 | - | return exprTypmod((Node *) ((const NamedArgExpr *) expr)->arg); | - |
| 330 | - | case T_NullIfExpr: | - |
| 331 | - | { | - |
| 332 | - | /* | - |
| 333 | - | * Result is either first argument or NULL, so we can report | - |
| 334 | - | * first argument's typmod if known. | - |
| 335 | - | */ | - |
| 336 | - | const NullIfExpr *nexpr = (const NullIfExpr *) expr; | - |
| 337 | - | - | |
| 338 | - | return exprTypmod((Node *) linitial(nexpr->args)); | - |
| 339 | - | } | - |
| 340 | - | break; | - |
| 341 | - | case T_SubLink: | - |
| 342 | - | { | - |
| 343 | - | const SubLink *sublink = (const SubLink *) expr; | - |
| 344 | - | - | |
| 345 | - | if (sublink->subLinkType == EXPR_SUBLINK || | - |
| 346 | - | sublink->subLinkType == ARRAY_SUBLINK) | - |
| 347 | - | { | - |
| 348 | - | /* get the typmod of the subselect's first target column */ | - |
| 349 | - | Query *qtree = (Query *) sublink->subselect; | - |
| 350 | - | TargetEntry *tent; | - |
| 351 | - | - | |
| 352 | - | if (!qtree || !IsA(qtree, Query)) | - |
| 353 | - | elog(ERROR, "cannot get type for untransformed sublink"); | - |
| 354 | - | tent = linitial_node(TargetEntry, qtree->targetList); | - |
| 355 | - | Assert(!tent->resjunk); | - |
| 356 | - | return exprTypmod((Node *) tent->expr); | - |
| 357 | - | /* note we don't need to care if it's an array */ | - |
| 358 | - | } | - |
| 359 | - | /* otherwise, result is RECORD or BOOLEAN, typmod is -1 */ | - |
| 360 | - | } | - |
| 361 | - | break; | - |
| 362 | - | case T_SubPlan: | - |
| 363 | - | { | - |
| 364 | - | const SubPlan *subplan = (const SubPlan *) expr; | - |
| 365 | - | - | |
| 366 | - | if (subplan->subLinkType == EXPR_SUBLINK || | - |
| 367 | - | subplan->subLinkType == ARRAY_SUBLINK) | - |
| 368 | - | { | - |
| 369 | - | /* get the typmod of the subselect's first target column */ | - |
| 370 | - | /* note we don't need to care if it's an array */ | - |
| 371 | - | return subplan->firstColTypmod; | - |
| 372 | - | } | - |
| 373 | - | /* otherwise, result is RECORD or BOOLEAN, typmod is -1 */ | - |
| 374 | - | } | - |
| 375 | - | break; | - |
| 376 | - | case T_AlternativeSubPlan: | - |
| 377 | - | { | - |
| 378 | - | const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr; | - |
| 379 | - | - | |
| 380 | - | /* subplans should all return the same thing */ | - |
| 381 | - | return exprTypmod((Node *) linitial(asplan->subplans)); | - |
| 382 | - | } | - |
| 383 | - | break; | - |
| 384 | - | case T_FieldSelect: | - |
| 385 | - | return ((const FieldSelect *) expr)->resulttypmod; | - |
| 386 | - | case T_RelabelType: | - |
| 387 | - | return ((const RelabelType *) expr)->resulttypmod; | - |
| 388 | - | case T_ArrayCoerceExpr: | - |
| 389 | - | return ((const ArrayCoerceExpr *) expr)->resulttypmod; | - |
| 390 | - | case T_CollateExpr: | - |
| 391 | - | return exprTypmod((Node *) ((const CollateExpr *) expr)->arg); | - |
| 392 | - | case T_CaseExpr: | - |
| 393 | - | { | - |
| 394 | - | /* | - |
| 395 | - | * If all the alternatives agree on type/typmod, return that | - |
| 396 | - | * typmod, else use -1 | - |
| 397 | - | */ | - |
| 398 | - | const CaseExpr *cexpr = (const CaseExpr *) expr; | - |
| 399 | - | Oid casetype = cexpr->casetype; | - |
| 400 | - | int32 typmod; | - |
| 401 | - | ListCell *arg; | - |
| 402 | - | - | |
| 403 | - | if (!cexpr->defresult) | - |
| 404 | - | return -1; | - |
| 405 | - | if (exprType((Node *) cexpr->defresult) != casetype) | - |
| 406 | - | return -1; | - |
| 407 | - | typmod = exprTypmod((Node *) cexpr->defresult); | - |
| 408 | - | if (typmod < 0) | - |
| 409 | - | return -1; /* no point in trying harder */ | - |
| 410 | - | foreach(arg, cexpr->args) | - |
| 411 | - | { | - |
| 412 | - | CaseWhen *w = lfirst_node(CaseWhen, arg); | - |
| 413 | - | - | |
| 414 | - | if (exprType((Node *) w->result) != casetype) | - |
| 415 | - | return -1; | - |
| 416 | - | if (exprTypmod((Node *) w->result) != typmod) | - |
| 417 | - | return -1; | - |
| 418 | - | } | - |
| 419 | - | return typmod; | - |
| 420 | - | } | - |
| 421 | - | break; | - |
| 422 | - | case T_CaseTestExpr: | - |
| 423 | - | return ((const CaseTestExpr *) expr)->typeMod; | - |
| 424 | - | case T_ArrayExpr: | - |
| 425 | - | { | - |
| 426 | - | /* | - |
| 427 | - | * If all the elements agree on type/typmod, return that | - |
| 428 | - | * typmod, else use -1 | - |
| 429 | - | */ | - |
| 430 | - | const ArrayExpr *arrayexpr = (const ArrayExpr *) expr; | - |
| 431 | - | Oid commontype; | - |
| 432 | - | int32 typmod; | - |
| 433 | - | ListCell *elem; | - |
| 434 | - | - | |
| 435 | - | if (arrayexpr->elements == NIL) | - |
| 436 | - | return -1; | - |
| 437 | - | typmod = exprTypmod((Node *) linitial(arrayexpr->elements)); | - |
| 438 | - | if (typmod < 0) | - |
| 439 | - | return -1; /* no point in trying harder */ | - |
| 440 | - | if (arrayexpr->multidims) | - |
| 441 | - | commontype = arrayexpr->array_typeid; | - |
| 442 | - | else | - |
| 443 | - | commontype = arrayexpr->element_typeid; | - |
| 444 | - | foreach(elem, arrayexpr->elements) | - |
| 445 | - | { | - |
| 446 | - | Node *e = (Node *) lfirst(elem); | - |
| 447 | - | - | |
| 448 | - | if (exprType(e) != commontype) | - |
| 449 | - | return -1; | - |
| 450 | - | if (exprTypmod(e) != typmod) | - |
| 451 | - | return -1; | - |
| 452 | - | } | - |
| 453 | - | return typmod; | - |
| 454 | - | } | - |
| 455 | - | break; | - |
| 456 | - | case T_CoalesceExpr: | - |
| 457 | - | { | - |
| 458 | - | /* | - |
| 459 | - | * If all the alternatives agree on type/typmod, return that | - |
| 460 | - | * typmod, else use -1 | - |
| 461 | - | */ | - |
| 462 | - | const CoalesceExpr *cexpr = (const CoalesceExpr *) expr; | - |
| 463 | - | Oid coalescetype = cexpr->coalescetype; | - |
| 464 | - | int32 typmod; | - |
| 465 | - | ListCell *arg; | - |
| 466 | - | - | |
| 467 | - | if (exprType((Node *) linitial(cexpr->args)) != coalescetype) | - |
| 468 | - | return -1; | - |
| 469 | - | typmod = exprTypmod((Node *) linitial(cexpr->args)); | - |
| 470 | - | if (typmod < 0) | - |
| 471 | - | return -1; /* no point in trying harder */ | - |
| 472 | - | for_each_from(arg, cexpr->args, 1) | - |
| 473 | - | { | - |
| 474 | - | Node *e = (Node *) lfirst(arg); | - |
| 475 | - | - | |
| 476 | - | if (exprType(e) != coalescetype) | - |
| 477 | - | return -1; | - |
| 478 | - | if (exprTypmod(e) != typmod) | - |
| 479 | - | return -1; | - |
| 480 | - | } | - |
| 481 | - | return typmod; | - |
| 482 | - | } | - |
| 483 | - | break; | - |
| 484 | - | case T_MinMaxExpr: | - |
| 485 | - | { | - |
| 486 | - | /* | - |
| 487 | - | * If all the alternatives agree on type/typmod, return that | - |
| 488 | - | * typmod, else use -1 | - |
| 489 | - | */ | - |
| 490 | - | const MinMaxExpr *mexpr = (const MinMaxExpr *) expr; | - |
| 491 | - | Oid minmaxtype = mexpr->minmaxtype; | - |
| 492 | - | int32 typmod; | - |
| 493 | - | ListCell *arg; | - |
| 494 | - | - | |
| 495 | - | if (exprType((Node *) linitial(mexpr->args)) != minmaxtype) | - |
| 496 | - | return -1; | - |
| 497 | - | typmod = exprTypmod((Node *) linitial(mexpr->args)); | - |
| 498 | - | if (typmod < 0) | - |
| 499 | - | return -1; /* no point in trying harder */ | - |
| 500 | - | for_each_from(arg, mexpr->args, 1) | - |
| 501 | - | { | - |
| 502 | - | Node *e = (Node *) lfirst(arg); | - |
| 503 | - | - | |
| 504 | - | if (exprType(e) != minmaxtype) | - |
| 505 | - | return -1; | - |
| 506 | - | if (exprTypmod(e) != typmod) | - |
| 507 | - | return -1; | - |
| 508 | - | } | - |
| 509 | - | return typmod; | - |
| 510 | - | } | - |
| 511 | - | break; | - |
| 512 | - | case T_SQLValueFunction: | - |
| 513 | - | return ((const SQLValueFunction *) expr)->typmod; | - |
| 514 | - | case T_JsonValueExpr: | - |
| 515 | - | return exprTypmod((Node *) ((const JsonValueExpr *) expr)->formatted_expr); | - |
| 516 | - | case T_JsonConstructorExpr: | - |
| 517 | - | return ((const JsonConstructorExpr *) expr)->returning->typmod; | - |
| 518 | - | case T_JsonExpr: | - |
| 519 | - | { | - |
| 520 | - | const JsonExpr *jexpr = (const JsonExpr *) expr; | - |
| 521 | - | - | |
| 522 | - | return jexpr->returning->typmod; | - |
| 523 | - | } | - |
| 524 | - | break; | - |
| 525 | - | case T_JsonBehavior: | - |
| 526 | - | { | - |
| 527 | - | const JsonBehavior *behavior = (const JsonBehavior *) expr; | - |
| 528 | - | - | |
| 529 | - | return exprTypmod(behavior->expr); | - |
| 530 | - | } | - |
| 531 | - | break; | - |
| 532 | - | case T_CoerceToDomain: | - |
| 533 | - | return ((const CoerceToDomain *) expr)->resulttypmod; | - |
| 534 | - | case T_CoerceToDomainValue: | - |
| 535 | - | return ((const CoerceToDomainValue *) expr)->typeMod; | - |
| 536 | - | case T_SetToDefault: | - |
| 537 | - | return ((const SetToDefault *) expr)->typeMod; | - |
| 538 | - | case T_ReturningExpr: | - |
| 539 | - | return exprTypmod((Node *) ((const ReturningExpr *) expr)->retexpr); | - |
| 540 | - | case T_PlaceHolderVar: | - |
| 541 | - | return exprTypmod((Node *) ((const PlaceHolderVar *) expr)->phexpr); | - |
| 542 | 909 | case T_GraphPropertyRef: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 543 | 909 | return ((const GraphPropertyRef *) expr)->typmod; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 544 | - | default: | - |
| 545 | - | break; | - |
| 546 | - | } | - |
| 547 | - | return -1; | - |
| 548 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 826 | - | exprCollation(const Node *expr) | - |
| 827 | - | { | - |
| 828 | - | Oid coll; | - |
| 829 | - | - | |
| 830 | - | if (!expr) | - |
| 831 | - | return InvalidOid; | - |
| 832 | - | - | |
| 833 | - | switch (nodeTag(expr)) | - |
| 834 | - | { | - |
| 835 | - | case T_Var: | - |
| 836 | - | coll = ((const Var *) expr)->varcollid; | - |
| 837 | - | break; | - |
| 838 | - | case T_Const: | - |
| 839 | - | coll = ((const Const *) expr)->constcollid; | - |
| 840 | - | break; | - |
| 841 | - | case T_Param: | - |
| 842 | - | coll = ((const Param *) expr)->paramcollid; | - |
| 843 | - | break; | - |
| 844 | - | case T_Aggref: | - |
| 845 | - | coll = ((const Aggref *) expr)->aggcollid; | - |
| 846 | - | break; | - |
| 847 | - | case T_GroupingFunc: | - |
| 848 | - | coll = InvalidOid; | - |
| 849 | - | break; | - |
| 850 | - | case T_WindowFunc: | - |
| 851 | - | coll = ((const WindowFunc *) expr)->wincollid; | - |
| 852 | - | break; | - |
| 853 | - | case T_MergeSupportFunc: | - |
| 854 | - | coll = ((const MergeSupportFunc *) expr)->msfcollid; | - |
| 855 | - | break; | - |
| 856 | - | case T_SubscriptingRef: | - |
| 857 | - | coll = ((const SubscriptingRef *) expr)->refcollid; | - |
| 858 | - | break; | - |
| 859 | - | case T_FuncExpr: | - |
| 860 | - | coll = ((const FuncExpr *) expr)->funccollid; | - |
| 861 | - | break; | - |
| 862 | - | case T_NamedArgExpr: | - |
| 863 | - | coll = exprCollation((Node *) ((const NamedArgExpr *) expr)->arg); | - |
| 864 | - | break; | - |
| 865 | - | case T_OpExpr: | - |
| 866 | - | coll = ((const OpExpr *) expr)->opcollid; | - |
| 867 | - | break; | - |
| 868 | - | case T_DistinctExpr: | - |
| 869 | - | coll = ((const DistinctExpr *) expr)->opcollid; | - |
| 870 | - | break; | - |
| 871 | - | case T_NullIfExpr: | - |
| 872 | - | coll = ((const NullIfExpr *) expr)->opcollid; | - |
| 873 | - | break; | - |
| 874 | - | case T_ScalarArrayOpExpr: | - |
| 875 | - | /* ScalarArrayOpExpr's result is boolean ... */ | - |
| 876 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 877 | - | break; | - |
| 878 | - | case T_BoolExpr: | - |
| 879 | - | /* BoolExpr's result is boolean ... */ | - |
| 880 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 881 | - | break; | - |
| 882 | - | case T_SubLink: | - |
| 883 | - | { | - |
| 884 | - | const SubLink *sublink = (const SubLink *) expr; | - |
| 885 | - | - | |
| 886 | - | if (sublink->subLinkType == EXPR_SUBLINK || | - |
| 887 | - | sublink->subLinkType == ARRAY_SUBLINK) | - |
| 888 | - | { | - |
| 889 | - | /* get the collation of subselect's first target column */ | - |
| 890 | - | Query *qtree = (Query *) sublink->subselect; | - |
| 891 | - | TargetEntry *tent; | - |
| 892 | - | - | |
| 893 | - | if (!qtree || !IsA(qtree, Query)) | - |
| 894 | - | elog(ERROR, "cannot get collation for untransformed sublink"); | - |
| 895 | - | tent = linitial_node(TargetEntry, qtree->targetList); | - |
| 896 | - | Assert(!tent->resjunk); | - |
| 897 | - | coll = exprCollation((Node *) tent->expr); | - |
| 898 | - | /* collation doesn't change if it's converted to array */ | - |
| 899 | - | } | - |
| 900 | - | else | - |
| 901 | - | { | - |
| 902 | - | /* otherwise, SubLink's result is RECORD or BOOLEAN */ | - |
| 903 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 904 | - | } | - |
| 905 | - | } | - |
| 906 | - | break; | - |
| 907 | - | case T_SubPlan: | - |
| 908 | - | { | - |
| 909 | - | const SubPlan *subplan = (const SubPlan *) expr; | - |
| 910 | - | - | |
| 911 | - | if (subplan->subLinkType == EXPR_SUBLINK || | - |
| 912 | - | subplan->subLinkType == ARRAY_SUBLINK) | - |
| 913 | - | { | - |
| 914 | - | /* get the collation of subselect's first target column */ | - |
| 915 | - | coll = subplan->firstColCollation; | - |
| 916 | - | /* collation doesn't change if it's converted to array */ | - |
| 917 | - | } | - |
| 918 | - | else | - |
| 919 | - | { | - |
| 920 | - | /* otherwise, SubPlan's result is RECORD or BOOLEAN */ | - |
| 921 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 922 | - | } | - |
| 923 | - | } | - |
| 924 | - | break; | - |
| 925 | - | case T_AlternativeSubPlan: | - |
| 926 | - | { | - |
| 927 | - | const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr; | - |
| 928 | - | - | |
| 929 | - | /* subplans should all return the same thing */ | - |
| 930 | - | coll = exprCollation((Node *) linitial(asplan->subplans)); | - |
| 931 | - | } | - |
| 932 | - | break; | - |
| 933 | - | case T_FieldSelect: | - |
| 934 | - | coll = ((const FieldSelect *) expr)->resultcollid; | - |
| 935 | - | break; | - |
| 936 | - | case T_FieldStore: | - |
| 937 | - | /* FieldStore's result is composite ... */ | - |
| 938 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 939 | - | break; | - |
| 940 | - | case T_RelabelType: | - |
| 941 | - | coll = ((const RelabelType *) expr)->resultcollid; | - |
| 942 | - | break; | - |
| 943 | - | case T_CoerceViaIO: | - |
| 944 | - | coll = ((const CoerceViaIO *) expr)->resultcollid; | - |
| 945 | - | break; | - |
| 946 | - | case T_ArrayCoerceExpr: | - |
| 947 | - | coll = ((const ArrayCoerceExpr *) expr)->resultcollid; | - |
| 948 | - | break; | - |
| 949 | - | case T_ConvertRowtypeExpr: | - |
| 950 | - | /* ConvertRowtypeExpr's result is composite ... */ | - |
| 951 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 952 | - | break; | - |
| 953 | - | case T_CollateExpr: | - |
| 954 | - | coll = ((const CollateExpr *) expr)->collOid; | - |
| 955 | - | break; | - |
| 956 | - | case T_CaseExpr: | - |
| 957 | - | coll = ((const CaseExpr *) expr)->casecollid; | - |
| 958 | - | break; | - |
| 959 | - | case T_CaseTestExpr: | - |
| 960 | - | coll = ((const CaseTestExpr *) expr)->collation; | - |
| 961 | - | break; | - |
| 962 | - | case T_ArrayExpr: | - |
| 963 | - | coll = ((const ArrayExpr *) expr)->array_collid; | - |
| 964 | - | break; | - |
| 965 | - | case T_RowExpr: | - |
| 966 | - | /* RowExpr's result is composite ... */ | - |
| 967 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 968 | - | break; | - |
| 969 | - | case T_RowCompareExpr: | - |
| 970 | - | /* RowCompareExpr's result is boolean ... */ | - |
| 971 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 972 | - | break; | - |
| 973 | - | case T_CoalesceExpr: | - |
| 974 | - | coll = ((const CoalesceExpr *) expr)->coalescecollid; | - |
| 975 | - | break; | - |
| 976 | - | case T_MinMaxExpr: | - |
| 977 | - | coll = ((const MinMaxExpr *) expr)->minmaxcollid; | - |
| 978 | - | break; | - |
| 979 | - | case T_SQLValueFunction: | - |
| 980 | - | /* Returns either NAME or a non-collatable type */ | - |
| 981 | - | if (((const SQLValueFunction *) expr)->type == NAMEOID) | - |
| 982 | - | coll = C_COLLATION_OID; | - |
| 983 | - | else | - |
| 984 | - | coll = InvalidOid; | - |
| 985 | - | break; | - |
| 986 | - | case T_XmlExpr: | - |
| 987 | - | - | |
| 988 | - | /* | - |
| 989 | - | * XMLSERIALIZE returns text from non-collatable inputs, so its | - |
| 990 | - | * collation is always default. The other cases return boolean or | - |
| 991 | - | * XML, which are non-collatable. | - |
| 992 | - | */ | - |
| 993 | - | if (((const XmlExpr *) expr)->op == IS_XMLSERIALIZE) | - |
| 994 | - | coll = DEFAULT_COLLATION_OID; | - |
| 995 | - | else | - |
| 996 | - | coll = InvalidOid; | - |
| 997 | - | break; | - |
| 998 | - | case T_JsonValueExpr: | - |
| 999 | - | coll = exprCollation((Node *) ((const JsonValueExpr *) expr)->formatted_expr); | - |
| 1000 | - | break; | - |
| 1001 | - | case T_JsonConstructorExpr: | - |
| 1002 | - | { | - |
| 1003 | - | const JsonConstructorExpr *ctor = (const JsonConstructorExpr *) expr; | - |
| 1004 | - | - | |
| 1005 | - | if (ctor->coercion) | - |
| 1006 | - | coll = exprCollation((Node *) ctor->coercion); | - |
| 1007 | - | else | - |
| 1008 | - | coll = InvalidOid; | - |
| 1009 | - | } | - |
| 1010 | - | break; | - |
| 1011 | - | case T_JsonIsPredicate: | - |
| 1012 | - | /* IS JSON's result is boolean ... */ | - |
| 1013 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 1014 | - | break; | - |
| 1015 | - | case T_JsonExpr: | - |
| 1016 | - | { | - |
| 1017 | - | const JsonExpr *jsexpr = (JsonExpr *) expr; | - |
| 1018 | - | - | |
| 1019 | - | coll = jsexpr->collation; | - |
| 1020 | - | } | - |
| 1021 | - | break; | - |
| 1022 | - | case T_JsonBehavior: | - |
| 1023 | - | { | - |
| 1024 | - | const JsonBehavior *behavior = (JsonBehavior *) expr; | - |
| 1025 | - | - | |
| 1026 | - | if (behavior->expr) | - |
| 1027 | - | coll = exprCollation(behavior->expr); | - |
| 1028 | - | else | - |
| 1029 | - | coll = InvalidOid; | - |
| 1030 | - | } | - |
| 1031 | - | break; | - |
| 1032 | - | case T_NullTest: | - |
| 1033 | - | /* NullTest's result is boolean ... */ | - |
| 1034 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 1035 | - | break; | - |
| 1036 | - | case T_BooleanTest: | - |
| 1037 | - | /* BooleanTest's result is boolean ... */ | - |
| 1038 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 1039 | - | break; | - |
| 1040 | - | case T_CoerceToDomain: | - |
| 1041 | - | coll = ((const CoerceToDomain *) expr)->resultcollid; | - |
| 1042 | - | break; | - |
| 1043 | - | case T_CoerceToDomainValue: | - |
| 1044 | - | coll = ((const CoerceToDomainValue *) expr)->collation; | - |
| 1045 | - | break; | - |
| 1046 | - | case T_SetToDefault: | - |
| 1047 | - | coll = ((const SetToDefault *) expr)->collation; | - |
| 1048 | - | break; | - |
| 1049 | - | case T_CurrentOfExpr: | - |
| 1050 | - | /* CurrentOfExpr's result is boolean ... */ | - |
| 1051 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 1052 | - | break; | - |
| 1053 | - | case T_NextValueExpr: | - |
| 1054 | - | /* NextValueExpr's result is an integer type ... */ | - |
| 1055 | - | coll = InvalidOid; /* ... so it has no collation */ | - |
| 1056 | - | break; | - |
| 1057 | - | case T_InferenceElem: | - |
| 1058 | - | coll = exprCollation((Node *) ((const InferenceElem *) expr)->expr); | - |
| 1059 | - | break; | - |
| 1060 | - | case T_ReturningExpr: | - |
| 1061 | - | coll = exprCollation((Node *) ((const ReturningExpr *) expr)->retexpr); | - |
| 1062 | - | break; | - |
| 1063 | - | case T_PlaceHolderVar: | - |
| 1064 | - | coll = exprCollation((Node *) ((const PlaceHolderVar *) expr)->phexpr); | - |
| 1065 | - | break; | - |
| 1066 | 1155 | case T_GraphPropertyRef: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1067 | 1155 | coll = ((const GraphPropertyRef *) expr)->collation; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1068 | 1155 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1069 | - | default: | - |
| 1070 | - | elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr)); | - |
| 1071 | - | coll = InvalidOid; /* keep compiler quiet */ | - |
| 1072 | - | break; | - |
| 1073 | - | } | - |
| 1074 | - | return coll; | - |
| 1075 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 2097 | - | expression_tree_walker_impl(Node *node, | - |
| 2098 | - | tree_walker_callback walker, | - |
| 2099 | - | void *context) | - |
| 2100 | - | { | - |
| 2101 | - | ListCell *temp; | - |
| 2102 | - | - | |
| 2103 | - | /* | - |
| 2104 | - | * The walker has already visited the current node, and so we need only | - |
| 2105 | - | * recurse into any sub-nodes it has. | - |
| 2106 | - | * | - |
| 2107 | - | * We assume that the walker is not interested in List nodes per se, so | - |
| 2108 | - | * when we expect a List we just recurse directly to self without | - |
| 2109 | - | * bothering to call the walker. | - |
| 2110 | - | */ | - |
| 2111 | - | #define WALK(n) walker((Node *) (n), context) | - |
| 2112 | - | - | |
| 2113 | - | #define LIST_WALK(l) expression_tree_walker_impl((Node *) (l), walker, context) | - |
| 2114 | - | - | |
| 2115 | - | if (node == NULL) | - |
| 2116 | - | return false; | - |
| 2117 | - | - | |
| 2118 | - | /* Guard against stack overflow due to overly complex expressions */ | - |
| 2119 | - | check_stack_depth(); | - |
| 2120 | - | - | |
| 2121 | - | switch (nodeTag(node)) | - |
| 2122 | - | { | - |
| 2123 | - | case T_Var: | - |
| 2124 | - | case T_Const: | - |
| 2125 | - | case T_Param: | - |
| 2126 | - | case T_CaseTestExpr: | - |
| 2127 | - | case T_SQLValueFunction: | - |
| 2128 | - | case T_CoerceToDomainValue: | - |
| 2129 | - | case T_SetToDefault: | - |
| 2130 | - | case T_CurrentOfExpr: | - |
| 2131 | - | case T_NextValueExpr: | - |
| 2132 | - | case T_RangeTblRef: | - |
| 2133 | - | case T_SortGroupClause: | - |
| 2134 | - | case T_CTESearchClause: | - |
| 2135 | - | case T_GraphPropertyRef: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2136 | - | case T_MergeSupportFunc: | - |
| 2137 | - | /* primitive node types with no expression subnodes */ | - |
| 2138 | - | break; | - |
| 2139 | - | case T_WithCheckOption: | - |
| 2140 | - | return WALK(((WithCheckOption *) node)->qual); | - |
| 2141 | - | case T_Aggref: | - |
| 2142 | - | { | - |
| 2143 | - | Aggref *expr = (Aggref *) node; | - |
| 2144 | - | - | |
| 2145 | - | /* recurse directly on Lists */ | - |
| 2146 | - | if (LIST_WALK(expr->aggdirectargs)) | - |
| 2147 | - | return true; | - |
| 2148 | - | if (LIST_WALK(expr->args)) | - |
| 2149 | - | return true; | - |
| 2150 | - | if (LIST_WALK(expr->aggorder)) | - |
| 2151 | - | return true; | - |
| 2152 | - | if (LIST_WALK(expr->aggdistinct)) | - |
| 2153 | - | return true; | - |
| 2154 | - | if (WALK(expr->aggfilter)) | - |
| 2155 | - | return true; | - |
| 2156 | - | } | - |
| 2157 | - | break; | - |
| 2158 | - | case T_GroupingFunc: | - |
| 2159 | - | { | - |
| 2160 | - | GroupingFunc *grouping = (GroupingFunc *) node; | - |
| 2161 | - | - | |
| 2162 | - | if (LIST_WALK(grouping->args)) | - |
| 2163 | - | return true; | - |
| 2164 | - | } | - |
| 2165 | - | break; | - |
| 2166 | - | case T_WindowFunc: | - |
| 2167 | - | { | - |
| 2168 | - | WindowFunc *expr = (WindowFunc *) node; | - |
| 2169 | - | - | |
| 2170 | - | /* recurse directly on List */ | - |
| 2171 | - | if (LIST_WALK(expr->args)) | - |
| 2172 | - | return true; | - |
| 2173 | - | if (WALK(expr->aggfilter)) | - |
| 2174 | - | return true; | - |
| 2175 | - | if (WALK(expr->runCondition)) | - |
| 2176 | - | return true; | - |
| 2177 | - | } | - |
| 2178 | - | break; | - |
| 2179 | - | case T_WindowFuncRunCondition: | - |
| 2180 | - | { | - |
| 2181 | - | WindowFuncRunCondition *expr = (WindowFuncRunCondition *) node; | - |
| 2182 | - | - | |
| 2183 | - | if (WALK(expr->arg)) | - |
| 2184 | - | return true; | - |
| 2185 | - | } | - |
| 2186 | - | break; | - |
| 2187 | - | case T_SubscriptingRef: | - |
| 2188 | - | { | - |
| 2189 | - | SubscriptingRef *sbsref = (SubscriptingRef *) node; | - |
| 2190 | - | - | |
| 2191 | - | /* recurse directly for upper/lower container index lists */ | - |
| 2192 | - | if (LIST_WALK(sbsref->refupperindexpr)) | - |
| 2193 | - | return true; | - |
| 2194 | - | if (LIST_WALK(sbsref->reflowerindexpr)) | - |
| 2195 | - | return true; | - |
| 2196 | - | /* walker must see the refexpr and refassgnexpr, however */ | - |
| 2197 | - | if (WALK(sbsref->refexpr)) | - |
| 2198 | - | return true; | - |
| 2199 | - | - | |
| 2200 | - | if (WALK(sbsref->refassgnexpr)) | - |
| 2201 | - | return true; | - |
| 2202 | - | } | - |
| 2203 | - | break; | - |
| 2204 | - | case T_FuncExpr: | - |
| 2205 | - | { | - |
| 2206 | - | FuncExpr *expr = (FuncExpr *) node; | - |
| 2207 | - | - | |
| 2208 | - | if (LIST_WALK(expr->args)) | - |
| 2209 | - | return true; | - |
| 2210 | - | } | - |
| 2211 | - | break; | - |
| 2212 | - | case T_NamedArgExpr: | - |
| 2213 | - | return WALK(((NamedArgExpr *) node)->arg); | - |
| 2214 | - | case T_OpExpr: | - |
| 2215 | - | case T_DistinctExpr: /* struct-equivalent to OpExpr */ | - |
| 2216 | - | case T_NullIfExpr: /* struct-equivalent to OpExpr */ | - |
| 2217 | - | { | - |
| 2218 | - | OpExpr *expr = (OpExpr *) node; | - |
| 2219 | - | - | |
| 2220 | - | if (LIST_WALK(expr->args)) | - |
| 2221 | - | return true; | - |
| 2222 | - | } | - |
| 2223 | - | break; | - |
| 2224 | - | case T_ScalarArrayOpExpr: | - |
| 2225 | - | { | - |
| 2226 | - | ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node; | - |
| 2227 | - | - | |
| 2228 | - | if (LIST_WALK(expr->args)) | - |
| 2229 | - | return true; | - |
| 2230 | - | } | - |
| 2231 | - | break; | - |
| 2232 | - | case T_BoolExpr: | - |
| 2233 | - | { | - |
| 2234 | - | BoolExpr *expr = (BoolExpr *) node; | - |
| 2235 | - | - | |
| 2236 | - | if (LIST_WALK(expr->args)) | - |
| 2237 | - | return true; | - |
| 2238 | - | } | - |
| 2239 | - | break; | - |
| 2240 | - | case T_SubLink: | - |
| 2241 | - | { | - |
| 2242 | - | SubLink *sublink = (SubLink *) node; | - |
| 2243 | - | - | |
| 2244 | - | if (WALK(sublink->testexpr)) | - |
| 2245 | - | return true; | - |
| 2246 | - | - | |
| 2247 | - | /* | - |
| 2248 | - | * Also invoke the walker on the sublink's Query node, so it | - |
| 2249 | - | * can recurse into the sub-query if it wants to. | - |
| 2250 | - | */ | - |
| 2251 | - | return WALK(sublink->subselect); | - |
| 2252 | - | } | - |
| 2253 | - | break; | - |
| 2254 | - | case T_SubPlan: | - |
| 2255 | - | { | - |
| 2256 | - | SubPlan *subplan = (SubPlan *) node; | - |
| 2257 | - | - | |
| 2258 | - | /* recurse into the testexpr, but not into the Plan */ | - |
| 2259 | - | if (WALK(subplan->testexpr)) | - |
| 2260 | - | return true; | - |
| 2261 | - | /* also examine args list */ | - |
| 2262 | - | if (LIST_WALK(subplan->args)) | - |
| 2263 | - | return true; | - |
| 2264 | - | } | - |
| 2265 | - | break; | - |
| 2266 | - | case T_AlternativeSubPlan: | - |
| 2267 | - | return LIST_WALK(((AlternativeSubPlan *) node)->subplans); | - |
| 2268 | - | case T_FieldSelect: | - |
| 2269 | - | return WALK(((FieldSelect *) node)->arg); | - |
| 2270 | - | case T_FieldStore: | - |
| 2271 | - | { | - |
| 2272 | - | FieldStore *fstore = (FieldStore *) node; | - |
| 2273 | - | - | |
| 2274 | - | if (WALK(fstore->arg)) | - |
| 2275 | - | return true; | - |
| 2276 | - | if (WALK(fstore->newvals)) | - |
| 2277 | - | return true; | - |
| 2278 | - | } | - |
| 2279 | - | break; | - |
| 2280 | - | case T_RelabelType: | - |
| 2281 | - | return WALK(((RelabelType *) node)->arg); | - |
| 2282 | - | case T_CoerceViaIO: | - |
| 2283 | - | return WALK(((CoerceViaIO *) node)->arg); | - |
| 2284 | - | case T_ArrayCoerceExpr: | - |
| 2285 | - | { | - |
| 2286 | - | ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node; | - |
| 2287 | - | - | |
| 2288 | - | if (WALK(acoerce->arg)) | - |
| 2289 | - | return true; | - |
| 2290 | - | if (WALK(acoerce->elemexpr)) | - |
| 2291 | - | return true; | - |
| 2292 | - | } | - |
| 2293 | - | break; | - |
| 2294 | - | case T_ConvertRowtypeExpr: | - |
| 2295 | - | return WALK(((ConvertRowtypeExpr *) node)->arg); | - |
| 2296 | - | case T_CollateExpr: | - |
| 2297 | - | return WALK(((CollateExpr *) node)->arg); | - |
| 2298 | - | case T_CaseExpr: | - |
| 2299 | - | { | - |
| 2300 | - | CaseExpr *caseexpr = (CaseExpr *) node; | - |
| 2301 | - | - | |
| 2302 | - | if (WALK(caseexpr->arg)) | - |
| 2303 | - | return true; | - |
| 2304 | - | /* we assume walker doesn't care about CaseWhens, either */ | - |
| 2305 | - | foreach(temp, caseexpr->args) | - |
| 2306 | - | { | - |
| 2307 | - | CaseWhen *when = lfirst_node(CaseWhen, temp); | - |
| 2308 | - | - | |
| 2309 | - | if (WALK(when->expr)) | - |
| 2310 | - | return true; | - |
| 2311 | - | if (WALK(when->result)) | - |
| 2312 | - | return true; | - |
| 2313 | - | } | - |
| 2314 | - | if (WALK(caseexpr->defresult)) | - |
| 2315 | - | return true; | - |
| 2316 | - | } | - |
| 2317 | - | break; | - |
| 2318 | - | case T_ArrayExpr: | - |
| 2319 | - | return WALK(((ArrayExpr *) node)->elements); | - |
| 2320 | - | case T_RowExpr: | - |
| 2321 | - | /* Assume colnames isn't interesting */ | - |
| 2322 | - | return WALK(((RowExpr *) node)->args); | - |
| 2323 | - | case T_RowCompareExpr: | - |
| 2324 | - | { | - |
| 2325 | - | RowCompareExpr *rcexpr = (RowCompareExpr *) node; | - |
| 2326 | - | - | |
| 2327 | - | if (WALK(rcexpr->largs)) | - |
| 2328 | - | return true; | - |
| 2329 | - | if (WALK(rcexpr->rargs)) | - |
| 2330 | - | return true; | - |
| 2331 | - | } | - |
| 2332 | - | break; | - |
| 2333 | - | case T_CoalesceExpr: | - |
| 2334 | - | return WALK(((CoalesceExpr *) node)->args); | - |
| 2335 | - | case T_MinMaxExpr: | - |
| 2336 | - | return WALK(((MinMaxExpr *) node)->args); | - |
| 2337 | - | case T_XmlExpr: | - |
| 2338 | - | { | - |
| 2339 | - | XmlExpr *xexpr = (XmlExpr *) node; | - |
| 2340 | - | - | |
| 2341 | - | if (WALK(xexpr->named_args)) | - |
| 2342 | - | return true; | - |
| 2343 | - | /* we assume walker doesn't care about arg_names */ | - |
| 2344 | - | if (WALK(xexpr->args)) | - |
| 2345 | - | return true; | - |
| 2346 | - | } | - |
| 2347 | - | break; | - |
| 2348 | - | case T_JsonValueExpr: | - |
| 2349 | - | { | - |
| 2350 | - | JsonValueExpr *jve = (JsonValueExpr *) node; | - |
| 2351 | - | - | |
| 2352 | - | if (WALK(jve->raw_expr)) | - |
| 2353 | - | return true; | - |
| 2354 | - | if (WALK(jve->formatted_expr)) | - |
| 2355 | - | return true; | - |
| 2356 | - | } | - |
| 2357 | - | break; | - |
| 2358 | - | case T_JsonConstructorExpr: | - |
| 2359 | - | { | - |
| 2360 | - | JsonConstructorExpr *ctor = (JsonConstructorExpr *) node; | - |
| 2361 | - | - | |
| 2362 | - | if (WALK(ctor->args)) | - |
| 2363 | - | return true; | - |
| 2364 | - | if (WALK(ctor->func)) | - |
| 2365 | - | return true; | - |
| 2366 | - | if (WALK(ctor->coercion)) | - |
| 2367 | - | return true; | - |
| 2368 | - | } | - |
| 2369 | - | break; | - |
| 2370 | - | case T_JsonIsPredicate: | - |
| 2371 | - | return WALK(((JsonIsPredicate *) node)->expr); | - |
| 2372 | - | case T_JsonExpr: | - |
| 2373 | - | { | - |
| 2374 | - | JsonExpr *jexpr = (JsonExpr *) node; | - |
| 2375 | - | - | |
| 2376 | - | if (WALK(jexpr->formatted_expr)) | - |
| 2377 | - | return true; | - |
| 2378 | - | if (WALK(jexpr->path_spec)) | - |
| 2379 | - | return true; | - |
| 2380 | - | if (WALK(jexpr->passing_values)) | - |
| 2381 | - | return true; | - |
| 2382 | - | /* we assume walker doesn't care about passing_names */ | - |
| 2383 | - | if (WALK(jexpr->on_empty)) | - |
| 2384 | - | return true; | - |
| 2385 | - | if (WALK(jexpr->on_error)) | - |
| 2386 | - | return true; | - |
| 2387 | - | } | - |
| 2388 | - | break; | - |
| 2389 | - | case T_JsonBehavior: | - |
| 2390 | - | { | - |
| 2391 | - | JsonBehavior *behavior = (JsonBehavior *) node; | - |
| 2392 | - | - | |
| 2393 | - | if (WALK(behavior->expr)) | - |
| 2394 | - | return true; | - |
| 2395 | - | } | - |
| 2396 | - | break; | - |
| 2397 | - | case T_NullTest: | - |
| 2398 | - | return WALK(((NullTest *) node)->arg); | - |
| 2399 | - | case T_BooleanTest: | - |
| 2400 | - | return WALK(((BooleanTest *) node)->arg); | - |
| 2401 | - | case T_CoerceToDomain: | - |
| 2402 | - | return WALK(((CoerceToDomain *) node)->arg); | - |
| 2403 | - | case T_TargetEntry: | - |
| 2404 | - | return WALK(((TargetEntry *) node)->expr); | - |
| 2405 | - | case T_Query: | - |
| 2406 | - | /* Do nothing with a sub-Query, per discussion above */ | - |
| 2407 | - | break; | - |
| 2408 | - | case T_WindowClause: | - |
| 2409 | - | { | - |
| 2410 | - | WindowClause *wc = (WindowClause *) node; | - |
| 2411 | - | - | |
| 2412 | - | if (WALK(wc->partitionClause)) | - |
| 2413 | - | return true; | - |
| 2414 | - | if (WALK(wc->orderClause)) | - |
| 2415 | - | return true; | - |
| 2416 | - | if (WALK(wc->startOffset)) | - |
| 2417 | - | return true; | - |
| 2418 | - | if (WALK(wc->endOffset)) | - |
| 2419 | - | return true; | - |
| 2420 | - | } | - |
| 2421 | - | break; | - |
| 2422 | - | case T_CTECycleClause: | - |
| 2423 | - | { | - |
| 2424 | - | CTECycleClause *cc = (CTECycleClause *) node; | - |
| 2425 | - | - | |
| 2426 | - | if (WALK(cc->cycle_mark_value)) | - |
| 2427 | - | return true; | - |
| 2428 | - | if (WALK(cc->cycle_mark_default)) | - |
| 2429 | - | return true; | - |
| 2430 | - | } | - |
| 2431 | - | break; | - |
| 2432 | - | case T_CommonTableExpr: | - |
| 2433 | - | { | - |
| 2434 | - | CommonTableExpr *cte = (CommonTableExpr *) node; | - |
| 2435 | - | - | |
| 2436 | - | /* | - |
| 2437 | - | * Invoke the walker on the CTE's Query node, so it can | - |
| 2438 | - | * recurse into the sub-query if it wants to. | - |
| 2439 | - | */ | - |
| 2440 | - | if (WALK(cte->ctequery)) | - |
| 2441 | - | return true; | - |
| 2442 | - | - | |
| 2443 | - | if (WALK(cte->search_clause)) | - |
| 2444 | - | return true; | - |
| 2445 | - | if (WALK(cte->cycle_clause)) | - |
| 2446 | - | return true; | - |
| 2447 | - | } | - |
| 2448 | - | break; | - |
| 2449 | - | case T_JsonKeyValue: | - |
| 2450 | - | { | - |
| 2451 | - | JsonKeyValue *kv = (JsonKeyValue *) node; | - |
| 2452 | - | - | |
| 2453 | - | if (WALK(kv->key)) | - |
| 2454 | - | return true; | - |
| 2455 | - | if (WALK(kv->value)) | - |
| 2456 | - | return true; | - |
| 2457 | - | } | - |
| 2458 | - | break; | - |
| 2459 | - | case T_JsonObjectConstructor: | - |
| 2460 | - | { | - |
| 2461 | - | JsonObjectConstructor *ctor = (JsonObjectConstructor *) node; | - |
| 2462 | - | - | |
| 2463 | - | if (LIST_WALK(ctor->exprs)) | - |
| 2464 | - | return true; | - |
| 2465 | - | } | - |
| 2466 | - | break; | - |
| 2467 | - | case T_JsonArrayConstructor: | - |
| 2468 | - | { | - |
| 2469 | - | JsonArrayConstructor *ctor = (JsonArrayConstructor *) node; | - |
| 2470 | - | - | |
| 2471 | - | if (LIST_WALK(ctor->exprs)) | - |
| 2472 | - | return true; | - |
| 2473 | - | } | - |
| 2474 | - | break; | - |
| 2475 | - | case T_JsonArrayQueryConstructor: | - |
| 2476 | - | { | - |
| 2477 | - | JsonArrayQueryConstructor *ctor = (JsonArrayQueryConstructor *) node; | - |
| 2478 | - | - | |
| 2479 | - | if (WALK(ctor->query)) | - |
| 2480 | - | return true; | - |
| 2481 | - | } | - |
| 2482 | - | break; | - |
| 2483 | - | case T_JsonAggConstructor: | - |
| 2484 | - | { | - |
| 2485 | - | JsonAggConstructor *ctor = (JsonAggConstructor *) node; | - |
| 2486 | - | - | |
| 2487 | - | if (WALK(ctor->agg_filter)) | - |
| 2488 | - | return true; | - |
| 2489 | - | if (WALK(ctor->agg_order)) | - |
| 2490 | - | return true; | - |
| 2491 | - | if (WALK(ctor->over)) | - |
| 2492 | - | return true; | - |
| 2493 | - | } | - |
| 2494 | - | break; | - |
| 2495 | - | case T_JsonObjectAgg: | - |
| 2496 | - | { | - |
| 2497 | - | JsonObjectAgg *ctor = (JsonObjectAgg *) node; | - |
| 2498 | - | - | |
| 2499 | - | if (WALK(ctor->constructor)) | - |
| 2500 | - | return true; | - |
| 2501 | - | if (WALK(ctor->arg)) | - |
| 2502 | - | return true; | - |
| 2503 | - | } | - |
| 2504 | - | break; | - |
| 2505 | - | case T_JsonArrayAgg: | - |
| 2506 | - | { | - |
| 2507 | - | JsonArrayAgg *ctor = (JsonArrayAgg *) node; | - |
| 2508 | - | - | |
| 2509 | - | if (WALK(ctor->constructor)) | - |
| 2510 | - | return true; | - |
| 2511 | - | if (WALK(ctor->arg)) | - |
| 2512 | - | return true; | - |
| 2513 | - | } | - |
| 2514 | - | break; | - |
| 2515 | - | - | |
| 2516 | - | case T_PartitionBoundSpec: | - |
| 2517 | - | { | - |
| 2518 | - | PartitionBoundSpec *pbs = (PartitionBoundSpec *) node; | - |
| 2519 | - | - | |
| 2520 | - | if (WALK(pbs->listdatums)) | - |
| 2521 | - | return true; | - |
| 2522 | - | if (WALK(pbs->lowerdatums)) | - |
| 2523 | - | return true; | - |
| 2524 | - | if (WALK(pbs->upperdatums)) | - |
| 2525 | - | return true; | - |
| 2526 | - | } | - |
| 2527 | - | break; | - |
| 2528 | - | case T_PartitionRangeDatum: | - |
| 2529 | - | { | - |
| 2530 | - | PartitionRangeDatum *prd = (PartitionRangeDatum *) node; | - |
| 2531 | - | - | |
| 2532 | - | if (WALK(prd->value)) | - |
| 2533 | - | return true; | - |
| 2534 | - | } | - |
| 2535 | - | break; | - |
| 2536 | - | case T_List: | - |
| 2537 | - | foreach(temp, (List *) node) | - |
| 2538 | - | { | - |
| 2539 | - | if (WALK(lfirst(temp))) | - |
| 2540 | - | return true; | - |
| 2541 | - | } | - |
| 2542 | - | break; | - |
| 2543 | - | case T_FromExpr: | - |
| 2544 | - | { | - |
| 2545 | - | FromExpr *from = (FromExpr *) node; | - |
| 2546 | - | - | |
| 2547 | - | if (LIST_WALK(from->fromlist)) | - |
| 2548 | - | return true; | - |
| 2549 | - | if (WALK(from->quals)) | - |
| 2550 | - | return true; | - |
| 2551 | - | } | - |
| 2552 | - | break; | - |
| 2553 | - | case T_OnConflictExpr: | - |
| 2554 | - | { | - |
| 2555 | - | OnConflictExpr *onconflict = (OnConflictExpr *) node; | - |
| 2556 | - | - | |
| 2557 | - | if (WALK(onconflict->arbiterElems)) | - |
| 2558 | - | return true; | - |
| 2559 | - | if (WALK(onconflict->arbiterWhere)) | - |
| 2560 | - | return true; | - |
| 2561 | - | if (WALK(onconflict->onConflictSet)) | - |
| 2562 | - | return true; | - |
| 2563 | - | if (WALK(onconflict->onConflictWhere)) | - |
| 2564 | - | return true; | - |
| 2565 | - | if (WALK(onconflict->exclRelTlist)) | - |
| 2566 | - | return true; | - |
| 2567 | - | } | - |
| 2568 | - | break; | - |
| 2569 | - | case T_MergeAction: | - |
| 2570 | - | { | - |
| 2571 | - | MergeAction *action = (MergeAction *) node; | - |
| 2572 | - | - | |
| 2573 | - | if (WALK(action->qual)) | - |
| 2574 | - | return true; | - |
| 2575 | - | if (WALK(action->targetList)) | - |
| 2576 | - | return true; | - |
| 2577 | - | } | - |
| 2578 | - | break; | - |
| 2579 | - | case T_PartitionPruneStepOp: | - |
| 2580 | - | { | - |
| 2581 | - | PartitionPruneStepOp *opstep = (PartitionPruneStepOp *) node; | - |
| 2582 | - | - | |
| 2583 | - | if (WALK(opstep->exprs)) | - |
| 2584 | - | return true; | - |
| 2585 | - | } | - |
| 2586 | - | break; | - |
| 2587 | - | case T_PartitionPruneStepCombine: | - |
| 2588 | - | /* no expression subnodes */ | - |
| 2589 | - | break; | - |
| 2590 | - | case T_JoinExpr: | - |
| 2591 | - | { | - |
| 2592 | - | JoinExpr *join = (JoinExpr *) node; | - |
| 2593 | - | - | |
| 2594 | - | if (WALK(join->larg)) | - |
| 2595 | - | return true; | - |
| 2596 | - | if (WALK(join->rarg)) | - |
| 2597 | - | return true; | - |
| 2598 | - | if (WALK(join->quals)) | - |
| 2599 | - | return true; | - |
| 2600 | - | - | |
| 2601 | - | /* | - |
| 2602 | - | * alias clause, using list are deemed uninteresting. | - |
| 2603 | - | */ | - |
| 2604 | - | } | - |
| 2605 | - | break; | - |
| 2606 | - | case T_SetOperationStmt: | - |
| 2607 | - | { | - |
| 2608 | - | SetOperationStmt *setop = (SetOperationStmt *) node; | - |
| 2609 | - | - | |
| 2610 | - | if (WALK(setop->larg)) | - |
| 2611 | - | return true; | - |
| 2612 | - | if (WALK(setop->rarg)) | - |
| 2613 | - | return true; | - |
| 2614 | - | - | |
| 2615 | - | /* groupClauses are deemed uninteresting */ | - |
| 2616 | - | } | - |
| 2617 | - | break; | - |
| 2618 | - | case T_IndexClause: | - |
| 2619 | - | { | - |
| 2620 | - | IndexClause *iclause = (IndexClause *) node; | - |
| 2621 | - | - | |
| 2622 | - | if (WALK(iclause->rinfo)) | - |
| 2623 | - | return true; | - |
| 2624 | - | if (LIST_WALK(iclause->indexquals)) | - |
| 2625 | - | return true; | - |
| 2626 | - | } | - |
| 2627 | - | break; | - |
| 2628 | - | case T_PlaceHolderVar: | - |
| 2629 | - | return WALK(((PlaceHolderVar *) node)->phexpr); | - |
| 2630 | - | case T_InferenceElem: | - |
| 2631 | - | return WALK(((InferenceElem *) node)->expr); | - |
| 2632 | - | case T_ReturningExpr: | - |
| 2633 | - | return WALK(((ReturningExpr *) node)->retexpr); | - |
| 2634 | - | case T_AppendRelInfo: | - |
| 2635 | - | { | - |
| 2636 | - | AppendRelInfo *appinfo = (AppendRelInfo *) node; | - |
| 2637 | - | - | |
| 2638 | - | if (LIST_WALK(appinfo->translated_vars)) | - |
| 2639 | - | return true; | - |
| 2640 | - | } | - |
| 2641 | - | break; | - |
| 2642 | - | case T_PlaceHolderInfo: | - |
| 2643 | - | return WALK(((PlaceHolderInfo *) node)->ph_var); | - |
| 2644 | - | case T_RangeTblFunction: | - |
| 2645 | - | return WALK(((RangeTblFunction *) node)->funcexpr); | - |
| 2646 | - | case T_TableSampleClause: | - |
| 2647 | - | { | - |
| 2648 | - | TableSampleClause *tsc = (TableSampleClause *) node; | - |
| 2649 | - | - | |
| 2650 | - | if (LIST_WALK(tsc->args)) | - |
| 2651 | - | return true; | - |
| 2652 | - | if (WALK(tsc->repeatable)) | - |
| 2653 | - | return true; | - |
| 2654 | - | } | - |
| 2655 | - | break; | - |
| 2656 | - | case T_TableFunc: | - |
| 2657 | - | { | - |
| 2658 | - | TableFunc *tf = (TableFunc *) node; | - |
| 2659 | - | - | |
| 2660 | - | if (WALK(tf->ns_uris)) | - |
| 2661 | - | return true; | - |
| 2662 | - | if (WALK(tf->docexpr)) | - |
| 2663 | - | return true; | - |
| 2664 | - | if (WALK(tf->rowexpr)) | - |
| 2665 | - | return true; | - |
| 2666 | - | if (WALK(tf->colexprs)) | - |
| 2667 | - | return true; | - |
| 2668 | - | if (WALK(tf->coldefexprs)) | - |
| 2669 | - | return true; | - |
| 2670 | - | if (WALK(tf->colvalexprs)) | - |
| 2671 | - | return true; | - |
| 2672 | - | if (WALK(tf->passingvalexprs)) | - |
| 2673 | - | return true; | - |
| 2674 | - | } | - |
| 2675 | - | break; | - |
| 2676 | 87 | case T_GraphElementPattern: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2677 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2678 | 87 | GraphElementPattern *gep = (GraphElementPattern *) node; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2679 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 2680 | 87 | if (WALK(gep->subexpr)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2681 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2682 | 87 | if (WALK(gep->whereClause)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2683 | 0 | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2684 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2685 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2686 | 37 | case T_GraphPattern: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2687 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2688 | 37 | GraphPattern *gp = (GraphPattern *) node; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2689 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 2690 | 37 | if (LIST_WALK(gp->path_pattern_list)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2691 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2692 | 37 | if (WALK(gp->whereClause)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2693 | 0 | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2694 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2695 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2696 | - | default: | - |
| 2697 | - | elog(ERROR, "unrecognized node type: %d", | - |
| 2698 | - | (int) nodeTag(node)); | - |
| 2699 | - | break; | - |
| 2700 | - | } | - |
| 2701 | - | return false; | - |
| 2702 | - | - | |
| 2703 | - | /* The WALK() macro can be re-used below, but LIST_WALK() not so much */ | - |
| 2704 | - | #undef LIST_WALK | - |
| 2705 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 2847 | - | range_table_entry_walker_impl(RangeTblEntry *rte, | - |
| 2848 | - | tree_walker_callback walker, | - |
| 2849 | - | void *context, | - |
| 2850 | - | int flags) | - |
| 2851 | - | { | - |
| 2852 | - | /* | - |
| 2853 | - | * Walkers might need to examine the RTE node itself either before or | - |
| 2854 | - | * after visiting its contents (or, conceivably, both). Note that if you | - |
| 2855 | - | * specify neither flag, the walker won't be called on the RTE at all. | - |
| 2856 | - | */ | - |
| 2857 | - | if (flags & QTW_EXAMINE_RTES_BEFORE) | - |
| 2858 | - | if (WALK(rte)) | - |
| 2859 | - | return true; | - |
| 2860 | - | - | |
| 2861 | - | switch (rte->rtekind) | - |
| 2862 | - | { | - |
| 2863 | - | case RTE_RELATION: | - |
| 2864 | - | if (WALK(rte->tablesample)) | - |
| 2865 | - | return true; | - |
| 2866 | - | break; | - |
| 2867 | - | case RTE_SUBQUERY: | - |
| 2868 | - | if (!(flags & QTW_IGNORE_RT_SUBQUERIES)) | - |
| 2869 | - | if (WALK(rte->subquery)) | - |
| 2870 | - | return true; | - |
| 2871 | - | break; | - |
| 2872 | - | case RTE_JOIN: | - |
| 2873 | - | if (!(flags & QTW_IGNORE_JOINALIASES)) | - |
| 2874 | - | if (WALK(rte->joinaliasvars)) | - |
| 2875 | - | return true; | - |
| 2876 | - | break; | - |
| 2877 | - | case RTE_FUNCTION: | - |
| 2878 | - | if (WALK(rte->functions)) | - |
| 2879 | - | return true; | - |
| 2880 | - | break; | - |
| 2881 | - | case RTE_TABLEFUNC: | - |
| 2882 | - | if (WALK(rte->tablefunc)) | - |
| 2883 | - | return true; | - |
| 2884 | - | break; | - |
| 2885 | - | case RTE_VALUES: | - |
| 2886 | - | if (WALK(rte->values_lists)) | - |
| 2887 | - | return true; | - |
| 2888 | - | break; | - |
| 2889 | 37 | case RTE_GRAPH_TABLE: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2890 | 37 | if (WALK(rte->graph_pattern)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2891 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2892 | 37 | if (WALK(rte->graph_table_columns)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2893 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2894 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2895 | - | case RTE_CTE: | - |
| 2896 | - | case RTE_NAMEDTUPLESTORE: | - |
| 2897 | - | case RTE_RESULT: | - |
| 2898 | - | /* nothing to do */ | - |
| 2899 | - | break; | - |
| 2900 | - | case RTE_GROUP: | - |
| 2901 | - | if (!(flags & QTW_IGNORE_GROUPEXPRS)) | - |
| 2902 | - | if (WALK(rte->groupexprs)) | - |
| 2903 | - | return true; | - |
| 2904 | - | break; | - |
| 2905 | - | } | - |
| 2906 | - | - | |
| 2907 | - | if (WALK(rte->securityQuals)) | - |
| 2908 | - | return true; | - |
| 2909 | - | - | |
| 2910 | - | if (flags & QTW_EXAMINE_RTES_AFTER) | - |
| 2911 | - | if (WALK(rte)) | - |
| 2912 | - | return true; | - |
| 2913 | - | - | |
| 2914 | - | return false; | - |
| 2915 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 3899 | - | range_table_mutator_impl(List *rtable, | - |
| 3900 | - | tree_mutator_callback mutator, | - |
| 3901 | - | void *context, | - |
| 3902 | - | int flags) | - |
| 3903 | - | { | - |
| 3904 | - | List *newrt = NIL; | - |
| 3905 | - | ListCell *rt; | - |
| 3906 | - | - | |
| 3907 | - | foreach(rt, rtable) | - |
| 3908 | - | { | - |
| 3909 | - | RangeTblEntry *rte = (RangeTblEntry *) lfirst(rt); | - |
| 3910 | - | RangeTblEntry *newrte; | - |
| 3911 | - | - | |
| 3912 | - | FLATCOPY(newrte, rte, RangeTblEntry); | - |
| 3913 | - | switch (rte->rtekind) | - |
| 3914 | - | { | - |
| 3915 | - | case RTE_RELATION: | - |
| 3916 | - | MUTATE(newrte->tablesample, rte->tablesample, | - |
| 3917 | - | TableSampleClause *); | - |
| 3918 | - | /* we don't bother to copy eref, aliases, etc; OK? */ | - |
| 3919 | - | break; | - |
| 3920 | - | case RTE_SUBQUERY: | - |
| 3921 | - | if (!(flags & QTW_IGNORE_RT_SUBQUERIES)) | - |
| 3922 | - | MUTATE(newrte->subquery, rte->subquery, Query *); | - |
| 3923 | - | else | - |
| 3924 | - | { | - |
| 3925 | - | /* else, copy RT subqueries as-is */ | - |
| 3926 | - | newrte->subquery = copyObject(rte->subquery); | - |
| 3927 | - | } | - |
| 3928 | - | break; | - |
| 3929 | - | case RTE_JOIN: | - |
| 3930 | - | if (!(flags & QTW_IGNORE_JOINALIASES)) | - |
| 3931 | - | MUTATE(newrte->joinaliasvars, rte->joinaliasvars, List *); | - |
| 3932 | - | else | - |
| 3933 | - | { | - |
| 3934 | - | /* else, copy join aliases as-is */ | - |
| 3935 | - | newrte->joinaliasvars = copyObject(rte->joinaliasvars); | - |
| 3936 | - | } | - |
| 3937 | - | break; | - |
| 3938 | - | case RTE_FUNCTION: | - |
| 3939 | - | MUTATE(newrte->functions, rte->functions, List *); | - |
| 3940 | - | break; | - |
| 3941 | - | case RTE_TABLEFUNC: | - |
| 3942 | - | MUTATE(newrte->tablefunc, rte->tablefunc, TableFunc *); | - |
| 3943 | - | break; | - |
| 3944 | - | case RTE_VALUES: | - |
| 3945 | - | MUTATE(newrte->values_lists, rte->values_lists, List *); | - |
| 3946 | - | break; | - |
| 3947 | 0 | case RTE_GRAPH_TABLE: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3948 | 0 | MUTATE(newrte->graph_pattern, rte->graph_pattern, GraphPattern *); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3949 | 0 | MUTATE(newrte->graph_table_columns, rte->graph_table_columns, List *); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3950 | 0 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3951 | - | case RTE_CTE: | - |
| 3952 | - | case RTE_NAMEDTUPLESTORE: | - |
| 3953 | - | case RTE_RESULT: | - |
| 3954 | - | /* nothing to do */ | - |
| 3955 | - | break; | - |
| 3956 | - | case RTE_GROUP: | - |
| 3957 | - | if (!(flags & QTW_IGNORE_GROUPEXPRS)) | - |
| 3958 | - | MUTATE(newrte->groupexprs, rte->groupexprs, List *); | - |
| 3959 | - | else | - |
| 3960 | - | { | - |
| 3961 | - | /* else, copy grouping exprs as-is */ | - |
| 3962 | - | newrte->groupexprs = copyObject(rte->groupexprs); | - |
| 3963 | - | } | - |
| 3964 | - | break; | - |
| 3965 | - | } | - |
| 3966 | - | MUTATE(newrte->securityQuals, rte->securityQuals, List *); | - |
| 3967 | - | newrt = lappend(newrt, newrte); | - |
| 3968 | - | } | - |
| 3969 | - | return newrt; | - |
| 3970 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 4035 | - | raw_expression_tree_walker_impl(Node *node, | - |
| 4036 | - | tree_walker_callback walker, | - |
| 4037 | - | void *context) | - |
| 4038 | - | { | - |
| 4039 | - | ListCell *temp; | - |
| 4040 | - | - | |
| 4041 | - | /* | - |
| 4042 | - | * The walker has already visited the current node, and so we need only | - |
| 4043 | - | * recurse into any sub-nodes it has. | - |
| 4044 | - | */ | - |
| 4045 | - | if (node == NULL) | - |
| 4046 | - | return false; | - |
| 4047 | - | - | |
| 4048 | - | /* Guard against stack overflow due to overly complex expressions */ | - |
| 4049 | - | check_stack_depth(); | - |
| 4050 | - | - | |
| 4051 | - | switch (nodeTag(node)) | - |
| 4052 | - | { | - |
| 4053 | - | case T_JsonFormat: | - |
| 4054 | - | case T_SetToDefault: | - |
| 4055 | - | case T_CurrentOfExpr: | - |
| 4056 | - | case T_SQLValueFunction: | - |
| 4057 | - | case T_Integer: | - |
| 4058 | - | case T_Float: | - |
| 4059 | - | case T_Boolean: | - |
| 4060 | - | case T_String: | - |
| 4061 | - | case T_BitString: | - |
| 4062 | - | case T_ParamRef: | - |
| 4063 | - | case T_A_Const: | - |
| 4064 | - | case T_A_Star: | - |
| 4065 | - | case T_MergeSupportFunc: | - |
| 4066 | - | case T_ReturningOption: | - |
| 4067 | - | /* primitive node types with no subnodes */ | - |
| 4068 | - | break; | - |
| 4069 | - | case T_Alias: | - |
| 4070 | - | /* we assume the colnames list isn't interesting */ | - |
| 4071 | - | break; | - |
| 4072 | - | case T_RangeVar: | - |
| 4073 | - | return WALK(((RangeVar *) node)->alias); | - |
| 4074 | - | case T_GroupingFunc: | - |
| 4075 | - | return WALK(((GroupingFunc *) node)->args); | - |
| 4076 | - | case T_SubLink: | - |
| 4077 | - | { | - |
| 4078 | - | SubLink *sublink = (SubLink *) node; | - |
| 4079 | - | - | |
| 4080 | - | if (WALK(sublink->testexpr)) | - |
| 4081 | - | return true; | - |
| 4082 | - | /* we assume the operName is not interesting */ | - |
| 4083 | - | if (WALK(sublink->subselect)) | - |
| 4084 | - | return true; | - |
| 4085 | - | } | - |
| 4086 | - | break; | - |
| 4087 | - | case T_CaseExpr: | - |
| 4088 | - | { | - |
| 4089 | - | CaseExpr *caseexpr = (CaseExpr *) node; | - |
| 4090 | - | - | |
| 4091 | - | if (WALK(caseexpr->arg)) | - |
| 4092 | - | return true; | - |
| 4093 | - | /* we assume walker doesn't care about CaseWhens, either */ | - |
| 4094 | - | foreach(temp, caseexpr->args) | - |
| 4095 | - | { | - |
| 4096 | - | CaseWhen *when = lfirst_node(CaseWhen, temp); | - |
| 4097 | - | - | |
| 4098 | - | if (WALK(when->expr)) | - |
| 4099 | - | return true; | - |
| 4100 | - | if (WALK(when->result)) | - |
| 4101 | - | return true; | - |
| 4102 | - | } | - |
| 4103 | - | if (WALK(caseexpr->defresult)) | - |
| 4104 | - | return true; | - |
| 4105 | - | } | - |
| 4106 | - | break; | - |
| 4107 | - | case T_RowExpr: | - |
| 4108 | - | /* Assume colnames isn't interesting */ | - |
| 4109 | - | return WALK(((RowExpr *) node)->args); | - |
| 4110 | - | case T_CoalesceExpr: | - |
| 4111 | - | return WALK(((CoalesceExpr *) node)->args); | - |
| 4112 | - | case T_MinMaxExpr: | - |
| 4113 | - | return WALK(((MinMaxExpr *) node)->args); | - |
| 4114 | - | case T_XmlExpr: | - |
| 4115 | - | { | - |
| 4116 | - | XmlExpr *xexpr = (XmlExpr *) node; | - |
| 4117 | - | - | |
| 4118 | - | if (WALK(xexpr->named_args)) | - |
| 4119 | - | return true; | - |
| 4120 | - | /* we assume walker doesn't care about arg_names */ | - |
| 4121 | - | if (WALK(xexpr->args)) | - |
| 4122 | - | return true; | - |
| 4123 | - | } | - |
| 4124 | - | break; | - |
| 4125 | - | case T_JsonReturning: | - |
| 4126 | - | return WALK(((JsonReturning *) node)->format); | - |
| 4127 | - | case T_JsonValueExpr: | - |
| 4128 | - | { | - |
| 4129 | - | JsonValueExpr *jve = (JsonValueExpr *) node; | - |
| 4130 | - | - | |
| 4131 | - | if (WALK(jve->raw_expr)) | - |
| 4132 | - | return true; | - |
| 4133 | - | if (WALK(jve->formatted_expr)) | - |
| 4134 | - | return true; | - |
| 4135 | - | if (WALK(jve->format)) | - |
| 4136 | - | return true; | - |
| 4137 | - | } | - |
| 4138 | - | break; | - |
| 4139 | - | case T_JsonParseExpr: | - |
| 4140 | - | { | - |
| 4141 | - | JsonParseExpr *jpe = (JsonParseExpr *) node; | - |
| 4142 | - | - | |
| 4143 | - | if (WALK(jpe->expr)) | - |
| 4144 | - | return true; | - |
| 4145 | - | if (WALK(jpe->output)) | - |
| 4146 | - | return true; | - |
| 4147 | - | } | - |
| 4148 | - | break; | - |
| 4149 | - | case T_JsonScalarExpr: | - |
| 4150 | - | { | - |
| 4151 | - | JsonScalarExpr *jse = (JsonScalarExpr *) node; | - |
| 4152 | - | - | |
| 4153 | - | if (WALK(jse->expr)) | - |
| 4154 | - | return true; | - |
| 4155 | - | if (WALK(jse->output)) | - |
| 4156 | - | return true; | - |
| 4157 | - | } | - |
| 4158 | - | break; | - |
| 4159 | - | case T_JsonSerializeExpr: | - |
| 4160 | - | { | - |
| 4161 | - | JsonSerializeExpr *jse = (JsonSerializeExpr *) node; | - |
| 4162 | - | - | |
| 4163 | - | if (WALK(jse->expr)) | - |
| 4164 | - | return true; | - |
| 4165 | - | if (WALK(jse->output)) | - |
| 4166 | - | return true; | - |
| 4167 | - | } | - |
| 4168 | - | break; | - |
| 4169 | - | case T_JsonConstructorExpr: | - |
| 4170 | - | { | - |
| 4171 | - | JsonConstructorExpr *ctor = (JsonConstructorExpr *) node; | - |
| 4172 | - | - | |
| 4173 | - | if (WALK(ctor->args)) | - |
| 4174 | - | return true; | - |
| 4175 | - | if (WALK(ctor->func)) | - |
| 4176 | - | return true; | - |
| 4177 | - | if (WALK(ctor->coercion)) | - |
| 4178 | - | return true; | - |
| 4179 | - | if (WALK(ctor->returning)) | - |
| 4180 | - | return true; | - |
| 4181 | - | } | - |
| 4182 | - | break; | - |
| 4183 | - | case T_JsonIsPredicate: | - |
| 4184 | - | return WALK(((JsonIsPredicate *) node)->expr); | - |
| 4185 | - | case T_JsonArgument: | - |
| 4186 | - | return WALK(((JsonArgument *) node)->val); | - |
| 4187 | - | case T_JsonFuncExpr: | - |
| 4188 | - | { | - |
| 4189 | - | JsonFuncExpr *jfe = (JsonFuncExpr *) node; | - |
| 4190 | - | - | |
| 4191 | - | if (WALK(jfe->context_item)) | - |
| 4192 | - | return true; | - |
| 4193 | - | if (WALK(jfe->pathspec)) | - |
| 4194 | - | return true; | - |
| 4195 | - | if (WALK(jfe->passing)) | - |
| 4196 | - | return true; | - |
| 4197 | - | if (WALK(jfe->output)) | - |
| 4198 | - | return true; | - |
| 4199 | - | if (WALK(jfe->on_empty)) | - |
| 4200 | - | return true; | - |
| 4201 | - | if (WALK(jfe->on_error)) | - |
| 4202 | - | return true; | - |
| 4203 | - | } | - |
| 4204 | - | break; | - |
| 4205 | - | case T_JsonBehavior: | - |
| 4206 | - | { | - |
| 4207 | - | JsonBehavior *jb = (JsonBehavior *) node; | - |
| 4208 | - | - | |
| 4209 | - | if (WALK(jb->expr)) | - |
| 4210 | - | return true; | - |
| 4211 | - | } | - |
| 4212 | - | break; | - |
| 4213 | - | case T_JsonTable: | - |
| 4214 | - | { | - |
| 4215 | - | JsonTable *jt = (JsonTable *) node; | - |
| 4216 | - | - | |
| 4217 | - | if (WALK(jt->context_item)) | - |
| 4218 | - | return true; | - |
| 4219 | - | if (WALK(jt->pathspec)) | - |
| 4220 | - | return true; | - |
| 4221 | - | if (WALK(jt->passing)) | - |
| 4222 | - | return true; | - |
| 4223 | - | if (WALK(jt->columns)) | - |
| 4224 | - | return true; | - |
| 4225 | - | if (WALK(jt->on_error)) | - |
| 4226 | - | return true; | - |
| 4227 | - | } | - |
| 4228 | - | break; | - |
| 4229 | - | case T_JsonTableColumn: | - |
| 4230 | - | { | - |
| 4231 | - | JsonTableColumn *jtc = (JsonTableColumn *) node; | - |
| 4232 | - | - | |
| 4233 | - | if (WALK(jtc->typeName)) | - |
| 4234 | - | return true; | - |
| 4235 | - | if (WALK(jtc->on_empty)) | - |
| 4236 | - | return true; | - |
| 4237 | - | if (WALK(jtc->on_error)) | - |
| 4238 | - | return true; | - |
| 4239 | - | if (WALK(jtc->columns)) | - |
| 4240 | - | return true; | - |
| 4241 | - | } | - |
| 4242 | - | break; | - |
| 4243 | - | case T_JsonTablePathSpec: | - |
| 4244 | - | return WALK(((JsonTablePathSpec *) node)->string); | - |
| 4245 | - | case T_NullTest: | - |
| 4246 | - | return WALK(((NullTest *) node)->arg); | - |
| 4247 | - | case T_BooleanTest: | - |
| 4248 | - | return WALK(((BooleanTest *) node)->arg); | - |
| 4249 | - | case T_JoinExpr: | - |
| 4250 | - | { | - |
| 4251 | - | JoinExpr *join = (JoinExpr *) node; | - |
| 4252 | - | - | |
| 4253 | - | if (WALK(join->larg)) | - |
| 4254 | - | return true; | - |
| 4255 | - | if (WALK(join->rarg)) | - |
| 4256 | - | return true; | - |
| 4257 | - | if (WALK(join->quals)) | - |
| 4258 | - | return true; | - |
| 4259 | - | if (WALK(join->alias)) | - |
| 4260 | - | return true; | - |
| 4261 | - | /* using list is deemed uninteresting */ | - |
| 4262 | - | } | - |
| 4263 | - | break; | - |
| 4264 | - | case T_IntoClause: | - |
| 4265 | - | { | - |
| 4266 | - | IntoClause *into = (IntoClause *) node; | - |
| 4267 | - | - | |
| 4268 | - | if (WALK(into->rel)) | - |
| 4269 | - | return true; | - |
| 4270 | - | /* colNames, options are deemed uninteresting */ | - |
| 4271 | - | /* viewQuery should be null in raw parsetree, but check it */ | - |
| 4272 | - | if (WALK(into->viewQuery)) | - |
| 4273 | - | return true; | - |
| 4274 | - | } | - |
| 4275 | - | break; | - |
| 4276 | - | case T_List: | - |
| 4277 | - | foreach(temp, (List *) node) | - |
| 4278 | - | { | - |
| 4279 | - | if (WALK((Node *) lfirst(temp))) | - |
| 4280 | - | return true; | - |
| 4281 | - | } | - |
| 4282 | - | break; | - |
| 4283 | - | case T_InsertStmt: | - |
| 4284 | - | { | - |
| 4285 | - | InsertStmt *stmt = (InsertStmt *) node; | - |
| 4286 | - | - | |
| 4287 | - | if (WALK(stmt->relation)) | - |
| 4288 | - | return true; | - |
| 4289 | - | if (WALK(stmt->cols)) | - |
| 4290 | - | return true; | - |
| 4291 | - | if (WALK(stmt->selectStmt)) | - |
| 4292 | - | return true; | - |
| 4293 | - | if (WALK(stmt->onConflictClause)) | - |
| 4294 | - | return true; | - |
| 4295 | - | if (WALK(stmt->returningClause)) | - |
| 4296 | - | return true; | - |
| 4297 | - | if (WALK(stmt->withClause)) | - |
| 4298 | - | return true; | - |
| 4299 | - | } | - |
| 4300 | - | break; | - |
| 4301 | - | case T_DeleteStmt: | - |
| 4302 | - | { | - |
| 4303 | - | DeleteStmt *stmt = (DeleteStmt *) node; | - |
| 4304 | - | - | |
| 4305 | - | if (WALK(stmt->relation)) | - |
| 4306 | - | return true; | - |
| 4307 | - | if (WALK(stmt->usingClause)) | - |
| 4308 | - | return true; | - |
| 4309 | - | if (WALK(stmt->whereClause)) | - |
| 4310 | - | return true; | - |
| 4311 | - | if (WALK(stmt->returningClause)) | - |
| 4312 | - | return true; | - |
| 4313 | - | if (WALK(stmt->withClause)) | - |
| 4314 | - | return true; | - |
| 4315 | - | } | - |
| 4316 | - | break; | - |
| 4317 | - | case T_UpdateStmt: | - |
| 4318 | - | { | - |
| 4319 | - | UpdateStmt *stmt = (UpdateStmt *) node; | - |
| 4320 | - | - | |
| 4321 | - | if (WALK(stmt->relation)) | - |
| 4322 | - | return true; | - |
| 4323 | - | if (WALK(stmt->targetList)) | - |
| 4324 | - | return true; | - |
| 4325 | - | if (WALK(stmt->whereClause)) | - |
| 4326 | - | return true; | - |
| 4327 | - | if (WALK(stmt->fromClause)) | - |
| 4328 | - | return true; | - |
| 4329 | - | if (WALK(stmt->returningClause)) | - |
| 4330 | - | return true; | - |
| 4331 | - | if (WALK(stmt->withClause)) | - |
| 4332 | - | return true; | - |
| 4333 | - | } | - |
| 4334 | - | break; | - |
| 4335 | - | case T_MergeStmt: | - |
| 4336 | - | { | - |
| 4337 | - | MergeStmt *stmt = (MergeStmt *) node; | - |
| 4338 | - | - | |
| 4339 | - | if (WALK(stmt->relation)) | - |
| 4340 | - | return true; | - |
| 4341 | - | if (WALK(stmt->sourceRelation)) | - |
| 4342 | - | return true; | - |
| 4343 | - | if (WALK(stmt->joinCondition)) | - |
| 4344 | - | return true; | - |
| 4345 | - | if (WALK(stmt->mergeWhenClauses)) | - |
| 4346 | - | return true; | - |
| 4347 | - | if (WALK(stmt->returningClause)) | - |
| 4348 | - | return true; | - |
| 4349 | - | if (WALK(stmt->withClause)) | - |
| 4350 | - | return true; | - |
| 4351 | - | } | - |
| 4352 | - | break; | - |
| 4353 | - | case T_MergeWhenClause: | - |
| 4354 | - | { | - |
| 4355 | - | MergeWhenClause *mergeWhenClause = (MergeWhenClause *) node; | - |
| 4356 | - | - | |
| 4357 | - | if (WALK(mergeWhenClause->condition)) | - |
| 4358 | - | return true; | - |
| 4359 | - | if (WALK(mergeWhenClause->targetList)) | - |
| 4360 | - | return true; | - |
| 4361 | - | if (WALK(mergeWhenClause->values)) | - |
| 4362 | - | return true; | - |
| 4363 | - | } | - |
| 4364 | - | break; | - |
| 4365 | - | case T_ReturningClause: | - |
| 4366 | - | { | - |
| 4367 | - | ReturningClause *returning = (ReturningClause *) node; | - |
| 4368 | - | - | |
| 4369 | - | if (WALK(returning->options)) | - |
| 4370 | - | return true; | - |
| 4371 | - | if (WALK(returning->exprs)) | - |
| 4372 | - | return true; | - |
| 4373 | - | } | - |
| 4374 | - | break; | - |
| 4375 | - | case T_SelectStmt: | - |
| 4376 | - | { | - |
| 4377 | - | SelectStmt *stmt = (SelectStmt *) node; | - |
| 4378 | - | - | |
| 4379 | - | if (WALK(stmt->distinctClause)) | - |
| 4380 | - | return true; | - |
| 4381 | - | if (WALK(stmt->intoClause)) | - |
| 4382 | - | return true; | - |
| 4383 | - | if (WALK(stmt->targetList)) | - |
| 4384 | - | return true; | - |
| 4385 | - | if (WALK(stmt->fromClause)) | - |
| 4386 | - | return true; | - |
| 4387 | - | if (WALK(stmt->whereClause)) | - |
| 4388 | - | return true; | - |
| 4389 | - | if (WALK(stmt->groupClause)) | - |
| 4390 | - | return true; | - |
| 4391 | - | if (WALK(stmt->havingClause)) | - |
| 4392 | - | return true; | - |
| 4393 | - | if (WALK(stmt->windowClause)) | - |
| 4394 | - | return true; | - |
| 4395 | - | if (WALK(stmt->valuesLists)) | - |
| 4396 | - | return true; | - |
| 4397 | - | if (WALK(stmt->sortClause)) | - |
| 4398 | - | return true; | - |
| 4399 | - | if (WALK(stmt->limitOffset)) | - |
| 4400 | - | return true; | - |
| 4401 | - | if (WALK(stmt->limitCount)) | - |
| 4402 | - | return true; | - |
| 4403 | - | if (WALK(stmt->lockingClause)) | - |
| 4404 | - | return true; | - |
| 4405 | - | if (WALK(stmt->withClause)) | - |
| 4406 | - | return true; | - |
| 4407 | - | if (WALK(stmt->larg)) | - |
| 4408 | - | return true; | - |
| 4409 | - | if (WALK(stmt->rarg)) | - |
| 4410 | - | return true; | - |
| 4411 | - | } | - |
| 4412 | - | break; | - |
| 4413 | - | case T_PLAssignStmt: | - |
| 4414 | - | { | - |
| 4415 | - | PLAssignStmt *stmt = (PLAssignStmt *) node; | - |
| 4416 | - | - | |
| 4417 | - | if (WALK(stmt->indirection)) | - |
| 4418 | - | return true; | - |
| 4419 | - | if (WALK(stmt->val)) | - |
| 4420 | - | return true; | - |
| 4421 | - | } | - |
| 4422 | - | break; | - |
| 4423 | - | case T_A_Expr: | - |
| 4424 | - | { | - |
| 4425 | - | A_Expr *expr = (A_Expr *) node; | - |
| 4426 | - | - | |
| 4427 | - | if (WALK(expr->lexpr)) | - |
| 4428 | - | return true; | - |
| 4429 | - | if (WALK(expr->rexpr)) | - |
| 4430 | - | return true; | - |
| 4431 | - | /* operator name is deemed uninteresting */ | - |
| 4432 | - | } | - |
| 4433 | - | break; | - |
| 4434 | - | case T_BoolExpr: | - |
| 4435 | - | { | - |
| 4436 | - | BoolExpr *expr = (BoolExpr *) node; | - |
| 4437 | - | - | |
| 4438 | - | if (WALK(expr->args)) | - |
| 4439 | - | return true; | - |
| 4440 | - | } | - |
| 4441 | - | break; | - |
| 4442 | - | case T_ColumnRef: | - |
| 4443 | - | /* we assume the fields contain nothing interesting */ | - |
| 4444 | - | break; | - |
| 4445 | - | case T_FuncCall: | - |
| 4446 | - | { | - |
| 4447 | - | FuncCall *fcall = (FuncCall *) node; | - |
| 4448 | - | - | |
| 4449 | - | if (WALK(fcall->args)) | - |
| 4450 | - | return true; | - |
| 4451 | - | if (WALK(fcall->agg_order)) | - |
| 4452 | - | return true; | - |
| 4453 | - | if (WALK(fcall->agg_filter)) | - |
| 4454 | - | return true; | - |
| 4455 | - | if (WALK(fcall->over)) | - |
| 4456 | - | return true; | - |
| 4457 | - | /* function name is deemed uninteresting */ | - |
| 4458 | - | } | - |
| 4459 | - | break; | - |
| 4460 | - | case T_NamedArgExpr: | - |
| 4461 | - | return WALK(((NamedArgExpr *) node)->arg); | - |
| 4462 | - | case T_A_Indices: | - |
| 4463 | - | { | - |
| 4464 | - | A_Indices *indices = (A_Indices *) node; | - |
| 4465 | - | - | |
| 4466 | - | if (WALK(indices->lidx)) | - |
| 4467 | - | return true; | - |
| 4468 | - | if (WALK(indices->uidx)) | - |
| 4469 | - | return true; | - |
| 4470 | - | } | - |
| 4471 | - | break; | - |
| 4472 | - | case T_A_Indirection: | - |
| 4473 | - | { | - |
| 4474 | - | A_Indirection *indir = (A_Indirection *) node; | - |
| 4475 | - | - | |
| 4476 | - | if (WALK(indir->arg)) | - |
| 4477 | - | return true; | - |
| 4478 | - | if (WALK(indir->indirection)) | - |
| 4479 | - | return true; | - |
| 4480 | - | } | - |
| 4481 | - | break; | - |
| 4482 | - | case T_A_ArrayExpr: | - |
| 4483 | - | return WALK(((A_ArrayExpr *) node)->elements); | - |
| 4484 | - | case T_ResTarget: | - |
| 4485 | - | { | - |
| 4486 | - | ResTarget *rt = (ResTarget *) node; | - |
| 4487 | - | - | |
| 4488 | - | if (WALK(rt->indirection)) | - |
| 4489 | - | return true; | - |
| 4490 | - | if (WALK(rt->val)) | - |
| 4491 | - | return true; | - |
| 4492 | - | } | - |
| 4493 | - | break; | - |
| 4494 | - | case T_MultiAssignRef: | - |
| 4495 | - | return WALK(((MultiAssignRef *) node)->source); | - |
| 4496 | - | case T_TypeCast: | - |
| 4497 | - | { | - |
| 4498 | - | TypeCast *tc = (TypeCast *) node; | - |
| 4499 | - | - | |
| 4500 | - | if (WALK(tc->arg)) | - |
| 4501 | - | return true; | - |
| 4502 | - | if (WALK(tc->typeName)) | - |
| 4503 | - | return true; | - |
| 4504 | - | } | - |
| 4505 | - | break; | - |
| 4506 | - | case T_CollateClause: | - |
| 4507 | - | return WALK(((CollateClause *) node)->arg); | - |
| 4508 | - | case T_SortBy: | - |
| 4509 | - | return WALK(((SortBy *) node)->node); | - |
| 4510 | - | case T_WindowDef: | - |
| 4511 | - | { | - |
| 4512 | - | WindowDef *wd = (WindowDef *) node; | - |
| 4513 | - | - | |
| 4514 | - | if (WALK(wd->partitionClause)) | - |
| 4515 | - | return true; | - |
| 4516 | - | if (WALK(wd->orderClause)) | - |
| 4517 | - | return true; | - |
| 4518 | - | if (WALK(wd->startOffset)) | - |
| 4519 | - | return true; | - |
| 4520 | - | if (WALK(wd->endOffset)) | - |
| 4521 | - | return true; | - |
| 4522 | - | } | - |
| 4523 | - | break; | - |
| 4524 | - | case T_RangeSubselect: | - |
| 4525 | - | { | - |
| 4526 | - | RangeSubselect *rs = (RangeSubselect *) node; | - |
| 4527 | - | - | |
| 4528 | - | if (WALK(rs->subquery)) | - |
| 4529 | - | return true; | - |
| 4530 | - | if (WALK(rs->alias)) | - |
| 4531 | - | return true; | - |
| 4532 | - | } | - |
| 4533 | - | break; | - |
| 4534 | - | case T_RangeFunction: | - |
| 4535 | - | { | - |
| 4536 | - | RangeFunction *rf = (RangeFunction *) node; | - |
| 4537 | - | - | |
| 4538 | - | if (WALK(rf->functions)) | - |
| 4539 | - | return true; | - |
| 4540 | - | if (WALK(rf->alias)) | - |
| 4541 | - | return true; | - |
| 4542 | - | if (WALK(rf->coldeflist)) | - |
| 4543 | - | return true; | - |
| 4544 | - | } | - |
| 4545 | - | break; | - |
| 4546 | - | case T_RangeTableSample: | - |
| 4547 | - | { | - |
| 4548 | - | RangeTableSample *rts = (RangeTableSample *) node; | - |
| 4549 | - | - | |
| 4550 | - | if (WALK(rts->relation)) | - |
| 4551 | - | return true; | - |
| 4552 | - | /* method name is deemed uninteresting */ | - |
| 4553 | - | if (WALK(rts->args)) | - |
| 4554 | - | return true; | - |
| 4555 | - | if (WALK(rts->repeatable)) | - |
| 4556 | - | return true; | - |
| 4557 | - | } | - |
| 4558 | - | break; | - |
| 4559 | - | case T_RangeTableFunc: | - |
| 4560 | - | { | - |
| 4561 | - | RangeTableFunc *rtf = (RangeTableFunc *) node; | - |
| 4562 | - | - | |
| 4563 | - | if (WALK(rtf->docexpr)) | - |
| 4564 | - | return true; | - |
| 4565 | - | if (WALK(rtf->rowexpr)) | - |
| 4566 | - | return true; | - |
| 4567 | - | if (WALK(rtf->namespaces)) | - |
| 4568 | - | return true; | - |
| 4569 | - | if (WALK(rtf->columns)) | - |
| 4570 | - | return true; | - |
| 4571 | - | if (WALK(rtf->alias)) | - |
| 4572 | - | return true; | - |
| 4573 | - | } | - |
| 4574 | - | break; | - |
| 4575 | - | case T_RangeTableFuncCol: | - |
| 4576 | - | { | - |
| 4577 | - | RangeTableFuncCol *rtfc = (RangeTableFuncCol *) node; | - |
| 4578 | - | - | |
| 4579 | - | if (WALK(rtfc->colexpr)) | - |
| 4580 | - | return true; | - |
| 4581 | - | if (WALK(rtfc->coldefexpr)) | - |
| 4582 | - | return true; | - |
| 4583 | - | } | - |
| 4584 | - | break; | - |
| 4585 | 0 | case T_RangeGraphTable: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4586 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4587 | 0 | RangeGraphTable *rgt = (RangeGraphTable *) node; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4588 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4589 | 0 | if (WALK(rgt->graph_pattern)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4590 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4591 | 0 | if (WALK(rgt->columns)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4592 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4593 | 0 | if (WALK(rgt->alias)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4594 | 0 | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4595 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4596 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4597 | - | case T_TypeName: | - |
| 4598 | - | { | - |
| 4599 | - | TypeName *tn = (TypeName *) node; | - |
| 4600 | - | - | |
| 4601 | - | if (WALK(tn->typmods)) | - |
| 4602 | - | return true; | - |
| 4603 | - | if (WALK(tn->arrayBounds)) | - |
| 4604 | - | return true; | - |
| 4605 | - | /* type name itself is deemed uninteresting */ | - |
| 4606 | - | } | - |
| 4607 | - | break; | - |
| 4608 | - | case T_ColumnDef: | - |
| 4609 | - | { | - |
| 4610 | - | ColumnDef *coldef = (ColumnDef *) node; | - |
| 4611 | - | - | |
| 4612 | - | if (WALK(coldef->typeName)) | - |
| 4613 | - | return true; | - |
| 4614 | - | if (WALK(coldef->raw_default)) | - |
| 4615 | - | return true; | - |
| 4616 | - | if (WALK(coldef->collClause)) | - |
| 4617 | - | return true; | - |
| 4618 | - | /* for now, constraints are ignored */ | - |
| 4619 | - | } | - |
| 4620 | - | break; | - |
| 4621 | - | case T_IndexElem: | - |
| 4622 | - | { | - |
| 4623 | - | IndexElem *indelem = (IndexElem *) node; | - |
| 4624 | - | - | |
| 4625 | - | if (WALK(indelem->expr)) | - |
| 4626 | - | return true; | - |
| 4627 | - | /* collation and opclass names are deemed uninteresting */ | - |
| 4628 | - | } | - |
| 4629 | - | break; | - |
| 4630 | - | case T_GroupingSet: | - |
| 4631 | - | return WALK(((GroupingSet *) node)->content); | - |
| 4632 | - | case T_LockingClause: | - |
| 4633 | - | return WALK(((LockingClause *) node)->lockedRels); | - |
| 4634 | - | case T_XmlSerialize: | - |
| 4635 | - | { | - |
| 4636 | - | XmlSerialize *xs = (XmlSerialize *) node; | - |
| 4637 | - | - | |
| 4638 | - | if (WALK(xs->expr)) | - |
| 4639 | - | return true; | - |
| 4640 | - | if (WALK(xs->typeName)) | - |
| 4641 | - | return true; | - |
| 4642 | - | } | - |
| 4643 | - | break; | - |
| 4644 | - | case T_WithClause: | - |
| 4645 | - | return WALK(((WithClause *) node)->ctes); | - |
| 4646 | - | case T_InferClause: | - |
| 4647 | - | { | - |
| 4648 | - | InferClause *stmt = (InferClause *) node; | - |
| 4649 | - | - | |
| 4650 | - | if (WALK(stmt->indexElems)) | - |
| 4651 | - | return true; | - |
| 4652 | - | if (WALK(stmt->whereClause)) | - |
| 4653 | - | return true; | - |
| 4654 | - | } | - |
| 4655 | - | break; | - |
| 4656 | - | case T_OnConflictClause: | - |
| 4657 | - | { | - |
| 4658 | - | OnConflictClause *stmt = (OnConflictClause *) node; | - |
| 4659 | - | - | |
| 4660 | - | if (WALK(stmt->infer)) | - |
| 4661 | - | return true; | - |
| 4662 | - | if (WALK(stmt->targetList)) | - |
| 4663 | - | return true; | - |
| 4664 | - | if (WALK(stmt->whereClause)) | - |
| 4665 | - | return true; | - |
| 4666 | - | } | - |
| 4667 | - | break; | - |
| 4668 | - | case T_CommonTableExpr: | - |
| 4669 | - | /* search_clause and cycle_clause are not interesting here */ | - |
| 4670 | - | return WALK(((CommonTableExpr *) node)->ctequery); | - |
| 4671 | - | case T_JsonOutput: | - |
| 4672 | - | { | - |
| 4673 | - | JsonOutput *out = (JsonOutput *) node; | - |
| 4674 | - | - | |
| 4675 | - | if (WALK(out->typeName)) | - |
| 4676 | - | return true; | - |
| 4677 | - | if (WALK(out->returning)) | - |
| 4678 | - | return true; | - |
| 4679 | - | } | - |
| 4680 | - | break; | - |
| 4681 | - | case T_JsonKeyValue: | - |
| 4682 | - | { | - |
| 4683 | - | JsonKeyValue *jkv = (JsonKeyValue *) node; | - |
| 4684 | - | - | |
| 4685 | - | if (WALK(jkv->key)) | - |
| 4686 | - | return true; | - |
| 4687 | - | if (WALK(jkv->value)) | - |
| 4688 | - | return true; | - |
| 4689 | - | } | - |
| 4690 | - | break; | - |
| 4691 | - | case T_JsonObjectConstructor: | - |
| 4692 | - | { | - |
| 4693 | - | JsonObjectConstructor *joc = (JsonObjectConstructor *) node; | - |
| 4694 | - | - | |
| 4695 | - | if (WALK(joc->output)) | - |
| 4696 | - | return true; | - |
| 4697 | - | if (WALK(joc->exprs)) | - |
| 4698 | - | return true; | - |
| 4699 | - | } | - |
| 4700 | - | break; | - |
| 4701 | - | case T_JsonArrayConstructor: | - |
| 4702 | - | { | - |
| 4703 | - | JsonArrayConstructor *jac = (JsonArrayConstructor *) node; | - |
| 4704 | - | - | |
| 4705 | - | if (WALK(jac->output)) | - |
| 4706 | - | return true; | - |
| 4707 | - | if (WALK(jac->exprs)) | - |
| 4708 | - | return true; | - |
| 4709 | - | } | - |
| 4710 | - | break; | - |
| 4711 | - | case T_JsonAggConstructor: | - |
| 4712 | - | { | - |
| 4713 | - | JsonAggConstructor *ctor = (JsonAggConstructor *) node; | - |
| 4714 | - | - | |
| 4715 | - | if (WALK(ctor->output)) | - |
| 4716 | - | return true; | - |
| 4717 | - | if (WALK(ctor->agg_order)) | - |
| 4718 | - | return true; | - |
| 4719 | - | if (WALK(ctor->agg_filter)) | - |
| 4720 | - | return true; | - |
| 4721 | - | if (WALK(ctor->over)) | - |
| 4722 | - | return true; | - |
| 4723 | - | } | - |
| 4724 | - | break; | - |
| 4725 | - | case T_JsonObjectAgg: | - |
| 4726 | - | { | - |
| 4727 | - | JsonObjectAgg *joa = (JsonObjectAgg *) node; | - |
| 4728 | - | - | |
| 4729 | - | if (WALK(joa->constructor)) | - |
| 4730 | - | return true; | - |
| 4731 | - | if (WALK(joa->arg)) | - |
| 4732 | - | return true; | - |
| 4733 | - | } | - |
| 4734 | - | break; | - |
| 4735 | - | case T_JsonArrayAgg: | - |
| 4736 | - | { | - |
| 4737 | - | JsonArrayAgg *jaa = (JsonArrayAgg *) node; | - |
| 4738 | - | - | |
| 4739 | - | if (WALK(jaa->constructor)) | - |
| 4740 | - | return true; | - |
| 4741 | - | if (WALK(jaa->arg)) | - |
| 4742 | - | return true; | - |
| 4743 | - | } | - |
| 4744 | - | break; | - |
| 4745 | - | case T_JsonArrayQueryConstructor: | - |
| 4746 | - | { | - |
| 4747 | - | JsonArrayQueryConstructor *jaqc = (JsonArrayQueryConstructor *) node; | - |
| 4748 | - | - | |
| 4749 | - | if (WALK(jaqc->output)) | - |
| 4750 | - | return true; | - |
| 4751 | - | if (WALK(jaqc->query)) | - |
| 4752 | - | return true; | - |
| 4753 | - | } | - |
| 4754 | - | break; | - |
| 4755 | 0 | case T_GraphElementPattern: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4756 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4757 | 0 | GraphElementPattern *gep = (GraphElementPattern *) node; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4758 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4759 | 0 | if (WALK(gep->subexpr)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4760 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4761 | 0 | if (WALK(gep->whereClause)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4762 | 0 | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4763 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4764 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4765 | 0 | case T_GraphPattern: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4766 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4767 | 0 | GraphPattern *gp = (GraphPattern *) node; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4768 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4769 | 0 | if (WALK(gp->path_pattern_list)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4770 | - | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4771 | 0 | if (WALK(gp->whereClause)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4772 | 0 | return true; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4773 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4774 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4775 | - | default: | - |
| 4776 | - | elog(ERROR, "unrecognized node type: %d", | - |
| 4777 | - | (int) nodeTag(node)); | - |
| 4778 | - | break; | - |
| 4779 | - | } | - |
| 4780 | - | return false; | - |
| 4781 | - | } | - |