1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
|
/*-------------------------------------------------------------------------
*
* pg_overexplain.c
* allow EXPLAIN to dump even more details
*
* Copyright (c) 2016-2025, PostgreSQL Global Development Group
*
* contrib/pg_overexplain/pg_overexplain.c
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/pg_class.h"
#include "commands/defrem.h"
#include "commands/explain.h"
#include "commands/explain_format.h"
#include "commands/explain_state.h"
#include "fmgr.h"
#include "parser/parsetree.h"
#include "storage/lock.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
PG_MODULE_MAGIC_EXT(
.name = "pg_overexplain",
.version = PG_VERSION
);
typedef struct
{
bool debug;
bool range_table;
} overexplain_options;
static overexplain_options *overexplain_ensure_options(ExplainState *es);
static void overexplain_debug_handler(ExplainState *es, DefElem *opt,
ParseState *pstate);
static void overexplain_range_table_handler(ExplainState *es, DefElem *opt,
ParseState *pstate);
static void overexplain_per_node_hook(PlanState *planstate, List *ancestors,
const char *relationship,
const char *plan_name,
ExplainState *es);
static void overexplain_per_plan_hook(PlannedStmt *plannedstmt,
IntoClause *into,
ExplainState *es,
const char *queryString,
ParamListInfo params,
QueryEnvironment *queryEnv);
static void overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es);
static void overexplain_range_table(PlannedStmt *plannedstmt,
ExplainState *es);
static void overexplain_alias(const char *qlabel, Alias *alias,
ExplainState *es);
static void overexplain_bitmapset(const char *qlabel, Bitmapset *bms,
ExplainState *es);
static void overexplain_intlist(const char *qlabel, List *list,
ExplainState *es);
static int es_extension_id;
static explain_per_node_hook_type prev_explain_per_node_hook;
static explain_per_plan_hook_type prev_explain_per_plan_hook;
/*
* Initialization we do when this module is loaded.
*/
void
_PG_init(void)
{
/* Get an ID that we can use to cache data in an ExplainState. */
es_extension_id = GetExplainExtensionId("pg_overexplain");
/* Register the new EXPLAIN options implemented by this module. */
RegisterExtensionExplainOption("debug", overexplain_debug_handler);
RegisterExtensionExplainOption("range_table",
overexplain_range_table_handler);
/* Use the per-node and per-plan hooks to make our options do something. */
prev_explain_per_node_hook = explain_per_node_hook;
explain_per_node_hook = overexplain_per_node_hook;
prev_explain_per_plan_hook = explain_per_plan_hook;
explain_per_plan_hook = overexplain_per_plan_hook;
}
/*
* Get the overexplain_options structure from an ExplainState; if there is
* none, create one, attach it to the ExplainState, and return it.
*/
static overexplain_options *
overexplain_ensure_options(ExplainState *es)
{
overexplain_options *options;
options = GetExplainExtensionState(es, es_extension_id);
if (options == NULL)
{
options = palloc0(sizeof(overexplain_options));
SetExplainExtensionState(es, es_extension_id, options);
}
return options;
}
/*
* Parse handler for EXPLAIN (DEBUG).
*/
static void
overexplain_debug_handler(ExplainState *es, DefElem *opt, ParseState *pstate)
{
overexplain_options *options = overexplain_ensure_options(es);
options->debug = defGetBoolean(opt);
}
/*
* Parse handler for EXPLAIN (RANGE_TABLE).
*/
static void
overexplain_range_table_handler(ExplainState *es, DefElem *opt,
ParseState *pstate)
{
overexplain_options *options = overexplain_ensure_options(es);
options->range_table = defGetBoolean(opt);
}
/*
* Print out additional per-node information as appropriate. If the user didn't
* specify any of the options we support, do nothing; else, print whatever is
* relevant to the specified options.
*/
static void
overexplain_per_node_hook(PlanState *planstate, List *ancestors,
const char *relationship, const char *plan_name,
ExplainState *es)
{
overexplain_options *options;
Plan *plan = planstate->plan;
if (prev_explain_per_node_hook)
(*prev_explain_per_node_hook) (planstate, ancestors, relationship,
plan_name, es);
options = GetExplainExtensionState(es, es_extension_id);
if (options == NULL)
return;
/*
* If the "debug" option was given, display miscellaneous fields from the
* "Plan" node that would not otherwise be displayed.
*/
if (options->debug)
{
/*
* Normal EXPLAIN will display "Disabled: true" if the node is
* disabled; but that is based on noticing that plan->disabled_nodes
* is higher than the sum of its children; here, we display the raw
* value, for debugging purposes.
*/
ExplainPropertyInteger("Disabled Nodes", NULL, plan->disabled_nodes,
es);
/*
* Normal EXPLAIN will display the parallel_aware flag; here, we show
* the parallel_safe flag as well.
*/
ExplainPropertyBool("Parallel Safe", plan->parallel_safe, es);
/*
* The plan node ID isn't normally displayed, since it is only useful
* for debugging.
*/
ExplainPropertyInteger("Plan Node ID", NULL, plan->plan_node_id, es);
/*
* It is difficult to explain what extParam and allParam mean in plain
* language, so we simply display these fields labelled with the
* structure member name. For compactness, the text format omits the
* display of this information when the bitmapset is empty.
*/
if (es->format != EXPLAIN_FORMAT_TEXT || !bms_is_empty(plan->extParam))
overexplain_bitmapset("extParam", plan->extParam, es);
if (es->format != EXPLAIN_FORMAT_TEXT || !bms_is_empty(plan->allParam))
overexplain_bitmapset("allParam", plan->allParam, es);
}
/*
* If the "range_table" option was specified, display information about
* the range table indexes for this node.
*/
if (options->range_table)
{
switch (nodeTag(plan))
{
case T_SeqScan:
case T_SampleScan:
case T_IndexScan:
case T_IndexOnlyScan:
case T_BitmapHeapScan:
case T_TidScan:
case T_TidRangeScan:
case T_SubqueryScan:
case T_FunctionScan:
case T_TableFuncScan:
case T_ValuesScan:
case T_CteScan:
case T_NamedTuplestoreScan:
case T_WorkTableScan:
ExplainPropertyInteger("Scan RTI", NULL,
((Scan *) plan)->scanrelid, es);
break;
case T_ForeignScan:
overexplain_bitmapset("Scan RTIs",
((ForeignScan *) plan)->fs_base_relids,
es);
break;
case T_CustomScan:
overexplain_bitmapset("Scan RTIs",
((CustomScan *) plan)->custom_relids,
es);
break;
case T_ModifyTable:
ExplainPropertyInteger("Nominal RTI", NULL,
((ModifyTable *) plan)->nominalRelation, es);
ExplainPropertyInteger("Exclude Relation RTI", NULL,
((ModifyTable *) plan)->exclRelRTI, es);
break;
case T_Append:
overexplain_bitmapset("Append RTIs",
((Append *) plan)->apprelids,
es);
break;
case T_MergeAppend:
overexplain_bitmapset("Append RTIs",
((MergeAppend *) plan)->apprelids,
es);
break;
default:
break;
}
}
}
/*
* Print out additional per-query information as appropriate. Here again, if
* the user didn't specify any of the options implemented by this module, do
* nothing; otherwise, call the appropriate function for each specified
* option.
*/
static void
overexplain_per_plan_hook(PlannedStmt *plannedstmt,
IntoClause *into,
ExplainState *es,
const char *queryString,
ParamListInfo params,
QueryEnvironment *queryEnv)
{
overexplain_options *options;
if (prev_explain_per_plan_hook)
(*prev_explain_per_plan_hook) (plannedstmt, into, es, queryString,
params, queryEnv);
options = GetExplainExtensionState(es, es_extension_id);
if (options == NULL)
return;
if (options->debug)
overexplain_debug(plannedstmt, es);
if (options->range_table)
overexplain_range_table(plannedstmt, es);
}
/*
* Print out various details from the PlannedStmt that wouldn't otherwise
* be displayed.
*
* We don't try to print everything here. Information that would be displayed
* anyway doesn't need to be printed again here, and things with lots of
* substructure probably should be printed via separate options, or not at all.
*/
static void
overexplain_debug(PlannedStmt *plannedstmt, ExplainState *es)
{
char *commandType = NULL;
StringInfoData flags;
/* Even in text mode, we want to set this output apart as its own group. */
ExplainOpenGroup("PlannedStmt", "PlannedStmt", true, es);
if (es->format == EXPLAIN_FORMAT_TEXT)
{
ExplainIndentText(es);
appendStringInfoString(es->str, "PlannedStmt:\n");
es->indent++;
}
/* Print the command type. */
switch (plannedstmt->commandType)
{
case CMD_UNKNOWN:
commandType = "unknown";
break;
case CMD_SELECT:
commandType = "select";
break;
case CMD_UPDATE:
commandType = "update";
break;
case CMD_INSERT:
commandType = "insert";
break;
case CMD_DELETE:
commandType = "delete";
break;
case CMD_MERGE:
commandType = "merge";
break;
case CMD_UTILITY:
commandType = "utility";
break;
case CMD_NOTHING:
commandType = "nothing";
break;
}
ExplainPropertyText("Command Type", commandType, es);
/* Print various properties as a comma-separated list of flags. */
initStringInfo(&flags);
if (plannedstmt->hasReturning)
appendStringInfoString(&flags, ", hasReturning");
if (plannedstmt->hasModifyingCTE)
appendStringInfoString(&flags, ", hasModifyingCTE");
if (plannedstmt->canSetTag)
appendStringInfoString(&flags, ", canSetTag");
if (plannedstmt->transientPlan)
appendStringInfoString(&flags, ", transientPlan");
if (plannedstmt->dependsOnRole)
appendStringInfoString(&flags, ", dependsOnRole");
if (plannedstmt->parallelModeNeeded)
appendStringInfoString(&flags, ", parallelModeNeeded");
if (flags.len == 0)
appendStringInfoString(&flags, ", none");
ExplainPropertyText("Flags", flags.data + 2, es);
/* Various lists of integers. */
overexplain_bitmapset("Subplans Needing Rewind",
plannedstmt->rewindPlanIDs, es);
overexplain_intlist("Relation OIDs",
plannedstmt->relationOids, es);
overexplain_intlist("Executor Parameter Types",
plannedstmt->paramExecTypes, es);
/*
* Print the statement location. (If desired, we could alternatively print
* stmt_location and stmt_len as two separate fields.)
*/
if (plannedstmt->stmt_location == -1)
ExplainPropertyText("Parse Location", "Unknown", es);
else if (plannedstmt->stmt_len == 0)
ExplainPropertyText("Parse Location",
psprintf("%d to end", plannedstmt->stmt_location),
es);
else
ExplainPropertyText("Parse Location",
psprintf("%d for %d bytes",
plannedstmt->stmt_location,
plannedstmt->stmt_len),
es);
/* Done with this group. */
if (es->format == EXPLAIN_FORMAT_TEXT)
es->indent--;
ExplainCloseGroup("PlannedStmt", "PlannedStmt", true, es);
}
/*
* Provide detailed information about the contents of the PlannedStmt's
* range table.
*/
static void
overexplain_range_table(PlannedStmt *plannedstmt, ExplainState *es)
{
Index rti;
/* Open group, one entry per RangeTblEntry */
ExplainOpenGroup("Range Table", "Range Table", false, es);
/* Iterate over the range table */
for (rti = 1; rti <= list_length(plannedstmt->rtable); ++rti)
{
RangeTblEntry *rte = rt_fetch(rti, plannedstmt->rtable);
char *kind = NULL;
char *relkind;
/* NULL entries are possible; skip them */
if (rte == NULL)
continue;
/* Translate rtekind to a string */
switch (rte->rtekind)
{
case RTE_RELATION:
kind = "relation";
break;
case RTE_SUBQUERY:
kind = "subquery";
break;
case RTE_JOIN:
kind = "join";
break;
case RTE_FUNCTION:
kind = "function";
break;
case RTE_TABLEFUNC:
kind = "tablefunc";
break;
case RTE_VALUES:
kind = "values";
break;
case RTE_CTE:
kind = "cte";
break;
case RTE_NAMEDTUPLESTORE:
kind = "namedtuplestore";
break;
case RTE_RESULT:
kind = "result";
break;
case RTE_GROUP:
kind = "group";
break;
}
/* Begin group for this specific RTE */
ExplainOpenGroup("Range Table Entry", NULL, true, es);
/*
* In text format, the summary line displays the range table index and
* rtekind, plus indications if rte->inh and/or rte->inFromCl are set.
* In other formats, we display those as separate properties.
*/
if (es->format == EXPLAIN_FORMAT_TEXT)
{
ExplainIndentText(es);
appendStringInfo(es->str, "RTI %u (%s%s%s):\n", rti, kind,
rte->inh ? ", inherited" : "",
rte->inFromCl ? ", in-from-clause" : "");
es->indent++;
}
else
{
ExplainPropertyUInteger("RTI", NULL, rti, es);
ExplainPropertyText("Kind", kind, es);
ExplainPropertyBool("Inherited", rte->inh, es);
ExplainPropertyBool("In From Clause", rte->inFromCl, es);
}
/* rte->alias is optional; rte->eref is requested */
if (rte->alias != NULL)
overexplain_alias("Alias", rte->alias, es);
overexplain_alias("Eref", rte->eref, es);
/*
* We adhere to the usual EXPLAIN convention that schema names are
* displayed only in verbose mode, and we emit nothing if there is no
* relation OID.
*/
if (rte->relid != 0)
{
const char *relname;
const char *qualname;
relname = quote_identifier(get_rel_name(rte->relid));
if (es->verbose)
{
Oid nspoid = get_rel_namespace(rte->relid);
char *nspname;
nspname = get_namespace_name_or_temp(nspoid);
qualname = psprintf("%s.%s", quote_identifier(nspname),
relname);
}
else
qualname = relname;
ExplainPropertyText("Relation", qualname, es);
}
/* Translate relkind, if any, to a string */
switch (rte->relkind)
{
case RELKIND_RELATION:
relkind = "relation";
break;
case RELKIND_INDEX:
relkind = "index";
break;
case RELKIND_SEQUENCE:
relkind = "sequence";
break;
case RELKIND_TOASTVALUE:
relkind = "toastvalue";
break;
case RELKIND_VIEW:
relkind = "view";
break;
case RELKIND_MATVIEW:
relkind = "matview";
break;
case RELKIND_COMPOSITE_TYPE:
relkind = "composite_type";
break;
case RELKIND_FOREIGN_TABLE:
relkind = "foreign_table";
break;
case RELKIND_PARTITIONED_TABLE:
relkind = "partitioned_table";
break;
case RELKIND_PARTITIONED_INDEX:
relkind = "partitioned_index";
break;
case '\0':
relkind = NULL;
break;
default:
relkind = psprintf("%c", rte->relkind);
break;
}
/* If there is a relkind, show it */
if (relkind != NULL)
ExplainPropertyText("Relation Kind", relkind, es);
/* If there is a lock mode, show it */
if (rte->rellockmode != 0)
ExplainPropertyText("Relation Lock Mode",
GetLockmodeName(DEFAULT_LOCKMETHOD,
rte->rellockmode), es);
/*
* If there is a perminfoindex, show it. We don't try to display
* information from the RTEPermissionInfo node here because they are
* just indexes plannedstmt->permInfos which could be separately
* dumped if someone wants to add EXPLAIN (PERMISSIONS) or similar.
*/
if (rte->perminfoindex != 0)
ExplainPropertyInteger("Permission Info Index", NULL,
rte->perminfoindex, es);
/*
* add_rte_to_flat_rtable will clear rte->tablesample and
* rte->subquery in the finished plan, so skip those fields.
*
* However, the security_barrier flag is not shown by the core code,
* so let's print it here.
*/
if (es->format != EXPLAIN_FORMAT_TEXT || rte->security_barrier)
ExplainPropertyBool("Security Barrier", rte->security_barrier, es);
/*
* If this is a join, print out the fields that are specifically valid
* for joins.
*/
if (rte->rtekind == RTE_JOIN)
{
char *jointype;
switch (rte->jointype)
{
case JOIN_INNER:
jointype = "Inner";
break;
case JOIN_LEFT:
jointype = "Left";
break;
case JOIN_FULL:
jointype = "Full";
break;
case JOIN_RIGHT:
jointype = "Right";
break;
case JOIN_SEMI:
jointype = "Semi";
break;
case JOIN_ANTI:
jointype = "Anti";
break;
case JOIN_RIGHT_SEMI:
jointype = "Right Semi";
break;
case JOIN_RIGHT_ANTI:
jointype = "Right Anti";
break;
default:
jointype = "???";
break;
}
/* Join type */
ExplainPropertyText("Join Type", jointype, es);
/* # of JOIN USING columns */
if (es->format != EXPLAIN_FORMAT_TEXT || rte->joinmergedcols != 0)
ExplainPropertyInteger("JOIN USING Columns", NULL,
rte->joinmergedcols, es);
/*
* add_rte_to_flat_rtable will clear joinaliasvars, joinleftcols,
* joinrightcols, and join_using_alias here, so skip those fields.
*/
}
/*
* add_rte_to_flat_rtable will clear functions, tablefunc, and
* values_lists, but we can display funcordinality.
*/
if (rte->rtekind == RTE_FUNCTION)
ExplainPropertyBool("WITH ORDINALITY", rte->funcordinality, es);
/*
* If this is a CTE, print out CTE-related properties.
*/
if (rte->rtekind == RTE_CTE)
{
ExplainPropertyText("CTE Name", rte->ctename, es);
ExplainPropertyUInteger("CTE Levels Up", NULL, rte->ctelevelsup,
es);
ExplainPropertyBool("CTE Self-Reference", rte->self_reference, es);
}
/*
* add_rte_to_flat_rtable will clear coltypes, coltypmods, and
* colcollations, so skip those fields.
*
* If this is an ephemeral named relation, print out ENR-related
* properties.
*/
if (rte->rtekind == RTE_NAMEDTUPLESTORE)
{
ExplainPropertyText("ENR Name", rte->enrname, es);
ExplainPropertyFloat("ENR Tuples", NULL, rte->enrtuples, 0, es);
}
/*
* add_rte_to_flat_rtable will clear groupexprs and securityQuals, so
* skip that field. We have handled inFromCl above, so the only thing
* left to handle here is rte->lateral.
*/
if (es->format != EXPLAIN_FORMAT_TEXT || rte->lateral)
ExplainPropertyBool("Lateral", rte->lateral, es);
/* Done with this RTE */
if (es->format == EXPLAIN_FORMAT_TEXT)
es->indent--;
ExplainCloseGroup("Range Table Entry", NULL, true, es);
}
/* Print PlannedStmt fields that contain RTIs. */
if (es->format != EXPLAIN_FORMAT_TEXT ||
!bms_is_empty(plannedstmt->unprunableRelids))
overexplain_bitmapset("Unprunable RTIs", plannedstmt->unprunableRelids,
es);
if (es->format != EXPLAIN_FORMAT_TEXT ||
plannedstmt->resultRelations != NIL)
overexplain_intlist("Result RTIs", plannedstmt->resultRelations, es);
/* Close group, we're all done */
ExplainCloseGroup("Range Table", "Range Table", false, es);
}
/*
* Emit a text property describing the contents of an Alias.
*
* Column lists can be quite long here, so perhaps we should have an option
* to limit the display length by # of column or # of characters, but for
* now, just display everything.
*/
static void
overexplain_alias(const char *qlabel, Alias *alias, ExplainState *es)
{
StringInfoData buf;
bool first = true;
Assert(alias != NULL);
initStringInfo(&buf);
appendStringInfo(&buf, "%s (", quote_identifier(alias->aliasname));
foreach_node(String, cn, alias->colnames)
{
appendStringInfo(&buf, "%s%s",
first ? "" : ", ",
quote_identifier(cn->sval));
first = false;
}
appendStringInfoChar(&buf, ')');
ExplainPropertyText(qlabel, buf.data, es);
pfree(buf.data);
}
/*
* Emit a text property describing the contents of a bitmapset -- either a
* space-separated list of integer members, or the word "none" if the bitmapset
* is empty.
*/
static void
overexplain_bitmapset(const char *qlabel, Bitmapset *bms, ExplainState *es)
{
int x = -1;
StringInfoData buf;
if (bms_is_empty(bms))
{
ExplainPropertyText(qlabel, "none", es);
return;
}
initStringInfo(&buf);
while ((x = bms_next_member(bms, x)) >= 0)
appendStringInfo(&buf, " %d", x);
Assert(buf.data[0] == ' ');
ExplainPropertyText(qlabel, buf.data + 1, es);
pfree(buf.data);
}
/*
* Emit a text property describing the contents of a list of integers, OIDs,
* or XIDs -- either a space-separated list of integer members, or the word
* "none" if the list is empty.
*/
static void
overexplain_intlist(const char *qlabel, List *list, ExplainState *es)
{
StringInfoData buf;
initStringInfo(&buf);
if (list == NIL)
{
ExplainPropertyText(qlabel, "none", es);
return;
}
if (IsA(list, IntList))
{
foreach_int(i, list)
appendStringInfo(&buf, " %d", i);
}
else if (IsA(list, OidList))
{
foreach_oid(o, list)
appendStringInfo(&buf, " %u", o);
}
else if (IsA(list, XidList))
{
foreach_xid(x, list)
appendStringInfo(&buf, " %u", x);
}
else
{
appendStringInfoString(&buf, " not an integer list");
Assert(false);
}
if (buf.len > 0)
ExplainPropertyText(qlabel, buf.data + 1, es);
pfree(buf.data);
}
|