diff options
| author | Teodor Sigaev <teodor@sigaev.ru> | 2009-05-21 20:09:36 +0000 |
|---|---|---|
| committer | Teodor Sigaev <teodor@sigaev.ru> | 2009-05-21 20:09:36 +0000 |
| commit | c6c458e24dd225e719ac289efdee50b2d6d1d16a (patch) | |
| tree | 2495202d9f2ccf138ac6ec905b91871eabbeb5fe /src/backend/utils/adt/tsvector.c | |
| parent | ab9981ccc69b6d850ed9c671b1a64a8b90b33032 (diff) | |
| download | postgresql-c6c458e24dd225e719ac289efdee50b2d6d1d16a.tar.gz | |
Resort tsvector's lexemes in tsvectorrecv instead of emmiting an error.
Basically, it's needed to support binary dump from 8.3 because ordering rule
was changed.
Per discussion with Bruce.
Diffstat (limited to 'src/backend/utils/adt/tsvector.c')
| -rw-r--r-- | src/backend/utils/adt/tsvector.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c index ba2fef94aa..f449695725 100644 --- a/src/backend/utils/adt/tsvector.c +++ b/src/backend/utils/adt/tsvector.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector.c,v 1.16 2009/05/21 12:54:27 meskes Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector.c,v 1.17 2009/05/21 20:09:36 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -451,6 +451,7 @@ tsvectorrecv(PG_FUNCTION_ARGS) * WordEntries */ Size hdrlen; Size len; /* allocated size of vec */ + bool needSort = false; nentries = pq_getmsgint(buf, sizeof(int32)); if (nentries < 0 || nentries > (MaxAllocSize / sizeof(WordEntry))) @@ -507,7 +508,7 @@ tsvectorrecv(PG_FUNCTION_ARGS) if (i > 0 && WordEntryCMP(&vec->entries[i], &vec->entries[i - 1], STRPTR(vec)) <= 0) - elog(ERROR, "lexemes are misordered"); + needSort = true; /* Receive positions */ if (npos > 0) @@ -542,5 +543,9 @@ tsvectorrecv(PG_FUNCTION_ARGS) SET_VARSIZE(vec, hdrlen + datalen); + if (needSort) + qsort_arg((void *) ARRPTR(vec), vec->size, sizeof(WordEntry), + compareentry, (void*)STRPTR(vec)); + PG_RETURN_TSVECTOR(vec); } |
