time.err 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <sql-statement>
  2. --
  3. -- TIME
  4. --
  5. CREATE TABLE TIME_TBL (f1 time(2));
  6. </sql-statement>
  7. <sql-statement>
  8. INSERT INTO TIME_TBL VALUES ('00:00');
  9. </sql-statement>
  10. <sql-statement>
  11. INSERT INTO TIME_TBL VALUES ('01:00');
  12. </sql-statement>
  13. <sql-statement>
  14. -- as of 7.4, timezone spec should be accepted and ignored
  15. INSERT INTO TIME_TBL VALUES ('02:03 PST');
  16. </sql-statement>
  17. -stdin-:<main>: Fatal: Execution
  18. -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
  19. -- as of 7.4, timezone spec should be accepted and ignored
  20. ^
  21. -stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type time: "02:03 PST"
  22. -- as of 7.4, timezone spec should be accepted and ignored
  23. ^
  24. <sql-statement>
  25. INSERT INTO TIME_TBL VALUES ('11:59 EDT');
  26. </sql-statement>
  27. -stdin-:<main>: Fatal: Execution
  28. -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
  29. INSERT INTO TIME_TBL VALUES ('11:59 EDT');
  30. ^
  31. -stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type time: "11:59 EDT"
  32. INSERT INTO TIME_TBL VALUES ('11:59 EDT');
  33. ^
  34. <sql-statement>
  35. INSERT INTO TIME_TBL VALUES ('12:00');
  36. </sql-statement>
  37. <sql-statement>
  38. INSERT INTO TIME_TBL VALUES ('12:01');
  39. </sql-statement>
  40. <sql-statement>
  41. INSERT INTO TIME_TBL VALUES ('23:59');
  42. </sql-statement>
  43. <sql-statement>
  44. INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
  45. </sql-statement>
  46. <sql-statement>
  47. INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
  48. </sql-statement>
  49. -stdin-:<main>: Fatal: Execution
  50. -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
  51. INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
  52. ^
  53. -stdin-:<main>:1:1: Fatal: ERROR: time zone "america/new_york" not recognized
  54. INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
  55. ^
  56. <sql-statement>
  57. INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
  58. </sql-statement>
  59. -stdin-:<main>: Fatal: Execution
  60. -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
  61. INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
  62. ^
  63. -stdin-:<main>:1:1: Fatal: ERROR: time zone "america/new_york" not recognized
  64. INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
  65. ^
  66. <sql-statement>
  67. -- this should fail (the timezone offset is not known)
  68. INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York');
  69. </sql-statement>
  70. -stdin-:<main>: Fatal: Execution
  71. -stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
  72. -- this should fail (the timezone offset is not known)
  73. ^
  74. -stdin-:<main>:1:1: Fatal: ERROR: time zone "america/new_york" not recognized
  75. -- this should fail (the timezone offset is not known)
  76. ^
  77. <sql-statement>
  78. SELECT f1 AS "Time" FROM TIME_TBL;
  79. </sql-statement>
  80. <sql-statement>
  81. SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
  82. </sql-statement>
  83. <sql-statement>
  84. SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07';
  85. </sql-statement>
  86. <sql-statement>
  87. SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00';
  88. </sql-statement>
  89. <sql-statement>
  90. SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
  91. </sql-statement>
  92. <sql-statement>
  93. -- Check edge cases
  94. SELECT '23:59:59.999999'::time;
  95. </sql-statement>
  96. <sql-statement>
  97. SELECT '23:59:59.9999999'::time; -- rounds up
  98. </sql-statement>
  99. <sql-statement>
  100. SELECT '23:59:60'::time; -- rounds up
  101. </sql-statement>
  102. <sql-statement>
  103. SELECT '24:00:00'::time; -- allowed
  104. </sql-statement>
  105. <sql-statement>
  106. SELECT '24:00:00.01'::time; -- not allowed
  107. </sql-statement>
  108. -stdin-:<main>: Fatal: Execution
  109. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  110. SELECT '24:00:00.01'::time; -- not allowed
  111. ^
  112. -stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "24:00:00.01"
  113. SELECT '24:00:00.01'::time; -- not allowed
  114. ^
  115. <sql-statement>
  116. SELECT '23:59:60.01'::time; -- not allowed
  117. </sql-statement>
  118. -stdin-:<main>: Fatal: Execution
  119. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  120. SELECT '23:59:60.01'::time; -- not allowed
  121. ^
  122. -stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "23:59:60.01"
  123. SELECT '23:59:60.01'::time; -- not allowed
  124. ^
  125. <sql-statement>
  126. SELECT '24:01:00'::time; -- not allowed
  127. </sql-statement>
  128. -stdin-:<main>: Fatal: Execution
  129. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  130. SELECT '24:01:00'::time; -- not allowed
  131. ^
  132. -stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "24:01:00"
  133. SELECT '24:01:00'::time; -- not allowed
  134. ^
  135. <sql-statement>
  136. SELECT '25:00:00'::time; -- not allowed
  137. </sql-statement>
  138. -stdin-:<main>: Fatal: Execution
  139. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  140. SELECT '25:00:00'::time; -- not allowed
  141. ^
  142. -stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "25:00:00"
  143. SELECT '25:00:00'::time; -- not allowed
  144. ^
  145. <sql-statement>
  146. --
  147. -- TIME simple math
  148. --
  149. -- We now make a distinction between time and intervals,
  150. -- and adding two times together makes no sense at all.
  151. -- Leave in one query to show that it is rejected,
  152. -- and do the rest of the testing in horology.sql
  153. -- where we do mixed-type arithmetic. - thomas 2000-12-02
  154. SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
  155. </sql-statement>
  156. <sql-statement>
  157. --
  158. -- test EXTRACT
  159. --
  160. SELECT EXTRACT(MICROSECOND FROM TIME '2020-05-26 13:30:25.575401');
  161. </sql-statement>
  162. <sql-statement>
  163. SELECT EXTRACT(MILLISECOND FROM TIME '2020-05-26 13:30:25.575401');
  164. </sql-statement>
  165. <sql-statement>
  166. SELECT EXTRACT(SECOND FROM TIME '2020-05-26 13:30:25.575401');
  167. </sql-statement>
  168. <sql-statement>
  169. SELECT EXTRACT(MINUTE FROM TIME '2020-05-26 13:30:25.575401');
  170. </sql-statement>
  171. <sql-statement>
  172. SELECT EXTRACT(HOUR FROM TIME '2020-05-26 13:30:25.575401');
  173. </sql-statement>
  174. <sql-statement>
  175. SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401'); -- error
  176. </sql-statement>
  177. -stdin-:<main>: Fatal: Execution
  178. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  179. SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401'); -- error
  180. ^
  181. -stdin-:<main>:1:1: Fatal: ERROR: "time" units "day" not recognized
  182. SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401'); -- error
  183. ^
  184. <sql-statement>
  185. SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401'); -- error
  186. </sql-statement>
  187. -stdin-:<main>: Fatal: Execution
  188. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  189. SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401'); -- error
  190. ^
  191. -stdin-:<main>:1:1: Fatal: ERROR: "time" units "fortnight" not recognized
  192. SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401'); -- error
  193. ^
  194. <sql-statement>
  195. SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401'); -- error
  196. </sql-statement>
  197. -stdin-:<main>: Fatal: Execution
  198. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  199. SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401'); -- error
  200. ^
  201. -stdin-:<main>:1:1: Fatal: ERROR: "time" units "timezone" not recognized
  202. SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401'); -- error
  203. ^
  204. <sql-statement>
  205. SELECT EXTRACT(EPOCH FROM TIME '2020-05-26 13:30:25.575401');
  206. </sql-statement>
  207. <sql-statement>
  208. -- date_part implementation is mostly the same as extract, so only
  209. -- test a few cases for additional coverage.
  210. SELECT date_part('microsecond', TIME '2020-05-26 13:30:25.575401');
  211. </sql-statement>
  212. <sql-statement>
  213. SELECT date_part('millisecond', TIME '2020-05-26 13:30:25.575401');
  214. </sql-statement>
  215. <sql-statement>
  216. SELECT date_part('second', TIME '2020-05-26 13:30:25.575401');
  217. </sql-statement>
  218. <sql-statement>
  219. SELECT date_part('epoch', TIME '2020-05-26 13:30:25.575401');
  220. </sql-statement>