getRootFromContextForDatabase returns the working session's root from the context for a specific database, along with the session.
(ctx *sql.Context, database string)
| 90 | |
| 91 | // getRootFromContextForDatabase returns the working session's root from the context for a specific database, along with the session. |
| 92 | func getRootFromContextForDatabase(ctx *sql.Context, database string) (*dsess.DoltSession, *RootValue, error) { |
| 93 | session := dsess.DSessFromSess(ctx.Session) |
| 94 | |
| 95 | if len(database) == 0 { |
| 96 | database = ctx.GetCurrentDatabase() |
| 97 | } |
| 98 | state, ok, err := session.LookupDbState(ctx, database) |
| 99 | if err != nil { |
| 100 | return nil, nil, err |
| 101 | } |
| 102 | if !ok { |
| 103 | return nil, nil, sql.ErrDatabaseNotFound.New(database) |
| 104 | } |
| 105 | return session, state.WorkingRoot().(*RootValue), nil |
| 106 | } |
| 107 | |
| 108 | // IsContextValid returns whether the context is valid for use with any of the functions in the package. If this is not |
| 109 | // false, then there's a high likelihood that the context is being used in a temporary scenario (such as setting up the |
no outgoing calls
no test coverage detected