Re: [PATCHES] patch adding new regexp functions

2007-03-28 Thread Jeremy Drake
Jeremy Drake wrote: 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. I just realized that the last patch removed all usage of fcinfo in the setup_regexp_matches

Re: [PATCHES] patch adding new regexp functions

2007-03-28 Thread Bruce Momjian
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. ---

Re: [PATCHES] patch adding new regexp functions

2007-03-28 Thread Neil Conway
Jeremy Drake wrote: I just realized that the last patch removed all usage of fcinfo in the setup_regexp_matches function, so this version of the patch also removes it as a parameter to that function. Applied, thanks. -Neil ---(end of

Re: [PATCHES] patch adding new regexp functions

2007-03-27 Thread Bruce Momjian
Jeremy Drake wrote: On Mon, 26 Mar 2007, Bruce Momjian wrote: Tom Lane wrote: Or were you speaking to the question of whether to adjust the regexp patch to conform more nearly to the coding practices found elsewhere? I agree with that, but I thought there was already a submitted

Re: [PATCHES] patch adding new regexp functions

2007-03-27 Thread Bruce Momjian
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. ---

Re: [PATCHES] patch adding new regexp functions

2007-03-26 Thread Bruce Momjian
Jeremy Drake wrote: On Thu, 22 Mar 2007, Tom Lane wrote: AFAIR, the reason there's no TextPGetDatum (and ditto for lots of other datatypes) is lack of obvious usefulness. A function dealing with a text * doesn't normally have reason to convert that to a Datum until it returns --- and

Re: [PATCHES] patch adding new regexp functions

2007-03-26 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Jeremy Drake wrote: On Thu, 22 Mar 2007, Tom Lane wrote: AFAIR, the reason there's no TextPGetDatum (and ditto for lots of other datatypes) is lack of obvious usefulness. If you are asking why I have reason to convert text * to a Datum in cases other

Re: [PATCHES] patch adding new regexp functions

2007-03-26 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Jeremy Drake wrote: On Thu, 22 Mar 2007, Tom Lane wrote: AFAIR, the reason there's no TextPGetDatum (and ditto for lots of other datatypes) is lack of obvious usefulness. If you are asking why I have reason to convert text * to a

Re: [PATCHES] patch adding new regexp functions

2007-03-26 Thread Jeremy Drake
On Mon, 26 Mar 2007, Bruce Momjian wrote: Tom Lane wrote: Or were you speaking to the question of whether to adjust the regexp patch to conform more nearly to the coding practices found elsewhere? I agree with that, but I thought there was already a submitted patch for it. Yes, regex

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Gregory Stark
Jeremy Drake [EMAIL PROTECTED] writes: BTW, should I be calling get_typlenbyvalalign on TEXTOID or are there macros for those also? Hardcoding -1 for typlen of varlenas is one of the few (the only?) magic constants used throughout the source code. I'm surprised there isn't a macro for it

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Gregory Stark
Gregory Stark [EMAIL PROTECTED] writes: Jeremy Drake [EMAIL PROTECTED] writes: BTW, should I be calling get_typlenbyvalalign on TEXTOID or are there macros for those also? Hardcoding -1 for typlen of varlenas is one of the few (the only?) magic constants used throughout the source code.

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: BTW, should I be calling get_typlenbyvalalign on TEXTOID or are there macros for those also? By and large we tend to hard-wire those properties too, eg there are plenty of places that do things like this: /* XXX: this hardcodes assumptions about the

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Jeremy Drake
On Wed, 21 Mar 2007, Tom Lane wrote: Jeremy Drake [EMAIL PROTECTED] writes: BTW, should I be calling get_typlenbyvalalign on TEXTOID or are there macros for those also? By and large we tend to hard-wire those properties too, eg there are plenty of places that do things like this: /*

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: On Wed, 21 Mar 2007, Tom Lane wrote: By and large we tend to hard-wire those properties too, eg there are plenty of places that do things like this: So, what action (if any) should be taken? Should all (or some) of these values be hardcoded, or should

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Jeremy Drake
On Wed, 21 Mar 2007, Gregory Stark wrote: The only thing I would say is that this should maybe be a TextGetDatum() just for code hygiene. It should be exactly equivalent though: I could not find such a thing using ctags, nor TextPGetDatum(). I looked at PG_RETURN_TEXT_P and it just uses

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Jeremy Drake
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

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: I could not find such a thing using ctags, nor TextPGetDatum(). I looked at PG_RETURN_TEXT_P and it just uses PG_RETURN_POINTER, which in turn uses PointerGetDatum. If there is such a thing, it is well camoflaged... AFAIR, the reason there's no

Re: [PATCHES] patch adding new regexp functions

2007-03-21 Thread Jeremy Drake
On Thu, 22 Mar 2007, Tom Lane wrote: AFAIR, the reason there's no TextPGetDatum (and ditto for lots of other datatypes) is lack of obvious usefulness. A function dealing with a text * doesn't normally have reason to convert that to a Datum until it returns --- and at that point

Re: [PATCHES] patch adding new regexp functions

2007-03-20 Thread Neil Conway
Jeremy Drake wrote: The patch has been sitting in the unapplied patches queue for a while, and the inevitable bitrot finally caught up with it. This version of the patch is exactly the same as the one in the patches queue, except for using new, non-conflicting oids for the functions.

Re: [PATCHES] patch adding new regexp functions

2007-03-20 Thread Tom Lane
Neil Conway [EMAIL PROTECTED] writes: * Comments like /* get text type oid, too lazy to do it some other way */ do not exactly inspire confidence :) Surely the code was just using the TEXTOID macro? If so, it does not require a comment. If not, it should be fixed ...

