64 curnode = node + *
str;
70 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
71 errmsg(
"duplicate source strings, first one will be used")));
104 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
105 errmsg(
"could not open unaccent file \"%s\": %m",
146 char *trgstore = NULL;
151 bool trgquoted =
false;
154 for (ptr = line; *ptr; ptr += ptrlen)
208 if (*(ptr + 1) ==
'"')
236 if (trgquoted &&
state > 0)
239 trgstore = (
char *)
palloc(
sizeof(
char) * (trglen - 2));
241 for (
int i = 1;
i < trglen - 1;
i++)
243 trgstore[trgstorelen] = trg[
i];
246 if (trg[
i] ==
'"' && trg[
i + 1] ==
'"')
252 trgstore = (
char *)
palloc(
sizeof(
char) * trglen);
253 trgstorelen = trglen;
254 memcpy(trgstore, trg, trgstorelen);
259 (
unsigned char *) src, srclen,
260 trgstore, trgstorelen);
261 else if (
state == -1)
263 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
264 errmsg(
"invalid syntax: more than two strings in unaccent rule")));
265 else if (
state == -2)
267 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
268 errmsg(
"invalid syntax: unfinished quoted string in unaccent rule")));
282 if (errdata->
sqlerrcode == ERRCODE_UNTRANSLATABLE_CHARACTER)
316 while (node && matchlen < srclen)
318 node = node + src[matchlen];
324 *p_matchlen = matchlen;
339 bool fileloaded =
false;
342 foreach(l, dictoptions)
346 if (strcmp(defel->
defname,
"rules") == 0)
350 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
351 errmsg(
"multiple Rules parameters")));
358 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
359 errmsg(
"unrecognized Unaccent parameter: \"%s\"",
367 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
368 errmsg(
"missing Rules parameter")));
381 char *srcstart = srcchar;
397 if (
buf.data == NULL)
402 if (srcchar != srcstart)
410 if (
buf.data != NULL)
419 if (
buf.data != NULL)
451 const char *dictname =
"unaccent";
458 (
errcode(ERRCODE_UNDEFINED_OBJECT),
459 errmsg(
"text search dictionary \"%s.%s\" does not exist",
484 else if (
res->lexeme == NULL)
#define Assert(condition)
#define OidIsValid(objectId)
static void PGresult * res
char * defGetString(DefElem *def)
void FlushErrorState(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
ErrorData * CopyErrorData(void)
#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)
char * get_namespace_name(Oid nspid)
Oid get_func_namespace(Oid funcid)
int pg_mblen(const char *mbstr)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
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)
MemoryContextSwitchTo(old_ctx)
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)
int t_isspace(const char *ptr)
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)
Datum unaccent_dict(PG_FUNCTION_ARGS)
static TrieChar * placeChar(TrieChar *node, const unsigned char *str, int lenstr, const char *replaceTo, int replacelen)
static TrieChar * findReplaceTo(TrieChar *node, const unsigned char *src, int srclen, int *p_matchlen)
#define VARSIZE_ANY_EXHDR(PTR)
text * cstring_to_text(const char *s)