Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Hardware parameters: Apple Silicon (arm64)\n- OS type: macOS\n- Others: freshly built local standalone instance; SQL endpoint 127.0.0.1:6001Actual Behavior
CREATE DATABASE ... CLONE succeeds but produces a partial database: stored procedures in the source database are silently omitted. In all 3 independent runs, the ordinary table control was cloned with its row, while the target had no matching row in mo_catalog.mo_stored_procedure and CALL .p_answer() failed with ERROR 1122 (HY000): function p_answer doesn't exist.
Expected Behavior
A database clone should preserve database-scoped stored procedures. After cloning, the target should contain p_answer and CALL .p_answer() should return 42, just as it does in the source.
Steps to Reproduce
1. Start MatrixOne main at 1d7b6311ce91df0968da435bb405f3d68137c595.\n2. Run:\n\nDROP DATABASE IF EXISTS clone_proc_dst;\nDROP DATABASE IF EXISTS clone_proc_src;\nCREATE DATABASE clone_proc_src;\nCREATE TABLE clone_proc_src.control_t(id INT PRIMARY KEY);\nINSERT INTO clone_proc_src.control_t VALUES (1);\nCREATE PROCEDURE clone_proc_src.p_answer() 'begin select 42 as answer; end';\nCALL clone_proc_src.p_answer();\nCREATE DATABASE clone_proc_dst CLONE clone_proc_src;\nSELECT COUNT(*) FROM clone_proc_dst.control_t;\nSELECT db, name FROM mo_catalog.mo_stored_procedure\n WHERE db = 'clone_proc_dst' AND name = 'p_answer';\nCALL clone_proc_dst.p_answer();
Activity
Ariznawlll commentedon Aug 13, 2026
Additional scope verification on the same build (1d7b631): this is not limited to the CREATE DATABASE CLONE spelling or stored procedures.
DATA BRANCH CREATE DATABASE also omits procedures: 3 independent source/destination pairs each retained a control table (COUNT(*) = 1) but had 0 matching rows in mo_catalog.mo_stored_procedure; CALL on every destination failed with ERROR 1122.
SQL functions are also omitted by CREATE DATABASE CLONE: for three unique functions (each source function returned 42 for input 41), each destination retained its control table (COUNT(*) = 1) but had 0 matching function metadata rows. Calling each destination function failed with ERROR 20105 (not supported: function or operator ...).
Both routes therefore appear to share the database-clone source collector's table-only metadata scope. External tables were separately checked 3/3 and correctly rejected atomically (no destination database left behind), so that behavior is unrelated.
Ariznawlll commentedon Aug 13, 2026
Additional compatibility impact: a view that depends on a database SQL function makes the clone fail entirely.
For three independent source/destination pairs, each source contained:
SELECT * FROM source.vreturned42for every run. EachCREATE DATABASE destination CLONE sourcethen failed while restoring the view with:The destination database count was
0after every failure, so rollback is atomic. This confirms that database routines need to be restored before dependent views; otherwise a source database that is internally valid cannot be cloned at all.gouhongshen commentedon Aug 17, 2026
PR #27169 is trying to fix this issue.
gouhongshen commentedon Aug 21, 2026
PR #27169 has merged and is awaiting manual validation. The issue remains open.
Ariznawlll commentedon Aug 25, 2026
测试版本
main22b91fe986b269d24a6b8816eafdd1fa6327c8e1原问题验证
连续 3 轮执行含普通表和
p_answer()的源库 clone;目标目录与调用结果均正确。Happy Path 覆盖
42,目标表行数为1。mo_stored_procedure的p_answer计数为1。Unhappy Path 覆盖
1007;sentinel 行保持(9,'keep'),未产生源表。白盒验证
pkg/frontend的过程恢复与 clone routine 聚焦测试连续 3 次通过。回归测试
已加入 motr PR #121:
12_git4data.issue_27091_clone_stored_procedure,repeat 3 为63/63断言通过。测试证据
修复提交
344d852ac已包含在 main;以上黑盒、白盒与 MOTR 均在该版本完成。测试结论
测试通过。