diff --git a/src/backend/distributed/utils/attribute.c b/src/backend/distributed/utils/attribute.c index 3e564d045..75f5abf02 100644 --- a/src/backend/distributed/utils/attribute.c +++ b/src/backend/distributed/utils/attribute.c @@ -30,7 +30,7 @@ static void AttributeMetricsIfApplicable(void); ExecutorEnd_hook_type prev_ExecutorEnd = NULL; -#define ATTRIBUTE_PREFIX "/*{" +#define ATTRIBUTE_PREFIX "{\"tId\":" #define ATTRIBUTE_STRING_FORMAT "/*{\"tId\":%s,\"cId\":%d}*/" #define CITUS_STATS_TENANTS_COLUMNS 7 #define ONE_QUERY_SCORE 1000000000 @@ -159,34 +159,32 @@ AttributeQueryIfAnnotated(const char *query_string, CmdType commandType) return; } - char *annotation = extractTopComment(query_string); - if (annotation != NULL) + if (strncmp(ATTRIBUTE_PREFIX, query_string, strlen(ATTRIBUTE_PREFIX)) == 0) { - Datum jsonbDatum = DirectFunctionCall1(jsonb_in, PointerGetDatum(annotation)); - - text *tenantIdTextP = ExtractFieldTextP(jsonbDatum, "tId"); - if (tenantIdTextP != NULL) + char *annotation = extractTopComment(query_string); + if (annotation != NULL) { - char *tenantId = text_to_cstring(tenantIdTextP); - strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId); - } + Datum jsonbDatum = DirectFunctionCall1(jsonb_in, PointerGetDatum(annotation)); - colocationGroupId = ExtractFieldInt32(jsonbDatum, "cId", 0); + text *tenantIdTextP = ExtractFieldTextP(jsonbDatum, "tId"); + if (tenantIdTextP != NULL) + { + char *tenantId = text_to_cstring(tenantIdTextP); + strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId); + } - if (MultiTenantMonitoringLogLevel != CITUS_LOG_LEVEL_OFF) - { - ereport(NOTICE, (errmsg( - "attributing query to tenant: %s, colocationGroupId: %d", - quote_literal_cstr(attributeToTenant), - colocationGroupId))); + colocationGroupId = ExtractFieldInt32(jsonbDatum, "cId", 0); + + if (MultiTenantMonitoringLogLevel != CITUS_LOG_LEVEL_OFF) + { + ereport(NOTICE, (errmsg( + "attributing query to tenant: %s, colocationGroupId: %d", + quote_literal_cstr(attributeToTenant), + colocationGroupId))); + } } } - else - { - /*Assert(attributeToTenant == NULL); */ - } - /*DetachSegment(); */ attributeToTenantStart = clock(); }