mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 05:21:27 +03:00
Fix compare bug for tsvector: problem was in aligment. Per Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> and Phil Frost <indigo@bitglue.com>
This commit is contained in:
parent
368f3b2cca
commit
2ec2b2caf0
@ -962,17 +962,43 @@ silly_cmp_tsvector(const tsvector * a, const tsvector * b)
|
|||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char *aptr = (unsigned char *) (a->data) + DATAHDRSIZE;
|
WordEntry *aptr = ARRPTR(a);
|
||||||
unsigned char *bptr = (unsigned char *) (b->data) + DATAHDRSIZE;
|
WordEntry *bptr = ARRPTR(b);
|
||||||
|
int i = 0;
|
||||||
|
int res;
|
||||||
|
|
||||||
while (aptr - ((unsigned char *) (a->data)) < a->len)
|
|
||||||
{
|
for(i=0;i<a->size;i++) {
|
||||||
if (*aptr != *bptr)
|
if ( aptr->haspos != bptr->haspos ) {
|
||||||
return (*aptr < *bptr) ? -1 : 1;
|
return ( aptr->haspos > bptr->haspos ) ? -1 : 1;
|
||||||
aptr++;
|
} else if ( aptr->pos != bptr->pos ) {
|
||||||
bptr++;
|
return ( aptr->pos > bptr->pos ) ? -1 : 1;
|
||||||
|
} else if ( aptr->len != bptr->len ) {
|
||||||
|
return ( aptr->len > bptr->len ) ? -1 : 1;
|
||||||
|
} else if ( (res=strncmp(STRPTR(a) + aptr->pos, STRPTR(b) + bptr->pos, b->len))!= 0 ) {
|
||||||
|
return res;
|
||||||
|
} else if ( aptr->haspos ) {
|
||||||
|
WordEntryPos *ap = POSDATAPTR(a, aptr);
|
||||||
|
WordEntryPos *bp = POSDATAPTR(b, bptr);
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if ( POSDATALEN(a, aptr) != POSDATALEN(b, bptr) )
|
||||||
|
return ( POSDATALEN(a, aptr) > POSDATALEN(b, bptr) ) ? -1 : 1;
|
||||||
|
|
||||||
|
for(j=0;j<POSDATALEN(a, aptr);j++) {
|
||||||
|
if ( WEP_GETPOS(*ap) != WEP_GETPOS(*bp) ) {
|
||||||
|
return ( WEP_GETPOS(*ap) > WEP_GETPOS(*bp) ) ? -1 : 1;
|
||||||
|
} else if ( WEP_GETWEIGHT(*ap) != WEP_GETWEIGHT(*bp) ) {
|
||||||
|
return ( WEP_GETWEIGHT(*ap) > WEP_GETWEIGHT(*bp) ) ? -1 : 1;
|
||||||
|
}
|
||||||
|
ap++, bp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aptr++; bptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user