MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetCurrentDatabaseOwner

Method GetCurrentDatabaseOwner

backend/plugin/db/pg/pg.go:770–784  ·  view source on GitHub ↗

GetCurrentDatabaseOwner gets the role of the current database.

(ctx context.Context)

Source from the content-addressed store, hash-verified

768
769// GetCurrentDatabaseOwner gets the role of the current database.
770func (d *Driver) GetCurrentDatabaseOwner(ctx context.Context) (string, error) {
771 const query = `
772 SELECT
773 u.rolname
774 FROM
775 pg_roles AS u JOIN pg_database AS d ON (d.datdba = u.oid)
776 WHERE
777 d.datname = current_database();
778 `
779 var owner string
780 if err := d.db.QueryRowContext(ctx, query).Scan(&owner); err != nil {
781 return "", err
782 }
783 return owner, nil
784}
785
786// QueryConn queries a SQL statement in a given connection.
787func (d *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) {

Callers 2

OpenMethod · 0.95
ExecuteMethod · 0.95

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 1

ScanMethod · 0.80

Tested by

no test coverage detected