Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Luca Ferrari
On Wed, Aug 28, 2013 at 5:08 PM, Charles Sheridan  wrote:
> Does anyone know if there are any CTAGS extensions or variants that support
> PL/pgSQL ?
>
> I use exuberant-ctags which does not support it, and a web search does not
> return anything promising.

As far as I know, the quick answer is NO.
However I made a few simple tests with etags and it seems to work with
plpgsql. However I would expect it to fail for some advanced features.

Luca


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Using regexp_matches in the WHERE clause

2013-08-29 Thread spulatkan
I noticed that regexp_matches already returns the rows which matches the
regular expression

now when I make a full table select query


but if I make a search with regexp_matches, it only returns rows that
matches regular expression


on pgadmin the column type is shown as text[] thus I also do not understand
why array_length on where condition does not work for this.



But maybe as it was pointed out, the return type is setof text[], that the
result could have been like this (one row of data may result in multiple
rows)


If you have a regular expression that may end in one or more elements in the
text[] then you may use inner query


ps: last query is pointless as it will return 2 elements for each row (that
matches the regular expression), but there may be a regular expression that
may return one or more elements for each row



--
View this message in context: 
http://postgresql.1045698.n5.nabble.com/Using-regexp-matches-in-the-WHERE-clause-tp5733684p5768923.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Charles Sheridan



Does anyone know if there are any CTAGS extensions or variants that support
PL/pgSQL ?

I use exuberant-ctags which does not support it, and a web search does not
return anything promising.

As far as I know, the quick answer is NO.
However I made a few simple tests with etags and it seems to work with
plpgsql. However I would expect it to fail for some advanced features.

Luca

Thanks Luca, unfortunately (?) I'm a pretty heavy Vim user, so etags is 
not in my scope.


Regards,
Charles



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Bruce Momjian
On Thu, Aug 29, 2013 at 08:18:03AM -0500, Charles Sheridan wrote:
> 
> >>Does anyone know if there are any CTAGS extensions or variants that support
> >>PL/pgSQL ?
> >>
> >>I use exuberant-ctags which does not support it, and a web search does not
> >>return anything promising.
> >As far as I know, the quick answer is NO.
> >However I made a few simple tests with etags and it seems to work with
> >plpgsql. However I would expect it to fail for some advanced features.
> >
> >Luca
> >
> Thanks Luca, unfortunately (?) I'm a pretty heavy Vim user, so etags
> is not in my scope.

Uh, I think Vim can use etags, no?  Isn't etags Exuberant Ctags?  The 
Exuberant Ctags's FAQ mentions Vim:

http://ctags.sourceforge.net/faq.html#11

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + It's impossible for everything to be true. +


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Using regexp_matches in the WHERE clause

2013-08-29 Thread David Johnston
spulatkan wrote
> so following is enough to get the rows that matches regular expression

> 

This is bad form even if it works.  If the only point of the expression is
to filter rows it should appear in the WHERE clause.  The fact that
regexp_matches(...) behaves in this way at all is, IMO, a flaw of the
implementation.


> on pgadmin the column type is shown as text[] thus I also do not
> understand why array_length on where condition does not work for this.

> 

This works because the array_length formula is applied once to each "row" of
the returned set.  

As mentioned before it makes absolutely no sense to evaluate a set-returning
function within the WHERE clause and so attempting to do so causes a fatal
exception.  For my usage I've simply written a wrapper function that
implements the same basic API as regexp_matches but that returns a scalar
"text[]" instead of a "setof text[]".  It makes coding these kinds of
queries easier if you know/understand the fact that your matching will never
cause more than 1 row to be returned.  If zero rows are returned I return an
empty array and the normal 1-row case returns the matching array.

David J.






--
View this message in context: 
http://postgresql.1045698.n5.nabble.com/Using-regexp-matches-in-the-WHERE-clause-tp5733684p5768926.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Luca Ferrari
On Thu, Aug 29, 2013 at 3:33 PM, Bruce Momjian  wrote:

> Uh, I think Vim can use etags, no?  Isn't etags Exuberant Ctags?  The
> Exuberant Ctags's FAQ mentions Vim:
>

I was referring to the etags shipped with emacs, that even if does not
support (explicitly) sql seems to work for a very simple test. I've
done the same test using the etags (from ctags) and it works too, so
now the important thing is to make vim using the tags file and see
what is missing.


Luca


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Charles Sheridan

On 13-08-29 9:00 AM, Luca Ferrari wrote:

On Thu, Aug 29, 2013 at 3:33 PM, Bruce Momjian  wrote:


Uh, I think Vim can use etags, no?  Isn't etags Exuberant Ctags?  The
Exuberant Ctags's FAQ mentions Vim:


I was referring to the etags shipped with emacs, that even if does not
support (explicitly) sql seems to work for a very simple test. I've
done the same test using the etags (from ctags) and it works too, so
now the important thing is to make vim using the tags file and see
what is missing.


Luca


Vim documentation states that ctags won't work w/ vim, and recommends 
exuberant-ctags.  If ctags does process PL/pgSQL, perhaps that output 
could be added to the exuberant-ctags tags file, likely w/ some 
processing.  I've got exuberant-ctags on a cron, and I think that Vim 
also calls it periodically during a Vim session, so I'd also cron ctags 
for regular update to the same tags file.   To avoid sync problems, 
where exuberant-ctags overwrites the ctags content, I'd actually want to 
call both tags programs from the a common exuberant-ctags wrapper.


Charles



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql