When creating a temporary table from a SELECT statement (CTAS) while the Orca optimizer is enabled (optimizer=on), columns cast to a specific varchar length (e.g., varchar(50)) are incorrectly created as unbounded character varying.
Symptoms:
varchar(50) should truncate values exceeding 50 characters.character varying without a length limit.LIMIT clause is added to the SELECT statement or if the Orca optimizer is disabled.The issue is caused by a product defect in the Orca optimizer's logic for processing column metadata during CREATE TABLE AS SELECT operations.
Under certain execution plans, the optimizer fails to propagate the specific length constraints of character varying types to the table definition unless explicitly triggered by other operators like LIMIT.
A permanent fix for this defect is scheduled for a future release.
Workaround: To ensure varchar limits are correctly defined in the resulting table, use one of the following methods:
LIMIT row in the SELECT statement used for table creation.