Alvaro Herrera escribió:

> En términos de código, esa limitación de tamaño de conversión podría
> eliminarse ahora que Postgres tiene código reciente para manejar trozos
> de memoria grandes.

Como en el parche adjunto (que no sé si compila)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index bec54bb5cb..d0d92541e2 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -348,17 +348,8 @@ pg_do_encoding_conversion(unsigned char *src, int len,
 						pg_encoding_to_char(src_encoding),
 						pg_encoding_to_char(dest_encoding))));
 
-	/*
-	 * Allocate space for conversion result, being wary of integer overflow
-	 */
-	if ((Size) len >= (MaxAllocSize / (Size) MAX_CONVERSION_GROWTH))
-		ereport(ERROR,
-				(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
-				 errmsg("out of memory"),
-				 errdetail("String of %d bytes is too long for encoding conversion.",
-						   len)));
-
-	result = palloc(len * MAX_CONVERSION_GROWTH + 1);
+	result = palloc_extended((Size) len * MAX_CONVERSION_GROWTH + 1,
+							 MCXT_ALLOC_HUGE);
 
 	OidFunctionCall5(proc,
 					 Int32GetDatum(src_encoding),

Reply via email to