b0VIM 7.4      SÿcTRT\ -{  pg                                      hamster                                 ~pg/postgresql/0001-Move-Levenshtein-distance-implementation-into-core.patch                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       3210    #"! U                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 tp
           h                     ÿÿÿÿÿÿÿÿo       i              þÿÿÿÿÿÿÿr       Ø              ýÿÿÿÿÿÿÿr       J             üÿÿÿÿÿÿÿ{       ¼             ûÿÿÿÿÿÿÿQ       7             úÿÿÿÿÿÿÿu       ˆ             ùÿÿÿÿÿÿÿ~       ý             øÿÿÿÿÿÿÿ}       {                           ø                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ad     É     h       ¹  “  m  %  $  á  ˜  Z  !     Ù  ‘  H      ì  ·  g  8  é  ¹  Š  T    ä
  ã
  –
  x
  S
  .
  
  Ú	  ©	  ¢	   	  o	  ?	  ä  Æ  š  n  I  !  ñ  ï  ¿  «  o  l  Z  V  L  1        	    í  Í  ³  ±  ƒ  |  R    ð  Ì  ¨  ¦  ^  H  2  !      Ú  ½     `  <      Î  ´  ±  ¯  ­  z  w  P  )  '  ë  Õ  ¿  ®     ž  g  J  -  í  É  È               +	s_bytes = VARSIZE_ANY_EXHDR(src); +	/* Determine length of each string in bytes and characters */ +	t_data = VARDATA_ANY(dst); +	s_data = VARDATA_ANY(src); +	/* Extract a pointer to the actual character data */ + +				t_bytes; +	int			s_bytes, +	const char *t_data; +	const char *s_data; -	PG_RETURN_INT32(levenshtein_internal(src, dst, 1, 1, 1)); -  	text	   *dst = PG_GETARG_TEXT_PP(1);  	text	   *src = PG_GETARG_TEXT_PP(0);  { @@ -191,8 +186,20 @@ levenshtein(PG_FUNCTION_ARGS)      } +								 del_c, sub_c)); +	PG_RETURN_INT32(varstr_leven(s_data, s_bytes, t_data, t_bytes, ins_c, + +	t_bytes = VARSIZE_ANY_EXHDR(dst); +	s_bytes = VARSIZE_ANY_EXHDR(src); +	/* Determine length of each string in bytes and characters */ +	t_data = VARDATA_ANY(dst); +	s_data = VARDATA_ANY(src); +	/* Extract a pointer to the actual character data */ + +				t_bytes; +	int			s_bytes, +	const char *t_data; +	const char *s_data; -	PG_RETURN_INT32(levenshtein_internal(src, dst, ins_c, del_c, sub_c)); -  	int			sub_c = PG_GETARG_INT32(4);  	int			del_c = PG_GETARG_INT32(3);  	int			ins_c = PG_GETARG_INT32(2); @@ -180,8 +163,20 @@ levenshtein_with_costs(PG_FUNCTION_ARGS)  levenshtein_with_costs(PG_FUNCTION_ARGS)  Datum  PG_FUNCTION_INFO_V1(levenshtein_with_costs); - -#include "levenshtein.c" -#define LEVENSHTEIN_LESS_EQUAL -#include "levenshtein.c" - -} -	return true; -	} -			return false; -		if (s1[len] != s2[len]) -		len--; -	{ -	while (len > 0) -{ -rest_of_char_same(const char *s1, const char *s2, int len) -static inline bool -/* Faster than memcmp(), for this use case. */    #define NOGHTOF(c)	(getcode(c) & 16)	/* BDH */  /* These prevent GH from becoming F */ @@ -154,23 +154,6 @@ getcode(char c) +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c --- a/contrib/fuzzystrmatch/fuzzystrmatch.c index 7a53d8a..62e650f 100644 diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c -fuzzystrmatch.o: fuzzystrmatch.c levenshtein.c -# levenshtein.c is #included by fuzzystrmatch.c -  endif  include $(top_srcdir)/contrib/contrib-global.mk  include $(top_builddir)/src/Makefile.global @@ -17,6 +17,3 @@ top_builddir = ../.. +++ b/contrib/fuzzystrmatch/Makefile --- a/contrib/fuzzystrmatch/Makefile index 024265d..0327d95 100644 diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile   create mode 100644 src/backend/utils/adt/levenshtein.c  delete mode 100644 contrib/fuzzystrmatch/levenshtein.c  7 files changed, 481 insertions(+), 431 deletions(-)  src/include/utils/builtins.h          |   5 +  src/backend/utils/adt/varlena.c       |  24 ++  src/backend/utils/adt/levenshtein.c   | 394 +++++++++++++++++++++++++++++++++  src/backend/utils/adt/Makefile        |   2 +  contrib/fuzzystrmatch/levenshtein.c   | 403 ----------------------------------  contrib/fuzzystrmatch/fuzzystrmatch.c |  81 ++++---  contrib/fuzzystrmatch/Makefile        |   3 - --- helpful in building diagnostic messages. An in-core Levenshtein distance implementation is only anticipated to be into core in the future, due to the MAX_LEVENSHTEIN_STRLEN restriction. It is not anticipated that the user-facing SQL functions will be moved  fuzzystmatch definitions become simple forwarding stubs. only be used with the fuzzystmatch extension installed -- the /contrib to core.  However, the related SQL-callable functions may still The fuzzystmatch Levenshtein distance implementation is moved from  Subject: [PATCH 1/2] Move Levenshtein distance implementation into core Date: Sat, 30 Nov 2013 23:15:00 -0800 From: Peter Geoghegan <pg@heroku.com> From b7df918f1a52107637600f3b22d1cff18bd07ae1 Mon Sep 17 00:00:00 2001 ad  Ô  0            Ý  •  j  ?  ï  ¤  p  .  û  Ï  ™  U  ;  7  1  0  /                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1.9.1 --   					  List **namelist);  extern bool SplitIdentifierString(char *rawstring, char separator,  extern List *textToQualifiedNameList(text *textval); +									int del_c, int sub_c, int max_d); +									const char *target, int tlen, int ins_c, +extern int	varstr_leven_less_equal(const char *source, int slen, +						 int tlen, int ins_c, int del_c, int sub_c); +extern int	varstr_leven(const char *source, int slen, const char *target,  extern int	varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid);  extern Datum text_name(PG_FUNCTION_ARGS);  extern Datum name_text(PG_FUNCTION_ARGS); @@ -786,6 +786,11 @@ extern Datum textoverlay_no_len(PG_FUNCTION_ARGS); +++ b/src/include/utils/builtins.h 