GetCurrentDatabaseOwner gets the role of the current database.
(ctx context.Context)
| 768 | |
| 769 | // GetCurrentDatabaseOwner gets the role of the current database. |
| 770 | func (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. |
| 787 | func (d *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) { |
no test coverage detected