0001-EXPLAIN-JSON-format-should-not-add-quotes-in-index-n.patch
text/x-patch
Filename: 0001-EXPLAIN-JSON-format-should-not-add-quotes-in-index-n.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: EXPLAIN JSON format should not add quotes in index names
| File | + | − |
|---|---|---|
| src/backend/commands/explain.c | 7 | 5 |
From 5441915ddb26af9b7d861c988b6d99757130424e Mon Sep 17 00:00:00 2001
From: Euler Taveira <euler.taveira@2ndquadrant.com>
Date: Sat, 20 Jun 2020 14:14:49 -0300
Subject: [PATCH] EXPLAIN JSON format should not add quotes in index names
JSON format does not have to quote relation names. However, index names
are quoted twice. It was reported in bug #16502.
---
src/backend/commands/explain.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 67bdcb2b27..250af77a1a 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -115,7 +115,7 @@ static void show_instrumentation_count(const char *qlabel, int which,
PlanState *planstate, ExplainState *es);
static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es);
static void show_eval_params(Bitmapset *bms_params, ExplainState *es);
-static const char *explain_get_index_name(Oid indexId);
+static const char *explain_get_index_name(Oid indexId, ExplainState *es);
static void show_buffer_usage(ExplainState *es, const BufferUsage *usage);
static void show_wal_usage(ExplainState *es, const WalUsage *usage);
static void ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir,
@@ -1453,7 +1453,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
{
BitmapIndexScan *bitmapindexscan = (BitmapIndexScan *) plan;
const char *indexname =
- explain_get_index_name(bitmapindexscan->indexid);
+ explain_get_index_name(bitmapindexscan->indexid, es);
if (es->format == EXPLAIN_FORMAT_TEXT)
appendStringInfo(es->str, " on %s", indexname);
@@ -3269,7 +3269,7 @@ show_eval_params(Bitmapset *bms_params, ExplainState *es)
* indexes can be explained.
*/
static const char *
-explain_get_index_name(Oid indexId)
+explain_get_index_name(Oid indexId, ExplainState *es)
{
const char *result;
@@ -3283,7 +3283,9 @@ explain_get_index_name(Oid indexId)
result = get_rel_name(indexId);
if (result == NULL)
elog(ERROR, "cache lookup failed for index %u", indexId);
- result = quote_identifier(result);
+ /* don't quote all formats, some formats have its own quote routine */
+ if (es->format == EXPLAIN_FORMAT_TEXT)
+ result = quote_identifier(result);
}
return result;
}
@@ -3457,7 +3459,7 @@ static void
ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir,
ExplainState *es)
{
- const char *indexname = explain_get_index_name(indexid);
+ const char *indexname = explain_get_index_name(indexid, es);
if (es->format == EXPLAIN_FORMAT_TEXT)
{
--
2.20.1