prepare.pt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # Test PREPARE, EXECUTE, DEALLOCATE.
  2. send
  3. Query {"query": "DROP TABLE IF EXISTS t"}
  4. ----
  5. until ignore=NoticeResponse
  6. ReadyForQuery
  7. ----
  8. CommandComplete {"tag":"DROP TABLE"}
  9. ReadyForQuery {"status":"I"}
  10. send
  11. Query {"query": "DEALLOCATE ALL"}
  12. Query {"query": "DEALLOCATE a"}
  13. Query {"query": "EXECUTE a"}
  14. ----
  15. until
  16. ReadyForQuery
  17. ReadyForQuery
  18. ----
  19. CommandComplete {"tag":"DEALLOCATE ALL"}
  20. ReadyForQuery {"status":"I"}
  21. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
  22. ReadyForQuery {"status":"I"}
  23. # TOOD(mjibson): Teach scl.rs how to return error codes.
  24. until no_error_fields
  25. ReadyForQuery
  26. ----
  27. ErrorResponse {"fields":[]}
  28. ReadyForQuery {"status":"I"}
  29. send
  30. Query {"query": "PREPARE a AS SELECT 1"}
  31. Query {"query": "PREPARE a AS SELECT 1"}
  32. Query {"query": "EXECUTE a"}
  33. Query {"query": "EXECUTE a"}
  34. Query {"query": "DEALLOCATE a"}
  35. Query {"query": "EXECUTE a"}
  36. Query {"query": "DEALLOCATE a"}
  37. ----
  38. until
  39. ReadyForQuery
  40. ReadyForQuery
  41. ReadyForQuery
  42. ReadyForQuery
  43. ReadyForQuery
  44. ----
  45. CommandComplete {"tag":"PREPARE"}
  46. ReadyForQuery {"status":"I"}
  47. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P05"},{"typ":"M","value":"prepared statement \"a\" already exists"}]}
  48. ReadyForQuery {"status":"I"}
  49. RowDescription {"fields":[{"name":"?column?"}]}
  50. DataRow {"fields":["1"]}
  51. CommandComplete {"tag":"SELECT 1"}
  52. ReadyForQuery {"status":"I"}
  53. RowDescription {"fields":[{"name":"?column?"}]}
  54. DataRow {"fields":["1"]}
  55. CommandComplete {"tag":"SELECT 1"}
  56. ReadyForQuery {"status":"I"}
  57. CommandComplete {"tag":"DEALLOCATE"}
  58. ReadyForQuery {"status":"I"}
  59. # TOOD(mjibson): Teach scl.rs how to return error codes.
  60. until no_error_fields
  61. ReadyForQuery
  62. ----
  63. ErrorResponse {"fields":[]}
  64. ReadyForQuery {"status":"I"}
  65. until
  66. ReadyForQuery
  67. ----
  68. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
  69. ReadyForQuery {"status":"I"}
  70. send
  71. Query {"query": "PREPARE a AS SELECT 1"}
  72. Query {"query": "EXECUTE a"}
  73. Query {"query": "DEALLOCATE ALL"}
  74. Query {"query": "EXECUTE a"}
  75. ----
  76. until
  77. ReadyForQuery
  78. ReadyForQuery
  79. ReadyForQuery
  80. ----
  81. CommandComplete {"tag":"PREPARE"}
  82. ReadyForQuery {"status":"I"}
  83. RowDescription {"fields":[{"name":"?column?"}]}
  84. DataRow {"fields":["1"]}
  85. CommandComplete {"tag":"SELECT 1"}
  86. ReadyForQuery {"status":"I"}
  87. CommandComplete {"tag":"DEALLOCATE ALL"}
  88. ReadyForQuery {"status":"I"}
  89. # TOOD(mjibson): Teach scl.rs how to return error codes.
  90. until no_error_fields
  91. ReadyForQuery
  92. ----
  93. ErrorResponse {"fields":[]}
  94. ReadyForQuery {"status":"I"}
  95. send
  96. Query {"query": "PREPARE a AS SELECT 1 + $2"}
  97. Query {"query": "PREPARE a AS SELECT 1 + $1"}
  98. Query {"query": "EXECUTE a"}
  99. Query {"query": "EXECUTE a ('a')"}
  100. Query {"query": "EXECUTE a (1, 2)"}
  101. Query {"query": "EXECUTE a (1)"}
  102. Query {"query": "DEALLOCATE a"}
  103. ----
  104. until no_error_fields
  105. ReadyForQuery
  106. ReadyForQuery
  107. ReadyForQuery
  108. ReadyForQuery
  109. ReadyForQuery
  110. ReadyForQuery
  111. ReadyForQuery
  112. ----
  113. ErrorResponse {"fields":[]}
  114. ReadyForQuery {"status":"I"}
  115. CommandComplete {"tag":"PREPARE"}
  116. ReadyForQuery {"status":"I"}
  117. ErrorResponse {"fields":[]}
  118. ReadyForQuery {"status":"I"}
  119. ErrorResponse {"fields":[]}
  120. ReadyForQuery {"status":"I"}
  121. ErrorResponse {"fields":[]}
  122. ReadyForQuery {"status":"I"}
  123. RowDescription {"fields":[{"name":"?column?"}]}
  124. DataRow {"fields":["2"]}
  125. CommandComplete {"tag":"SELECT 1"}
  126. ReadyForQuery {"status":"I"}
  127. CommandComplete {"tag":"DEALLOCATE"}
  128. ReadyForQuery {"status":"I"}
  129. send
  130. Query {"query": "CREATE TABLE t (i INT)"}
  131. Query {"query": "INSERT INTO t VALUES (1)"}
  132. Query {"query": "PREPARE a AS SELECT * FROM t"}
  133. Query {"query": "EXECUTE a"}
  134. Query {"query": "DROP TABLE t"}
  135. Query {"query": "EXECUTE a"}
  136. Query {"query": "CREATE TABLE t (a TEXT, b FLOAT)"}
  137. Query {"query": "INSERT INTO t VALUES ('a', 3)"}
  138. Query {"query": "EXECUTE a"}
  139. Query {"query": "DEALLOCATE a"}
  140. ----
  141. # TODO(mjibson): Ignore RowDescription here, see desc.pt for why.
  142. until no_error_fields ignore=RowDescription
  143. ReadyForQuery
  144. ReadyForQuery
  145. ReadyForQuery
  146. ReadyForQuery
  147. ReadyForQuery
  148. ReadyForQuery
  149. ReadyForQuery
  150. ReadyForQuery
  151. ReadyForQuery
  152. ReadyForQuery
  153. ----
  154. CommandComplete {"tag":"CREATE TABLE"}
  155. ReadyForQuery {"status":"I"}
  156. CommandComplete {"tag":"INSERT 0 1"}
  157. ReadyForQuery {"status":"I"}
  158. CommandComplete {"tag":"PREPARE"}
  159. ReadyForQuery {"status":"I"}
  160. DataRow {"fields":["1"]}
  161. CommandComplete {"tag":"SELECT 1"}
  162. ReadyForQuery {"status":"I"}
  163. CommandComplete {"tag":"DROP TABLE"}
  164. ReadyForQuery {"status":"I"}
  165. ErrorResponse {"fields":[]}
  166. ReadyForQuery {"status":"I"}
  167. CommandComplete {"tag":"CREATE TABLE"}
  168. ReadyForQuery {"status":"I"}
  169. CommandComplete {"tag":"INSERT 0 1"}
  170. ReadyForQuery {"status":"I"}
  171. ErrorResponse {"fields":[]}
  172. ReadyForQuery {"status":"I"}
  173. CommandComplete {"tag":"DEALLOCATE"}
  174. ReadyForQuery {"status":"I"}