From dea230603d69e5b5320398d6227118d2e6969b84 Mon Sep 17 00:00:00 2001 From: naisila Date: Mon, 29 Jul 2024 13:18:38 +0200 Subject: [PATCH] Check whether table AM is default PG 17 added support for DEFAULT in ALTER TABLE .. SET ACCESS METHOD Relevant PG commit: d61a6cad6418f643a5773352038d0dfe5d3535b8 https://github.com/postgres/postgres/commit/d61a6cad6418f643a5773352038d0dfe5d3535b8 In that case, name in AlterTableCmd would be null. Add a null check here to avoid crash. (cherry picked from commit 71b997438dc83d948906f294e0b0e3cb2aaf90f6) (cherry picked from commit 52d3329bf63ea9d38da7bf6e6cd1f7ba34b68d8c) --- src/backend/columnar/columnar_tableam.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/columnar/columnar_tableam.c b/src/backend/columnar/columnar_tableam.c index 1292f7b9974..148ccb50710 100644 --- a/src/backend/columnar/columnar_tableam.c +++ b/src/backend/columnar/columnar_tableam.c @@ -2256,7 +2256,9 @@ ColumnarProcessAlterTable(AlterTableStmt *alterTableStmt, List **columnarOptions "Specify SET ACCESS METHOD before storage parameters, or use separate ALTER TABLE commands."))); } - destIsColumnar = (strcmp(alterTableCmd->name, COLUMNAR_AM_NAME) == 0); + destIsColumnar = (strcmp(alterTableCmd->name ? alterTableCmd->name : + default_table_access_method, + COLUMNAR_AM_NAME) == 0); if (srcIsColumnar && !destIsColumnar) {