At 11:45 10.11.01 -0500, Tom Lane wrote:
> >> In particular, i have NUMERIC test failing with same 'ERROR: cannot
> >> create unique index. Table contains noon-unique values'. Also CREATE
> >> VIEW fails with 'cannot insert a duplicate key into unique index
> >> pg_rewrite_rulename_index'
>
>Hm. Is this with current Postgres sources (7.1 or later)?
That was 7.1.3, but I get the same result in the regression test with
the cvs from last week.
>At this point it seems that we must be dealing with either a compiler
>bug (which compiler are you using?) or some so-far-unrecognized
>portability mistake in the Postgres code. If it's the latter then
>I'd like to find and fix it. Can you dig into it with a debugger and
>try to determine where the code goes wrong? The CREATE VIEW case would
>probably be easier to analyze than the numeric index creation.
I have rebuild postgres with -g2 and Watcom-C. The error message is
generated in comparetup_index@tuplesort.c when enforceUnique is set
and it's tuples compare identical. As far as I can see, it is
called from qsort_comparetup which is called by the QNX qsort library
function. It looks like QNX qsort does in fact call the comparison
function to compare a tuple with itself (tuple pointers a and b have
the same value).
Changing line 1873 (in 7.1.3, line 1885 in my last cvs version)
! if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2)
elog(ERROR, "Cannot create unique index. Table contains non-uniq
makes the error go away.
Regards, Bernd Tegge