Hi folks,
I'm having troubles writing a function that reads a file from fisk and
return a bytea to database.
Can anyone help me?
I read the entire file into a (char *) and then return it as a bytea:
fseek(file, 0L, SEEK_END);
tamanhoArquivo = ftell(file);
rewind(file);
fileContent = palloc(fileSize + 1);
if(fileContent == NULL )
{
elog(ERROR, "Error alocating memory (%i bytes)", fileSize + 1);
}
fread(fileContent, fileSize, 1, file);
fclose(file);
PG_RETURN_BYTEA_P((bytea *) fileContent);
And, when I call the funcion in psql, it gives me the following message:
ERROR: Memory exhausted in AllocSetAlloc(879718306)
Am I doing something wrong?
TIA,
--
Diogo Biazus
diogo@ikono.com.br
http://www.ikono.com.br
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера