MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / getPgType

Method getPgType

plugins/destination/postgresql/client/client.go:185–209  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

183}
184
185func (c *Client) getPgType(ctx context.Context) (pgType, error) {
186 var version string
187 var typ pgType
188 err := c.conn.QueryRow(ctx, "select version()").Scan(&version)
189 if err != nil {
190 return typ, err
191 }
192 versionTokens := strings.Split(version, " ")
193 if len(versionTokens) == 0 {
194 return typ, fmt.Errorf("failed to parse version string %s", version)
195 }
196 name := strings.ToLower(versionTokens[0])
197 switch name {
198 case "postgresql":
199 typ = pgTypePostgreSQL
200 case "cockroachdb":
201 typ = pgTypeCockroachDB
202 case "cratedb":
203 typ = pgTypeCrateDB
204 default:
205 return typ, fmt.Errorf("unknown database type %s", name)
206 }
207
208 return typ, nil
209}
210
211func (c *Client) hasPgVectorConfig() bool {
212 return c.spec != nil && c.pgType == pgTypePostgreSQL && c.spec.HasPgVectorConfig()

Callers 1

NewFunction · 0.95

Calls 3

ScanMethod · 0.80
ErrorfMethod · 0.80
QueryRowMethod · 0.65

Tested by

no test coverage detected