Re: [PATCHES] patch adding new regexp functions

2007-03-20 Thread Jeremy Drake
On Wed, 21 Mar 2007, Tom Lane wrote: Neil Conway [EMAIL PROTECTED] writes: * Comments like /* get text type oid, too lazy to do it some other way */ do not exactly inspire confidence :) Surely the code was just using the TEXTOID macro? If so, it does not require a comment. If not, it

Re: [PATCHES] patch adding new regexp functions

2007-03-17 Thread Neil Conway
Jeremy Drake wrote: The patch has been sitting in the unapplied patches queue for a while Barring any objections, I'll apply this tomorrow. -Neil ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate

Re: [PATCHES] patch adding new regexp functions

2007-02-20 Thread Bruce Momjian
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. ---

Re: [PATCHES] patch adding new regexp functions

2007-02-18 Thread Peter Eisentraut
Jeremy Drake wrote: As for the argument about array vs setof, I could see doing both to end the argument of which one is really superior for any particular problem. regexp_split(string text, pattern text[, flags text]) returns setof text regexp_split_array(string text, pattern text[.

Re: [PATCHES] patch adding new regexp functions

2007-02-18 Thread Jeremy Drake
On Sun, 18 Feb 2007, Jeremy Drake wrote: On Sun, 18 Feb 2007, Peter Eisentraut wrote: regexp_split(string text, pattern text[, flags text]) returns setof text regexp_split_array(string text, pattern text[. flags text[, limit int]]) returns text[] Since you are not splitting

Re: [PATCHES] patch adding new regexp functions

2007-02-18 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: I will rename the functions regexp_split_to_(table|array) and I will add an optional limit parameter to the regexp_split_to_table function, for consistency and to avoid ordering concerns with LIMIT. I'd go the other way: get rid of the limit option all

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Peter Eisentraut
Jeremy Drake wrote: In case you haven't noticed, I am rather averse to making this return text[] because it is much easier in my experience to use the results when returned in SETOF rather than text[], The primary use case I know for string splitting is parsing comma/pipe/whatever separated

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread David Fetter
On Sat, Feb 17, 2007 at 09:02:24AM +0100, Peter Eisentraut wrote: Jeremy Drake wrote: In case you haven't noticed, I am rather averse to making this return text[] because it is much easier in my experience to use the results when returned in SETOF rather than text[], The primary use case

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Jeremy Drake
On Sat, 17 Feb 2007, Peter Eisentraut wrote: Jeremy Drake wrote: In case you haven't noticed, I am rather averse to making this return text[] because it is much easier in my experience to use the results when returned in SETOF rather than text[], The primary use case I know for string

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Peter Eisentraut
David Fetter wrote: What is it about having the whole match, pre-match and post-match available that you're objecting to? Are you saying there aren't common uses for any or all of these? Regular expression users use them all over the place, You keep saying that, and I keep saying please

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes: David Fetter wrote: What is it about having the whole match, pre-match and post-match available that you're objecting to? Are you saying there aren't common uses for any or all of these? Regular expression users use them all over the place, You

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Peter Eisentraut
Jeremy Drake wrote: For this case see string_to_array: That only works with fixed delimiters, and I was hoping that regexp_split would be an alternative with regexp delimiters. It's certainly another argument that all the split functions in PostgreSQL should offer analogous interfaces.

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Jeremy Drake
Finally the voice of reason :) On Sat, 17 Feb 2007, Tom Lane wrote: So I'd vote against complicating the API in order to make special provision for these results. I claim that all we need is a function taking (string text, pattern text, flags text) and returning either array of text or setof

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Mark Dilger
Jeremy Drake wrote: The regexp_split function code was based on some code that a friend of mine wrote which used PCRE rather than postgres' internal regexp support. I don't know exactly what his use-case was, but he probably had one because he wrote the function and had it returning SETOF text

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Tom Lane
Jeremy Drake [EMAIL PROTECTED] writes: On Sat, 17 Feb 2007, Tom Lane wrote: So I'd vote against complicating the API in order to make special provision for these results. I claim that all we need is a function taking (string text, pattern text, flags text) and returning either array of text

Re: [PATCHES] patch adding new regexp functions

2007-02-17 Thread Jeremy Drake
On Sat, 17 Feb 2007, Tom Lane wrote: Jeremy Drake [EMAIL PROTECTED] writes: On Sat, 17 Feb 2007, Tom Lane wrote: So I'd vote against complicating the API in order to make special provision for these results. I claim that all we need is a function taking (string text, pattern text, flags

Re: [PATCHES] patch adding new regexp functions

2007-02-16 Thread Peter Eisentraut
Am Freitag, 16. Februar 2007 08:02 schrieb Jeremy Drake: On Thu, 15 Feb 2007, Peter Eisentraut wrote: I have no strong opinion about how matches are returned. Seeing the definitional difficulties that you point out, it may be fine to return them unordered. But then all matches functions

Re: [PATCHES] patch adding new regexp functions

2007-02-16 Thread David Fetter
On Fri, Feb 16, 2007 at 05:54:47PM +0100, Peter Eisentraut wrote: Am Freitag, 16. Februar 2007 17:11 schrieb David Fetter: As for the regexp_matches() function, it seems to me that it returns too much information at once. What is the use case for getting all of prematch, fullmatch,

Re: [PATCHES] patch adding new regexp functions

2007-02-16 Thread Andrew Dunstan
David Fetter wrote: The question is, what is the use case? If there is one in Perl, can this proposed function API support it? Perl makes the following variables available in any regex match, although it optimizes some cases for when they're not there: $1, ... $n (captured matches in

Re: [PATCHES] patch adding new regexp functions

2007-02-16 Thread Peter Eisentraut
David Fetter wrote: The question is, what is the use case? If there is one in Perl, can this proposed function API support it? Perl makes the following variables available in any regex match, That is not a use case. -- Peter Eisentraut http://developer.postgresql.org/~petere/

Re: [PATCHES] patch adding new regexp functions

2007-02-16 Thread Jeremy Drake
On Fri, 16 Feb 2007, Peter Eisentraut wrote: Am Freitag, 16. Februar 2007 08:02 schrieb Jeremy Drake: Does this version sufficiently address your concerns? I don't think anyone asked for the start position and length in the result of regexp_split(). The result should be an array of text.

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Peter Eisentraut
Neil Conway wrote: On Wed, 2007-02-14 at 16:49 -0800, Jeremy Drake wrote: What was the status of this? Was there anything else I needed to do with this patch, or is it ready to be applied? Let me know if there is anything else I need to do on this... Will do -- I'm planning to apply

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Jeremy Drake
On Thu, 15 Feb 2007, Peter Eisentraut wrote: Neil Conway wrote: On Wed, 2007-02-14 at 16:49 -0800, Jeremy Drake wrote: What was the status of this? Was there anything else I needed to do with this patch, or is it ready to be applied? Let me know if there is anything else I need to

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Peter Eisentraut
Jeremy Drake wrote: regexp_matches uses a text[] for the match groups. If you specify the global flag, it could return multiple matches. Couple this with the requested feature of pre- and postmatch returns (with its own flag) and the return would turn into some sort of nasty array of

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Alvaro Herrera
Jeremy Drake wrote: The functions added are: * regexp_split(str text, pattern text) RETURNS SETOF text regexp_split(str text, pattern text, flags text) RETURNS SETOF text returns each section of the string delimited by the pattern. * regexp_matches(str text, pattern text) RETURNS text[]

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes: Jeremy Drake wrote: # My experience with the array code leads me to believe that building up an array is an expensive proposition. I know I could code it smarter so that the array is only constructed in the end. You can make any code arbitrarily

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes: so that you would have the position for each match, automatically. Is this information available in the regex code? Certainly, that's where we got the text snippets from to begin with. However, I'm not sure that this is important enough to justify a

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Alvaro Herrera
Tom Lane wrote: Alvaro Herrera [EMAIL PROTECTED] writes: so that you would have the position for each match, automatically. Is this information available in the regex code? Certainly, that's where we got the text snippets from to begin with. However, I'm not sure that this is important

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Peter Eisentraut
Alvaro Herrera wrote: On the other hand, I don't think it's impossible to have matches that start earlier than others in the string, but are actually found later (say, because they are a parentized expression that ends later). So giving the starting positions allows one to know where are they

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread David Fetter
On Thu, Feb 15, 2007 at 10:37:26AM -0500, Tom Lane wrote: Alvaro Herrera [EMAIL PROTECTED] writes: so that you would have the position for each match, automatically. Is this information available in the regex code? Certainly, that's where we got the text snippets from to begin with.

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Jeremy Drake
On Thu, 15 Feb 2007, Alvaro Herrera wrote: Jeremy Drake wrote: The functions added are: * regexp_split(str text, pattern text) RETURNS SETOF text regexp_split(str text, pattern text, flags text) RETURNS SETOF text returns each section of the string delimited by the pattern. *

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Tom Lane
David Fetter [EMAIL PROTECTED] writes: I've obviously misunderstood the scope of the TODO because it appears that an INSERT into pg_type at creation time for compound types that looks something like the below would do it. What have I missed? There are a couple of issues. One is that we

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread David Fetter
On Thu, Feb 15, 2007 at 07:35:46PM -0500, Tom Lane wrote: David Fetter [EMAIL PROTECTED] writes: I've obviously misunderstood the scope of the TODO because it appears that an INSERT into pg_type at creation time for compound types that looks something like the below would do it. What have

Re: [PATCHES] patch adding new regexp functions

2007-02-15 Thread Andrew Dunstan
Tom Lane wrote: David Fetter [EMAIL PROTECTED] writes: I've obviously misunderstood the scope of the TODO because it appears that an INSERT into pg_type at creation time for compound types that looks something like the below would do it. What have I missed? There are a couple of

Re: [PATCHES] patch adding new regexp functions

2007-02-14 Thread Jeremy Drake
What was the status of this? Was there anything else I needed to do with this patch, or is it ready to be applied? Let me know if there is anything else I need to do on this... -- What this country needs is a good five cent nickel. ---(end of

Re: [PATCHES] patch adding new regexp functions

2007-02-14 Thread Neil Conway
On Wed, 2007-02-14 at 16:49 -0800, Jeremy Drake wrote: What was the status of this? Was there anything else I needed to do with this patch, or is it ready to be applied? Let me know if there is anything else I need to do on this... Will do -- I'm planning to apply this as soon as I have the

Re: [PATCHES] patch adding new regexp functions

2007-02-09 Thread Neil Conway
On Fri, 2007-02-09 at 01:08 -0800, Jeremy Drake wrote: Yeah, I try to do that, but this one just barely passed my personal compression threshold. Guess I should raise my threshold :) No, don't pay any attention to me, I'm just lazy :) Here is a new version of the patch which fixes up the

