Test if a string is a valid, unquoted identifier?
3
votes
1
answer
784
views
I'm just wondering if there is an established method for testing if a string can be used as an *unquoted* PostgreSQL identifier? (unquoted because almost any string can be a quoted identifier).
I ask because as shown in a previous question (https://dba.stackexchange.com/questions/200419) , there are times when I would need to specify an identifier (such as the name of a table to be created) that does not yet exist, as string values (
text
) instead of a safer type such as regclass
. Quoting the string/name can be problematic as shown there and probably else where. Without quoting, it's susceptible to SQL injection.
I guess if one programs it hard enough, a string parsing function can be written ultimately. Just wanted to check if there are existing solutions.
Related:
https://dba.stackexchange.com/questions/45589
https://dba.stackexchange.com/questions/196015 (sql-server)
Asked by tinlyx
(3820 rep)
Mar 17, 2018, 07:43 AM
Last activity: Mar 20, 2018, 01:03 AM
Last activity: Mar 20, 2018, 01:03 AM