MCPcopy Create free account
hub / github.com/Percona-Lab/mysql_random_data_load / NewTable

Function NewTable

tableparser/tableparser.go:127–154  ·  view source on GitHub ↗
(db *sql.DB, schema, tableName string)

Source from the content-addressed store, hash-verified

125}
126
127func NewTable(db *sql.DB, schema, tableName string) (*Table, error) {
128 table := &Table{
129 Schema: url.QueryEscape(schema),
130 Name: url.QueryEscape(tableName),
131 conn: db,
132 }
133
134 var err error
135 table.Indexes, err = getIndexes(db, table.Schema, table.Name)
136 if err != nil {
137 return nil, err
138 }
139 table.Constraints, err = getConstraints(db, table.Schema, table.Name)
140 if err != nil {
141 return nil, err
142 }
143 table.Triggers, err = getTriggers(db, table.Schema, table.Name)
144 if err != nil {
145 return nil, err
146 }
147
148 err = table.parse()
149 if err != nil {
150 return nil, err
151 }
152 table.conn = nil // to save memory since it is not going to be used again
153 return table, nil
154}
155
156func (t *Table) parse() error {
157 // +--------------------------- field type

Callers 1

TestParseFunction · 0.85

Calls 4

parseMethod · 0.95
getIndexesFunction · 0.85
getConstraintsFunction · 0.85
getTriggersFunction · 0.85

Tested by 1

TestParseFunction · 0.68