12conflict_update.mql 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. -- ============================================================
  2. -- On Conflict Update 测试
  3. -- ============================================================
  4. -- 1. 条件更新 (已知新版server on conflict 表达式读取已有值问题)
  5. insert into /test/aaa/test_conflict (c_name, c_value, c_count) values ('conflict_update_001', 100, 1) on conflict update c_value=200, c_count=c_count+1
  6. /**
  7. onerror(continue,'ReviseFieldValue')
  8. **/
  9. ;
  10. -- 首次插入,c_count=1
  11. select c_value, c_count from /test/aaa/test_conflict where c_name='conflict_update_001'
  12. /**
  13. output()
  14. **/
  15. ;
  16. -- 2. 再次冲突更新 c_count 应累加 (已知新版server on conflict 表达式读取已有值问题)
  17. insert into /test/aaa/test_conflict (c_name, c_value, c_count) values ('conflict_update_001', 300, 5) on conflict update c_value=c_value, c_count=c_count+c_count
  18. /**
  19. onerror(continue)
  20. **/
  21. ;
  22. select c_value, c_count from /test/aaa/test_conflict where c_name='conflict_update_001'
  23. /**
  24. output()
  25. **/
  26. ;
  27. -- 3. 多字段 conflict update (已知新版server on conflict 表达式读取已有值问题)
  28. insert into /test/aaa/test_conflict (c_name, c_value, c_count) values ('conflict_update_002', 100, 1) on conflict update c_value=c_value+c_value, c_count=c_count+10
  29. /**
  30. onerror(continue)
  31. **/
  32. ;
  33. -- 首次
  34. select c_value, c_count from /test/aaa/test_conflict where c_name='conflict_update_002'
  35. /**
  36. output()
  37. **/
  38. ;
  39. -- 再次冲突 (已知新版server on conflict 表达式读取已有值问题)
  40. insert into /test/aaa/test_conflict (c_name, c_value, c_count) values ('conflict_update_002', 200, 5) on conflict update c_value=c_value+c_value, c_count=c_count+10
  41. /**
  42. onerror(continue)
  43. **/
  44. ;
  45. select c_value, c_count from /test/aaa/test_conflict where c_name='conflict_update_002'
  46. /**
  47. output()
  48. **/
  49. ;