Skip to content

Commit b77c6c7

Browse files
committed
Whoops, missed updating dsynonym_init for new dictionary parameter method.
1 parent b2a52b3 commit b77c6c7

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/backend/tsearch/dict_synonym.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.1 2007/08/21 01:11:18 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.2 2007/08/22 04:13:15 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
1515

16+
#include "commands/defrem.h"
1617
#include "storage/fd.h"
1718
#include "tsearch/ts_locale.h"
1819
#include "tsearch/ts_public.h"
@@ -21,6 +22,7 @@
2122

2223

2324
#define SYNBUFLEN 4096
25+
2426
typedef struct
2527
{
2628
char *in;
@@ -63,27 +65,37 @@ compareSyn(const void *a, const void *b)
6365
Datum
6466
dsynonym_init(PG_FUNCTION_ARGS)
6567
{
66-
text *in;
68+
List *dictoptions = (List *) PG_GETARG_POINTER(0);
6769
DictSyn *d;
68-
int cur = 0;
70+
ListCell *l;
71+
char *filename = NULL;
6972
FILE *fin;
70-
char *filename;
7173
char buf[SYNBUFLEN];
7274
char *starti,
7375
*starto,
7476
*end = NULL;
77+
int cur = 0;
7578
int slen;
7679

77-
/* init functions must defend against NULLs for themselves */
78-
if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
80+
foreach(l, dictoptions)
81+
{
82+
DefElem *defel = (DefElem *) lfirst(l);
83+
84+
if (pg_strcasecmp("Synonyms", defel->defname) == 0)
85+
filename = defGetString(defel);
86+
else
87+
ereport(ERROR,
88+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
89+
errmsg("unrecognized synonym parameter: \"%s\"",
90+
defel->defname)));
91+
}
92+
93+
if (!filename)
7994
ereport(ERROR,
8095
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
81-
errmsg("NULL config not allowed for Synonym")));
82-
in = PG_GETARG_TEXT_P(0);
83-
84-
filename = get_tsearch_config_filename(TextPGetCString(in), "syn");
96+
errmsg("missing Synonyms parameter")));
8597

86-
PG_FREE_IF_COPY(in, 0);
98+
filename = get_tsearch_config_filename(filename, "syn");
8799

88100
if ((fin = AllocateFile(filename, "r")) == NULL)
89101
ereport(ERROR,
@@ -142,7 +154,6 @@ dsynonym_init(PG_FUNCTION_ARGS)
142154
if (cur > 1)
143155
qsort(d->syn, d->len, sizeof(Syn), compareSyn);
144156

145-
pfree(filename);
146157
PG_RETURN_POINTER(d);
147158
}
148159

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy