typeof.slt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #
  10. # This file is derived from the logic test suite in CockroachDB. The
  11. # original file was retrieved on June 10, 2019 from:
  12. #
  13. # The original source code is subject to the terms of the Apache
  14. # 2.0 license, a copy of which can be found in the LICENSE file at the
  15. # root of this repository.
  16. query error could not determine data type of parameter \$1
  17. SELECT pg_typeof($1)
  18. query T
  19. SELECT pg_typeof('1')
  20. ----
  21. unknown
  22. query T
  23. SELECT pg_typeof(text '1')
  24. ----
  25. text
  26. query T
  27. SELECT pg_typeof(1)
  28. ----
  29. integer
  30. query T
  31. SELECT pg_typeof(1.0)
  32. ----
  33. numeric
  34. # Custom types
  35. statement ok
  36. CREATE TYPE int4_list AS LIST (ELEMENT TYPE = int4)
  37. statement ok
  38. CREATE TYPE int4_list_list AS LIST (ELEMENT TYPE = int4_list)
  39. statement ok
  40. CREATE TYPE composite AS (a int, b text, c float8);
  41. query T
  42. SELECT pg_typeof('{1}'::int4 list)
  43. ----
  44. integer list
  45. query T
  46. SELECT pg_typeof('{1}'::int4_list)
  47. ----
  48. int4_list
  49. query T
  50. SELECT pg_typeof('{{1}}'::int4 list list)
  51. ----
  52. integer list list
  53. query T
  54. SELECT pg_typeof('{{1}}'::int4_list_list)
  55. ----
  56. int4_list_list
  57. query T
  58. SELECT pg_typeof('{{1}}'::int4_list list)
  59. ----
  60. int4_list list
  61. query T
  62. SELECT pg_typeof((1,'abc',2.0)::composite);
  63. ----
  64. composite
  65. statement ok
  66. CREATE SCHEMA other;
  67. statement ok
  68. CREATE TYPE other.composite AS (a text, b text, c float8);
  69. query T
  70. SELECT pg_typeof(ROW('1', '2', 2.0)::composite)
  71. ----
  72. composite
  73. query T
  74. SELECT pg_typeof(ROW('1', '2', 2.0)::other.composite)
  75. ----
  76. other.composite
  77. query T
  78. SELECT pg_typeof(ARRAY[1::uint2])
  79. ----
  80. uint2[]
  81. query T
  82. SELECT pg_typeof(ARRAY[1::uint4])
  83. ----
  84. uint4[]
  85. query T
  86. SELECT pg_typeof(ARRAY[1::uint8])
  87. ----
  88. uint8[]
  89. query T
  90. SELECT pg_typeof(ARRAY[1::mz_timestamp])
  91. ----
  92. mz_timestamp[]
  93. query T
  94. SELECT pg_typeof(ARRAY[mz_internal.make_mz_aclitem('u1', 'u2', 'CREATE')])
  95. ----
  96. mz_aclitem[]