Re: [patch] Proposal for \crosstabview in psql - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [patch] Proposal for \crosstabview in psql
Date
Msg-id 20160407225517.GA612264@alvherre.pgsql
Whole thread Raw
In response to Re: [patch] Proposal for \crosstabview in psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: [patch] Proposal for \crosstabview in psql  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
Daniel Verite wrote:

> > * In the "if (cont.cells[idx] != NULL && cont.cells[idx][0] != '\0')"
> > block (line 497 in the attached), can't we do the same thing by using
> > psprintf?
>
> In that block, we can't pass a cell contents as a valist and be done with
> that cell, because duplicates of (col value,row value) may happen
> at any iteration of the upper loop over PQntuples(results). Any cell really
> may need reallocation unpredictably until that loop is done, whereas
> psprintf starts by allocating a new buffer unconditionally, so it doesn't
> look
> to me like it could help to simplify that block.

I messed with that code some more, as it looked unnecessarily
complicated; please see attached and verify that it still behaves
sanely.  This needs those regression tests you promised.  I tested a few
cases and it seems good to me.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: snapshot too old, configured by time
Next
From: Kevin Grittner
Date:
Subject: Re: snapshot too old, configured by time