清理
This commit is contained in:
1 parent
7600f0f9ed
commit
687c012841
8 files changed
+2
-194
No files matched your search
@@ -1,102 +0,0 @@
|
||||
-- ============================================================================
|
||||
-- ChuSQL DROP TABLE + 统计信息 手测脚本
|
||||
-- 用法:
|
||||
-- 1. 另开终端起 Rust server:cd chusql-storage && cargo run --bin chusql-storage
|
||||
-- 2. GHCi 里执行::script ghci-scripts/drop-table-test.ghci
|
||||
-- ============================================================================
|
||||
|
||||
:set -XOverloadedStrings
|
||||
|
||||
import ChuSQL.Storage
|
||||
import ChuSQL.Storage.IPC
|
||||
import ChuSQL.Model
|
||||
import ChuSQL.Engine
|
||||
import ChuSQL.Syntax.AST
|
||||
import ChuSQL.Syntax.Parser
|
||||
|
||||
-- 辅助:把一条 SQL 字符串跑到底
|
||||
let runSql sql = case parseQuery sql of { Left e -> putStrLn ("parse error: " ++ e); Right q -> runIPCStorage (runQueryM q) >>= print }
|
||||
|
||||
-- ============================================================================
|
||||
-- 2. 清场:如果 demo3 存在就删掉
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [2] cleanup"
|
||||
runSql "DROP TABLE demo3"
|
||||
|
||||
-- ============================================================================
|
||||
-- 3. 建表
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [3] CREATE TABLE"
|
||||
runSql "CREATE TABLE demo3 (id INT, name TEXT)"
|
||||
|
||||
-- ============================================================================
|
||||
-- 4. describe:列应为 id/name,行数应为 0
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [4] describe (row_count should be 0)"
|
||||
doDescribeTable "demo3"
|
||||
|
||||
-- ============================================================================
|
||||
-- 5. 空表能扫
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [5] scan empty table"
|
||||
runIPCStorage (scan "demo3")
|
||||
|
||||
-- ============================================================================
|
||||
-- 6. 插 3 行
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [6] INSERT 3 rows"
|
||||
runSql "INSERT INTO demo3 (id, name) VALUES (1, 'Alice')"
|
||||
runSql "INSERT INTO demo3 (id, name) VALUES (2, 'Bob')"
|
||||
runSql "INSERT INTO demo3 (id, name) VALUES (3, 'Carol')"
|
||||
|
||||
-- ============================================================================
|
||||
-- 7. describe:行数应为 3
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [7] describe (row_count should be 3)"
|
||||
doDescribeTable "demo3"
|
||||
|
||||
-- ============================================================================
|
||||
-- 8. 扫回三行
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [8] scan 3 rows"
|
||||
runIPCStorage (scan "demo3")
|
||||
|
||||
-- ============================================================================
|
||||
-- 9. SQL SELECT,走索引
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [9] SELECT WHERE id = 2"
|
||||
runSql "SELECT name FROM demo3 WHERE id = 2"
|
||||
|
||||
-- ============================================================================
|
||||
-- 10. 重复建表应报错
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [10] CREATE TABLE again (should fail)"
|
||||
runSql "CREATE TABLE demo3 (x INT)"
|
||||
|
||||
-- ============================================================================
|
||||
-- 11. 删表
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [11] DROP TABLE"
|
||||
runSql "DROP TABLE demo3"
|
||||
|
||||
-- ============================================================================
|
||||
-- 12. 删后再查,应报 unknown table
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [12a] scan after drop (should fail)"
|
||||
runIPCStorage (scan "demo3")
|
||||
putStrLn ">>> [12b] describe after drop (should fail)"
|
||||
doDescribeTable "demo3"
|
||||
|
||||
-- ============================================================================
|
||||
-- 13. 删不存在的表应报错
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [13] DROP TABLE nope (should fail)"
|
||||
runSql "DROP TABLE nope"
|
||||
|
||||
-- ============================================================================
|
||||
-- 14. 列出所有表,不应含 demo3
|
||||
-- ============================================================================
|
||||
putStrLn ">>> [14] list_tables"
|
||||
doListTables
|
||||
|
||||
putStrLn ">>> done. check chusql-storage/data/ for disk state"
|
||||
Reference in new issue
Block a user