MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / escapePostgresConfLiteral

Function escapePostgresConfLiteral

pkg/configfile/configfile.go:50–52  ·  view source on GitHub ↗

escapePostgresConfLiteral escapes an arbitrary string so it can be used as a value in a PostgreSQL configuration file, wrapped in single quotes. pq.QuoteLiteral is unsuitable here: it emits ` E'...'` when the value contains a backslash, and the PostgreSQL config parser does not recognise the `E'...

(value string)

Source from the content-addressed store, hash-verified

48// contains a backslash, and the PostgreSQL config parser does not recognise
49// the `E'...'` syntax.
50func escapePostgresConfLiteral(value string) string {
51 return "'" + postgresConfLiteralReplacer.Replace(value) + "'"
52}
53
54// UpdatePostgresConfigurationFile search and replace options in a Postgres configuration file.
55// If any managedOptions is passed, it will be removed unless present in the options map.

Callers 2

configfile_test.goFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected