66 curnode = node + *
str;
72 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
73 errmsg(
"duplicate source strings, first one will be used")));
106 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
107 errmsg(
"could not open unaccent file \"%s\": %m",
148 char *trgstore = NULL;
153 bool trgquoted =
false;
156 for (ptr = line; *ptr; ptr += ptrlen)
210 if (*(ptr + 1) ==
'"')
238 if (trgquoted &&
state > 0)
241 trgstore = (
char *)
palloc(
sizeof(
char) * (trglen - 2));
243 for (
int i = 1;
i < trglen - 1;
i++)
245 trgstore[trgstorelen] = trg[
i];
248 if (trg[
i] ==
'"' && trg[
i + 1] ==
'"')
254 trgstore = (
char *)
palloc(
sizeof(
char) * trglen);
255 trgstorelen = trglen;
256 memcpy(trgstore, trg, trgstorelen);
261 (
unsigned char *) src, srclen,
262 trgstore, trgstorelen);
263 else if (
state == -1)
265 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
266 errmsg(
"invalid syntax: more than two strings in unaccent rule")));
267 else if (
state == -2)
269 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
270 errmsg(
"invalid syntax: unfinished quoted string in unaccent rule")));
284 if (errdata->
sqlerrcode == ERRCODE_UNTRANSLATABLE_CHARACTER)
318 while (node && matchlen < srclen)
320 node = node + src[matchlen];
326 *p_matchlen = matchlen;
341 bool fileloaded =
false;
344 foreach(l, dictoptions)
348 if (strcmp(defel->
defname,
"rules") == 0)
352 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
353 errmsg(
"multiple Rules parameters")));
360 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
361 errmsg(
"unrecognized Unaccent parameter: \"%s\"",
369 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
370 errmsg(
"missing Rules parameter")));
383 char *srcstart = srcchar;
399 if (
buf.data == NULL)
404 if (srcchar != srcstart)
412 if (
buf.data != NULL)
421 if (
buf.data != NULL)
453 const char *dictname =
"unaccent";
460 (
errcode(ERRCODE_UNDEFINED_OBJECT),
461 errmsg(
"text search dictionary \"%s.%s\" does not exist",
486 else if (
res->lexeme == NULL)
#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)
Assert(fmt[strlen(fmt) - 1] !='\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 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)
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)