@@ -38,7 +38,6 @@ static char *GetIcebergExternalMetadataLocation(Oid relationId);
3838static char * GetIcebergCatalogMetadataLocationInternal (Oid relationId , bool isPrevMetadata , bool forUpdate );
3939static char * GetIcebergCatalogColumnInternal (Oid relationId , char * columnName , bool forUpdate , bool errorIfNotFound );
4040static void ErrorIfSameTableExistsInExternalCatalog (Oid relationId );
41- static bool ReportIfReadOnlyIcebergTable (Oid relationId , int logLevel );
4241
4342/*
4443 * InsertExternalIcebergCatalogTable inserts a record into the Iceberg
@@ -436,65 +435,6 @@ GetIcebergCatalogPreviousMetadataLocation(Oid relationId, bool forUpdate)
436435 return GetIcebergCatalogMetadataLocationInternal (relationId , true, forUpdate );
437436}
438437
439- /*
440- * ErrorIfReadOnlyIcebergTable checks if the iceberg table is read-only and
441- * throws an error if it is.
442- */
443- void
444- ErrorIfReadOnlyIcebergTable (Oid relationId )
445- {
446- ReportIfReadOnlyIcebergTable (relationId , ERROR );
447-
448- ErrorIfReadOnlyExternalCatalogIcebergTable (relationId );
449- }
450-
451- /*
452- * WarnIfReadOnlyIcebergTable checks if the iceberg table is read-only and
453- * throws a warning if it is.
454- */
455- bool
456- WarnIfReadOnlyIcebergTable (Oid relationId )
457- {
458- return ReportIfReadOnlyIcebergTable (relationId , WARNING );
459- }
460-
461- /*
462- * Similar to ErrorIfReadOnlyExternalCatalogIcebergTable, but for external
463- * catalog iceberg tables, namely rest catalog and object catalog tables.
464- */
465- void
466- ErrorIfReadOnlyExternalCatalogIcebergTable (Oid relationId )
467- {
468- IcebergCatalogType icebergCatalogType = GetIcebergCatalogType (relationId );
469-
470- if (icebergCatalogType == REST_CATALOG_READ_ONLY ||
471- icebergCatalogType == OBJECT_STORE_READ_ONLY )
472- ereport (ERROR , (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
473- errmsg ("modifications on read-only external catalog iceberg tables are not supported" )));
474- }
475-
476-
477- /*
478- * ReportIfReadOnlyIcebergTable checks if the iceberg table is read-only and
479- * reports an logLevel if it is.
480- *
481- * For non-error cases, it returns true if the table is read-only.
482- */
483- static bool
484- ReportIfReadOnlyIcebergTable (Oid relationId , int logLevel )
485- {
486- bool readOnly = IsReadOnlyIcebergTable (relationId );
487-
488- if (readOnly )
489- {
490- ereport (logLevel ,
491- (errcode (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE ),
492- errmsg ("iceberg table \"%s\" is read-only" , get_rel_name (relationId ))));
493- }
494-
495- return readOnly ;
496- }
497-
498438/*
499439* GetIcebergCatalogMetadataLocationInternal returns the metadata or previous metadata
500440* location for a table in the iceberg catalog table.
@@ -509,36 +449,6 @@ GetIcebergCatalogMetadataLocationInternal(Oid relationId, bool isPrevMetadata, b
509449}
510450
511451
512- /*
513- * IsReadOnlyIcebergTable checks if the iceberg table is read-only and
514- * returns true if it is.
515- */
516- bool
517- IsReadOnlyIcebergTable (Oid relationId )
518- {
519- if (GetPgLakeTableType (relationId ) != PG_LAKE_ICEBERG_TABLE_TYPE )
520- {
521- /* read-only feature is only applicable for pg_lake_iceberg tables */
522- return false;
523- }
524-
525- bool forUpdate = false;
526- char * columnName = "read_only" ;
527- bool errorIfNotFound = false;
528-
529-
530- char * readOnlyValue =
531- GetIcebergCatalogColumnInternal (relationId , columnName , forUpdate , errorIfNotFound );
532-
533- if (readOnlyValue != NULL && pg_strcasecmp (readOnlyValue , "t" ) == 0 )
534- {
535- /* let the caller know that this is a read-only table for non-errors */
536- return true;
537- }
538-
539- return false;
540- }
541-
542452
543453/*
544454* RelationExistsInTheIcebergCatalog checks if the relation exists in the iceberg
@@ -808,3 +718,13 @@ IsWritableIcebergTable(Oid relationId)
808718
809719 return (pg_strcasecmp (readOnlyValue , "f" ) == 0 );
810720}
721+
722+
723+ /*
724+ * IsReadOnlyIcebergTable - check if the iceberg table is read-only.
725+ */
726+ bool
727+ IsReadOnlyIcebergTable (Oid relationId )
728+ {
729+ return IsIcebergTable (relationId ) && !IsWritableIcebergTable (relationId );
730+ }
0 commit comments