@@ -10084,23 +10084,23 @@ void CreateRelationNode::defineQueryColumns(thread_db* tdbb, DsqlCompilerScratch
1008410084 sourceField = sourceFieldNode->dsqlField;
1008510085 }
1008610086
10087- if (sourceField && !fb_utils::implicit_domain(sourceField->fieldSource.object.c_str()))
10087+ if (sourceField)
10088+ {
10089+ METD_get_domain(dsqlScratch->getTransaction(), field, sourceField->fieldSource);
10090+ field->flags &= ~(FLD_computed | FLD_system);
10091+ }
10092+
10093+ if (sourceField &&
10094+ !fb_utils::implicit_domain(sourceField->fieldSource.object.c_str()) &&
10095+ !(!(field->flags & FLD_nullable) && (desc.dsc_flags & DSC_nullable)))
1008810096 {
1008910097 // Named domain: reference it directly, like "<field name> <domain name>".
1009010098 field->typeOfName = sourceField->fieldSource;
1009110099 field->fullDomain = true;
10092- field->flags |= sourceField->flags & FLD_nullable;
1009310100 }
1009410101 else
1009510102 {
10096- if (sourceField)
10097- {
10098- // Implicit domain: copy its exact stored type (precision, charset, collation,
10099- // dimensions, etc.) instead of sharing the domain object itself.
10100- METD_get_domain(dsqlScratch->getTransaction(), field, sourceField->fieldSource);
10101- field->flags &= ~(FLD_computed | FLD_system);
10102- }
10103- else
10103+ if (!sourceField)
1010410104 {
1010510105 field->dtype = desc.dsc_dtype;
1010610106 field->length = desc.dsc_length;
@@ -10128,12 +10128,12 @@ void CreateRelationNode::defineQueryColumns(thread_db* tdbb, DsqlCompilerScratch
1012810128 else if (desc.isExact() && field->subType != dsc_num_type_none)
1012910129 field->setExactPrecision();
1013010130 }
10131-
10132- field->flags &= ~FLD_nullable;
10133- if (desc.dsc_flags & DSC_nullable)
10134- field->flags |= FLD_nullable;
1013510131 }
1013610132
10133+ field->flags &= ~FLD_nullable;
10134+ if (desc.dsc_flags & DSC_nullable)
10135+ field->flags |= FLD_nullable;
10136+
1013710137 if (!(field->flags & FLD_nullable))
1013810138 {
1013910139 auto& notNullConstraint = clause->constraints.add();
0 commit comments