File tree Expand file tree Collapse file tree
pg_lake_iceberg/src/rest_catalog Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1549,8 +1549,9 @@ GetRestCatalogNamespace(Oid relationId)
15491549 * subsequent ALTER SERVER ? ADD/SET catalog_name cannot silently
15501550 * re-route an existing table to a different REST namespace.
15511551 *
1552- * Read-only tables resolve from table option > server option, and
1553- * must have catalog_name set on one of them.
1552+ * Read-only tables always have catalog_name baked into their table
1553+ * options at CREATE TABLE time (inherited from the server option or
1554+ * defaulted to the database name).
15541555 */
15551556char *
15561557GetRestCatalogName (Oid relationId )
@@ -1569,15 +1570,7 @@ GetRestCatalogName(Oid relationId)
15691570 if (catalogName != NULL )
15701571 return catalogName ;
15711572
1572- RestCatalogOptions * opts = GetRestCatalogOptionsForRelation (relationId );
1573-
1574- if (opts -> catalogName != NULL )
1575- return opts -> catalogName ;
1576-
1577- ereport (ERROR ,
1578- (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1579- errmsg ("catalog_name is required for read-only REST catalog tables" ),
1580- errhint ("Set catalog_name on the table or the server." )));
1573+ elog (ERROR , "catalog_name missing on read-only REST catalog table %u" , relationId );
15811574}
15821575
15831576
Original file line number Diff line number Diff line change @@ -817,7 +817,19 @@ ProcessCreateIcebergTableFromForeignTableStmt(ProcessUtilityParams * params)
817817
818818 if (catalogNameProvided == NULL && hasExternalCatalogReadOnlyOption )
819819 {
820- catalogName = get_database_name (MyDatabaseId );
820+ if (hasRestCatalogOption )
821+ {
822+ char * catalogOptionValue =
823+ GetStringOption (createStmt -> options , "catalog" , false);
824+ RestCatalogOptions * opts =
825+ ResolveRestCatalogOptions (catalogOptionValue );
826+
827+ catalogName = opts -> catalogName ? pstrdup (opts -> catalogName )
828+ : get_database_name (MyDatabaseId );
829+ }
830+ else
831+ catalogName = get_database_name (MyDatabaseId );
832+
821833 createStmt -> options =
822834 lappend (createStmt -> options ,
823835 makeDefElem ("catalog_name" , (Node * ) makeString (catalogName ), -1 ));
You can’t perform that action at this time.
0 commit comments