Re: \du in psql patchp - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: \du in psql patchp
Date
Msg-id 200105091757.f49HvJl15666@candle.pha.pa.us
Whole thread Raw
In response to Re: \du in psql patchp  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
> Bruce Momjian writes:
>
> > Patch applied.  I removed the reference to asprintf() and changed it to
> > a string constant.  I have also added documentation changes.  Patch
> > attached.
>
> I think there's a memory leak, count your xmalloc's.  Also, perhaps the

I thought I had too many mallocs, but when I started looking, I couldn't
find the second one anymore.  I see it now, and fixed.  Looped through
cell and free'ed:

    for (i = 0; i < PQntuples(res); i++)
        free(cells[i * cols + 2]);
    free(cells);


> user ids should be right-aligned (printTable, 5th argument).

Got it:

    test=> \du
                    List of Users
     User Name | User ID |       Attributes
    -----------+---------+------------------------
     demouser2 |     140 | create DB
     postgres  |     139 | create user, create DB

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: \du in psql patchp
Next
From: Alex Perel
Date:
Subject: Re: \du in psql patchp