MCPcopy Index your code
hub / github.com/coder/coder / pgDumpUsable

Function pgDumpUsable

coderd/database/gen/dump/main.go:133–152  ·  view source on GitHub ↗

pgDumpUsable mirrors PGDumpSchemaOnly's requirement (pg_dump on PATH at v13 or later). PGDumpSchemaOnly silently falls back to `docker run` when either condition fails, so we only show the install hint here when the local pg_dump is genuinely unusable. Otherwise an old pg_dump would produce a mislea

()

Source from the content-addressed store, hash-verified

131// local pg_dump is genuinely unusable. Otherwise an old pg_dump would
132// produce a misleading Docker-not-found message.
133func pgDumpUsable() bool {
134 path, err := exec.LookPath("pg_dump")
135 if err != nil {
136 return false
137 }
138 out, err := exec.Command(path, "--version").Output()
139 if err != nil {
140 return false
141 }
142 // Output format: "pg_dump (PostgreSQL) 14.5 ..."
143 parts := strings.Fields(string(out))
144 if len(parts) < 3 {
145 return false
146 }
147 major, err := strconv.Atoi(strings.SplitN(parts[2], ".", 2)[0])
148 if err != nil {
149 return false
150 }
151 return major >= 13
152}
153
154func openEmbeddedPostgres() (string, func(), error) {
155 listener, err := net.Listen("tcp4", "127.0.0.1:0")

Callers 1

mainFunction · 0.85

Calls 3

CommandMethod · 0.80
OutputMethod · 0.65
FieldsMethod · 0.65

Tested by

no test coverage detected