mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Sorry - I should have gotten to this sooner. Here's a patch which you should
be able to apply against what you just committed. It rolls soundex into fuzzystrmatch. Remove soundex/metaphone and merge into fuzzystrmatch. Joe Conway
This commit is contained in:
@ -51,32 +51,43 @@
|
||||
#include "utils/builtins.h"
|
||||
|
||||
|
||||
#define MAX_LEVENSHTEIN_STRLEN 255
|
||||
#define MAX_METAPHONE_STRLEN 255
|
||||
|
||||
typedef struct dynmatrix
|
||||
{
|
||||
int value;
|
||||
} dynmat;
|
||||
|
||||
|
||||
/*
|
||||
* External declarations
|
||||
*/
|
||||
extern Datum levenshtein(PG_FUNCTION_ARGS);
|
||||
extern Datum metaphone(PG_FUNCTION_ARGS);
|
||||
extern Datum soundex(PG_FUNCTION_ARGS);
|
||||
|
||||
/*
|
||||
* Internal declarations
|
||||
* Soundex
|
||||
*/
|
||||
static void _soundex(const char *instr, char *outstr);
|
||||
|
||||
#define SOUNDEX_LEN 4
|
||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
||||
#define _textout(str) DatumGetPointer(DirectFunctionCall1(textout, PointerGetDatum(str)))
|
||||
|
||||
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||
static const char *soundex_table = "01230120022455012623010202";
|
||||
|
||||
#define soundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A']
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Levenshtein
|
||||
*/
|
||||
#define STRLEN(p) strlen(p)
|
||||
#define CHAREQ(p1, p2) (*(p1) == *(p2))
|
||||
#define NextChar(p) ((p)++)
|
||||
#define MAX_LEVENSHTEIN_STRLEN 255
|
||||
|
||||
|
||||
/*
|
||||
* Metaphone
|
||||
*/
|
||||
#define MAX_METAPHONE_STRLEN 255
|
||||
|
||||
/*
|
||||
* Original code by Michael G Schwern starts here.
|
||||
* Code slightly modified for use as PostgreSQL
|
||||
|
Reference in New Issue
Block a user