Re: proposal: function parse_ident - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: function parse_ident
Date
Msg-id CAFj8pRBy-qCerPpJLjOZrn4fSVWez9Vw3eiojq8EvyT277cD8A@mail.gmail.com
Whole thread Raw
In response to Re: proposal: function parse_ident  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: proposal: function parse_ident
List pgsql-hackers
Hi

2016-02-08 16:55 GMT+01:00 Teodor Sigaev <teodor@sigaev.ru>:
rebased, messages changes per Tom's proposal
Cool feature and sometimes I needed it a lot.

But, seems, there are some bugs in error processing.

1
Following query is okay:
# select * from parse_ident(E'"Some \r Schema".someTable');
         parse_ident
------------------------------
 {"Some \r Schema",sometable}
but:
% select * from parse_ident(E'"Some \r Schema".9someTable');
 Schema".9someTable"tifier after "." symbol: ""Some

Return carriage is not escaped in error message. Suppose, any other
special charaters will not be escaped.

2
# select * from parse_ident('.someTable');
ERROR:  missing identifier after "." symbol: ".someTable"
Why AFTER  instead of BEFORE?

fixed - now the function produce more adequate message - see regress tests
 

2
Function succesfully truncates long indentifier but not in case of quoted identifier.
select length(a[1]), length(a[2]) from parse_ident('"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') as a ;
 length | length
--------+--------
    414 |     63



fixed - I used the function downcase_truncate_identifier, that does truncating. I agree - in this case default truncating isn't practical - and user can explicitly truncate (or implicitly by casting to "name")

New patch attached

Thank you for test

Regards

Pavel

 






--
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                   WWW: http://www.sigaev.ru/

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [patch] Proposal for \crosstabview in psql
Next
From: Masahiko Sawada
Date:
Subject: Re: Support for N synchronous standby servers - take 2