regproc.slt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Make sure that there are no functions with duplicate OIDs
  10. query I
  11. select oid from (select count(*) as cnt, oid from mz_catalog.mz_functions group by oid) where cnt>1
  12. ----
  13. # regproc
  14. query T
  15. SELECT 1::regproc
  16. ----
  17. 1
  18. query T
  19. SELECT 1::int4::regproc
  20. ----
  21. 1
  22. query T
  23. SELECT 1::oid::regproc
  24. ----
  25. 1
  26. query T
  27. SELECT 1::oid::regproc::oid
  28. ----
  29. 1
  30. query T
  31. SELECT '1'::regproc
  32. ----
  33. 1
  34. query T
  35. SELECT '1'::pg_catalog.regproc
  36. ----
  37. 1
  38. query T
  39. SELECT '1'::regproc::text
  40. ----
  41. 1
  42. query T
  43. SELECT 'now'::regproc::text
  44. ----
  45. now
  46. # These overflows their stack in debug mode
  47. # query T
  48. # SELECT 'now'::regproc::text::regproc
  49. # ----
  50. # 1299
  51. #
  52. # query T
  53. # SELECT 'now'::regproc::text::regproc::text
  54. # ----
  55. # now
  56. #
  57. # query T
  58. # SELECT 'pg_catalog.now'::regproc::text::regproc::text
  59. # ----
  60. # now
  61. query T
  62. SELECT 'now'::regproc
  63. ----
  64. 1299
  65. query T
  66. SELECT 'now'::regproc::oid
  67. ----
  68. 1299
  69. query T
  70. SELECT NULL::regproc::text
  71. ----
  72. NULL
  73. query error db error: ERROR: more than one function named "max"
  74. SELECT 'max'::regproc
  75. query T
  76. SELECT min(oid::int)::regproc::text FROM mz_objects WHERE name = 'max';
  77. ----
  78. pg_catalog.max
  79. query error db error: ERROR: function "dne" does not exist
  80. SELECT 'dne'::regproc
  81. query T
  82. SELECT 'array_in'::regproc
  83. ----
  84. 750
  85. query B
  86. SELECT 750 = 'array_in'::regproc
  87. ----
  88. true
  89. statement ok
  90. CREATE TABLE text_to_regproc (a text);
  91. statement ok
  92. INSERT INTO text_to_regproc VALUES (NULL), ('array_in');
  93. query I
  94. SELECT a::regproc FROM text_to_regproc ORDER BY a
  95. ----
  96. 750
  97. NULL
  98. # Regression for 9194
  99. query I
  100. select 'now'::regproc::oid::regproc
  101. ----
  102. 1299
  103. # Check that we handle functions and types w/ same name
  104. query T
  105. SELECT '1178'::regproc::text;
  106. ----
  107. pg_catalog.date
  108. query T
  109. SELECT '1082'::regtype::text;
  110. ----
  111. date
  112. query error db error: ERROR: more than one function named "date"
  113. SELECT 'date'::regproc::text;
  114. query T
  115. SELECT 'date'::regtype::text;
  116. ----
  117. date
  118. statement ok
  119. CREATE TYPE array_length AS LIST (ELEMENT TYPE = int4);
  120. query T
  121. SELECT 'array_length'::regproc::text;
  122. ----
  123. array_length
  124. query T
  125. SELECT 'array_length'::regtype::text;
  126. ----
  127. array_length
  128. # Check that we handle functions and classes w/ same name
  129. statement ok
  130. CREATE TABLE quote_ident();
  131. query T
  132. SELECT 'quote_ident'::regclass::text;
  133. ----
  134. quote_ident
  135. query T
  136. SELECT 'quote_ident'::regproc::text;
  137. ----
  138. quote_ident
  139. # ensure that all existing functions can be cast to their respective names (materialize#9199)
  140. statement OK
  141. select oid, oid::regproc::text from (select oid from mz_catalog.mz_functions)
  142. # Regression for 18020
  143. query B
  144. SELECT returns_set FROM mz_functions WHERE name in ('generate_series', 'generate_subscripts', 'regexp_extract', 'jsonb_array_elements', 'jsonb_array_elements_text', 'jsonb_each', 'jsonb_each_text', 'jsonb_object_keys');
  145. ----
  146. true
  147. true
  148. true
  149. true
  150. true
  151. true
  152. true
  153. true
  154. true
  155. true
  156. true
  157. true
  158. true
  159. # ensure that catalog functions can be resolved if the active database is invalid
  160. statement OK
  161. SET database TO ''
  162. query T
  163. SELECT 'array_in'::regproc
  164. ----
  165. 750