8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 21:23:04 +01:00

Fixed CORE-5194 - Invalid computed by definition generated by isql -x.

This commit is contained in:
Adriano dos Santos Fernandes 2016-04-11 22:36:28 -03:00
parent 62ac4f0b5a
commit ee2456d3d7
2 changed files with 25 additions and 4 deletions

View File

@ -390,6 +390,27 @@ void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relati
field->subType = desc.dsc_sub_type;
}
if (field->precision == 0 && field->scale != 0)
{
switch (field->dtype)
{
case dtype_short:
field->precision = 4;
break;
case dtype_long:
field->precision = 9;
break;
case dtype_int64:
field->precision = 18;
break;
default:
fb_assert(false);
}
}
dsqlScratch->resetContextStack();
// Generate the source text.

View File

@ -1816,7 +1816,7 @@ bool ISQL_printNumericType(const char* fieldName, const int fieldType, const int
// We are ODS >= 10 and could be any Dialect
FOR FLD1 IN RDB$FIELDS WITH
FLD1.RDB$FIELD_NAME EQ fieldName
AND FLD1.RDB$FIELD_PRECISION NOT MISSING
AND NOT FLD1.RDB$FIELD_PRECISION EQ 0
// We are Dialect >=3 since FIELD_PRECISION is non-NULL
if (FLD1.RDB$FIELD_SUB_TYPE > 0 && FLD1.RDB$FIELD_SUB_TYPE <= MAX_INTSUBTYPES)
@ -1847,13 +1847,13 @@ bool ISQL_printNumericType(const char* fieldName, const int fieldType, const int
case INTEGER:
isqlGlob.printf("NUMERIC(9, %d)", -fieldScale);
break;
case BIGINT:
isqlGlob.printf("NUMERIC(18, %d)", -fieldScale);
break;
case DOUBLE_PRECISION:
isqlGlob.printf("NUMERIC(15, %d)", -fieldScale);
break;
default:
// BIGINT can't happen there because it would have an explicit field_precision
// and then would be caught by the previous if().
fb_assert(fieldType != BIGINT);
isqlGlob.printf("%s", Column_types[i].type_name);
}
}