andr-sokolov commented on code in PR #1842:
URL: https://github.com/apache/cloudberry/pull/1842#discussion_r3636020805
##########
src/backend/commands/tablecmds.c:
##########
@@ -17059,13 +17110,32 @@ static void
ATPrepSetAccessMethod(AlteredTableInfo *tab, Relation rel, const char *amname)
{
Oid amoid;
+ Oid iceberg_amoid;
/* Check that the table access method exists */
amoid = get_table_am_oid(amname, false);
if (rel->rd_rel->relam == amoid)
return;
+ /*
+ * The iceberg AM relies on catalog entries that only the CREATE/DROP
+ * LAKE TABLE paths manage, so a table cannot be converted to or from
+ * it with SET ACCESS METHOD.
+ */
+ iceberg_amoid = GetIcebergTableAmOid(true);
+ if (OidIsValid(iceberg_amoid) && amoid == iceberg_amoid)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot change access method of table
\"%s\" to \"%s\"",
+ RelationGetRelationName(rel),
ICEBERG_TABLE_AM_NAME),
+ errhint("Use CREATE LAKE TABLE ... USING
ICEBERG to create a lake table.")));
+ if (OidIsValid(iceberg_amoid) && rel->rd_rel->relam == iceberg_amoid)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot change access method of lake
table \"%s\"",
+ RelationGetRelationName(rel))));
Review Comment:
Let's check `OidIsValid(iceberg_amoid)` one time.
ICEBERG_TABLE_AM_NAME is a constant, but not variable, we can concatenate it
at compile time
```suggestion
if (OidIsValid(iceberg_amoid) {
if (amoid == iceberg_amoid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot change access method of
table \"%s\" to \"" ICEBERG_TABLE_AM_NAME "\"",
RelationGetRelationName(rel)),
errhint("Use CREATE LAKE TABLE ...
USING ICEBERG to create a lake table.")));
if (rel->rd_rel->relam == iceberg_amoid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot change access method of
lake table \"%s\"",
RelationGetRelationName(rel))));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]