sasha-alias / sqltabs

Rich SQL client for Postgresql, MySQL, MS SQL, Amazon Redshift, Google Firebase (Firestore)
https://www.sqltabs.com
GNU General Public License v3.0
803 stars 57 forks source link

Strange character varying max length value #112

Open zodo opened 6 years ago

zodo commented 6 years ago
  1. Get table info via sql tabs and CTRL + I

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

  2. Get table info via plain psql

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

Why the max lengths were increased by 4?

sasha-alias commented 6 years ago

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..