mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Whoops, missed updating dsynonym_init for new dictionary parameter method.
This commit is contained in:
parent
b2a52b3b80
commit
b77c6c7311
@ -7,12 +7,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.1 2007/08/21 01:11:18 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.2 2007/08/22 04:13:15 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include "commands/defrem.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
#include "tsearch/ts_locale.h"
|
#include "tsearch/ts_locale.h"
|
||||||
#include "tsearch/ts_public.h"
|
#include "tsearch/ts_public.h"
|
||||||
@ -21,6 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define SYNBUFLEN 4096
|
#define SYNBUFLEN 4096
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *in;
|
char *in;
|
||||||
@ -63,27 +65,37 @@ compareSyn(const void *a, const void *b)
|
|||||||
Datum
|
Datum
|
||||||
dsynonym_init(PG_FUNCTION_ARGS)
|
dsynonym_init(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *in;
|
List *dictoptions = (List *) PG_GETARG_POINTER(0);
|
||||||
DictSyn *d;
|
DictSyn *d;
|
||||||
int cur = 0;
|
ListCell *l;
|
||||||
|
char *filename = NULL;
|
||||||
FILE *fin;
|
FILE *fin;
|
||||||
char *filename;
|
|
||||||
char buf[SYNBUFLEN];
|
char buf[SYNBUFLEN];
|
||||||
char *starti,
|
char *starti,
|
||||||
*starto,
|
*starto,
|
||||||
*end = NULL;
|
*end = NULL;
|
||||||
|
int cur = 0;
|
||||||
int slen;
|
int slen;
|
||||||
|
|
||||||
/* init functions must defend against NULLs for themselves */
|
foreach(l, dictoptions)
|
||||||
if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
|
{
|
||||||
|
DefElem *defel = (DefElem *) lfirst(l);
|
||||||
|
|
||||||
|
if (pg_strcasecmp("Synonyms", defel->defname) == 0)
|
||||||
|
filename = defGetString(defel);
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("unrecognized synonym parameter: \"%s\"",
|
||||||
|
defel->defname)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("NULL config not allowed for Synonym")));
|
errmsg("missing Synonyms parameter")));
|
||||||
in = PG_GETARG_TEXT_P(0);
|
|
||||||
|
|
||||||
filename = get_tsearch_config_filename(TextPGetCString(in), "syn");
|
filename = get_tsearch_config_filename(filename, "syn");
|
||||||
|
|
||||||
PG_FREE_IF_COPY(in, 0);
|
|
||||||
|
|
||||||
if ((fin = AllocateFile(filename, "r")) == NULL)
|
if ((fin = AllocateFile(filename, "r")) == NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -142,7 +154,6 @@ dsynonym_init(PG_FUNCTION_ARGS)
|
|||||||
if (cur > 1)
|
if (cur > 1)
|
||||||
qsort(d->syn, d->len, sizeof(Syn), compareSyn);
|
qsort(d->syn, d->len, sizeof(Syn), compareSyn);
|
||||||
|
|
||||||
pfree(filename);
|
|
||||||
PG_RETURN_POINTER(d);
|
PG_RETURN_POINTER(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user