Re: plpython function problem workaround - Mailing list pgsql-general

From Sim Zacks
Subject Re: plpython function problem workaround
Date
Msg-id d1jnqj$1kdu$1@news.hub.org
Whole thread Raw
In response to plpython function problem workaround  ("Sim Zacks" <sim@compulab.co.il>)
List pgsql-general
Sorry it took me so long to respond. I've been out for a couple days.

While certain things may be permissible in a language, I think it is also
important to look at the context at which the language is applied and make a
determination if it will practically turn up in relevant code. If the answer
is no, then I think it would be acceptable to add a note that the postgresql
python implementation does not accept implicit newlines and any newlines
must be explicit (the text \r\n)

That being said, the only place I can see wanting to use a newline is for a
situation where you would want to either do a select statement with a
multiline where such as
   results = plpy.execute("""...where textfield= 'multi
                                                        line
                                                        string'...""")
or if you returned the results and wanted to do the same type of thing.
if results[0]["textfield"]=="""multi
                                            line
                                            string""":
...

However, this example assumes that the client writing the functions and the
client inserting the data are always using the same OS, because if a linux
client inserted the data and a windows client had written the function, it
wouldn't receive any results, because postgresql sees the newline as valid
characters. hat being the case I would say that while it is entirely
possible to put multiline quoted text in  python code, it would be
inappropriate in a postgresql environment.

Sim


"Tom Lane" <tgl@sss.pgh.pa.us> wrote in message
news:6000.1110898014@sss.pgh.pa.us...
> "Sim Zacks" <sim@compulab.co.il> writes:
> > I've been looking at the possibility of having a planned CR in the
source
> > code and I don't see a case where it would happen.
>
> Does python actually disallow newlines in string literals?  That is
>
> x = 'foo
> bar'
>
> Whether you think this is good style is not the question --- is it
> allowed by the language?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>



pgsql-general by date:

Previous
From: Sarah Ewen
Date:
Subject: Re: pg_dump fails with socket_not_open
Next
From: Peter Eisentraut
Date:
Subject: Re: Installing PostgreSQL in Debian