desc.pt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Test changing a table mid query by another connection.
  2. # This is incompatible with Postgres beacuse they, reasonably, block on DROP
  3. # TABLE while a portal is bound to it.
  4. send
  5. Query {"query": "DROP TABLE IF EXISTS t"}
  6. ----
  7. until ignore=NoticeResponse
  8. ReadyForQuery
  9. ----
  10. CommandComplete {"tag":"DROP TABLE"}
  11. ReadyForQuery {"status":"I"}
  12. send
  13. Query {"query": "CREATE TABLE t (a INT)"}
  14. Parse {"name": "q", "query": "SELECT * FROM t"}
  15. Bind {"statement": "q", "portal": "p"}
  16. Describe {"variant": "P", "name": "p"}
  17. Sync
  18. ----
  19. until
  20. ReadyForQuery
  21. ReadyForQuery
  22. ----
  23. CommandComplete {"tag":"CREATE TABLE"}
  24. ReadyForQuery {"status":"I"}
  25. ParseComplete
  26. BindComplete
  27. RowDescription {"fields":[{"name":"a"}]}
  28. ReadyForQuery {"status":"I"}
  29. # Bind then change the table in another connection. Don't send Sync because
  30. # that closes the portal.
  31. send
  32. Bind {"statement": "q", "portal": "p"}
  33. ----
  34. # Unfortunately we cannot wait for BindComplete because it doesn't show up
  35. # until Sync, so this is probably a bit racey. We need the bind to get processed before the `DROP TABLE`. We sleep first
  36. # to increase the chances of this.
  37. send conn=writer
  38. Query {"query": "SELECT mz_unsafe.mz_sleep(1)"}
  39. Query {"query": "DROP TABLE t"}
  40. Query {"query": "CREATE TABLE t (c INT, b INT)"}
  41. Query {"query": "INSERT INTO t VALUES (1, 2)"}
  42. ----
  43. until conn=writer
  44. ReadyForQuery
  45. ReadyForQuery
  46. ReadyForQuery
  47. ReadyForQuery
  48. ----
  49. RowDescription {"fields":[{"name":"?column?"}]}
  50. DataRow {"fields":["NULL"]}
  51. CommandComplete {"tag":"SELECT 1"}
  52. ReadyForQuery {"status":"I"}
  53. CommandComplete {"tag":"DROP TABLE"}
  54. ReadyForQuery {"status":"I"}
  55. CommandComplete {"tag":"CREATE TABLE"}
  56. ReadyForQuery {"status":"I"}
  57. CommandComplete {"tag":"INSERT 0 1"}
  58. ReadyForQuery {"status":"I"}
  59. # Executing (which in mz starts the portal) will now complain that the plan
  60. # changed before execution can start.
  61. # See: materialize#11214, materialize#11258
  62. send
  63. Execute {"portal": "p"}
  64. Sync
  65. ----
  66. until
  67. ReadyForQuery
  68. ----
  69. BindComplete
  70. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
  71. ReadyForQuery {"status":"I"}