Re: Removal of temp tables - Mailing list pgsql-patches

From Tom Lane
Subject Re: Removal of temp tables
Date
Msg-id 18432.992538784@sss.pgh.pa.us
Whole thread Raw
In response to Re: Removal of temp tables  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Removal of temp tables  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Here is an updated patch that uses underscores in temp table names so
> the DROP doesn't have to quote the table name:

That seems like a reasonable idea, but don't do it to temp file
names, ie, drop this part of the diff:

> *** src/backend/storage/file/fd.c    2001/06/11 04:12:29    1.81
> --- src/backend/storage/file/fd.c    2001/06/14 16:34:02
> ***************
> *** 756,762 ****
>        * transaction and database instance.
>        */
>       snprintf(tempfilepath, sizeof(tempfilepath),
> !              "%s/%s%d.%ld", PG_TEMP_FILES_DIR, PG_TEMP_FILE_PREFIX,
>                MyProcPid, tempFileCounter++);

>       /*
> --- 756,762 ----
>        * transaction and database instance.
>        */
>       snprintf(tempfilepath, sizeof(tempfilepath),
> !              "%s/%s%d_%ld", PG_TEMP_FILES_DIR, PG_TEMP_FILE_PREFIX,
>                MyProcPid, tempFileCounter++);

>       /*

There's no reason to spell temp file names as if they were rel names,
and probably it's best not to make them look the same.

Also, an item I've ranted about before:

> + #define is_temp_relname(relname) \
> +         (!strncmp(relname, PG_TEMP_REL_PREFIX, strlen(PG_TEMP_REL_PREFIX)))

It's bad style to treat the result of strcmp or strncmp as though it
were a boolean, cf
http://fts.postgresql.org/db/mw/msg.html?mid=68294
Write (strncmp(...) == 0) instead.


Otherwise the patch seems reasonable, although I wonder what your
motivation was for choosing these particular IsSystemRelationName calls
to tweak.  It looks like you did more than the minimum needed to allow
a DROP TABLE; why these extra ones and not others?  (Not that I'm
encouraging you to go around and hit every IsSystemRelationName call.
If you did, that'll just be more changes that I suspect we'll have to
remove again in the long run.  I'm just curious why you touched, for
example, VACUUM.)

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Removal of temp tables
Next
From: Bruce Momjian
Date:
Subject: Re: Removal of temp tables