desc.pt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # Test that prepared statement describe works if the underlying SQL object is
  2. # replaced.
  3. send
  4. Query {"query": "DROP TABLE IF EXISTS t"}
  5. ----
  6. until ignore=NoticeResponse
  7. ReadyForQuery
  8. ----
  9. CommandComplete {"tag":"DROP TABLE"}
  10. ReadyForQuery {"status":"I"}
  11. send
  12. Query {"query": "CREATE TABLE t (a INT)"}
  13. Parse {"name": "q", "query": "SELECT * FROM t"}
  14. Describe {"variant": "S", "name": "q"}
  15. Sync
  16. ----
  17. until
  18. ReadyForQuery
  19. ReadyForQuery
  20. ----
  21. CommandComplete {"tag":"CREATE TABLE"}
  22. ReadyForQuery {"status":"I"}
  23. ParseComplete
  24. ParameterDescription {"parameters":[]}
  25. RowDescription {"fields":[{"name":"a"}]}
  26. ReadyForQuery {"status":"I"}
  27. # Recreating the underlying object is fine.
  28. send
  29. Query {"query": "DROP TABLE t"}
  30. Query {"query": "CREATE TABLE t (a INT)"}
  31. Describe {"variant": "S", "name": "q"}
  32. Sync
  33. Query {"query": "EXECUTE q"}
  34. ----
  35. until
  36. ReadyForQuery
  37. ReadyForQuery
  38. ReadyForQuery
  39. ReadyForQuery
  40. ----
  41. CommandComplete {"tag":"DROP TABLE"}
  42. ReadyForQuery {"status":"I"}
  43. CommandComplete {"tag":"CREATE TABLE"}
  44. ReadyForQuery {"status":"I"}
  45. ParameterDescription {"parameters":[]}
  46. RowDescription {"fields":[{"name":"a"}]}
  47. ReadyForQuery {"status":"I"}
  48. RowDescription {"fields":[{"name":"a"}]}
  49. CommandComplete {"tag":"SELECT 0"}
  50. ReadyForQuery {"status":"I"}
  51. # But changing it will break the prepared statement.
  52. send
  53. Query {"query": "DROP TABLE t"}
  54. Query {"query": "CREATE TABLE t (c INT, b INT)"}
  55. ----
  56. until
  57. ReadyForQuery
  58. ReadyForQuery
  59. ----
  60. CommandComplete {"tag":"DROP TABLE"}
  61. ReadyForQuery {"status":"I"}
  62. CommandComplete {"tag":"CREATE TABLE"}
  63. ReadyForQuery {"status":"I"}
  64. send
  65. Describe {"variant": "S", "name": "q"}
  66. Sync
  67. ----
  68. # Postgres sends a ParameterDescription, but that seems wrong, so ignore it and
  69. # just look for the error.
  70. until ignore=ParameterDescription
  71. ReadyForQuery
  72. ----
  73. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
  74. ReadyForQuery {"status":"I"}
  75. send
  76. Query {"query": "EXECUTE q"}
  77. ----
  78. # TODO(mjibson): We send a RowDescription before the error. This isn't wrong
  79. # (feels about as wrong as Postgres sending ParameterDescription above), it's
  80. # just not what Postgres does, so ignore it to be in sync with them.
  81. until ignore=RowDescription
  82. ReadyForQuery
  83. ----
  84. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
  85. ReadyForQuery {"status":"I"}
  86. # Changing it back fixes it.
  87. send
  88. Query {"query": "DROP TABLE t"}
  89. Query {"query": "CREATE TABLE t (a INT)"}
  90. Describe {"variant": "S", "name": "q"}
  91. Sync
  92. Query {"query": "EXECUTE q"}
  93. ----
  94. until
  95. ReadyForQuery
  96. ReadyForQuery
  97. ReadyForQuery
  98. ReadyForQuery
  99. ----
  100. CommandComplete {"tag":"DROP TABLE"}
  101. ReadyForQuery {"status":"I"}
  102. CommandComplete {"tag":"CREATE TABLE"}
  103. ReadyForQuery {"status":"I"}
  104. ParameterDescription {"parameters":[]}
  105. RowDescription {"fields":[{"name":"a"}]}
  106. ReadyForQuery {"status":"I"}
  107. RowDescription {"fields":[{"name":"a"}]}
  108. CommandComplete {"tag":"SELECT 0"}
  109. ReadyForQuery {"status":"I"}
  110. # Check portals.
  111. send
  112. Bind {"statement": "q", "portal": "p"}
  113. Describe {"variant": "P", "name": "p"}
  114. Sync
  115. ----
  116. until
  117. ReadyForQuery
  118. ----
  119. BindComplete
  120. RowDescription {"fields":[{"name":"a"}]}
  121. ReadyForQuery {"status":"I"}
  122. send
  123. Query {"query": "DROP TABLE t"}
  124. Query {"query": "CREATE TABLE t (c INT, b INT)"}
  125. ----
  126. until
  127. ReadyForQuery
  128. ReadyForQuery
  129. ----
  130. CommandComplete {"tag":"DROP TABLE"}
  131. ReadyForQuery {"status":"I"}
  132. CommandComplete {"tag":"CREATE TABLE"}
  133. ReadyForQuery {"status":"I"}
  134. # Can't bind because the statement changed.
  135. send
  136. Bind {"statement": "q", "portal": "p"}
  137. Sync
  138. ----
  139. until
  140. ReadyForQuery
  141. ----
  142. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
  143. ReadyForQuery {"status":"I"}
  144. # Changing it back fixes it.
  145. send
  146. Query {"query": "DROP TABLE t"}
  147. Query {"query": "CREATE TABLE t (a INT)"}
  148. Bind {"statement": "q", "portal": "p"}
  149. Describe {"variant": "P", "name": "p"}
  150. Sync
  151. ----
  152. until
  153. ReadyForQuery
  154. ReadyForQuery
  155. ReadyForQuery
  156. ----
  157. CommandComplete {"tag":"DROP TABLE"}
  158. ReadyForQuery {"status":"I"}
  159. CommandComplete {"tag":"CREATE TABLE"}
  160. ReadyForQuery {"status":"I"}
  161. BindComplete
  162. RowDescription {"fields":[{"name":"a"}]}
  163. ReadyForQuery {"status":"I"}