portals.pt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # Test portal max rows. Note that even though there are two rows returned,
  2. # even after the second execute a portal suspended is returned, not
  3. # command complete.
  4. send
  5. Query {"query": "BEGIN"}
  6. Parse {"query": "VALUES (1), (2)"}
  7. Bind
  8. Execute {"max_rows": 1}
  9. Execute {"max_rows": 1}
  10. Execute {"max_rows": 1}
  11. Execute {"max_rows": 1}
  12. Query {"query": "COMMIT"}
  13. Sync
  14. ----
  15. until
  16. ReadyForQuery
  17. ReadyForQuery
  18. ReadyForQuery
  19. ----
  20. CommandComplete {"tag":"BEGIN"}
  21. ReadyForQuery {"status":"T"}
  22. ParseComplete
  23. BindComplete
  24. DataRow {"fields":["1"]}
  25. PortalSuspended
  26. DataRow {"fields":["2"]}
  27. PortalSuspended
  28. CommandComplete {"tag":"SELECT 0"}
  29. CommandComplete {"tag":"SELECT 0"}
  30. CommandComplete {"tag":"COMMIT"}
  31. ReadyForQuery {"status":"I"}
  32. ReadyForQuery {"status":"I"}
  33. # Test when max rows > number of total rows.
  34. send
  35. Query {"query": "BEGIN"}
  36. Parse {"query": "VALUES (1), (2)"}
  37. Bind
  38. Execute {"max_rows": 3}
  39. Execute {"max_rows": 3}
  40. Execute {"max_rows": 3}
  41. Query {"query": "COMMIT"}
  42. Sync
  43. ----
  44. until
  45. ReadyForQuery
  46. ReadyForQuery
  47. ReadyForQuery
  48. ----
  49. CommandComplete {"tag":"BEGIN"}
  50. ReadyForQuery {"status":"T"}
  51. ParseComplete
  52. BindComplete
  53. DataRow {"fields":["1"]}
  54. DataRow {"fields":["2"]}
  55. CommandComplete {"tag":"SELECT 2"}
  56. CommandComplete {"tag":"SELECT 0"}
  57. CommandComplete {"tag":"SELECT 0"}
  58. CommandComplete {"tag":"COMMIT"}
  59. ReadyForQuery {"status":"I"}
  60. ReadyForQuery {"status":"I"}
  61. # Verify correct Close error.
  62. send
  63. Query {"query": "CLOSE c"}
  64. ----
  65. until
  66. ReadyForQuery
  67. ----
  68. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"cursor \"c\" does not exist"}]}
  69. ReadyForQuery {"status":"I"}
  70. # Verify portal reuse errors.
  71. send
  72. Query {"query": "BEGIN; DECLARE c CURSOR FOR SELECT 1; DECLARE c CURSOR FOR SELECT 1"}
  73. Query {"query": "ROLLBACK"}
  74. ----
  75. until
  76. ReadyForQuery
  77. ReadyForQuery
  78. ----
  79. CommandComplete {"tag":"BEGIN"}
  80. CommandComplete {"tag":"DECLARE CURSOR"}
  81. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
  82. ReadyForQuery {"status":"E"}
  83. CommandComplete {"tag":"ROLLBACK"}
  84. ReadyForQuery {"status":"I"}
  85. send
  86. Query {"query": "BEGIN; DECLARE c CURSOR FOR SELECT 1"}
  87. Parse {"query": "VALUES (1), (2)"}
  88. Bind {"portal": "c"}
  89. Sync
  90. Query {"query": "ROLLBACK"}
  91. ----
  92. until
  93. ReadyForQuery
  94. ReadyForQuery
  95. ReadyForQuery
  96. ----
  97. CommandComplete {"tag":"BEGIN"}
  98. CommandComplete {"tag":"DECLARE CURSOR"}
  99. ReadyForQuery {"status":"T"}
  100. ParseComplete
  101. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
  102. ReadyForQuery {"status":"E"}
  103. CommandComplete {"tag":"ROLLBACK"}
  104. ReadyForQuery {"status":"I"}
  105. send
  106. Query {"query": "BEGIN"}
  107. Parse {"query": "VALUES (1), (2)"}
  108. Bind {"portal": "c"}
  109. Sync
  110. Query {"query": "DECLARE c CURSOR FOR SELECT 1"}
  111. Query {"query": "ROLLBACK"}
  112. ----
  113. until
  114. ReadyForQuery
  115. ReadyForQuery
  116. ReadyForQuery
  117. ReadyForQuery
  118. ----
  119. CommandComplete {"tag":"BEGIN"}
  120. ReadyForQuery {"status":"T"}
  121. ParseComplete
  122. BindComplete
  123. ReadyForQuery {"status":"T"}
  124. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
  125. ReadyForQuery {"status":"E"}
  126. CommandComplete {"tag":"ROLLBACK"}
  127. ReadyForQuery {"status":"I"}
  128. # Test that multiple execute commands are permitted in the same implicit
  129. # transaction.
  130. send
  131. Parse {"query": "VALUES (1), (2)"}
  132. Bind {"portal": "c"}
  133. Execute {"portal": "c", "max_rows": 1}
  134. Execute {"portal": "c", "max_rows": 1}
  135. Sync
  136. ----
  137. until
  138. ReadyForQuery
  139. ----
  140. ParseComplete
  141. BindComplete
  142. DataRow {"fields":["1"]}
  143. PortalSuspended
  144. DataRow {"fields":["2"]}
  145. PortalSuspended
  146. ReadyForQuery {"status":"I"}
  147. # Verify that portals (cursors) are destroyed after a Sync command commits
  148. # the implicit transaction.
  149. send
  150. Parse {"query": "VALUES (1), (2)"}
  151. Bind {"portal": "c"}
  152. Execute {"portal": "c", "max_rows": 1}
  153. Sync
  154. Query {"query": "FETCH c"}
  155. ----
  156. until
  157. ReadyForQuery
  158. ReadyForQuery
  159. ----
  160. ParseComplete
  161. BindComplete
  162. DataRow {"fields":["1"]}
  163. PortalSuspended
  164. ReadyForQuery {"status":"I"}
  165. ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"cursor \"c\" does not exist"}]}
  166. ReadyForQuery {"status":"I"}