48 .
name =
"fuzzystrmatch",
75#define MAX_METAPHONE_STRLEN 255
103#undef USE_TRADITIONAL_METAPHONE
118 1, 16, 4, 16, 9, 2, 4, 16, 9, 2, 0, 2, 2, 2, 1, 4, 0, 2, 4, 4, 1, 0, 0, 0, 8, 0
127 if (
c >=
'A' &&
c <=
'Z')
136 return (
c >=
'A' &&
c <=
'Z') ||
137 (
c >=
'a' &&
c <=
'z');
140#define isvowel(c) (getcode(c) & 1)
143#define NOCHANGE(c) (getcode(c) & 2)
146#define AFFECTH(c) (getcode(c) & 4)
149#define MAKESOFT(c) (getcode(c) & 8)
152#define NOGHTOF(c) (getcode(c) & 16)
279 errmsg(
"argument exceeds the maximum length of %d bytes",
286 errmsg(
"output exceeds the maximum length of %d bytes",
292 errmsg(
"output cannot be empty string")));
309#define Next_Letter (pg_ascii_toupper((unsigned char) word[w_idx+1]))
311#define Curr_Letter (pg_ascii_toupper((unsigned char) word[w_idx]))
313#define Look_Back_Letter(n) \
314 (w_idx >= (n) ? pg_ascii_toupper((unsigned char) word[w_idx-(n)]) : '\0')
316#define Prev_Letter (Look_Back_Letter(1))
318#define After_Next_Letter \
319 (Next_Letter != '\0' ? pg_ascii_toupper((unsigned char) word[w_idx+2]) : '\0')
320#define Look_Ahead_Letter(n) pg_ascii_toupper((unsigned char) Lookahead(word+w_idx, n))
341#define Phonize(c) do {(*phoned_word)[p_idx++] = c;} while (0)
343#define End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0)
345#define Phone_Len (p_idx)
348#define Isbreak(c) (!ascii_isalpha((unsigned char) (c)))
368 elog(
ERROR,
"metaphone: Requested output length must be > 0");
373 elog(
ERROR,
"metaphone: Input string length must be > 0");
525#ifndef USE_TRADITIONAL_METAPHONE
638#ifndef USE_TRADITIONAL_METAPHONE
Datum idx(PG_FUNCTION_ARGS)
#define TextDatumGetCString(d)
#define Assert(condition)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_TEXT_PP(n)
#define PG_MODULE_MAGIC_EXT(...)
#define PG_GETARG_DATUM(n)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
Datum metaphone(PG_FUNCTION_ARGS)
static void _metaphone(char *word, int max_phonemes, char **phoned_word)
#define After_Next_Letter
Datum levenshtein_less_equal_with_costs(PG_FUNCTION_ARGS)
#define Look_Back_Letter(n)
static const char *const soundex_table
Datum soundex(PG_FUNCTION_ARGS)
static char soundex_code(char letter)
static const char _codes[26]
Datum levenshtein_with_costs(PG_FUNCTION_ARGS)
static bool ascii_isalpha(char c)
static void _soundex(const char *instr, char *outstr)
static int getcode(char c)
Datum difference(PG_FUNCTION_ARGS)
#define MAX_METAPHONE_STRLEN
static char Lookahead(char *word, int how_far)
Datum levenshtein_less_equal(PG_FUNCTION_ARGS)
#define Look_Ahead_Letter(n)
Datum levenshtein(PG_FUNCTION_ARGS)
int varstr_levenshtein(const char *source, int slen, const char *target, int tlen, int ins_c, int del_c, int sub_c, bool trusted)
static unsigned char pg_ascii_toupper(unsigned char ch)
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
int varstr_levenshtein_less_equal(const char *source, int slen, const char *target, int tlen, int ins_c, int del_c, int sub_c, int max_d, bool trusted)