Re: bytea operator bugs (was Re: [GENERAL] BYTEA, indexes - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: bytea operator bugs (was Re: [GENERAL] BYTEA, indexes |
Date | |
Msg-id | 200208220447.g7M4lHR07410@candle.pha.pa.us Whole thread Raw |
In response to | Re: bytea operator bugs (was Re: [GENERAL] BYTEA, indexes (Joe Conway <mail@joeconway.com>) |
List | pgsql-patches |
Patch applied. Thanks. Added to TODO: * Allow bytea to handle LIKE with non-TEXT patterns --------------------------------------------------------------------------- Joe Conway wrote: > Joe Conway wrote: > > Back on the pattern selectivity issue. With some more study I can > > clearly see what you were referring to. Dragging string length through > > the maze of function calls that would need it would be a mess. > > > > In the longer term (i.e. not for 7.3) it might make sense to create a > > set of pattern selectivity functions, just for bytea, that are careful > > to avoid the null-terminated string assumption. But, for now, I'm > > leaning toward restricting the right-hand argument of bytealike to TEXT, > > as you suggested. > > As suggested by Tom, this patch restricts the right-hand argument of > bytealike to TEXT. > > This leaves like_escape_bytea() without anything to do, but I left it in > place in anticipation of the eventual bytea pattern selectivity > functions. If there is agreement that this would be the best long term > solution, I'll take it as a TODO for 7.4. > > I'll look around the docs to see if there is someplace where a note wrt > this is appropriate. > > If there are no objections, please apply. > > Thanks, > > Joe > Index: src/backend/utils/adt/like.c > =================================================================== > RCS file: /opt/src/cvs/pgsql-server/src/backend/utils/adt/like.c,v > retrieving revision 1.49 > diff -c -r1.49 like.c > *** src/backend/utils/adt/like.c 20 Jun 2002 20:29:37 -0000 1.49 > --- src/backend/utils/adt/like.c 19 Aug 2002 17:06:10 -0000 > *************** > *** 264,270 **** > bytealike(PG_FUNCTION_ARGS) > { > bytea *str = PG_GETARG_BYTEA_P(0); > ! bytea *pat = PG_GETARG_BYTEA_P(1); > bool result; > unsigned char *s, > *p; > --- 264,270 ---- > bytealike(PG_FUNCTION_ARGS) > { > bytea *str = PG_GETARG_BYTEA_P(0); > ! text *pat = PG_GETARG_TEXT_P(1); > bool result; > unsigned char *s, > *p; > *************** > *** 285,291 **** > byteanlike(PG_FUNCTION_ARGS) > { > bytea *str = PG_GETARG_BYTEA_P(0); > ! bytea *pat = PG_GETARG_BYTEA_P(1); > bool result; > unsigned char *s, > *p; > --- 285,291 ---- > byteanlike(PG_FUNCTION_ARGS) > { > bytea *str = PG_GETARG_BYTEA_P(0); > ! text *pat = PG_GETARG_TEXT_P(1); > bool result; > unsigned char *s, > *p; > Index: src/include/catalog/pg_operator.h > =================================================================== > RCS file: /opt/src/cvs/pgsql-server/src/include/catalog/pg_operator.h,v > retrieving revision 1.106 > diff -c -r1.106 pg_operator.h > *** src/include/catalog/pg_operator.h 24 Jul 2002 19:11:12 -0000 1.106 > --- src/include/catalog/pg_operator.h 19 Aug 2002 17:43:31 -0000 > *************** > *** 827,835 **** > DATA(insert OID = 1958 ( "<=" PGNSP PGUID b f 17 17 16 1960 1959 0 0 0 0 byteale scalarltsel scalarltjoinsel)); > DATA(insert OID = 1959 ( ">" PGNSP PGUID b f 17 17 16 1957 1958 0 0 0 0 byteagt scalargtsel scalargtjoinsel)); > DATA(insert OID = 1960 ( ">=" PGNSP PGUID b f 17 17 16 1958 1957 0 0 0 0 byteage scalargtsel scalargtjoinsel)); > ! DATA(insert OID = 2016 ( "~~" PGNSP PGUID b f 17 17 16 0 2017 0 0 0 0 bytealike likesel likejoinsel)); > #define OID_BYTEA_LIKE_OP 2016 > ! DATA(insert OID = 2017 ( "!~~" PGNSP PGUID b f 17 17 16 0 2016 0 0 0 0 byteanlike nlikesel nlikejoinsel)); > DATA(insert OID = 2018 ( "||" PGNSP PGUID b f 17 17 17 0 0 0 0 0 0 byteacat - - )); > > /* timestamp operators */ > --- 827,835 ---- > DATA(insert OID = 1958 ( "<=" PGNSP PGUID b f 17 17 16 1960 1959 0 0 0 0 byteale scalarltsel scalarltjoinsel)); > DATA(insert OID = 1959 ( ">" PGNSP PGUID b f 17 17 16 1957 1958 0 0 0 0 byteagt scalargtsel scalargtjoinsel)); > DATA(insert OID = 1960 ( ">=" PGNSP PGUID b f 17 17 16 1958 1957 0 0 0 0 byteage scalargtsel scalargtjoinsel)); > ! DATA(insert OID = 2016 ( "~~" PGNSP PGUID b f 17 25 16 0 2017 0 0 0 0 bytealike likesel likejoinsel)); > #define OID_BYTEA_LIKE_OP 2016 > ! DATA(insert OID = 2017 ( "!~~" PGNSP PGUID b f 17 25 16 0 2016 0 0 0 0 byteanlike nlikesel nlikejoinsel)); > DATA(insert OID = 2018 ( "||" PGNSP PGUID b f 17 17 17 0 0 0 0 0 0 byteacat - - )); > > /* timestamp operators */ > Index: src/include/catalog/pg_proc.h > =================================================================== > RCS file: /opt/src/cvs/pgsql-server/src/include/catalog/pg_proc.h,v > retrieving revision 1.256 > diff -c -r1.256 pg_proc.h > *** src/include/catalog/pg_proc.h 17 Aug 2002 13:04:15 -0000 1.256 > --- src/include/catalog/pg_proc.h 19 Aug 2002 17:06:10 -0000 > *************** > *** 2766,2778 **** > DATA(insert OID = 1969 ( timetz PGNSP PGUID 12 f f t f i 2 1266 "1266 23" timetz_scale - _null_ )); > DESCR("adjust time with time zone precision"); > > ! DATA(insert OID = 2005 ( bytealike PGNSP PGUID 12 f f t f i 2 16 "17 17" bytealike - _null_ )); > DESCR("matches LIKE expression"); > ! DATA(insert OID = 2006 ( byteanlike PGNSP PGUID 12 f f t f i 2 16 "17 17" byteanlike - _null_ )); > DESCR("does not match LIKE expression"); > ! DATA(insert OID = 2007 ( like PGNSP PGUID 12 f f t f i 2 16 "17 17" bytealike - _null_ )); > DESCR("matches LIKE expression"); > ! DATA(insert OID = 2008 ( notlike PGNSP PGUID 12 f f t f i 2 16 "17 17" byteanlike - _null_ )); > DESCR("does not match LIKE expression"); > DATA(insert OID = 2009 ( like_escape PGNSP PGUID 12 f f t f i 2 17 "17 17" like_escape_bytea - _null_ )); > DESCR("convert match pattern to use backslash escapes"); > --- 2766,2778 ---- > DATA(insert OID = 1969 ( timetz PGNSP PGUID 12 f f t f i 2 1266 "1266 23" timetz_scale - _null_ )); > DESCR("adjust time with time zone precision"); > > ! DATA(insert OID = 2005 ( bytealike PGNSP PGUID 12 f f t f i 2 16 "17 25" bytealike - _null_ )); > DESCR("matches LIKE expression"); > ! DATA(insert OID = 2006 ( byteanlike PGNSP PGUID 12 f f t f i 2 16 "17 25" byteanlike - _null_ )); > DESCR("does not match LIKE expression"); > ! DATA(insert OID = 2007 ( like PGNSP PGUID 12 f f t f i 2 16 "17 25" bytealike - _null_ )); > DESCR("matches LIKE expression"); > ! DATA(insert OID = 2008 ( notlike PGNSP PGUID 12 f f t f i 2 16 "17 25" byteanlike - _null_ )); > DESCR("does not match LIKE expression"); > DATA(insert OID = 2009 ( like_escape PGNSP PGUID 12 f f t f i 2 17 "17 17" like_escape_bytea - _null_ )); > DESCR("convert match pattern to use backslash escapes"); > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
pgsql-patches by date: