0

I use EXEC SQL to execute a very long SQL (6000 characters) in PGC file, sometimes error SQLSTATE=[YE001] SQLERRM=[out of memory on line 400], sometimes it works fine. Use vmstat to view memory

-------------memory----------
swpd free buff cache
13324 2116768 3264 6004164

There is enough memory left on the machineLooking at the C file compiled by PGC, this EXEC SQL is translated into

{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "...long sql...",
ECPGt_varchar,&(h_vstrSHORI_DT),(long)8 + 1,(long)1,sizeof(struct varchar_1),ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);
if (sqlca.sqlcode < 0) 
goto SQL_ERR;}

Query the source code of ECPGdo and call it in ECPGdo

char * ecpg_strdup(const char *string, int lineno) {
     char *new;
     if (string == NULL)
         return NULL;
     new = strdup(string);
     if (!new)     {
         ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
         return NULL;
     }
     return new;
 }

There will be an OOM error after the strdup fails here. I use the strdup function to test this long SQL without an OOM error, so it may not be an error here.

Is out of memory caused by insufficient memory of the machine or insufficient memory of postgresql?

What should I do to solve this problem?

kldd
  • 39
  • 5

0 Answers0