Thread: truncate cleanup

truncate cleanup

From
Neil Conway
Date:
The attached patch cleans up the implementation of the TRUNCATE command;
in the current code, the authentication logic (check user, check the
relation we're operating on, etc) is done in tcop/utility.c, whereas the
actual TRUNCATE command in done in TruncateRelation() in
commands/createinh.c (which is really just a wrapper over
heap_truncate() in catalog/heap.c). This patch moves the authentication
logic into TruncateRelation(), as well as making some minor code
cleanups.

FWIW, I'm not really sure why TruncateRelation() is in
commands/createinh.c to begin with; if there is a preference, I can
remove TruncateRelation() altogether and move everything into
heap_truncate().

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

Attachment

Re: truncate cleanup

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Neil Conway wrote:
> The attached patch cleans up the implementation of the TRUNCATE command;
> in the current code, the authentication logic (check user, check the
> relation we're operating on, etc) is done in tcop/utility.c, whereas the
> actual TRUNCATE command in done in TruncateRelation() in
> commands/createinh.c (which is really just a wrapper over
> heap_truncate() in catalog/heap.c). This patch moves the authentication
> logic into TruncateRelation(), as well as making some minor code
> cleanups.
>
> FWIW, I'm not really sure why TruncateRelation() is in
> commands/createinh.c to begin with; if there is a preference, I can
> remove TruncateRelation() altogether and move everything into
> heap_truncate().
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  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

Re: truncate cleanup

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Neil Conway wrote:
> The attached patch cleans up the implementation of the TRUNCATE command;
> in the current code, the authentication logic (check user, check the
> relation we're operating on, etc) is done in tcop/utility.c, whereas the
> actual TRUNCATE command in done in TruncateRelation() in
> commands/createinh.c (which is really just a wrapper over
> heap_truncate() in catalog/heap.c). This patch moves the authentication
> logic into TruncateRelation(), as well as making some minor code
> cleanups.
>
> FWIW, I'm not really sure why TruncateRelation() is in
> commands/createinh.c to begin with; if there is a preference, I can
> remove TruncateRelation() altogether and move everything into
> heap_truncate().
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  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