From 978de9d06d54de07547049e49ad5ed500e64edf0 Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Fri, 7 Sep 2007 16:03:40 +0000 Subject: Improvements from Heikki Linnakangas - change the alignment requirement of lexemes in TSVector slightly. Lexeme strings were always padded to 2-byte aligned length to make sure that if there's position array (uint16[]) it has the right alignment. The patch changes that so that the padding is not done when there's no positions. That makes the storage of tsvectors without positions slightly more compact. - added some #include "miscadmin.h" lines I missed in the earlier when I added calls to check_stack_depth(). - Reimplement the send/recv functions, and added a comment above them describing the on-wire format. The CRC is now recalculated in tsquery as well per previous discussion. --- src/backend/utils/adt/tsrank.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/backend/utils/adt/tsrank.c') diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index 30ccfa3f617..535a3541bf7 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.3 2007/09/07 15:35:10 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.4 2007/09/07 16:03:40 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ #include "tsearch/ts_type.h" #include "tsearch/ts_utils.h" #include "utils/array.h" +#include "miscadmin.h" static float weights[] = {0.1, 0.2, 0.4, 1.0}; @@ -176,8 +177,9 @@ SortAndUniqItems(TSQuery q, int *size) return res; } +/* A dummy WordEntryPos array to use when haspos is false */ static WordEntryPos POSNULL[] = { - 0, + 1, /* Number of elements that follow */ 0 }; @@ -207,7 +209,6 @@ calc_rank_and(float *w, TSVector t, TSQuery q) } pos = (uint16 **) palloc(sizeof(uint16 *) * q->size); memset(pos, 0, sizeof(uint16 *) * q->size); - *(uint16 *) POSNULL = lengthof(POSNULL) - 1; WEP_SETPOS(POSNULL[1], MAXENTRYPOS - 1); for (i = 0; i < size; i++) @@ -265,7 +266,6 @@ calc_rank_or(float *w, TSVector t, TSQuery q) QueryOperand **item; int size = q->size; - *(uint16 *) POSNULL = lengthof(POSNULL) - 1; item = SortAndUniqItems(q, &size); for (i = 0; i < size; i++) @@ -593,7 +593,6 @@ get_docrep(TSVector txt, TSQuery query, int *doclen) DocRepresentation *doc; char *operand; - *(uint16 *) POSNULL = lengthof(POSNULL) - 1; doc = (DocRepresentation *) palloc(sizeof(DocRepresentation) * len); operand = GETOPERAND(query); reset_istrue_flag(query); -- cgit v1.2.3