Re: [HACKERS] using arrays within structure in ECPG

2014-04-03 Thread Ashutosh Bapat
Hi Michael, The problem of offsets seems to be universal. If there is a structure within structure. The offset to the members of inner structure should be the size of the outer structure and not size of inner structure. Applying this rule recursively, offset to the member of any nested structure,

Re: [HACKERS] using arrays within structure in ECPG

2014-04-02 Thread Michael Meskes
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

Re: [HACKERS] using arrays within structure in ECPG

2014-04-02 Thread Ashutosh Bapat
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);

Re: [HACKERS] using arrays within structure in ECPG

2014-04-02 Thread Michael Meskes
On Wed, Apr 02, 2014 at 05:49:03PM +0530, Ashutosh Bapat wrote: I have one more doubt, regarding offsets. ... This is actually a very good question. Parts of this code are older than my work on ecpg, meaning they were already in version 0.1. It could very well be that with some changes over the

Re: [HACKERS] using arrays within structure in ECPG

2014-04-01 Thread Ashutosh Bapat
Hi MIchael, I tried to fix the offset problem. PFA the patch. It does solve the problem of setting wrong offset in ECPGdo() call. But then there is problem of interpreting the result from server as an array within array of structure. The problem is there is in ecpg_get_data(). This function can

Re: [HACKERS] using arrays within structure in ECPG

2014-04-01 Thread Michael Meskes
Hi Ashutosh, I tried to fix the offset problem. PFA the patch. It does solve the problem of setting wrong offset in ECPGdo() call. Thanks, looks correct to me. But then there is problem of interpreting the result from server as an array within array of structure. The problem is there is in

Re: [HACKERS] using arrays within structure in ECPG

2014-04-01 Thread Merlin Moncure
On Tue, Apr 1, 2014 at 11:50 AM, Michael Meskes mes...@postgresql.org wrote: Hi Ashutosh, I tried to fix the offset problem. PFA the patch. It does solve the problem of setting wrong offset in ECPGdo() call. Thanks, looks correct to me. But then there is problem of interpreting the result

Re: [HACKERS] using arrays within structure in ECPG

2014-04-01 Thread Ashutosh Bapat
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. On Tue, Apr 1, 2014 at 10:20 PM, Michael Meskes mes...@postgresql.orgwrote: Hi Ashutosh, I tried to fix the offset problem. PFA the patch. It does

Re: [HACKERS] using arrays within structure in ECPG

2014-03-27 Thread Michael Meskes
On Mon, Mar 24, 2014 at 11:52:30AM +0530, Ashutosh Bapat wrote: For all the members of struct employee, except arr_col, the size of array is set to 14 and next member offset is set of sizeof (struct employee). But for arr_col they are set to 3 and sizeof(int) resp. So, for the next row

[HACKERS] using arrays within structure in ECPG

2014-03-24 Thread Ashutosh Bapat
Hi, I tried using integer array within a structure array in ECPG code. But it resulted in some garbage values being printed from the table. Here are the details, The ECPG program is attached (array_test.pgc). It tries to read the contents of table emp, whose structure and contents are as follows

Re: [HACKERS] using arrays within structure in ECPG

2014-03-24 Thread Boszormenyi Zoltan
2014-03-24 07:22 keltezéssel, Ashutosh Bapat írta: Hi, I tried using integer array within a structure array in ECPG code. But it resulted in some garbage values being printed from the table. Here are the details, The ECPG program is attached (array_test.pgc). It tries to read the contents of

Re: [HACKERS] using arrays within structure in ECPG

2014-03-24 Thread Ashutosh Bapat
On Mon, Mar 24, 2014 at 3:40 PM, Boszormenyi Zoltan zbos...@pr.hu wrote: 2014-03-24 07:22 keltezéssel, Ashutosh Bapat írta: Hi, I tried using integer array within a structure array in ECPG code. But it resulted in some garbage values being printed from the table. Here are the details,