refactor CreateTupleDescCopy()

Поиск
Список
Период
Сортировка
Искать

refactor CreateTupleDescCopy()

От:
Neil Conway <neilc@samurai.com>
Дата:
Вложения:
This patch refactors CreateTupleDescCopy() and
CreateTupleDescCopyConstr() to remove some duplicated code, and clean
things up a little bit.

-Neil

Re: refactor CreateTupleDescCopy()

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Neil Conway  writes:
> This patch refactors CreateTupleDescCopy() and
> CreateTupleDescCopyConstr() to remove some duplicated code, and clean
> things up a little bit.

I think this is taking the "avoid duplicated code" mantra a little far.
You've defined a subroutine that returns a TupleDesc that is internally
inconsistent and cannot usefully be used for anything until it's fixed
by the parent routines.  That seems to me to make the module more
complex and confusing rather than less so.  The amount of code saved is
IMHO not worth that price.

			regards, tom lane

Re: refactor CreateTupleDescCopy()

От:
Neil Conway <neilc@samurai.com>
Дата:
Tom Lane  writes:
> I think this is taking the "avoid duplicated code" mantra a little
> far.  You've defined a subroutine that returns a TupleDesc that is
> internally inconsistent and cannot usefully be used for anything
> until it's fixed by the parent routines.

Fair enough. Another way to refactor this would be to implement both
CreateTupleDescCopy() and CreateTupleDescCopyConstr() in terms of an
internal function that takes a bool indicating whether or not to
include constraints in the returned TupleDesc. Now that I think about
it, we could also just change the API to remove
CreateTupleDescCopyConstr(), and replace it with an additional bool
parameter to CreateTupleDescCopy().

I'm leaning toward doing the latter, and updating the 30 odd call
sites this would affect. Does that sound good?

-Neil

Re: refactor CreateTupleDescCopy()

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Neil Conway  writes:
> Now that I think about
> it, we could also just change the API to remove
> CreateTupleDescCopyConstr(), and replace it with an additional bool
> parameter to CreateTupleDescCopy().

That would be okay with me.  It might be a good idea to change the name
completely (perhaps CopyTupleDesc() ?) as a means of catching places
that aren't correctly updated.  (I worry about add-on modules that might
not get recompiled between versions; they'd still link, but then crash,
if the routine name is the same.)

			regards, tom lane

Re: refactor CreateTupleDescCopy()

От:
Neil Conway <neilc@samurai.com>
Дата:
Вложения:
Tom Lane  writes:
> That would be okay with me.  It might be a good idea to change the
> name completely (perhaps CopyTupleDesc() ?) as a means of catching
> places that aren't correctly updated.

Done, and done -- a revised patch is attached.

-Neil

Re: refactor CreateTupleDescCopy()

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://momjian.postgresql.org/cgi-bin/pgpatches

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

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


Neil Conway wrote:
> Tom Lane  writes:
> > That would be okay with me.  It might be a good idea to change the
> > name completely (perhaps CopyTupleDesc() ?) as a means of catching
> > places that aren't correctly updated.
> 
> Done, and done -- a revised patch is attached.
> 
> -Neil
> 

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: refactor CreateTupleDescCopy()

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

This patch was withdrawn by the author.

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

Neil Conway wrote:
> Tom Lane  writes:
> > That would be okay with me.  It might be a good idea to change the
> > name completely (perhaps CopyTupleDesc() ?) as a means of catching
> > places that aren't correctly updated.
> 
> Done, and done -- a revised patch is attached.
> 
> -Neil
> 

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
FAQ