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

Function GetDoltTableFromContext

core/context.go:169–190  ·  view source on GitHub ↗

GetDoltTableFromContext returns the Dolt table from the context. Returns nil if no table was found.

(ctx *sql.Context, tableName doltdb.TableName)

Source from the content-addressed store, hash-verified

167
168// GetDoltTableFromContext returns the Dolt table from the context. Returns nil if no table was found.
169func GetDoltTableFromContext(ctx *sql.Context, tableName doltdb.TableName) (*doltdb.Table, error) {
170 _, root, err := GetRootFromContext(ctx)
171 if err != nil {
172 return nil, err
173 }
174
175 var table *doltdb.Table
176 if tableName.Schema == "" {
177 _, table, _, err = resolve.Table(ctx, root, tableName.Name)
178 if err != nil {
179 return nil, err
180 }
181 } else {
182 table, _, err = root.GetTable(ctx, tableName)
183 }
184
185 if err != nil {
186 return nil, err
187 }
188
189 return table, nil
190}
191
192// GetSqlDatabaseFromContext returns the database from the context. Uses the context's current database if an empty
193// string is provided. Returns nil if the database was not found.

Callers

nothing calls this directly

Calls 3

GetRootFromContextFunction · 0.85
GetTableMethod · 0.80
TableMethod · 0.45

Tested by

no test coverage detected