I fiddled with this problem for a little while, and I think that the
problem is that the index which is created behind-the-scenes to
implement the PRIMARY KEY constraint goes through a different
code path than the normal index which is created by CREATE INDEX.
In the case of
create table t (x varchar(1000));
create index t_ix on t;
we go through CreateIndexNode.makeConstantAction, where there
is code that looks at the size of the columns in the index and notices
that we need a larger page size for this index, and chooses the
larger page size automatically.
But in the case from the issue description
create table t (x varchar(1000) primary key)
we instead go through TableElementNode.genIndexAction,
which doesn't have any logic to notice that a larger page size is needed.
I think that we could fix this problem by arranging for the colInfos data
from the CreateTableNode to be passed through to TableElementNode.genIndexAction
so that it can check the size of the columns and see if it needs to create the
PRIMARY KEY index with a larger page size.
Ideally, it would be great if we could somehow share this code between
CreateIndexNode and TableElementNode, but I think that the data
structures are unfortunately not very similar so we may end up
with two bits of code instead.
At least, I can start by writing a second bit of code and demonstrating
that it fixes the problem, and then we can try to figure out how to share
the code and only compute the index's needed page size once.