Re: [PATCHES] patch adding new regexp functions

2007-02-09 Thread Neil Conway
On Fri, 2007-02-09 at 16:33 -0800, Jeremy Drake wrote: Here is a new version of the patch which eliminates the doing_srf stuff. * C89 require constant-sized stack allocated arrays, so the coding in perform_regexp_matches() is non-portable. * I'm not clear about the control flow in

Re: [PATCHES] patch adding new regexp functions

2007-02-08 Thread Neil Conway
On Thu, 2007-02-08 at 19:22 -0800, Jeremy Drake wrote: I have added documentation for the functions in this patch. At this point I am ready to submit this patch for the review and application process. Please let me know if you find any issues with it. Barring any objections, I'll review and

Re: [PATCHES] patch adding new regexp functions

2007-02-08 Thread Alvaro Herrera
Neil Conway wrote: BTW, unless the patch is truly large, leaving the patch uncompressed makes it easier to eyeball it without leaving my mail client. That's just personal preference, though... FWIW, I just do a | zcat | less, which shows it uncompressed. No big deal. I don't know if

Re: [PATCHES] patch adding new regexp functions

2007-02-08 Thread Bruce Momjian
Alvaro Herrera wrote: Neil Conway wrote: BTW, unless the patch is truly large, leaving the patch uncompressed makes it easier to eyeball it without leaving my mail client. That's just personal preference, though... FWIW, I just do a | zcat | less, which shows it uncompressed. No big