char-varchar-multibyte.td 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. # Make sure that multibyte characters are handled correctly
  11. #
  12. #
  13. > CREATE TABLE ct (f1 CHAR(20));
  14. > INSERT INTO ct VALUES ('това е текст');
  15. > SELECT * FROM ct;
  16. "това е текст "
  17. > CREATE TABLE vt (f1 VARCHAR(20));
  18. > INSERT INTO vt VALUES ('това е текст');
  19. > SELECT * FROM vt;
  20. "това е текст"
  21. > SELECT LENGTH(f1) FROM ct;
  22. 12
  23. > SELECT OCTET_LENGTH(f1) FROM ct;
  24. 30
  25. > SELECT LENGTH(f1) FROM vt;
  26. 12
  27. > SELECT OCTET_LENGTH(f1) FROM vt;
  28. 22
  29. ! INSERT INTO vt VALUES ('това е текст това е текст');
  30. contains:value too long for type character varying(20)
  31. ! INSERT INTO ct VALUES ('това е текст това е текст');
  32. contains:value too long for type character(20)