Skip to content

Commit 7ea980b

Browse files
committed
Truncate to DECIMAL(38, scale) if width > 38
1 parent 03eaed7 commit 7ea980b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/postgres_utils.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ LogicalType PostgresUtils::TypeToLogicalType(optional_ptr<PostgresTransaction> t
130130
} else if (pgtypename == "numeric") {
131131
auto width = ((type_info.type_modifier - sizeof(int32_t)) >> 16) & 0xffff;
132132
auto scale = (((type_info.type_modifier - sizeof(int32_t)) & 0x7ff) ^ 1024) - 1024;
133-
if (type_info.type_modifier == -1 || width < 0 || scale < 0 || width > 38) {
133+
if (type_info.type_modifier == -1 || width < 0 || scale < 0) {
134134
// fallback to double
135135
postgres_type.info = PostgresTypeAnnotation::NUMERIC_AS_DOUBLE;
136136
return LogicalType::DOUBLE;
137137
}
138+
if (width > 38) {
139+
postgres_type.info = PostgresTypeAnnotation::NUMERIC_TRUNCATE;
140+
return LogicalType::DECIMAL(38, scale);
141+
}
138142
return LogicalType::DECIMAL(width, scale);
139143
} else if (pgtypename == "char" || pgtypename == "bpchar") {
140144
postgres_type.info = PostgresTypeAnnotation::FIXED_LENGTH_CHAR;

0 commit comments

Comments
 (0)