Don't treate IndexStmt like AlterTable when DefineIndex is called from ProcessUtilitySlow.

From: 正华吕 <kainwen(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Don't treate IndexStmt like AlterTable when DefineIndex is called from ProcessUtilitySlow.
Date: 2022-11-17 13:08:42
Message-ID: CANerzActdrdFO1r4RSqK0M2d0Xtwu5t5bH=ZOoLsAQ=HhZrB=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Recently read the code, I find that when calling DefineIndex
from ProcessUtilitySlow, is_alter_table will be set true if
this statement is came from expandTableLikeClause.

I check the code of DefineIndex, there are only two places use
is_alter_table:
1. the function index_check_primary_key
2. print a debug log on what the statement is

For 1, since we are doing create table xxx (like yyy including
indexes), we are sure that the check relationHasPrimaryKey in the
function index_check_primary_key will be satisfied because we are just
create the new table.

For 2, I do not think it will mislead the user if we print it as
CreateStmt.

Based on the above, I think we can always a false value
for is_alter_table when DefineIndex is called from
ProcessUtilitySlow.

Here I attach a patch. Any ideas?
Thanks a lot.

Best,
Zhenghua Lyu

Attachment Content-Type Size
0001-Don-t-treate-IndexStmt-like-AlterTable-when-DefineIn.patch application/octet-stream 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-11-17 13:31:45 Re: Report checkpoint progress with pg_stat_progress_checkpoint (was: Report checkpoint progress in server logs)
Previous Message Bharath Rupireddy 2022-11-17 12:51:41 Introduce a new view for checkpointer related stats