| 226 | } |
| 227 | |
| 228 | static void |
| 229 | ProcessSubqueryToJoin_walker(Node *jtree, ConvertSubqueryToJoinContext *context) |
| 230 | { |
| 231 | if (IsA(jtree, JoinExpr)) |
| 232 | { |
| 233 | JoinExpr *je = (JoinExpr *) jtree; |
| 234 | |
| 235 | /* |
| 236 | * If subselect's join tree is not a plain relation or an inner join, |
| 237 | * we refuse to convert. |
| 238 | */ |
| 239 | if (je->jointype != JOIN_INNER) |
| 240 | { |
| 241 | context->safeToConvert = false; |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | ProcessSubqueryToJoin_walker(je->larg, context); |
| 246 | if (!context->safeToConvert) |
| 247 | return; |
| 248 | ProcessSubqueryToJoin_walker(je->rarg, context); |
| 249 | if (!context->safeToConvert) |
| 250 | return; |
| 251 | |
| 252 | SubqueryToJoinWalker(je->quals, context); |
| 253 | } |
| 254 | else if (IsA(jtree, FromExpr)) |
| 255 | { |
| 256 | FromExpr *fe = (FromExpr *) jtree; |
| 257 | ListCell *lc; |
| 258 | |
| 259 | foreach(lc, fe->fromlist) |
| 260 | { |
| 261 | ProcessSubqueryToJoin_walker(lfirst(lc), context); |
| 262 | if (!context->safeToConvert) |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | SubqueryToJoinWalker(fe->quals, context); |
| 267 | } |
| 268 | else if (IsA(jtree, RangeTblRef)) |
| 269 | { |
| 270 | /* nothing to do */ |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | elog(ERROR, "unexpected node of type %d in join tree", jtree->type); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Wipe out join quals i.e. top-level where clause and any quals in the top-level inner join. |
no test coverage detected