affected.pt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Test affected row counts.
  2. send
  3. Query {"query": "DROP TABLE IF EXISTS t"}
  4. Query {"query": "DROP TABLE IF EXISTS u"}
  5. ----
  6. until ignore=NoticeResponse
  7. ReadyForQuery
  8. ReadyForQuery
  9. ----
  10. CommandComplete {"tag":"DROP TABLE"}
  11. ReadyForQuery {"status":"I"}
  12. CommandComplete {"tag":"DROP TABLE"}
  13. ReadyForQuery {"status":"I"}
  14. send
  15. Query {"query": "CREATE TABLE t (i int)"}
  16. Query {"query": "INSERT INTO t VALUES (1), (1)"}
  17. Query {"query": "INSERT INTO t SELECT * FROM generate_series(1, 10)"}
  18. ----
  19. until
  20. ReadyForQuery
  21. ReadyForQuery
  22. ReadyForQuery
  23. ----
  24. CommandComplete {"tag":"CREATE TABLE"}
  25. ReadyForQuery {"status":"I"}
  26. CommandComplete {"tag":"INSERT 0 2"}
  27. ReadyForQuery {"status":"I"}
  28. CommandComplete {"tag":"INSERT 0 10"}
  29. ReadyForQuery {"status":"I"}
  30. # Our response to UPDATE reflects the number of rows changed by the operation;
  31. # not the number of rows processed by the operation as in PG
  32. send
  33. Query {"query": "UPDATE t SET i = i + 1"}
  34. ----
  35. # The preceding command only changes 3 rows, two of the rows that were 1 are now
  36. # 2, and one of the rows that was 1 is now 11. The remaining rows remain
  37. # unchanged from DD's perspective.
  38. until
  39. ReadyForQuery
  40. ----
  41. CommandComplete {"tag":"UPDATE 3"}
  42. ReadyForQuery {"status":"I"}
  43. send
  44. Query {"query": "CREATE TABLE u (i int, t text)"}
  45. Query {"query": "INSERT INTO u SELECT generate_series, generate_series::text FROM generate_series(1, 10)"}
  46. Query {"query": "UPDATE u SET i = i + 1"}
  47. ----
  48. # The preceding update changes all 10 rows because their column `t` values
  49. # remain unchanged, while the `i` values increment.
  50. until
  51. ReadyForQuery
  52. ReadyForQuery
  53. ReadyForQuery
  54. ----
  55. CommandComplete {"tag":"CREATE TABLE"}
  56. ReadyForQuery {"status":"I"}
  57. CommandComplete {"tag":"INSERT 0 10"}
  58. ReadyForQuery {"status":"I"}
  59. CommandComplete {"tag":"UPDATE 10"}
  60. ReadyForQuery {"status":"I"}