sqltabs icon indicating copy to clipboard operation
sqltabs copied to clipboard

Strange character varying max length value

Open zodo opened this issue 7 years ago • 1 comments

  1. Get table info via sql tabs and CTRL + I

legal_name character varying (259) display_name character varying (84)

  1. Get table info via plain psql

legal_name character varying(255) display_name character varying(80)

Why the max lengths were increased by 4?

zodo avatar Dec 20 '17 08:12 zodo

Hi, thank you for reporting the bug! The length of the field is taken from the pg_attribute.atttypmod. And apparently for varchar datatype it represents the actual length of the field which is 4 bytes longer than the value which can be stored there. The first 4 bytes store the length of the field and the rest the data itself. The proper behaviour should be the same as in psql. To be fixed..

sasha-alias avatar Dec 21 '17 07:12 sasha-alias