On Thu, 22 Mar 2007, Tom Lane wrote:

> I'd vote for making this new code look like the rest of it, to wit
> hardwire the values.

Attached please find a patch which does this.



-- 
Although written many years ago, Lady Chatterley's Lover has just been
reissued by the Grove Press, and this pictorial account of the
day-to-day life of an English gamekeeper is full of considerable
interest to outdoor minded readers, as it contains many passages on
pheasant-raising, the apprehending of poachers, ways to control vermin,
and other chores and duties of the professional gamekeeper.
Unfortunately, one is obliged to wade through many pages of extraneous
material in order to discover and savour those sidelights on the
management of a midland shooting estate, and in this reviewer's opinion
the book cannot take the place of J. R. Miller's "Practical
Gamekeeping."
                -- Ed Zern, "Field and Stream" (Nov. 1959)
Index: src/backend/utils/adt/regexp.c
===================================================================
RCS file: 
/home/jeremyd/local/postgres/cvsuproot/pgsql/src/backend/utils/adt/regexp.c,v
retrieving revision 1.70
diff -c -r1.70 regexp.c
*** src/backend/utils/adt/regexp.c      20 Mar 2007 05:44:59 -0000      1.70
--- src/backend/utils/adt/regexp.c      22 Mar 2007 05:17:15 -0000
***************
*** 30,35 ****
--- 30,36 ----
  #include "postgres.h"
  
  #include "access/heapam.h"
+ #include "catalog/pg_type.h"
  #include "funcapi.h"
  #include "regex/regex.h"
  #include "utils/builtins.h"
***************
*** 95,106 ****
        size_t            offset;
  
        re_comp_flags flags;
- 
-       /* text type info */
-       Oid                       param_type;
-       int16             typlen;
-       bool              typbyval;
-       char              typalign;
  } regexp_matches_ctx;
  
  typedef struct regexp_split_ctx
--- 96,101 ----
***************
*** 835,845 ****
        matchctx->pmatch = palloc(sizeof(regmatch_t) * 
(matchctx->cpattern->re_nsub + 1));
        matchctx->offset = 0;
  
-       /* get text type oid, too lazy to do it some other way */
-       matchctx->param_type = get_fn_expr_argtype(fcinfo->flinfo, 0);
-       get_typlenbyvalalign(matchctx->param_type, &matchctx->typlen,
-                                                &matchctx->typbyval, 
&matchctx->typalign);
- 
        matchctx->wide_str = palloc(sizeof(pg_wchar) * (matchctx->orig_len + 
1));
        matchctx->wide_len = pg_mb2wchar_with_len(VARDATA(matchctx->orig_str),
                                                                                
          matchctx->wide_str, matchctx->orig_len);
--- 830,835 ----
***************
*** 915,923 ****
                dims[0] = 1;
        }
  
        return construct_md_array(elems, nulls, ndims, dims, lbs,
!                                                         matchctx->param_type, 
matchctx->typlen,
!                                                         matchctx->typbyval, 
matchctx->typalign);
  }
  
  Datum
--- 905,913 ----
                dims[0] = 1;
        }
  
+       /* XXX: this hardcodes assumptions about the text type */
        return construct_md_array(elems, nulls, ndims, dims, lbs,
!                                                         TEXTOID, -1, false, 
'i');
  }
  
  Datum
***************
*** 976,991 ****
  {
        ArrayBuildState         *astate = NULL;
        regexp_split_ctx        *splitctx;
-       Oid                              param_type;
        int                              nitems;
  
        splitctx = setup_regexp_split(PG_GETARG_TEXT_P(0),
                                                                  
PG_GETARG_TEXT_P(1),
                                                                  
PG_GETARG_TEXT_P_IF_EXISTS(2));
  
-       /* get text type oid, too lazy to do it some other way */
-       param_type = get_fn_expr_argtype(fcinfo->flinfo, 0);
- 
        for (nitems = 0; splitctx->offset < splitctx->wide_len; nitems++)
        {
                if (nitems > splitctx->wide_len)
--- 966,977 ----
***************
*** 995,1001 ****
                astate = accumArrayResult(astate,
                                                                  
get_next_split(splitctx),
                                                                  false,
!                                                                 param_type,
                                                                  
CurrentMemoryContext);
        }
  
--- 981,987 ----
                astate = accumArrayResult(astate,
                                                                  
get_next_split(splitctx),
                                                                  false,
!                                                                 TEXTOID,
                                                                  
CurrentMemoryContext);
        }
  
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to