Re: [SQL] Postgresql “alter column type” creates an event which contains “temp_table_xxx”

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zehra Gül Çabuk <zgul(dot)cabuk(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] Postgresql “alter column type” creates an event which contains “temp_table_xxx”
Date: 2017-07-25 14:18:58
Message-ID: 4792.1500992338@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

=?UTF-8?B?WmVocmEgR8O8bCDDh2FidWs=?= <zgul(dot)cabuk(at)gmail(dot)com> writes:
> => ALTER TABLE test ALTER COLUMN x TYPE integer USING
> (trim(x)::integer);ALTER TABLE
> Last command I've executed to alter column data type creates an event like
> this:
> BEGIN 500913table public.pg_temp_1077668: INSERT: x[integer]:14table
> public.pg_temp_1077668: INSERT: x[integer]:42COMMIT 500913
> How could I find "real" table name using this record? Is there any way to
> see real table name in fetched record?

That is the real name --- table rewrites create a table with a temporary
name and the desired new column layout, then fill it with data, then
exchange the data area with the old table, then drop the temp table.

Evidently logical decoding is exposing some of this infrastructure
to you. I bet it isn't exposing the critical "swap data" step though,
so I wonder how exactly a logical decoding plugin is supposed to make
sense of what it can see here.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-07-25 14:23:37 Re: pl/perl extension fails on Windows
Previous Message Tom Lane 2017-07-25 14:13:47 Re: cache lookup failed error for partition key with custom opclass

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2017-07-25 15:04:01 Re: [SQL] Postgresql “alter column type” creates an event which contains “temp_table_xxx”
Previous Message Zehra Gül Çabuk 2017-07-25 06:18:29 Postgresql “alter column type” creates an event which contains “temp_table_xxx”