Обсуждение: Postgresql on Ultraparc/Linux , Bug report and patch!

Поиск
Список
Период
Сортировка

Postgresql on Ultraparc/Linux , Bug report and patch!

От
Silvio Macedo
Дата:
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Silvio Macedo
Your email address    : smacedo@ic.ac.uk

(or                        smacedo@inescn.pt)


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : Sun Ultrasparc 1
(143Mhz, 2.1 Gb disk, 64Mb RAM)

  Operating System (example: Linux 2.0.26 ELF)     : Linux 2.2.12 ELF, (RH6.1)

  PostgreSQL version (example: PostgreSQL-6.5.3): PostgreSQL-6.5.3/2/SNAP

  Compiler used (example:  gcc 2.8.0)        : gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
                          (comes with RH6.1)
                          GNUlibc 2.1.2


Please enter a FULL description of your problem:
------------------------------------------------

In 64 bit machines like the Ultraparc, strncmp can return -256.
In src/backend/utils/adt/name.c you do:
            return (bool) strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0;

In this way you are casting strncmp to bool, and not the comparison.

This is the description of the consequences, that I sent before I
discovered the problem:
(I am giving a really detailed description to maximize the chances that
you find the solution to my problem)

I have installed postgres many times in several Linux/Intel systems.

Now, I am trying to install Pg 6.5.3 ( or any other version of Pg) in a
Linux/(ultra)Sparc system. The system seems stable in any task other than
postgres stuff, but when I run initdb, it always dies with and error
about :
"Attribute 'aggtransfn1' is repeated."

I have downloaded source distribution PG 6.5.3, PG Snapshot, PG 6.5.2
and RPM binaries of Pg from RedHat 6.1 distribution and even SRPMS.

In all of them, after compiling and/or installing, when I do the initdb
-d, the script dies with this message:

> <aggname name>
<aggowner int4>
<aggtransfn1 regproc>
<aggtransfn2 regproc>
<aggfinalfn regproc>
<aggbasetype oid>
<aggtranstype1 oid>
<aggtranstype2 oid>
<aggfinaltype oid>
<agginitval1 text>
<agginitval2 text>
> ERROR:  Attribute 'aggtransfn1' is repeated
ERROR:  Attribute 'aggtransfn1' is repeated
initdb: could not create template database
initdb: cleaning up by wiping out /usr/local/pgsql/data/base/template1

I have also tried initdb with the full command line, etc..

This happens with all the versions of Pg that I have tested:
Pg Snapshot 22 Nov
Pg 6.5.3,
Pg 6.5.2,
Binaries in RPM from RedHat 6.1 Sparc
Source SRPM from '' ''


Then, I investigated the problem deeper, and deeper.
If I remove aggtransfn2 from the local1.????.bki.source, it gives the same
error in agginitval2.

I replaced the ERROR with a NOTICE on the elog on the file
src/backend/catalog/heap.c in the function CheckAttributeNames() and
everything went ok until I started regression tests. Lots of 'failed'
appeared in the char/string related tests, and those were real problems,
because I checked it myself (not just little differences); the backend
closed connection in some tests.

 I then added some lines in the src/backend/catalog/heap.c to see if the
strings were read ok and if NAMEDATALEN was ok. Yes, they were.
aggtransfn1 was compared to aggransfn2 by a call to nameeq(), and this
function returned that they were equal (obviously they differ on the last
character).

Then, finally I replaced the call to nameeq to a direct strncmp() between
both tuple->data's and it worked. The regression tests still failed.

Maybe there is a problem in the strncmp libraries in my system ? oh no...

[PS: The source of this problem as I wrote above, is in Postgres name.c
file, in nameeq() ]

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

configure --with-x --with-tcl --with-template=linux_sparc
make
make install
cd /usr/local/pgsql
initdb




If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------
I send both diff -f and diff -u in attach

--- postgresql-6.5.3/src/backend/utils/adt/name.c    Mon Aug  2 06:24:55 1999
+++ postgresql-6.5.3.my/src/backend/utils/adt/name.c    Thu Nov 25 11:53:39 1999
@@ -87,7 +87,7 @@
     if (!arg1 || !arg2)
         return 0;
     else
-        return (bool) strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0;
+            return (bool) (strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0);
 }

 bool

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
``````````````````````````````````````````````````````````````````````````
Silvio Emanuel Nunes Barbosa de Macedo

smacedo@ic.ac.uk                                         smacedo@inescn.pt
Imperial College, University of London                         INESC Porto
Intelligent and Interactive Systems                Telecom. and Multimedia
Exhibition Road,                                       Pc da Republica, 93
London SW7 2AZ, England                            4050-497 PORTO PORTUGAL
Tel:+44 171 5946323                                    Tel:+351 22 2094220

Re: [BUGS] Postgresql on Ultraparc/Linux , Bug report and patch!

От
Tom Lane
Дата:
Silvio Macedo <smacedo@ic.ac.uk> writes:
> In src/backend/utils/adt/name.c you do:
>     return (bool) strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0;
> In this way you are casting strncmp to bool, and not the comparison.

Oops.  Good catch!

Wonder if there are similar mistakes elsewhere?  If so, how could we
find them?

            regards, tom lane

Re: [BUGS] Postgresql on Ultraparc/Linux , Bug report and patch!

От
Bruce Momjian
Дата:
> Silvio Macedo <smacedo@ic.ac.uk> writes:
> > In src/backend/utils/adt/name.c you do:
> >     return (bool) strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0;
> > In this way you are casting strncmp to bool, and not the comparison.
>
> Oops.  Good catch!
>
> Wonder if there are similar mistakes elsewhere?  If so, how could we
> find them?

Patch applied.  I just went through utils/adt/*.c looking for bool, and
the rest look OK.

--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: [BUGS] Postgresql on Ultraparc/Linux , Bug report and patch!

От
Bruce Momjian
Дата:
Patch appied.


>
>
>
> If you know how this problem might be fixed, list the solution below:
> ---------------------------------------------------------------------
> I send both diff -f and diff -u in attach
>
> --- postgresql-6.5.3/src/backend/utils/adt/name.c    Mon Aug  2 06:24:55 1999
> +++ postgresql-6.5.3.my/src/backend/utils/adt/name.c    Thu Nov 25 11:53:39 1999
> @@ -87,7 +87,7 @@
>      if (!arg1 || !arg2)
>          return 0;
>      else
> -        return (bool) strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0;
> +            return (bool) (strncmp(arg1->data, arg2->data, NAMEDATALEN) == 0);
>  }
>
>  bool
>
> ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
> ``````````````````````````````````````````````````````````````````````````
> Silvio Emanuel Nunes Barbosa de Macedo
>
> smacedo@ic.ac.uk                                         smacedo@inescn.pt
> Imperial College, University of London                         INESC Porto
> Intelligent and Interactive Systems                Telecom. and Multimedia
> Exhibition Road,                                       Pc da Republica, 93
> London SW7 2AZ, England                            4050-497 PORTO PORTUGAL
> Tel:+44 171 5946323                                    Tel:+351 22 2094220
>
>
>
Content-Description:

[Attachment, skipping...]
Content-Description:

[Attachment, skipping...]


--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026