Double Backslash example patch
Kind people,
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes��. I believe it will help intrepid regex
users. :)
Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
Attachments:
are_example.difftext/plain; charset=us-asciiDownload
Index: func.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.180
diff -2 -c -r1.180 func.sgml
*** func.sgml 29 Nov 2003 19:51:37 -0000 1.180
--- func.sgml 7 Dec 2003 01:46:46 -0000
***************
*** 2634,2638 ****
regular expression is allowed to match anywhere within a string, unless
the regular expression is explicitly anchored to the beginning or
! end of the string.
</para>
--- 2634,2640 ----
regular expression is allowed to match anywhere within a string, unless
the regular expression is explicitly anchored to the beginning or
! end of the string. The last example includes a double backslash,
! which is usually required for using ARE shorthand <xref
! linkend="posix-class-shorthand-escapes-table">.
</para>
***************
*** 2644,2647 ****
--- 2646,2650 ----
'abc' ~ '(b|d)' <lineannotation>true</lineannotation>
'abc' ~ '^(b|c)' <lineannotation>false</lineannotation>
+ '123' ~ '^\\d{3}' <lineannotation>true</lineannotation>
</programlisting>
</para>
David Fetter wrote:
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes®. I believe it will help intrepid regex
users. :)
If you want to explain something, it's normally better to create an
example just for that point, instead of piggybacking it onto another
example. Else you just make it harder for people to recognize the
relevant information.
For instance, in the case you want to patch the example aims to show how
patterns are not anchored, as opposed to the pattern for the LIKE
operator. What does the escape syntax of the pattern have to do with
that?
Peter Eisentraut wrote:
David Fetter wrote:
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes??. I believe it will help intrepid regex
users. :)If you want to explain something, it's normally better to create an
example just for that point, instead of piggybacking it onto another
example. Else you just make it harder for people to recognize the
relevant information.For instance, in the case you want to patch the example aims to show how
patterns are not anchored, as opposed to the pattern for the LIKE
operator. What does the escape syntax of the pattern have to do with
that?
He is reminding folks about double-backslashes in a relivant place ---
makes sense to me.
--
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
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
David Fetter wrote:
Kind people,
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes��. I believe it will help intrepid regex
users. :)Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
--
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
Bruce Momjian writes:
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
Please don't.
Add a new example if you want, but don't overload existing examples with
unrelated information.
Show quoted text
---------------------------------------------------------------------------
David Fetter wrote:
Kind people,
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes®. I believe it will help intrepid regex
users. :)Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778[ Attachment, skipping... ]
---------------------------(end of
broadcast)--------------------------- TIP 4: Don't 'kill -9' the
postmaster-- 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
Bruce Momjian wrote:
He is reminding folks about double-backslashes in a relivant place --- makes sense to me.
The relevant place would be far below where it already says:
Note: Keep in mind that an escape's leading \ will need to be doubled
when entering the pattern as an SQL string constant.
So it's already covered.
On Tue, Dec 16, 2003 at 04:32:37PM +0100, Peter Eisentraut wrote:
Bruce Momjian wrote:
He is reminding folks about double-backslashes in a relivant place --- makes sense to me.The relevant place would be far below where it already says:
Note: Keep in mind that an escape's leading \ will need to be
doubled when entering the pattern as an SQL string constant.So it's already covered.
With all due respect, Peter, it is only implicit in the docs, and that
is not always good enough. An explicit example will help, as
PostgreSQL's quoting system would qualify for an early place on the
'gotchas' page (cf. http://sql-info.de/mysql/gotchas.html) if
PostgreSQL had one.
Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
On Tue, Dec 16, 2003 at 11:17:11AM -0800, David Fetter wrote:
[Moved to hackers -- this belongs to -docs anyway, doesn't it?]
With all due respect, Peter, it is only implicit in the docs, and that
is not always good enough. An explicit example will help, as
PostgreSQL's quoting system would qualify for an early place on the
'gotchas' page (cf. http://sql-info.de/mysql/gotchas.html) if
PostgreSQL had one.
BTW, what happened to the $QUOTE$ quoting idea? Was it applied, or
even developed?
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"The problem with the future is that it keeps turning into the present"
(Hobbes)
David Fetter wrote:
With all due respect, Peter, it is only implicit in the docs, and
that is not always good enough. An explicit example will help, as
Sure, I'm just pointing out the most appropriate place to put it.
On Tue, 16 Dec 2003, Alvaro Herrera wrote:
BTW, what happened to the $QUOTE$ quoting idea? Was it applied, or
even developed?
I believe it's still on the to-do list, but was pushed off until 7.5 or
whenever it gets done.
Jon
Alvaro Herrera wrote:
On Tue, Dec 16, 2003 at 11:17:11AM -0800, David Fetter wrote:
[Moved to hackers -- this belongs to -docs anyway, doesn't it?]
With all due respect, Peter, it is only implicit in the docs, and that
is not always good enough. An explicit example will help, as
PostgreSQL's quoting system would qualify for an early place on the
'gotchas' page (cf. http://sql-info.de/mysql/gotchas.html) if
PostgreSQL had one.BTW, what happened to the $QUOTE$ quoting idea? Was it applied, or
even developed?
Not implemented yet.
--
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
Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
BTW, what happened to the $QUOTE$ quoting idea? Was it applied, or
even developed?
I'd like to see it done for 7.5, but haven't personally had time to go
further than the proof-of-concept backend patch I posted awhile ago.
I think the minimum amount of additional work that has to be done before
we can apply it is to teach psql's input parser about $QUOTE$ ---
without that, the feature is not only useless but counterproductive.
After that we could get on with teaching pg_dump and other stuff about
it, at our leisure.
Any volunteers to fix psql?
regards, tom lane
Tom Lane wrote:
I think the minimum amount of additional work that has to be done before
we can apply it is to teach psql's input parser about $QUOTE$ ---
without that, the feature is not only useless but counterproductive.
IMHO it's not useless. pgAdmin already knows that quoting scheme... not
yet tested, I'll have to check that patch.
Regards,
Andreas
Andreas Pflug wrote:
Tom Lane wrote:
I think the minimum amount of additional work that has to be done before
we can apply it is to teach psql's input parser about $QUOTE$ ---
without that, the feature is not only useless but counterproductive.IMHO it's not useless. pgAdmin already knows that quoting scheme...
not yet tested, I'll have to check that patch.
OTOH we sure want it for psql - being able to use this in scripts fed to
psql is very important IMNSHO.
I see that psql/mainloop.c contains this comment:
* FIXME: rewrite this whole thing with flex
Is now the time to do that? It would be a pity if substantial changes
were made here only to be thrown away ...
cheers
andrew
Andrew Dunstan <andrew@dunslane.net> writes:
I see that psql/mainloop.c contains this comment:
* FIXME: rewrite this whole thing with flex
Is now the time to do that?
If you feel like giving it a shot, ain't nobody gonna stand in your way.
MainLoop() is well past the level of unmaintainability IMHO (which is
why I'd not tried to touch it in the original quick patch).
I'm not totally convinced that flex can do the job, but in any case a
ground-up redesign for legibility might be the only cure.
regards, tom lane
Tom Lane wrote:
Andrew Dunstan <andrew@dunslane.net> writes:
I see that psql/mainloop.c contains this comment:
* FIXME: rewrite this whole thing with flex
Is now the time to do that?If you feel like giving it a shot, ain't nobody gonna stand in your way.
MainLoop() is well past the level of unmaintainability IMHO (which is
why I'd not tried to touch it in the original quick patch).I'm not totally convinced that flex can do the job, but in any case a
ground-up redesign for legibility might be the only cure.
I will take a look - no guarantees though. I agree that flex might well
end up making things more obscure than less.
Keeping track of open quote operators to make sure we have proper
nesting and closing looks like it might be a bit messy, but doable.
cheers
andrew
I have applied your additional example in the place Peter suggested.
Patch attached.
---------------------------------------------------------------------------
David Fetter wrote:
Kind people,
Please find enclosed a patch exemplifying typical use of the ARE
Class-Shorthand Escapes��. I believe it will help intrepid regex
users. :)Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
--
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
Attachments:
/bjm/difftext/plainDownload
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.182
diff -c -c -r1.182 func.sgml
*** doc/src/sgml/func.sgml 16 Dec 2003 15:27:58 -0000 1.182
--- doc/src/sgml/func.sgml 18 Dec 2003 03:53:59 -0000
***************
*** 3134,3140 ****
<note>
<para>
Keep in mind that an escape's leading <literal>\</> will need to be
! doubled when entering the pattern as an SQL string constant.
</para>
</note>
--- 3134,3143 ----
<note>
<para>
Keep in mind that an escape's leading <literal>\</> will need to be
! doubled when entering the pattern as an SQL string constant. For example:
! <programlisting>
! '123' ~ '^\\d{3}' <lineannotation>true</lineannotation>
! </programlisting>
</para>
</note>