int2vector.slt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. # 🔬🔬 int2vector
  10. query T
  11. SELECT '1'::int2vector::text
  12. ----
  13. 1
  14. query T
  15. SELECT '1'::text::int2vector::text
  16. ----
  17. 1
  18. query T
  19. SELECT '1'::pg_catalog.int2vector::text
  20. ----
  21. 1
  22. query T
  23. SELECT '1 2 3'::int2vector::text
  24. ----
  25. 1 2 3
  26. query T
  27. SELECT '1 2 3'::int2vector::int2[]::text
  28. ----
  29. {1,2,3}
  30. query T
  31. SELECT null::int2vector::text
  32. ----
  33. NULL
  34. query T
  35. SELECT null::int2vector::int2[]::text
  36. ----
  37. NULL
  38. query error invalid input syntax for type int2vector
  39. SELECT 'a'::int2vector::text
  40. query error CAST does not support casting from smallint\[\] to int2vector
  41. SELECT '{1,2,3}'::int2[]::int2vector::text
  42. query T
  43. SELECT ('1 2 3'::int2vector)[1]::text;
  44. ----
  45. 2
  46. query T
  47. SELECT ('1 2 3'::int2vector::int2[])[1]::text;
  48. ----
  49. 1
  50. query T
  51. SELECT ('1 2'::int2vector || '{3}'::int2[])::text;
  52. ----
  53. {1,2,3}
  54. query T
  55. SELECT ('{1,2}'::int2[] || '3'::int2vector)::text;
  56. ----
  57. {1,2,3}
  58. query T
  59. SELECT array_cat('1 2'::int2vector, '{3}'::int2[])::text;
  60. ----
  61. {1,2,3}
  62. query T
  63. SELECT array_cat('{1,2}'::int2[], '3'::int2vector)::text;
  64. ----
  65. {1,2,3}
  66. query I
  67. SELECT array_length('{1,2}'::int2[], 1);
  68. ----
  69. 2
  70. query I
  71. SELECT array_length('1 2'::int2vector, 1);
  72. ----
  73. 2
  74. query T
  75. SELECT ('{1 2 3, 4 5 6}'::int2vector[])[2]::text;
  76. ----
  77. 4 5 6
  78. query T
  79. SELECT ('{1 2 3, 4 5 6}'::int2vector[])[2][1]::text;
  80. ----
  81. NULL
  82. query T
  83. SELECT (('{1 2 3, 4 5 6}'::int2vector[])[2])[1]::text;
  84. ----
  85. 5
  86. query T
  87. SELECT ARRAY (SELECT * FROM (VALUES ('1 2'::INT2VECTOR), ('3 4')))::text;
  88. ----
  89. {"1 2","3 4"}
  90. query TII
  91. SELECT
  92. l.b::text, l.a, r.a
  93. FROM
  94. (
  95. SELECT
  96. 5 AS a,
  97. ARRAY (SELECT * FROM (VALUES ('1 2'::INT2VECTOR), ('3 4')))
  98. AS b
  99. )
  100. AS l
  101. JOIN (SELECT 6 AS a, '{1 2, 3 4}'::INT2VECTOR[] AS b) AS r ON
  102. l.b = r.b;
  103. ----
  104. {"1 2","3 4"}
  105. 5
  106. 6