|
| 1 | +// Copyright 2025 Dolthub, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package queries |
| 16 | + |
| 17 | +import "github.com/dolthub/go-mysql-server/sql" |
| 18 | + |
| 19 | +var ShowTableStatusQueries = []QueryTest{ |
| 20 | + { |
| 21 | + Query: `SHOW TABLE STATUS FROM mydb`, |
| 22 | + Expected: []sql.Row{ |
| 23 | + {"mytable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 24 | + {"othertable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 25 | + }, |
| 26 | + }, |
| 27 | + { |
| 28 | + Query: `SHOW TABLE STATUS LIKE '%table'`, |
| 29 | + Expected: []sql.Row{ |
| 30 | + {"mytable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 31 | + {"othertable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 32 | + }, |
| 33 | + }, |
| 34 | + { |
| 35 | + Query: `SHOW TABLE STATUS FROM mydb LIKE 'othertable'`, |
| 36 | + Expected: []sql.Row{ |
| 37 | + {"othertable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 38 | + }, |
| 39 | + }, |
| 40 | + { |
| 41 | + Query: `SHOW TABLE STATUS WHERE Name = 'mytable'`, |
| 42 | + Expected: []sql.Row{ |
| 43 | + {"mytable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 44 | + }, |
| 45 | + }, |
| 46 | + { |
| 47 | + Query: `SHOW TABLE STATUS`, |
| 48 | + Expected: []sql.Row{ |
| 49 | + {"mytable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 50 | + {"othertable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 51 | + }, |
| 52 | + }, |
| 53 | + { |
| 54 | + Query: `SHOW TABLE STATUS FROM mydb LIKE 'othertable'`, |
| 55 | + Expected: []sql.Row{ |
| 56 | + {"othertable", "InnoDB", "10", "Fixed", uint64(3), uint64(88), uint64(264), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, ""}, |
| 57 | + }, |
| 58 | + }, |
| 59 | +} |
| 60 | + |
| 61 | +var ShowTableStatusScripts = []ScriptTest{ |
| 62 | + { |
| 63 | + Name: "filter table status by comment", |
| 64 | + SetUpScript: []string{ |
| 65 | + "create table table_with_comment(pk int, c0 int) comment = 'table comment'", |
| 66 | + }, |
| 67 | + Assertions: []ScriptTestAssertion{ |
| 68 | + { |
| 69 | + Query: `show table status where comment = 'table comment'`, |
| 70 | + Expected: []sql.Row{ |
| 71 | + {"table_with_comment", "InnoDB", "10", "Fixed", uint64(0), uint64(0), uint64(0), uint64(0), int64(0), int64(0), nil, nil, nil, nil, "utf8mb4_0900_bin", nil, nil, "table comment"}, |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + }, |
| 76 | +} |
0 commit comments