BUG #13960: plpython fails with certain function names

From: Jim(dot)Nasby(at)BlueTreble(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13960: plpython fails with certain function names
Date: 2016-02-15 00:14:47
Message-ID: 20160215001447.2605.36302@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13960
Logged by: Jim Nasby
Email address: Jim(dot)Nasby(at)BlueTreble(dot)com
PostgreSQL version: 9.5.0
Operating system: OS X
Description:

If a Postgres function contains characters that are illegal for python
identifiers, compilation fails. Error message is not very helpful either:

~(at)decina(dot)local/21474# CREATE FUNCTION "test[]"() RETURNS text LANGUAGE
plpythonu AS $$return 'test'$$;
ERROR: could not compile PL/Python function "test[]"
DETAIL: SyntaxError: invalid syntax (<string>, line 1)
~(at)decina(dot)local/21474# CREATE FUNCTION "test"() RETURNS text LANGUAGE
plpythonu AS $$return 'test'$$;
CREATE FUNCTION
~(at)decina(dot)local/21474#

One possibility is to simply strip out invalid characters[1]. What's valid
expands in 3.5, but I don't think that really matters.

Another possibility would be to catch the python exception, but that's
probably more trouble than it's worth.

[1]
https://docs.python.org/2/reference/lexical_analysis.html#grammar-token-identifier
identifier ::= (letter|"_") (letter | digit | "_")*
letter ::= lowercase | uppercase
lowercase ::= "a"..."z"
uppercase ::= "A"..."Z"
digit ::= "0"..."9"

3.5:
https://docs.python.org/3.5/reference/lexical_analysis.html#grammar-token-identifier

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2016-02-15 00:24:32 Re: Standbys using commas in application_name cannot become sync nodes
Previous Message Andres Freund 2016-02-14 15:57:08 Re: Standbys using commas in application_name cannot become sync nodes