Any idea how this can happen? I have a table which I created by loading data into it via the COPY command. A column in it was declared as VARCHAR(200). I dumped the table, moved it to another computer, and tried to restore it but got an error
pg_restore: [archiver (db)] Error from TOC entry 4154; 0 259261 TABLE DATA foo postgres
pg_restore: [archiver (db)] COPY failed for table "foo": ERROR: value too long for type character varying(200)
CONTEXT: COPY foo, line 22556, column a: "สถานีอนามัยเฉลิมพระเกียรติพระบาทส?..."
pg_restore: *** aborted because of error
Update: Interestingly, when I check the length of this record, I get 82, safely less than 200.
SELECT Length(a) FROM foo WHERE a LIKE 'สถานีอนามัยเฉลิมพระเกียรติพระบาทส%'
82
And, yes, the new database is also set with UTF8 encoding.
SELECT Length(a, 'UTF8') FROM foo...
return? What version of PostgreSQL? Same version on both computers?SELECT Length(a, 'UTF8') FROM foo...
gives an error that the function doesn't exist. The source Pg is 9.0.4 and the target Pg is 9.1.2.length(a::bytea, 'UTF8')
.