MCPcopy Create free account
hub / github.com/dolthub/doltgresql / getRootFromContextForDatabase

Function getRootFromContextForDatabase

core/context.go:92–106  ·  view source on GitHub ↗

getRootFromContextForDatabase returns the working session's root from the context for a specific database, along with the session.

(ctx *sql.Context, database string)

Source from the content-addressed store, hash-verified

90
91// getRootFromContextForDatabase returns the working session's root from the context for a specific database, along with the session.
92func 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

Calls

no outgoing calls

Tested by

no test coverage detected