Skip to content

Commit 82a6edd

Browse files
committed
Merge branch '193-plan-text' into 'master'
feat: show explain settings in the plain text format (#193) Closes #193 See merge request postgres-ai/joe!185
2 parents bbbcc3e + 242705a commit 82a6edd

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pkg/pgexplain/pgexplain.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ type Explain struct {
5252
Plan Plan `json:"Plan"`
5353
Triggers []interface{} `json:"Triggers"`
5454

55-
PlanningTime float64 `json:"Planning Time"`
56-
ExecutionTime float64 `json:"Execution Time"`
55+
Settings map[string]string `json:"Settings"`
56+
PlanningTime float64 `json:"Planning Time"`
57+
ExecutionTime float64 `json:"Execution Time"`
5758
TotalTime float64
5859

5960
TotalCost float64
@@ -533,6 +534,10 @@ func (ex *Explain) writePlanText(writer io.Writer, plan *Plan, prefix string, de
533534
currentPrefix = prefix + subplanPrefix + " "
534535
}
535536

537+
if len(ex.Settings) > 0 {
538+
_, _ = outputFn("Settings: %s", printMap(ex.Settings))
539+
}
540+
536541
writePlanTextNodeDetails(outputFn, plan)
537542

538543
for index := range plan.Plans {
@@ -757,3 +762,13 @@ func formatDetails(plan *Plan) string {
757762

758763
return ""
759764
}
765+
766+
func printMap(items map[string]string) string {
767+
list := []string{}
768+
769+
for key, value := range items {
770+
list = append(list, fmt.Sprintf("%s = '%v'", key, value))
771+
}
772+
773+
return strings.Join(list, ", ")
774+
}

0 commit comments

Comments
 (0)