Re: plpgsql at what point does the knowledge of the query come in? - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: plpgsql at what point does the knowledge of the query come in?
Date
Msg-id 4EA095AA.5090107@iol.ie
Whole thread Raw
In response to Re: plpgsql at what point does the knowledge of the query come in?  (Henry Drexler <alonup8tb@gmail.com>)
Responses Re: plpgsql at what point does the knowledge of the query come in?  (Raymond O'Donnell <rod@iol.ie>)
Re: plpgsql at what point does the knowledge of the query come in?  (Henry Drexler <alonup8tb@gmail.com>)
List pgsql-general
On 20/10/2011 22:31, Henry Drexler wrote:
>
> On Thu, Oct 20, 2011 at 4:57 PM, Raymond O'Donnell <rod@iol.ie
> <mailto:rod@iol.ie>> wrote:
>
>
>
>     Not sure what you mean by the above...
>
>     Ray.
>
>
> This is what I thought it was doing.
> 1.  it gets the node from the first row
> 2.  measures its length
> 3.  then loops through removing one character at a time and comparing
> that to the whole column/query
> 4.  for threeee it found a match in threee

I was just trying to figure your function out... :-) I think you're
mistaken about step 3 - This statement -

node = substring(newnode, 1, i-1) || substring (newnode, i+1, nnlength)

- is contatenating two substrings - the first bit (up to the i-th
character) and the rest, and then comparing that to "node".

In fact, the second substring() call looks as if it will overrun the end
of the string in "newnode".

What version of PostgreSQL are you using? The docs for 9.0 show two
substring functions:

   substring(string [from int] [for int])
   substr(string, from [, count])

and a couple of variants using regexps, and what you have above doesn't
match any of them.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: Henry Drexler
Date:
Subject: Re: plpgsql at what point does the knowledge of the query come in?
Next
From: Joe Abbate
Date:
Subject: Re: how to disable all pkey/fkey constraints globally