Re: Views->Create Script + Regular Expressions

From: Michael Shapiro <mshapiro51(at)gmail(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>, pgadmin-support(at)postgresql(dot)org
Subject: Re: Views->Create Script + Regular Expressions
Date: 2011-08-24 15:50:07
Message-ID: CAGCvxeb+2okCwszd5RDnabeBiVr4FooN_vsoKrTqs3caekubUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

I ran into this warning when we switched from one version of Postgres to
another.
It complains when the view is created, but it works fine when I select from
it.

But I don't mix E' and \\

My views have strings like '\\.[0-9]+\\.'

Your view has both E' and \\ -- could it be that if you have E' you only
need \, not \\

On Wed, Aug 24, 2011 at 10:28 AM, Guillaume Lelarge
<guillaume(at)lelarge(dot)info>wrote:

> On Wed, 2011-08-24 at 08:04 -0700, Richard Broersma wrote:
> > On Tue, Aug 23, 2011 at 11:18 PM, Guillaume Lelarge
> > <guillaume(at)lelarge(dot)info> wrote:
> > > It would be great if you could provide us a complete example.
> >
> > Here is a sample view.
> >
> > --*************
> > CREATE VIEW TestView AS select cmpnt_name, regexp_matches(cmpnt_name,
> > E'(^\\d{1,2})-([A-Z]+) *- ?(\\d{3,4})-?([A-Z]*)?') from component;
> > --*************
> >
> > Here what Views->Create Script returns:
> >
> >
> >
> > --*************
> > -- View: testview
> >
> > -- DROP VIEW testview;
> >
> > CREATE OR REPLACE VIEW testview AS
> > SELECT component.cmpnt_name,
> > regexp_matches(component.cmpnt_name::text, '(^\\d{1,2})-([A-Z]+) *-
> > ?(\\d{3,4})-?([A-Z]*)?'::text) AS regexp_matches
> > FROM component;
> >
> > ALTER TABLE testview OWNER TO rbroersma;
> > --*************
> >
> >
> >
> > Notice what happens if I try to execute this script.
> >
> > WARNING: nonstandard use of \\ in a string literal
> > LINE 6: ..._name, regexp_matches(component.cmpnt_name::text,
> '(^\\d{1,2...
> > ^
> > HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
> > Query returned successfully with no result in 157 ms.
> >
> >
>
> There's not much we can do about this. The SELECT part is retrieved via
> a call to pg_getviewdef. So, if you want to call this a bug, this is a
> PostgreSQL bug (and I don't think this is).
>
>
> --
> Guillaume
> http://blog.guillaume.lelarge.info
> http://www.dalibo.com
>
>
> --
> Sent via pgadmin-support mailing list (pgadmin-support(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-support
>

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Richard Broersma 2011-08-24 16:09:56 Re: Views->Create Script + Regular Expressions
Previous Message Guillaume Lelarge 2011-08-24 15:28:35 Re: Views->Create Script + Regular Expressions