Thread: Macro From Hell

Macro From Hell

From
David Hartwig
Date:
This is a very recent addition at line 664 of copy.c   It will not
compile on AIX 4.1   Help!

gmake[2]: Entering directory `/gnu/postgresql-6.4f/src/backend/commands'

xlc -I../../include -I../../backend   -qchars=signed -qmaxmem=8192
-qhalt=w -qsrcmsg -qcheck=divzero -I/usr/local/include  -I..   -c
 copy.c -o copy.o
      664 |                                                 ptr = (
((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof (double) -
1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
 - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) == sizeof(char)) ?
( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
(((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
: (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );


........................................................................................................................


....................................................................................................................................

.......................................................................a..........

a - 1506-226 (S) The ":" operator is not allowed between "char*" and
"unsigned long".
gmake[2]: *** [copy.o] Error 1



Re: [HACKERS] Macro From Hell

From
Bruce Momjian
Date:
> This is a very recent addition at line 664 of copy.c   It will not
> compile on AIX 4.1   Help!
>
> gmake[2]: Entering directory `/gnu/postgresql-6.4f/src/backend/commands'
>
> xlc -I../../include -I../../backend   -qchars=signed -qmaxmem=8192
> -qhalt=w -qsrcmsg -qcheck=divzero -I/usr/local/include  -I..   -c
>  copy.c -o copy.o
>       664 |                                                 ptr = (
> ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof (double) -
> 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
>  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) == sizeof(char)) ?
> ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
> ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
>
>
........................................................................................................................
>
>
....................................................................................................................................
>
> .......................................................................a..........
>
> a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> "unsigned long".
> gmake[2]: *** [copy.o] Error 1
>

Looks like I am going to have to do another DISABLE_COMPLEX_MACROS entry
for that new macro, just like heap_getattr().

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Re: [HACKERS] Macro From Hell

From
"Billy G. Allie"
Date:
Bruce Momjian writes:
> Looks like I am going to have to do another DISABLE_COMPLEX_MACROS entry
> for that new macro, just like heap_getattr().
>
Please do not use the same define as the one used in heap_getattr().  The new
macro compiles fine on UnixWare 7 (and I assume UnixWare 2 and SCO OpenServer).
It may be restricted to the AIX compiler.
--
____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
|  /|      | 7436 Hartwell     | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/  |LLIE  | (313) 582-1540    |



Re: [HACKERS] Macro From Hell

From
"Thomas G. Lockhart"
Date:
> > ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> > ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof
> > (double) -
> > 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
> >  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) ==
> > sizeof(char)) ?
> > ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
      ^^^^^ should perhaps be (long)(ptr)
> > ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> > sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> > f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> > (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> > : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
> > a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> > "unsigned long".
> Looks like I am going to have to do another DISABLE_COMPLEX_MACROS
> entry for that new macro, just like heap_getattr().

The error message indicates that the AIX compiler is complaining about a
type mismatch within the macro, not the length of the macro itself. Try
adding that additional coersion and see if it helps. The macro is just a
bit "thick" (OK, _really_ thick :), so there may be another place in
there provoking the complaint...

                    - Tom

Re: [HACKERS] Macro From Hell

From
Bruce Momjian
Date:
> Bruce Momjian writes:
> > Looks like I am going to have to do another DISABLE_COMPLEX_MACROS entry
> > for that new macro, just like heap_getattr().
> >
> Please do not use the same define as the one used in heap_getattr().  The new
> macro compiles fine on UnixWare 7 (and I assume UnixWare 2 and SCO OpenServer).
> It may be restricted to the AIX compiler.

I now realize it is the mixing of the return types for ? : that it does
not like.  Will fix.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Re: [HACKERS] Macro From Hell

From
David Hartwig
Date:

Thomas G. Lockhart wrote:

> > > ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> > > ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof
> > > (double) -
> > > 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
> > >  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) ==
> > > sizeof(char)) ?
> > > ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
>       ^^^^^ should perhaps be (long)(ptr)
> > > ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> > > sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> > > f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> > > (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> > > : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
> > > a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> > > "unsigned long".
> > Looks like I am going to have to do another DISABLE_COMPLEX_MACROS
> > entry for that new macro, just like heap_getattr().
>
> The error message indicates that the AIX compiler is complaining about a
> type mismatch within the macro, not the length of the macro itself. Try
> adding that additional coersion and see if it helps. The macro is just a
> bit "thick" (OK, _really_ thick :), so there may be another place in
> there provoking the complaint...
>

That is correct.   I was able to do several casts to get it to work this
morning.  It is hacked in for now.   Basically the problem is this:

    ptr  =  (test) ? (espression resulting in pointer) :  (expression
resulting in long)

Our compiler does not like this.  Bruce, I can send a patch if you like.


Re: [HACKERS] Macro From Hell

From
Bruce Momjian
Date:
> > > ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> > > ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof
> > > (double) -
> > > 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
> > >  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) ==
> > > sizeof(char)) ?
> > > ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
>       ^^^^^ should perhaps be (long)(ptr)
> > > ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> > > sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> > > f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> > > (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> > > : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
> > > a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> > > "unsigned long".
> > Looks like I am going to have to do another DISABLE_COMPLEX_MACROS
> > entry for that new macro, just like heap_getattr().
>
> The error message indicates that the AIX compiler is complaining about a
> type mismatch within the macro, not the length of the macro itself. Try
> adding that additional coersion and see if it helps. The macro is just a
> bit "thick" (OK, _really_ thick :), so there may be another place in
> there provoking the complaint...

Fixed.  Need to cast the sizeof(char) entry to long.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Re: [HACKERS] Macro From Hell

From
Bruce Momjian
Date:
> > This is a very recent addition at line 664 of copy.c   It will not
> > compile on AIX 4.1   Help!
> >
> > gmake[2]: Entering directory `/gnu/postgresql-6.4f/src/backend/commands'
> >
> > xlc -I../../include -I../../backend   -qchars=signed -qmaxmem=8192
> > -qhalt=w -qsrcmsg -qcheck=divzero -I/usr/local/include  -I..   -c
> >  copy.c -o copy.o
> >       664 |                                                 ptr = (
> > ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> > ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof (double) -
> > 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
> >  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) == sizeof(char)) ?
> > ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
> > ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> > sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> > f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> > (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> > : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
> >
> >
........................................................................................................................
> >
> >
....................................................................................................................................
> >
> > .......................................................................a..........
> >
> > a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> > "unsigned long".
> > gmake[2]: *** [copy.o] Error 1
> >
>
> Looks like I am going to have to do another DISABLE_COMPLEX_MACROS entry
> for that new macro, just like heap_getattr().
>
> --
> Bruce Momjian                          |  830 Blythe Avenue
> maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
>   +  If your life is a hard drive,     |  (610) 353-9879(w)
>   +  Christ can be your backup.        |  (610) 853-3000(h)
>
>

> > ( (long)(ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
      ^^^^^^

This was the fix.  In the code it was:

            ((attlen) == sizeof(char)) ? \
            ( \
                (long)(cur_offset) \
            ) \

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Re: [HACKERS] Macro From Hell

From
David Hartwig
Date:

Bruce Momjian wrote:

> This was the fix.  In the code it was:
>
>             ((attlen) == sizeof(char)) ? \
>             ( \
>                 (long)(cur_offset) \
>             ) \
>

Needs one more tweak.

In backend/commands/copy.c   May I suggest at line 664:

   ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign)
         ^^^^^^^^


Re: [HACKERS] Macro From Hell

From
dg@informix.com (David Gould)
Date:
>
> This is a very recent addition at line 664 of copy.c   It will not
> compile on AIX 4.1   Help!
>
> gmake[2]: Entering directory `/gnu/postgresql-6.4f/src/backend/commands'
>
> xlc -I../../include -I../../backend   -qchars=signed -qmaxmem=8192
> -qhalt=w -qsrcmsg -qcheck=divzero -I/usr/local/include  -I..   -c
>  copy.c -o copy.o
>       664 |                                                 ptr = (
> ((attr[i]->attlen) < sizeof(int32)) ? ( ((attr[i]->attlen) == -1
> ) ? ( ((attr[i]->attalign) == 'd') ? (((long)(ptr) + (sizeof (double) -
> 1)) & ~(sizeof (double) -1)) : (((long)(ptr) + (sizeof (int)
>  - 1)) & ~(sizeof (int) -1)) ) : ( ((attr[i]->attlen) == sizeof(char)) ?
> ( (ptr) ) : ( (void)((char) 1), (((long)(ptr) + (sizeof (sh
> ort) - 1)) & ~(sizeof (short) - 1)) ) ) ) : ( ((attr[i]->attlen) ==
> sizeof(int32)) ? ( (((long)(ptr) + (sizeof (int) - 1)) & ~(sizeo
> f (int) -1)) ) : ( (void)((char) 1), ((attr[i]->attalign) == 'd') ?
> (((long)(ptr) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
> : (((long)(ptr) + (sizeof (long) - 1)) & ~(sizeof (long) -1)) ) ) );
>
> a - 1506-226 (S) The ":" operator is not allowed between "char*" and
> "unsigned long".
> gmake[2]: *** [copy.o] Error 1
>


This should not compile anywhere really. The trinary operator must return one
and only one type. That is for:

    (condition) ? (t_result) : (f_result)

both t_result and f_result must be of the same type.

-dg

David Gould            dg@informix.com           510.628.3783 or 510.305.9468
Informix Software  (No, really)         300 Lakeside Drive  Oakland, CA 94612
 - If simplicity worked, the world would be overrun with insects. -


Re: [HACKERS] Macro From Hell

From
Bruce Momjian
Date:
>
>
> Bruce Momjian wrote:
>
> > This was the fix.  In the code it was:
> >
> >             ((attlen) == sizeof(char)) ? \
> >             ( \
> >                 (long)(cur_offset) \
> >             ) \
> >
>
> Needs one more tweak.
>
> In backend/commands/copy.c   May I suggest at line 664:
>
>    ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign)

Done.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)