MCPcopy
hub / github.com/go-sql-driver/mysql / Exec

Method Exec

statement.go:54–98  ·  view source on GitHub ↗
(args []driver.Value)

Source from the content-addressed store, hash-verified

52}
53
54func (stmt *mysqlStmt) Exec(args []driver.Value) (driver.Result, error) {
55 if stmt.mc.closed.Load() {
56 return nil, driver.ErrBadConn
57 }
58 // Send command
59 err := stmt.writeExecutePacket(args)
60 if err != nil {
61 return nil, stmt.mc.markBadConn(err)
62 }
63
64 mc := stmt.mc
65 handleOk := stmt.mc.clearResult()
66
67 // Read Result
68 resLen, metadataFollows, err := handleOk.readResultSetHeaderPacket()
69 if err != nil {
70 return nil, err
71 }
72
73 if resLen > 0 {
74 // Columns
75 if metadataFollows && stmt.mc.extCapabilities&clientCacheMetadata != 0 {
76 // we can not skip column metadata because next stmt.Query() may use it.
77 if stmt.columns, err = mc.readColumns(resLen, stmt.columns); err != nil {
78 return nil, err
79 }
80 } else {
81 if err = mc.skipColumns(resLen); err != nil {
82 return nil, err
83 }
84 }
85
86 // Rows
87 if err = mc.skipRows(); err != nil {
88 return nil, err
89 }
90 }
91
92 if err := handleOk.discardResults(); err != nil {
93 return nil, err
94 }
95
96 copied := mc.result
97 return &copied, nil
98}
99
100func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
101 return stmt.query(args)

Callers 15

ExecContextMethod · 0.95
runTestsFunction · 0.45
runTestsParallelFunction · 0.45
mustExecMethod · 0.45
TestValuerWithValidationFunction · 0.45
TestTimestampMicrosFunction · 0.45
TestLoadDataFunction · 0.45
TestFailingCharsetFunction · 0.45
TestConcurrentFunction · 0.45
testDialErrorFunction · 0.45

Calls 8

writeExecutePacketMethod · 0.95
markBadConnMethod · 0.80
clearResultMethod · 0.80
readColumnsMethod · 0.80
skipColumnsMethod · 0.80
skipRowsMethod · 0.80
discardResultsMethod · 0.80

Tested by 15

runTestsFunction · 0.36
runTestsParallelFunction · 0.36
mustExecMethod · 0.36
TestValuerWithValidationFunction · 0.36
TestTimestampMicrosFunction · 0.36
TestLoadDataFunction · 0.36
TestFailingCharsetFunction · 0.36
TestConcurrentFunction · 0.36
testDialErrorFunction · 0.36
TestCustomDialFunction · 0.36