noisepage icon indicating copy to clipboard operation
noisepage copied to clipboard

Fixed length VARCHAR isn't enforced

Open mbutrovich opened this issue 4 years ago • 0 comments

Bug Report

Summary

We don't check whether incoming VARCHAR values adhere to the length limit.

Expected Behavior

Postgres:

matt=# create table foo (name varchar(3));
CREATE TABLE
Time: 14.160 ms
matt=# insert into foo values ('andy');
ERROR:  value too long for type character varying(3)
Time: 1.514 ms

Actual Behavior

NoisePage:

noisepage=# create table foo (name varchar(3));
CREATE TABLE
Time: 126.967 ms
noisepage=# insert into foo values ('andy');
INSERT 0 1
Time: 64.881 ms

Proposed Solution

I suspect this should be resolved in the binder. It has access to the query arguments (or prepared statement arguments) and access to the Catalog to check the schema. We should confirm what stage Postgres enforces this at if possible, and then return the same error code.

mbutrovich avatar Dec 07 '20 19:12 mbutrovich