Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6d9f7a0

Browse files
committed
Undo double-quoting of index names in non-text EXPLAIN output formats.
explain_get_index_name() applied quote_identifier() to the index name.This is fine for text output, but the non-text output formats all havetheir own quoting conventions and would much rather start from theactual index name. For example in JSON you'd get something like "Index Name": "\"My Index\"",which is surely not desirable, especially when the same does nothappen for table names. Hence, move the responsibility for applyingquoting out to the callers, where it can go into already-existingspecial code paths for text format.This changes the API spec for users of explain_get_index_name_hook:before, they were supposed to apply quote_identifier() if necessary,now they should not. Research suggests that the only publiclyavailable user of the hook is hypopg, and it actually forgot toapply quoting anyway, so it's fine. (In any case, there's nobehavioral change for the output of a hook as seen in non-textEXPLAIN formats, so this won't break any case that programs shouldbe relying on.)Digging in the commit logs, it appears that quoting was included inexplain_get_index_name's duties when commit604ffd2 invented it;and that was fine at the time because we only had text output format.This should have been rethought when non-text formats were invented,but it wasn't.This is a fairly clear bug for users of non-text EXPLAIN formats,so back-patch to all supported branches.Per bug #16502 from Maciek Sakrejda. Patch by me (based oninvestigation by Euler Taveira); thanks to Julien Rouhaud for review.Discussion:https://postgr.es/m/16502-57bd1c9f913ed1d1@postgresql.org
1 parent411febd commit6d9f7a0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/backend/commands/explain.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
11871187
explain_get_index_name(bitmapindexscan->indexid);
11881188

11891189
if (es->format==EXPLAIN_FORMAT_TEXT)
1190-
appendStringInfo(es->str," on %s",indexname);
1190+
appendStringInfo(es->str," on %s",
1191+
quote_identifier(indexname));
11911192
else
11921193
ExplainPropertyText("Index Name",indexname,es);
11931194
}
@@ -2447,6 +2448,10 @@ show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es)
24472448
*
24482449
* We allow plugins to get control here so that plans involving hypothetical
24492450
* indexes can be explained.
2451+
*
2452+
* Note: names returned by this function should be "raw"; the caller will
2453+
* apply quoting if needed. Formerly the convention was to do quoting here,
2454+
* but we don't want that in non-text output formats.
24502455
*/
24512456
staticconstchar*
24522457
explain_get_index_name(OidindexId)
@@ -2459,11 +2464,10 @@ explain_get_index_name(Oid indexId)
24592464
result=NULL;
24602465
if (result==NULL)
24612466
{
2462-
/* default behavior: look in the catalogs and quote it */
2467+
/* default behavior: lookit upin the catalogs */
24632468
result=get_rel_name(indexId);
24642469
if (result==NULL)
24652470
elog(ERROR,"cache lookup failed for index %u",indexId);
2466-
result=quote_identifier(result);
24672471
}
24682472
returnresult;
24692473
}
@@ -2591,7 +2595,7 @@ ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir,
25912595
{
25922596
if (ScanDirectionIsBackward(indexorderdir))
25932597
appendStringInfoString(es->str," Backward");
2594-
appendStringInfo(es->str," using %s",indexname);
2598+
appendStringInfo(es->str," using %s",quote_identifier(indexname));
25952599
}
25962600
else
25972601
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp