Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VuSbx-0006wK-Te for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Dec 2013 19:53:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VuSbv-00087v-Lx for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Dec 2013 19:53:19 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vu7Mv-0005Qt-TM for pgsql-bugs@postgresql.org; Fri, 20 Dec 2013 21:12:26 +0000 Received: from gw1.zacglen.com ([220.233.85.112] helo=zacglen.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vu7Mr-0005Hf-37 for pgsql-bugs@postgresql.org; Fri, 20 Dec 2013 21:12:24 +0000 Received: (from local) by zacglen.com (8.14.3/8.14.3) id rBKLCBGS015268 for pgsql-bugs@postgresql.org; Sat, 21 Dec 2013 08:12:11 +1100 Date: Sat, 21 Dec 2013 08:12:11 +1100 Message-Id: <201312202112.rBKLCBGS015268.zacglen.com@localhost> To: pgsql-bugs@postgresql.org Subject: Re: BUG #8662: psql -H and ts_headline From: cbfgterfdy@zacglen.net In-Reply-To: <52B463CC.50300@gmx.net> X-Pg-Spam-Score: 0.0 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org >> While "psql -H" is quite useful there is flaw when a query includes >> ts_headline(). The highlighting html gets escaped along with any other html >> special characters. > >How would you address that? There is no way for psql or any other >client to know that the text data that is being returned is actually >HTML. A proper fix would be having an HTML data type, or having >ts_headline() return type XML. > Perhaps it would be better if ts_headline() returned rows or an array giving the highlight offsets and lengths rather than attempting to mark-up the text. However one might also have a extra function that took the offset information and annotated the text as in "highlight(text, ts_headline(text))" So the fault is not with psql, it is the faulty design of ts_headline(). I have also tried using the StartSel etc options and very bad result if StartSel value involves a space or comma. Very strange design bundling options into a single function argument. Having to put options into a single-quote delimited string, yet not allowing for spaces or commas to be escaped is not very flexible. Perhaps the options could have been passed as a HSTORE type? Would have made a lot more sense. In any case a myriad of options seems to indicate that what should have been multiple functions have all been bundled into one function. And why couldn't the option arguments have been real separate arguments? Is there some arcane limit on the number of function arguments? Or was line wrap broken in authors text editor? Also, would be nice of psql could have some html escape mechanism so that something simple like "select ''||column||''" could be made to work. Unfortunately not so simple as a single character escape mechanism, so perhaps a special function such as unescaped(''). -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs