aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-08-25 02:29:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-08-25 02:29:45 +0000
commita13cefafb157989bc2c139e918323dc014fb3721 (patch)
treeb262249a460653310df4ffc8b4081f58eda8e127
parent93eab9312f5d13168e63b84338bdc7bff160e3d1 (diff)
downloadpostgresql-a13cefafb157989bc2c139e918323dc014fb3721.tar.gz
postgresql-a13cefafb157989bc2c139e918323dc014fb3721.zip
Fix synonym-dict breakage introduced in last patch :-(.
Minor other cleanups.
-rw-r--r--src/backend/tsearch/dict_synonym.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/tsearch/dict_synonym.c b/src/backend/tsearch/dict_synonym.c
index 1c0fd95413c..89819eb7443 100644
--- a/src/backend/tsearch/dict_synonym.c
+++ b/src/backend/tsearch/dict_synonym.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.3 2007/08/25 00:03:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.4 2007/08/25 02:29:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -120,30 +120,31 @@ dsynonym_init(PG_FUNCTION_ARGS)
/* Empty line */
goto skipline;
}
- *end = '\0';
- if (end >= line + strlen(line))
+ if (*end == '\0')
{
/* A line with only one word. Ignore silently. */
goto skipline;
}
+ *end = '\0';
starto = findwrd(end + 1, &end);
if (!starto)
{
- /* A line with only one word. Ignore silently. */
+ /* A line with only one word (+whitespace). Ignore silently. */
goto skipline;
}
*end = '\0';
- /* starti now points to the first word, and starto to the second
+ /*
+ * starti now points to the first word, and starto to the second
* word on the line, with a \0 terminator at the end of both words.
*/
- if (cur == d->len)
+ if (cur >= d->len)
{
if (d->len == 0)
{
- d->len = 16;
+ d->len = 64;
d->syn = (Syn *) palloc(sizeof(Syn) * d->len);
}
else
@@ -180,7 +181,8 @@ dsynonym_lexize(PG_FUNCTION_ARGS)
*found;
TSLexeme *res;
- if (len <= 0)
+ /* note: d->len test protects against Solaris bsearch-of-no-items bug */
+ if (len <= 0 || d->len <= 0)
PG_RETURN_POINTER(NULL);
key.in = lowerstr_with_len(in, len);