| 10142 | } |
| 10143 | |
| 10144 | static void |
| 10145 | get_dqa_expr(DQAExpr *dqa_expr,deparse_context *context) |
| 10146 | { |
| 10147 | int id = -1; |
| 10148 | StringInfo buf = context->buf; |
| 10149 | Bitmapset *bm = dqa_expr->agg_args_id_bms; |
| 10150 | deparse_namespace *dnps = (deparse_namespace *) linitial(context->namespaces); |
| 10151 | |
| 10152 | resetStringInfo(buf); |
| 10153 | appendStringInfoChar(buf, '('); |
| 10154 | while ((id = bms_next_member(bm, id)) >= 0) |
| 10155 | { |
| 10156 | TargetEntry *te = get_sortgroupref_tle((Index)id, dnps->plan->targetlist); |
| 10157 | char *exprstr; |
| 10158 | |
| 10159 | if (!te) |
| 10160 | elog(ERROR, "no tlist entry for sort key: %d", id); |
| 10161 | /* Deparse the expression, showing any top-level cast */ |
| 10162 | exprstr = deparse_expression((Node *) te->expr, context->namespaces, |
| 10163 | context->varprefix, true); |
| 10164 | |
| 10165 | appendStringInfoString(buf, exprstr); |
| 10166 | appendStringInfoChar(buf, ','); |
| 10167 | } |
| 10168 | buf->data[buf->len - 1] = ')'; |
| 10169 | |
| 10170 | if (dqa_expr->agg_filter != NULL) |
| 10171 | { |
| 10172 | appendStringInfoString(buf, " FILTER (WHERE "); |
| 10173 | get_rule_expr((Node *) dqa_expr->agg_filter, context, false); |
| 10174 | appendStringInfoChar(buf, ')'); |
| 10175 | } |
| 10176 | |
| 10177 | } |
| 10178 | |
| 10179 | /* |
| 10180 | * get_agg_expr - Parse back an Aggref node |
no test coverage detected