From 269a26fc0b6a3478baba308ccff214586b157948 Mon Sep 17 00:00:00 2001 From: roseduan Date: Fri, 11 Aug 2023 11:22:48 +0800 Subject: [PATCH 1/3] Fix: warehouse is not supported without unionstore This commit mainly adds that the warehouse feature is not supported by default, but we can create the unionstore extension to enable the feature. BTW, fix the bug when query from gp_segment_configuration table. --- src/backend/cdb/cdbutil.c | 7 ++++++- src/backend/tcop/utility.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/cdb/cdbutil.c b/src/backend/cdb/cdbutil.c index 0d6f7147d30..565f6e965cc 100644 --- a/src/backend/cdb/cdbutil.c +++ b/src/backend/cdb/cdbutil.c @@ -261,7 +261,12 @@ readGpSegConfigFromCatalog(int *total_dbs) attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_warehouseid, RelationGetDescr(gp_seg_config_rel), &isNull); Assert(!isNull); warehouseid = DatumGetObjectId(attr); - if (OidIsValid(warehouseid) && warehouseid != GetCurrentWarehouseId()) + + /* content */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_content, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + + if (warehouseid != GetCurrentWarehouseId() && (OidIsValid(warehouseid) || DatumGetInt16(attr) != MASTER_CONTENT_ID)) continue; config = &configs[idx]; diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index b558ae1db4d..42cbebf822c 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -1788,7 +1788,14 @@ ProcessUtilitySlow(ParseState *pstate, case T_DropTaskStmt: address = DropTask(pstate, (DropTaskStmt *) parsetree); - break; + break; + + case T_CreateWarehouseStmt: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("warehouse feature is not supported"), + errhint("Create extension unionstore to enable the feature."))); + break; case T_CreateExternalStmt: { From 95f4f33640d714c362fba2cf9702c484df373fc1 Mon Sep 17 00:00:00 2001 From: roseduan Date: Fri, 11 Aug 2023 15:03:48 +0800 Subject: [PATCH 2/3] update warehouse prompt message --- src/backend/tcop/utility.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 42cbebf822c..6d5c8b5f5f6 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -1791,10 +1791,10 @@ ProcessUtilitySlow(ParseState *pstate, break; case T_CreateWarehouseStmt: + case T_DropWarehouseStmt: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("warehouse feature is not supported"), - errhint("Create extension unionstore to enable the feature."))); + errmsg("warehouse feature is not supported"))); break; case T_CreateExternalStmt: From 6710f04f9df7f1877b0bf82c0c448585e5bcc800 Mon Sep 17 00:00:00 2001 From: roseduan Date: Fri, 11 Aug 2023 16:15:39 +0800 Subject: [PATCH 3/3] update gp_segment_configuration query --- src/backend/cdb/cdbutil.c | 102 +++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/backend/cdb/cdbutil.c b/src/backend/cdb/cdbutil.c index 565f6e965cc..ecdc1df6f08 100644 --- a/src/backend/cdb/cdbutil.c +++ b/src/backend/cdb/cdbutil.c @@ -266,69 +266,69 @@ readGpSegConfigFromCatalog(int *total_dbs) attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_content, RelationGetDescr(gp_seg_config_rel), &isNull); Assert(!isNull); - if (warehouseid != GetCurrentWarehouseId() && (OidIsValid(warehouseid) || DatumGetInt16(attr) != MASTER_CONTENT_ID)) - continue; - - config = &configs[idx]; + if (warehouseid == GetCurrentWarehouseId() || DatumGetInt16(attr) == MASTER_CONTENT_ID) + { + config = &configs[idx]; - /* dbid */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_dbid, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->dbid = DatumGetInt16(attr); + /* dbid */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_dbid, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->dbid = DatumGetInt16(attr); - /* content */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_content, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->segindex= DatumGetInt16(attr); + /* content */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_content, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->segindex= DatumGetInt16(attr); - /* role */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_role, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->role = DatumGetChar(attr); + /* role */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_role, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->role = DatumGetChar(attr); - /* preferred-role */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_preferred_role, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->preferred_role = DatumGetChar(attr); + /* preferred-role */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_preferred_role, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->preferred_role = DatumGetChar(attr); - /* mode */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_mode, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->mode = DatumGetChar(attr); + /* mode */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_mode, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->mode = DatumGetChar(attr); - /* status */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_status, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->status = DatumGetChar(attr); + /* status */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_status, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->status = DatumGetChar(attr); - /* hostname */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_hostname, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->hostname = TextDatumGetCString(attr); + /* hostname */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_hostname, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->hostname = TextDatumGetCString(attr); - /* address */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_address, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->address = TextDatumGetCString(attr); + /* address */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_address, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->address = TextDatumGetCString(attr); - /* port */ - attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_port, RelationGetDescr(gp_seg_config_rel), &isNull); - Assert(!isNull); - config->port = DatumGetInt32(attr); + /* port */ + attr = heap_getattr(gp_seg_config_tuple, Anum_gp_segment_configuration_port, RelationGetDescr(gp_seg_config_rel), &isNull); + Assert(!isNull); + config->port = DatumGetInt32(attr); - /* datadir is not dumped*/ + /* datadir is not dumped*/ - idx++; + idx++; - /* - * Expand CdbComponentDatabaseInfo array if we've used up - * currently allocated space - */ - if (idx >= array_size) - { - array_size = array_size * 2; - configs = (GpSegConfigEntry *) - repalloc(configs, sizeof(GpSegConfigEntry) * array_size); + /* + * Expand CdbComponentDatabaseInfo array if we've used up + * currently allocated space + */ + if (idx >= array_size) + { + array_size = array_size * 2; + configs = (GpSegConfigEntry *) + repalloc(configs, sizeof(GpSegConfigEntry) * array_size); + } } }