Thread

  1. aliases for temp tables....

    Alfonso Peniche <alfonso@iteso.mx> — 2001-02-15T22:04:46Z

    I've been looking everywhere and I can't find this:
    
    Everytime I create a temp table (Thanx Tom) within a procedure, a table
    named like pg_temp.###.# is created (I know this is MY temp table). How
    can I know the name (or alias) for this table so that I can, later on,
    check if it already exists.
    
    Example:
    I use a function to create a temp table named "mitabla1", so a physical
    table named pg_temp.32326.0 is created. I also create a temp table named
    "mitabla2" -> pg_temp.8732.2. I know there has to be a way of knowing
    which is which becuase if I run a select over "mitabla" I get the
    contents from the corresponding pg_temp.... table. I just couldn't find
    anywhere this information.
    
    Can anybody tell me where to find it or how?
    
    Thanx
    
    P.S. If I wasn't clear enough please let me know.....
    
    Cheers :-)
    
    
    
  2. Re: aliases for temp tables....

    Tom Lane <tgl@sss.pgh.pa.us> — 2001-02-18T05:36:34Z

    Alfonso Peniche <alfonso@iteso.mx> writes:
    > I've been looking everywhere and I can't find this:
    > Everytime I create a temp table (Thanx Tom) within a procedure, a table
    > named like pg_temp.###.# is created (I know this is MY temp table). How
    > can I know the name (or alias) for this table so that I can, later on,
    > check if it already exists.
    
    AFAIK there is no way to retrieve the temp-table name mapping from the
    backend.  Sorry ...
    
    When we implement schemas (hopefully for 7.2) perhaps it will be
    possible to reimplement temp tables in a slightly less klugy way,
    so that this sort of problem goes away.
    
    			regards, tom lane
    
    
  3. Re: aliases for temp tables....

    Bruce Momjian <pgman@candle.pha.pa.us> — 2001-02-18T05:53:49Z

    > AFAIK there is no way to retrieve the temp-table name mapping from the
    > backend.  Sorry ...
    > 
    > When we implement schemas (hopefully for 7.2) perhaps it will be
    > possible to reimplement temp tables in a slightly less klugy way,
    > so that this sort of problem goes away.
    
    There is a linked list stored in utils/cache/temprel.c.  There is no
    interface to that linked list.
    
    -- 
      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