Skip to content

Instantly share code, notes, and snippets.

@franckverrot
Created June 28, 2015 08:25
Show Gist options
  • Save franckverrot/8406d7d720730fe6fbbe to your computer and use it in GitHub Desktop.
Save franckverrot/8406d7d720730fe6fbbe to your computer and use it in GitHub Desktop.
Verbose constraint violation message
λ /usr/local/pgsql/bin/psql
psql (9.5devel)
Type "help" for help.
[email protected]/49942=# create table foo(bar varchar(4), baz varchar(2));
CREATE TABLE
[email protected]/49942=# insert into foo values ('foo!', 'ok');
INSERT 0 1
[email protected]/49942=# insert into foo values ('foo2!', 'ok');
ERROR: value too long for bar of type character varying(4)
[email protected]/49942=# insert into foo values ('foo!', 'ok2');
ERROR: value too long for baz of type character varying(2)
[email protected]/49942=#
λ psql
psql (9.4.1)
Type "help" for help.
[email protected]/50053=# create table foo(bar varchar(4), baz varchar(2));
CREATE TABLE
[email protected]/50053=# insert into foo values ('foo!', 'ok');
INSERT 0 1
[email protected]/50053=# insert into foo values ('foo2!', 'ok');
ERROR: value too long for type character varying(4)
[email protected]/50053=# insert into foo values ('foo!', 'ok2');
ERROR: value too long for type character varying(2)
[email protected]/50053=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment