Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: fix postgres handling on special chars in schema name (#15340)
Vincent Huangd12e3ad23f17
diff --git a/backend/plugin/db/pg/pg.go b/backend/plugin/db/pg/pg.goindex bd05dbc560..5bf0a66513 100644--- a/backend/plugin/db/pg/pg.go+++ b/backend/plugin/db/pg/pg.go@@ -682,9 +682,12 @@ func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement sreturn nil, err}+ // Sanitize the schema name by escaping any quotes.+ safeSchemeName := strings.ReplaceAll(queryContext.Schema, "\"", "\"\"")+// If the queryContext.Schema is not empty, set the search path for the database connection to the specified schema.if queryContext.Schema != "" {- if _, err := conn.ExecContext(ctx, fmt.Sprintf("SET search_path TO %s;", queryContext.Schema)); err != nil {+ if _, err := conn.ExecContext(ctx, fmt.Sprintf(`SET search_path TO "%s";`, safeSchemeName)); err != nil {return nil, err}}