PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <ctype.h>
#include "utils/builtins.h"
#include "utils/varlena.h"
#include "varatt.h"
Go to the source code of this file.
Macros | |
#define | SOUNDEX_LEN 4 |
#define | MAX_METAPHONE_STRLEN 255 |
#define | SH 'X' |
#define | TH '0' |
#define | isvowel(c) (getcode(c) & 1) /* AEIOU */ |
#define | NOCHANGE(c) (getcode(c) & 2) /* FJMNR */ |
#define | AFFECTH(c) (getcode(c) & 4) /* CGPST */ |
#define | MAKESOFT(c) (getcode(c) & 8) /* EIY */ |
#define | NOGHTOF(c) (getcode(c) & 16) /* BDH */ |
#define | Next_Letter (toupper((unsigned char) word[w_idx+1])) |
#define | Curr_Letter (toupper((unsigned char) word[w_idx])) |
#define | Look_Back_Letter(n) (w_idx >= (n) ? toupper((unsigned char) word[w_idx-(n)]) : '\0') |
#define | Prev_Letter (Look_Back_Letter(1)) |
#define | After_Next_Letter (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0') |
#define | Look_Ahead_Letter(n) toupper((unsigned char) Lookahead(word+w_idx, n)) |
#define | Phonize(c) do {(*phoned_word)[p_idx++] = c;} while (0) |
#define | End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0) |
#define | Phone_Len (p_idx) |
#define | Isbreak(c) (!isalpha((unsigned char) (c))) |
Functions | |
static void | _soundex (const char *instr, char *outstr) |
static char | soundex_code (char letter) |
static char | Lookahead (char *word, int how_far) |
static void | _metaphone (char *word, int max_phonemes, char **phoned_word) |
static int | getcode (char c) |
PG_FUNCTION_INFO_V1 (levenshtein_with_costs) | |
Datum | levenshtein_with_costs (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (levenshtein) | |
Datum | levenshtein (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (levenshtein_less_equal_with_costs) | |
Datum | levenshtein_less_equal_with_costs (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (levenshtein_less_equal) | |
Datum | levenshtein_less_equal (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (metaphone) | |
Datum | metaphone (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (soundex) | |
Datum | soundex (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (difference) | |
Datum | difference (PG_FUNCTION_ARGS) |
Variables | |
PG_MODULE_MAGIC | |
static const char *const | soundex_table = "01230120022455012623010202" |
static const char | _codes [26] |
Definition at line 138 of file fuzzystrmatch.c.
#define After_Next_Letter (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0') |
Definition at line 310 of file fuzzystrmatch.c.
#define Curr_Letter (toupper((unsigned char) word[w_idx])) |
Definition at line 303 of file fuzzystrmatch.c.
#define End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0) |
Definition at line 335 of file fuzzystrmatch.c.
Definition at line 340 of file fuzzystrmatch.c.
Definition at line 132 of file fuzzystrmatch.c.
Definition at line 312 of file fuzzystrmatch.c.
#define Look_Back_Letter | ( | n | ) | (w_idx >= (n) ? toupper((unsigned char) word[w_idx-(n)]) : '\0') |
Definition at line 305 of file fuzzystrmatch.c.
Definition at line 141 of file fuzzystrmatch.c.
#define MAX_METAPHONE_STRLEN 255 |
Definition at line 72 of file fuzzystrmatch.c.
#define Next_Letter (toupper((unsigned char) word[w_idx+1])) |
Definition at line 301 of file fuzzystrmatch.c.
Definition at line 135 of file fuzzystrmatch.c.
Definition at line 144 of file fuzzystrmatch.c.
#define Phone_Len (p_idx) |
Definition at line 337 of file fuzzystrmatch.c.
Definition at line 333 of file fuzzystrmatch.c.
#define Prev_Letter (Look_Back_Letter(1)) |
Definition at line 308 of file fuzzystrmatch.c.
#define SH 'X' |
Definition at line 103 of file fuzzystrmatch.c.
#define SOUNDEX_LEN 4 |
Definition at line 54 of file fuzzystrmatch.c.
#define TH '0' |
Definition at line 104 of file fuzzystrmatch.c.
|
static |
Definition at line 344 of file fuzzystrmatch.c.
References AFFECTH, After_Next_Letter, Curr_Letter, elog, End_Phoned_Word, ERROR, Isbreak, isvowel, Look_Ahead_Letter, Look_Back_Letter, MAKESOFT, Next_Letter, NOGHTOF, palloc(), Phone_Len, Phonize, Prev_Letter, SH, TH, and word().
Referenced by metaphone().
|
static |
Definition at line 723 of file fuzzystrmatch.c.
References Assert, soundex_code(), and SOUNDEX_LEN.
Referenced by difference(), and soundex().
Datum difference | ( | PG_FUNCTION_ARGS | ) |
Definition at line 775 of file fuzzystrmatch.c.
References _soundex(), i, PG_GETARG_TEXT_PP, PG_RETURN_INT32, SOUNDEX_LEN, and text_to_cstring().
Referenced by checkcondition_str(), ExtendMultiXactMember(), find_wordentry(), getKeyJsonValueFromContainer(), hstore_concat(), hstore_delete_array(), hstore_delete_hstore(), hstore_subscript_assign(), and hstoreFindKey().
|
static |
Datum levenshtein | ( | PG_FUNCTION_ARGS | ) |
Definition at line 174 of file fuzzystrmatch.c.
References PG_GETARG_TEXT_PP, PG_RETURN_INT32, VARDATA_ANY, VARSIZE_ANY_EXHDR, and varstr_levenshtein().
Datum levenshtein_less_equal | ( | PG_FUNCTION_ARGS | ) |
Definition at line 226 of file fuzzystrmatch.c.
References PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_INT32, VARDATA_ANY, VARSIZE_ANY_EXHDR, and varstr_levenshtein_less_equal().
Datum levenshtein_less_equal_with_costs | ( | PG_FUNCTION_ARGS | ) |
Definition at line 197 of file fuzzystrmatch.c.
References PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_INT32, VARDATA_ANY, VARSIZE_ANY_EXHDR, and varstr_levenshtein_less_equal().
Datum levenshtein_with_costs | ( | PG_FUNCTION_ARGS | ) |
Definition at line 148 of file fuzzystrmatch.c.
References PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_INT32, VARDATA_ANY, VARSIZE_ANY_EXHDR, and varstr_levenshtein().
|
static |
Definition at line 318 of file fuzzystrmatch.c.
Datum metaphone | ( | PG_FUNCTION_ARGS | ) |
Definition at line 257 of file fuzzystrmatch.c.
References _metaphone(), cstring_to_text(), ereport, errcode(), errmsg(), ERROR, MAX_METAPHONE_STRLEN, PG_GETARG_DATUM, PG_GETARG_INT32, PG_RETURN_TEXT_P, and TextDatumGetCString.
PG_FUNCTION_INFO_V1 | ( | difference | ) |
PG_FUNCTION_INFO_V1 | ( | levenshtein | ) |
PG_FUNCTION_INFO_V1 | ( | levenshtein_less_equal | ) |
PG_FUNCTION_INFO_V1 | ( | levenshtein_less_equal_with_costs | ) |
PG_FUNCTION_INFO_V1 | ( | levenshtein_with_costs | ) |
PG_FUNCTION_INFO_V1 | ( | metaphone | ) |
PG_FUNCTION_INFO_V1 | ( | soundex | ) |
Datum soundex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 710 of file fuzzystrmatch.c.
References _soundex(), arg, cstring_to_text(), PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, SOUNDEX_LEN, and text_to_cstring().
Referenced by daitch_mokotoff(), daitch_mokotoff_coding(), find_or_create_child_node(), update_leaves(), and update_node().
|
static |
|
static |
Definition at line 114 of file fuzzystrmatch.c.
Referenced by getcode().
PG_MODULE_MAGIC |
Definition at line 47 of file fuzzystrmatch.c.
|
static |
Definition at line 57 of file fuzzystrmatch.c.
Referenced by soundex_code().