MCPcopy
hub / github.com/radondb/radon / TestInsertPlanSort

Function TestInsertPlanSort

src/planner/insert_plan_test.go:144–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

142}
143
144func TestInsertPlanSort(t *testing.T) {
145 results := []string{
146 `{
147 "RawQuery": "insert into sbtest.A(id, b, c) values(1,2,3), (23,4,5), (65536,3,4)",
148 "Partitions": [
149 {
150 "Query": "insert into sbtest.A5(id, b, c) values (65536, 3, 4)",
151 "Backend": "backend6",
152 "Range": "[0-512)"
153 },
154 {
155 "Query": "insert into sbtest.A6(id, b, c) values (1, 2, 3), (23, 4, 5)",
156 "Backend": "backend6",
157 "Range": "[512-4096)"
158 }
159 ]
160}`,
161 `{
162 "RawQuery": "insert into sbtest.A(id, b, c) values(65536,3,4), (23,4,5), (1,2,3)",
163 "Partitions": [
164 {
165 "Query": "insert into sbtest.A5(id, b, c) values (65536, 3, 4)",
166 "Backend": "backend6",
167 "Range": "[0-512)"
168 },
169 {
170 "Query": "insert into sbtest.A6(id, b, c) values (23, 4, 5), (1, 2, 3)",
171 "Backend": "backend6",
172 "Range": "[512-4096)"
173 }
174 ]
175}`,
176 }
177 querys := []string{
178 "insert into sbtest.A(id, b, c) values(1,2,3), (23,4,5), (65536,3,4)",
179 "insert into sbtest.A(id, b, c) values(65536,3,4), (23,4,5), (1,2,3)",
180 }
181
182 log := xlog.NewStdLog(xlog.Level(xlog.PANIC))
183 database := "sbtest"
184
185 route, cleanup := router.MockNewRouter(log)
186 defer cleanup()
187
188 err := route.CreateDatabase(database)
189 assert.Nil(t, err)
190 err = route.AddForTest(database, router.MockTableDeadLockConfig())
191 assert.Nil(t, err)
192 for i, query := range querys {
193 node, err := sqlparser.Parse(query)
194 assert.Nil(t, err)
195 plan := NewInsertPlan(log, database, query, node.(*sqlparser.Insert), route)
196
197 // plan build
198 {
199 err := plan.Build()
200 assert.Nil(t, err)
201 got := plan.JSON()

Callers

nothing calls this directly

Calls 7

BuildMethod · 0.95
JSONMethod · 0.95
TypeMethod · 0.95
SizeMethod · 0.95
NewInsertPlanFunction · 0.85
CreateDatabaseMethod · 0.80
AddForTestMethod · 0.80

Tested by

no test coverage detected