ecpg test - Mailing list pgsql-patches

From Bruce Momjian
Subject ecpg test
Date
Msg-id 200401130131.i0D1VIr12928@candle.pha.pa.us
Whole thread Raw
List pgsql-patches
Nikola Milutinovic wrote:
> > Oh, glad you asked!  Compile/run interfaces/ecpg/test/test_thread.pgc.
>
> Just tried this:
>
> Legba:/# cd /home/r/root/build/postgresql-7.4.1/src/interfaces/ecpg/test
> Legba:/# gmake
>
> First it failed complaining on "bad object format in ../pgtypeslib".
> Aparently, the linker dislikes a space in "-L ../pgtypeslib". Deleting that
> space made the compile go through. The in failed on test3.cpg:
>
> ../preproc/ecpg -I./../include test3.pgc
> MM: birthinfo
> cc -std -O -ieee  -I./../include -I../../../../src/interfaces/libpq -I../../
> ../../src/include  -pthread  -c -o test3.o test3.c
> cc: Error: test3.pgc, line 71: In this statement, "ind_married" and "0" may
> not be compared with a relational operator.
>                 if (ind_married >= 0)
> --------------------^
>
> I've looked into the code. "ind_married" is defined as "int
> *ind_married=NULL". It really cannot be compared this way and I have a
> feeling it was not the intention.

Yes, that test is clearly wrong because ind_married is an int *.  I
think the test should be :

    *ind_married >= 0

and have applied the following patch to fix it.  I also added an include
required for malloc() on my system.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/interfaces/ecpg/test/test3.pgc
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/test/test3.pgc,v
retrieving revision 1.14
diff -c -c -r1.14 test3.pgc
*** src/interfaces/ecpg/test/test3.pgc    21 Mar 2002 09:42:52 -0000    1.14
--- src/interfaces/ecpg/test/test3.pgc    13 Jan 2004 01:25:31 -0000
***************
*** 68,74 ****
              printf(", born %ld", personal.birth.born);
          if (ind_personal.ind_birth.age >= 0)
              printf(", age = %d", personal.birth.age);
!         if (ind_married >= 0)
              printf(", married %10.10s", married->arr);
          if (ind_children >= 0)
              printf(", children = %d", children);
--- 68,74 ----
              printf(", born %ld", personal.birth.born);
          if (ind_personal.ind_birth.age >= 0)
              printf(", age = %d", personal.birth.age);
!         if (*ind_married >= 0)
              printf(", married %10.10s", married->arr);
          if (ind_children >= 0)
              printf(", children = %d", children);
***************
*** 98,104 ****
              printf(", born %ld", personal.birth.born);
          if (ind_personal.ind_birth.age >= 0)
              printf(", age = %d", personal.birth.age);
!         if (ind_married >= 0)
              printf(", married %10.10s", married->arr);
          if (ind_children >= 0)
              printf(", children = %d", children);
--- 98,104 ----
              printf(", born %ld", personal.birth.born);
          if (ind_personal.ind_birth.age >= 0)
              printf(", age = %d", personal.birth.age);
!         if (*ind_married >= 0)
              printf(", married %10.10s", married->arr);
          if (ind_children >= 0)
              printf(", children = %d", children);
Index: src/interfaces/ecpg/test/test4.pgc
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/test/test4.pgc,v
retrieving revision 1.12
diff -c -c -r1.12 test4.pgc
*** src/interfaces/ecpg/test/test4.pgc    20 Jun 2003 13:36:34 -0000    1.12
--- src/interfaces/ecpg/test/test4.pgc    13 Jan 2004 01:25:31 -0000
***************
*** 1,5 ****
--- 1,6 ----
  #include <locale.h>
  #include <string.h>
+ #include <stdlib.h>

  exec sql whenever sqlerror sqlprint;


pgsql-patches by date:

Previous
From: Claudio Natoli
Date:
Subject: Re: win32 patch: processCancelRequest/reaper (+ various minor cha
Next
From: Ludek Finstrle
Date:
Subject: WIN32 psql Ctrl+C support