showsign-debug.patch
text/x-diff
Filename: showsign-debug.patch
Type: text/x-diff
Part: 1
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index b328a09..b5be800 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -44,6 +44,9 @@ Datum gtrgm_penalty(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(gtrgm_picksplit);
Datum gtrgm_picksplit(PG_FUNCTION_ARGS);
+PG_FUNCTION_INFO_V1(gtrgm_showsign);
+Datum gtrgm_showsign(PG_FUNCTION_ARGS);
+
#define GETENTRY(vec,pos) ((TRGM *) DatumGetPointer((vec)->vector[(pos)].key))
/* Number of one-bits in an unsigned byte */
@@ -98,6 +101,32 @@ makesign(BITVECP sign, TRGM *a)
}
}
+static char *
+printsign(BITVECP sign)
+{
+ static char c[200];
+ char *p = c;
+ int i;
+ for(i=0; i < SIGLEN;i++)
+ {
+ p += snprintf(p, 3, "%02x", (unsigned int) (((unsigned char *) sign)[i]));
+ }
+ return c;
+}
+
+Datum
+gtrgm_showsign(PG_FUNCTION_ARGS)
+{
+ text *in = PG_GETARG_TEXT_P(0);
+ BITVEC sign;
+ TRGM *trg;
+
+ trg = generate_trgm(VARDATA(in), VARSIZE(in) - VARHDRSZ);
+ makesign(sign, trg);
+
+ PG_RETURN_TEXT_P(cstring_to_text(printsign(sign)));
+}
+
Datum
gtrgm_compress(PG_FUNCTION_ARGS)
{