Thread: RE: RE: [PATCHES] relation filename patch

RE: RE: [PATCHES] relation filename patch

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
>
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > > -----Original Message-----
> > > From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> > >
> > > > If I recognize correctly,RelationGetRelationName() macro returns the
> > > > relation name local to the backend and RelationGetPhysicalRelation-
> > > > Name() macro returns pg_class entry name currently. Those names
> > > > are same unless the relation is a temporary relation. They may be
> > > > able to have separate entries in pg_class. I don't know why they
> > > > don't currently.
> > >
> > > Different backends can have the same temp file names at the same time,
> > > so you would have to have a pg_class tuple that is visible only to the
> > > current transactions, and allow multiple duplicate ones.
> Easier not to
> > > have it in pg_class and just hack the syscache code.
> > >
> >
> > You are right. It seems sufficient to have an entry in relation
> descriptor
> > for the local relation name.
>
> Actually it is the system catalog cache.  The pg_class lookups to a
> translation from temp to physical name on pg_class lookups.  Only a few
> lines in backend/utils/cache/syscache.c:
>
>     /* temp table name remapping */
>     if (cacheId == RELNAME)
>     {
>         char       *nontemp_relname;
>
>         if ((nontemp_relname =
>              get_temp_rel_by_username(DatumGetPointer(key1))) != NULL)
>             key1 = PointerGetDatum(nontemp_relname);
>     }
>
> That is it, and temprel.c.
>

It's diffrent from what I meant.
My question is why the macro RelationGetRelationName()
needs the following implementation.
Is it bad to add another entry such as rd_username to relation
descriptor ?

#define RelationGetRelationName(relation) \
(\       (strncmp(RelationGetPhysicalRelationName(relation), \        "pg_temp.", strlen("pg_temp.")) != 0) \       ? \
             RelationGetPhysicalRelationName(relation) \       : \               get_temp_rel_by_physicalname( \
              RelationGetPhysicalRelationName(relation)) \
 
)

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp



Re: RE: [PATCHES] relation filename patch

From
Bruce Momjian
Date:
> It's diffrent from what I meant.
> My question is why the macro RelationGetRelationName()
> needs the following implementation.
> Is it bad to add another entry such as rd_username to relation
> descriptor ?
> 
> #define RelationGetRelationName(relation) \
> (\
>         (strncmp(RelationGetPhysicalRelationName(relation), \
>          "pg_temp.", strlen("pg_temp.")) != 0) \
>         ? \
>                 RelationGetPhysicalRelationName(relation) \
>         : \
>                 get_temp_rel_by_physicalname( \
>                         RelationGetPhysicalRelationName(relation)) \
> )

Yes, that would work too.

--  Bruce Momjian                        |  http://www.op.net/~candle 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,
Pennsylvania19026