| From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
|---|---|
| To: | Daniel Verite <daniel(at)manitou-mail(dot)org> |
| Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> |
| Subject: | Re: [patch] Proposal for \crosstabview in psql |
| Date: | 2016-04-07 22:55:17 |
| Message-ID: | 20160407225517.GA612264@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| psql-crosstabview-v16.patch | text/x-diff | 39.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kevin Grittner | 2016-04-07 22:56:59 | Re: snapshot too old, configured by time |
| Previous Message | Kevin Grittner | 2016-04-07 22:33:06 | Re: snapshot too old, configured by time |