MCPcopy
hub / github.com/sqlc-dev/sqlc / StartPostgreSQLServer

Function StartPostgreSQLServer

internal/sqltest/native/postgres.go:19–42  ·  view source on GitHub ↗

StartPostgreSQLServer starts an existing PostgreSQL installation natively (without Docker).

(ctx context.Context)

Source from the content-addressed store, hash-verified

17
18// StartPostgreSQLServer starts an existing PostgreSQL installation natively (without Docker).
19func StartPostgreSQLServer(ctx context.Context) (string, error) {
20 if err := Supported(); err != nil {
21 return "", err
22 }
23 if postgresURI != "" {
24 return postgresURI, nil
25 }
26 value, err, _ := postgresFlight.Do("postgresql", func() (interface{}, error) {
27 uri, err := startPostgreSQLServer(ctx)
28 if err != nil {
29 return "", err
30 }
31 postgresURI = uri
32 return uri, nil
33 })
34 if err != nil {
35 return "", err
36 }
37 data, ok := value.(string)
38 if !ok {
39 return "", fmt.Errorf("returned value was not a string")
40 }
41 return data, nil
42}
43
44func startPostgreSQLServer(ctx context.Context) (string, error) {
45 // Standard URI for test PostgreSQL

Callers 3

TestExpandPostgreSQLFunction · 0.92
TestReplayFunction · 0.92
postgreSQLFunction · 0.92

Calls 2

SupportedFunction · 0.85
startPostgreSQLServerFunction · 0.70

Tested by 2

TestExpandPostgreSQLFunction · 0.74
TestReplayFunction · 0.74