Skip to content

Commit 75e4cd3

Browse files
authored
Query for PG Aurora variant without errors (#3596)
1 parent 7bf6c7d commit 75e4cd3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

flow/connectors/postgres/postgres.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,14 +1727,18 @@ func (c *PostgresConnector) GetVersion(ctx context.Context) (string, error) {
17271727
}
17281728

17291729
func (c *PostgresConnector) GetDatabaseVariant(ctx context.Context) (protos.DatabaseVariant, error) {
1730-
// First check for Aurora by trying to call aurora_version()
1731-
var auroraVersion string
1732-
err := c.conn.QueryRow(ctx, "SELECT aurora_version()").Scan(&auroraVersion)
1733-
if err == nil && auroraVersion != "" {
1730+
// First check for Aurora by trying to look up aurora_version()
1731+
var isAurora bool
1732+
err := c.conn.QueryRow(ctx, "SELECT to_regproc('pg_catalog.aurora_version') IS NOT NULL").Scan(&isAurora)
1733+
if err != nil {
1734+
c.logger.Error("failed to query to_regproc for determining variant", slog.Any("error", err))
1735+
return protos.DatabaseVariant_VARIANT_UNKNOWN, err
1736+
}
1737+
if isAurora {
17341738
return protos.DatabaseVariant_AWS_AURORA, nil
17351739
}
17361740

1737-
// If aurora_version() fails, it's not Aurora - continue checking other variants
1741+
// It's not Aurora - continue checking other variants
17381742
settingsQuery := `
17391743
SELECT name, setting
17401744
FROM pg_settings

0 commit comments

Comments
 (0)