I have one more doubt, regarding offsets. In ECPGdump_a_simple() we have code if (siz == NULL || strlen(siz) == 0 || strcmp(arrsize, "0") == 0 || strcmp(arrsize, "1") == 0) fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, offset); else fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, siz);
If the caller has passed siz, it means that this variable is part of the a structure. Remember in dump_variables(), this function is called with struct_sizeof = NULL. So, once we know that siz != NULL and strlen(siz) != 0, it's evident that the simple variable we are dumping is part of a structure and hence we should be using "siz" instead of "offset". Why then we still check arrsize? In a case, where we are dumping a pointer to a structure, this code dumps each member with offset = size of that member, thus again corrupting memory, if there are more than one rows being saved through pointer. On Wed, Apr 2, 2014 at 3:10 PM, Michael Meskes <mes...@postgresql.org>wrote: > On Wed, Apr 02, 2014 at 09:33:15AM +0530, Ashutosh Bapat wrote: > > So, you are saying that we should try to catch such errors and report > > during pre-compile time. That's better than silently corrupting the data. > > Well, I think this goes without saying. > > Michael > -- > Michael Meskes > Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) > Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org > Jabber: michael.meskes at gmail dot com > VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL > -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company