67 curnode = node + *
str;
73 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
74 errmsg(
"duplicate source strings, first one will be used")));
107 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
108 errmsg(
"could not open unaccent file \"%s\": %m",
149 char *trgstore = NULL;
154 bool trgquoted =
false;
157 for (ptr = line; *ptr; ptr += ptrlen)
161 if (isspace((
unsigned char) *ptr))
211 if (*(ptr + 1) ==
'"')
239 if (trgquoted &&
state > 0)
242 trgstore = (
char *)
palloc(
sizeof(
char) * (trglen - 2));
244 for (
int i = 1;
i < trglen - 1;
i++)
246 trgstore[trgstorelen] = trg[
i];
249 if (trg[
i] ==
'"' && trg[
i + 1] ==
'"')
255 trgstore = (
char *)
palloc(
sizeof(
char) * trglen);
256 trgstorelen = trglen;
257 memcpy(trgstore, trg, trgstorelen);
262 (
unsigned char *) src, srclen,
263 trgstore, trgstorelen);
264 else if (
state == -1)
266 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
267 errmsg(
"invalid syntax: more than two strings in unaccent rule")));
268 else if (
state == -2)
270 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
271 errmsg(
"invalid syntax: unfinished quoted string in unaccent rule")));
285 if (errdata->
sqlerrcode == ERRCODE_UNTRANSLATABLE_CHARACTER)
319 while (node && matchlen < srclen)
321 node = node + src[matchlen];
327 *p_matchlen = matchlen;
342 bool fileloaded =
false;
345 foreach(l, dictoptions)
349 if (strcmp(defel->
defname,
"rules") == 0)
353 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
354 errmsg(
"multiple Rules parameters")));
361 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
362 errmsg(
"unrecognized Unaccent parameter: \"%s\"",
370 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
371 errmsg(
"missing Rules parameter")));
384 char *srcstart = srcchar;
400 if (
buf.data == NULL)
405 if (srcchar != srcstart)
413 if (
buf.data != NULL)
422 if (
buf.data != NULL)
454 const char *dictname =
"unaccent";
461 (
errcode(ERRCODE_UNDEFINED_OBJECT),
462 errmsg(
"text search dictionary \"%s.%s\" does not exist",
487 else if (res->
lexeme == NULL)
#define OidIsValid(objectId)
char * defGetString(DefElem *def)
ErrorData * CopyErrorData(void)
void FlushErrorState(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_POINTER(n)
#define FunctionCall4(flinfo, arg1, arg2, arg3, arg4)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_POINTER(x)
#define PG_GETARG_TEXT_P_COPY(n)
Assert(PointerIsAligned(start, uint64))
Oid get_func_namespace(Oid funcid)
char * get_namespace_name(Oid nspid)
int pg_mblen(const char *mbstr)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static const struct exclude_list_item skip[]
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void initStringInfo(StringInfo str)
struct TrieChar * nextChar
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
TSDictionaryCacheEntry * lookup_ts_dictionary_cache(Oid dictId)
bool tsearch_readline_begin(tsearch_readline_state *stp, const char *filename)
char * tsearch_readline(tsearch_readline_state *stp)
void tsearch_readline_end(tsearch_readline_state *stp)
char * get_tsearch_config_filename(const char *basename, const char *extension)
static TrieChar * initTrie(const char *filename)
Datum unaccent_init(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(unaccent_init)
Datum unaccent_lexize(PG_FUNCTION_ARGS)
static TrieChar * placeChar(TrieChar *node, const unsigned char *str, int lenstr, const char *replaceTo, int replacelen)
Datum unaccent_dict(PG_FUNCTION_ARGS)
static TrieChar * findReplaceTo(TrieChar *node, const unsigned char *src, int srclen, int *p_matchlen)
PG_MODULE_MAGIC_EXT(.name="unaccent",.version=PG_VERSION)
#define VARSIZE_ANY_EXHDR(PTR)
text * cstring_to_text(const char *s)