Re: [PATCHES] Small perf fixes/cleanup in src/backend/utils/adt/like.c...

2003-06-23 Thread Sean Chittenden
> > While doing some review of the LIKE function, I noticed some useless
> > bits left over from the pre-MB and converting-MB world.
> 
> Isn't this patch going to destroy performance in single-byte
> encodings?  I don't think the present state of the LIKE code is an
> intermediate state --- it's exactly where we want it to be.

cpp is my friend.  I get how this was working now: didn't notice the
2nd #include "like_match.c" earlier and thought all definitions of
MatchText and MBMatchText were the same.  Tricky with the macro
expansion and redefinitions.  -sc

-- 
Sean Chittenden

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [PATCHES] Small perf fixes/cleanup in src/backend/utils/adt/like.c...

2003-06-23 Thread Tom Lane
Sean Chittenden <[EMAIL PROTECTED]> writes:
> While doing some review of the LIKE function, I noticed some useless
> bits left over from the pre-MB and converting-MB world.

Isn't this patch going to destroy performance in single-byte encodings?
I don't think the present state of the LIKE code is an intermediate
state --- it's exactly where we want it to be.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


[PATCHES] Small perf fixes/cleanup in src/backend/utils/adt/like.c...

2003-06-22 Thread Sean Chittenden
While doing some review of the LIKE function, I noticed some useless
bits left over from the pre-MB and converting-MB world.  These are
close to no ops, but it removes at least one function call from every
row processed by the LIKE operator, and it seemed like a slight clean
up of some #defines, which helped reduce some clutter.  If someone'd
like, I can clean this up so it's not doing a #include of a .c file,
which seemed a bit hoakey, but with least resistance as the goal, this
patch should stand alone and as it is: all regression tests pass. -sc

-- 
Sean Chittenden
Index: like.c
===
RCS file: /home/ncvs/pgsql/pgsql-server/src/backend/utils/adt/like.c,v
retrieving revision 1.53
diff -u -r1.53 like.c
--- like.c  3 Sep 2002 21:45:42 -   1.53
+++ like.c  23 Jun 2003 06:19:01 -
@@ -36,11 +36,6 @@
   unsigned char *p, int plen);
 static text *do_like_escape(text *, text *);
 
-static int MBMatchText(unsigned char *t, int tlen,
-   unsigned char *p, int plen);
-static int MBMatchTextIC(unsigned char *t, int tlen,
- unsigned char *p, int plen);
-static text *MB_do_like_escape(text *, text *);
 
 /*
  * Support routine for MatchText. Compares given multibyte streams
@@ -116,17 +111,11 @@
 *(dst)++ = *(src)++; \
   } while (0)
 
-#define MatchText  MBMatchText
-#define MatchTextIC MBMatchTextIC
-#define do_like_escape MB_do_like_escape
 #include "like_match.c"
 #undef CHAREQ
 #undef ICHAREQ
 #undef NextChar
 #undef CopyAdvChar
-#undef MatchText
-#undef MatchTextIC
-#undef do_like_escape
 
 #define CHAREQ(p1, p2) (*(p1) == *(p2))
 #define ICHAREQ(p1, p2) (tolower(*(p1)) == tolower(*(p2)))
@@ -136,7 +125,6 @@
 #define BYTEA_CHAREQ(p1, p2) (*(p1) == *(p2))
 #define BYTEA_NextChar(p, plen) ((p)++, (plen)--)
 #define BYTEA_CopyAdvChar(dst, src, srclen) (*(dst)++ = *(src)++, (srclen)--)
-#include "like_match.c"
 
 /*
  * interface routines called by the function manager
@@ -158,10 +146,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
-   else
-   result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+   result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -182,10 +167,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
-   else
-   result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+   result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -206,10 +188,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
-   else
-   result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
+   result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -230,10 +209,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
-   else
-   result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
+   result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -300,10 +276,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
-   else
-   result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+   result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -324,10 +297,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
-   else
-   result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
+   result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -348,10 +318,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_length() == 1)
-   result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
-   else
-   result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
+   result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
 
PG_RETURN_BOOL(result);
 }
@@ -372,10 +339,7 @@
p = VARDATA(pat);
plen = (VARSIZE(pat) - VARHDRSZ);
 
-   if (pg_database_encoding_max_