New string functions; initdb required
New string functions; initdb required
От:
Thomas Lockhart <thomas@pgsql.com>
Дата:
I've just committed changes which implement three SQL99 functions and
operators. OVERLAY() allows substituting a string into another string,
SIMILAR TO is an operator for pattern matching, and a new variant of
SUBSTRING() accepts a pattern to match.
Regression tests have been augmented and pass. Docs have been updated.
The system catalogs were updated, so it is initdb time. Details from the
cvs log below...
- Thomas
Implement SQL99 OVERLAY(). Allows substitution of a substring in a
string.
Implement SQL99 SIMILAR TO as a synonym for our existing operator "~".
Implement SQL99 regular expression SUBSTRING(string FROM pat FOR
escape).Extend the definition to make the FOR clause optional.Define textregexsubstr() to actually implement this feature.
Update the regression test to include these new string features.All tests pass.
Rename the regular expression support routines from "pg95_xxx" to
"pg_xxx".
Define CREATE CHARACTER SET in the parser per SQL99. No implementation
yet.
Re: New string functions; initdb required
От:
Josh Berkus <josh@agliodbs.com>
Дата:
Thomas, > I've just committed changes which implement three SQL99 functions and > operators. OVERLAY() allows substituting a string into another string, > SIMILAR TO is an operator for pattern matching, and a new variant of > SUBSTRING() accepts a pattern to match. Way cool! Thank you ... this replaces several of my custom PL/pgSQL functions. How is SIMILAR TO different from ~ ? -- -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco
Re: New string functions; initdb required
От:
"Ross J. Reedstrom" <reedstrm@rice.edu>
Дата:
On Tue, Jun 11, 2002 at 11:08:11AM -0700, Josh Berkus wrote: > Thomas, > > > I've just committed changes which implement three SQL99 functions and > > operators. OVERLAY() allows substituting a string into another string, > > SIMILAR TO is an operator for pattern matching, and a new variant of > > SUBSTRING() accepts a pattern to match. > > Way cool! Thank you ... this replaces several of my custom PL/pgSQL > functions. > > How is SIMILAR TO different from ~ ? From the part of Thomas's email you snipped: Implement SQL99 SIMILAR TO as a synonym for our existing operator "~". So the answer is "not at all" Ross
Re: New string functions; initdb required
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Thomas Lockhart wrote: > I've just committed changes which implement three SQL99 functions and > operators. OVERLAY() allows substituting a string into another string, > SIMILAR TO is an operator for pattern matching, and a new variant of TODO item marked as done: * -Add SIMILAR TO to allow character classes, 'pg_[a-c]%' -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: New string functions; initdb required
От:
Thomas Lockhart <lockhart@fourpalms.org>
Дата:
> TODO item marked as done:
> * -Add SIMILAR TO to allow character classes, 'pg_[a-c]%'
Darn. Will have to be more careful next time ;)
- Thomas
Re: New string functions; initdb required
От:
Thomas Lockhart <lockhart@fourpalms.org>
Дата:
> > How is SIMILAR TO different from ~ ?
> >From the part of Thomas's email you snipped:
> Implement SQL99 SIMILAR TO as a synonym for our existing operator "~".
> So the answer is "not at all"
Right. I'm not certain about the regex syntax defined by SQL99; I used
the syntax that we already have enabled and it looks like we have a
couple of other variants available if we need them. If someone wants to
research the *actual* syntax specified by SQL99 that would be good...
- Thomas
Re: New string functions; initdb required
От:
"Ken Hirsch" <kenhirsch@myself.com>
Дата:
Thomas Lockhart wrote: > Right. I'm not certain about the regex syntax defined by SQL99; I used > the syntax that we already have enabled and it looks like we have a > couple of other variants available if we need them. If someone wants to > research the *actual* syntax specified by SQL99 that would be good... As usual: ( ) + * [ ] |Instead of dot . there is underscore _There is % to mean .* just like LIKEThere is no ? or ^ or $ Regular expressions match the whole string, as if there were animplicit ^ before and $ after the pattern. You have to add % ifyou want to match anywhere in a string. As far as I can tell, there is no default escape character like \but you can specify one. 8.6 Similar predicate Function Specify a character string similarity by means of a regular expression. Format ::= [ NOT ] SIMILAR TO [ ESCAPE ] ::= ::= | ::= | ::= | | ::= | | | ::= | ::= !! See the Syntax Rules ::= !! See the Syntax Rules ::= | ... | ... | ::= | ::= *stuff omitted* 3) The value of the that is a shall be either ALPHA, UPPER, LOWER, DIGIT, or ALNUM. *collating stuff omitted* 5) A is any single character from the character set of the that is not a , , , , , , , , , , , or the character specified by the result of the of . A that is a represents itself. 6) An is a sequence of two characters: the character specified by the result of the of , followed by a second character that is a , , , , , , , , , , , or the character specified by the result of the of . A that is an represents its second character.
Re: New string functions; initdb required
От:
Thomas Lockhart <lockhart@fourpalms.org>
Дата:
Thanks for the info! I have a question...
> As usual: ( ) + * [ ] |
> Instead of dot . there is underscore _
> There is % to mean .* just like LIKE
> There is no ? or ^ or $
> Regular expressions match the whole string, as if there were an
> implicit ^ before and $ after the pattern. You have to add % if
> you want to match anywhere in a string.
Hmm. So if there are no explicit anchors then there must be a slightly
different syntax for the regular-expression version of the substring()
function? Otherwise, substrings would always have to start from the
first character, right?
Percents and underscores carried over from LIKE are really annoying.
I'll think about implementing an expression rewriter to convert SQL99 to
our modern regexp syntax.
- Thomas