mirror of https://github.com/citusdata/citus.git
Validate attribute prefix existance on query string
parent
6d8cd8a9a0
commit
21298f6661
|
@ -33,7 +33,7 @@ static void AttributeMetricsIfApplicable(void);
|
||||||
|
|
||||||
ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
||||||
|
|
||||||
#define ATTRIBUTE_PREFIX "/*{"
|
#define ATTRIBUTE_PREFIX "{\"tId\":"
|
||||||
#define ATTRIBUTE_STRING_FORMAT "/*{\"tId\":%s,\"cId\":%d}*/"
|
#define ATTRIBUTE_STRING_FORMAT "/*{\"tId\":%s,\"cId\":%d}*/"
|
||||||
#define CITUS_STATS_TENANTS_COLUMNS 7
|
#define CITUS_STATS_TENANTS_COLUMNS 7
|
||||||
#define ONE_QUERY_SCORE 1000000000
|
#define ONE_QUERY_SCORE 1000000000
|
||||||
|
@ -202,34 +202,32 @@ AttributeQueryIfAnnotated(const char *query_string, CmdType commandType)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *annotation = extractTopComment(query_string);
|
if (strncmp(ATTRIBUTE_PREFIX, query_string, strlen(ATTRIBUTE_PREFIX)) == 0)
|
||||||
if (annotation != NULL)
|
|
||||||
{
|
{
|
||||||
Datum jsonbDatum = DirectFunctionCall1(jsonb_in, PointerGetDatum(annotation));
|
char *annotation = extractTopComment(query_string);
|
||||||
|
if (annotation != NULL)
|
||||||
text *tenantIdTextP = ExtractFieldTextP(jsonbDatum, "tId");
|
|
||||||
if (tenantIdTextP != NULL)
|
|
||||||
{
|
{
|
||||||
char *tenantId = text_to_cstring(tenantIdTextP);
|
Datum jsonbDatum = DirectFunctionCall1(jsonb_in, PointerGetDatum(annotation));
|
||||||
strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId);
|
|
||||||
}
|
text *tenantIdTextP = ExtractFieldTextP(jsonbDatum, "tId");
|
||||||
|
if (tenantIdTextP != NULL)
|
||||||
|
{
|
||||||
|
char *tenantId = text_to_cstring(tenantIdTextP);
|
||||||
|
strcpy_s(attributeToTenant, sizeof(attributeToTenant), tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
colocationGroupId = ExtractFieldInt32(jsonbDatum, "cId", INVALID_COLOCATION_ID);
|
colocationGroupId = ExtractFieldInt32(jsonbDatum, "cId", INVALID_COLOCATION_ID);
|
||||||
|
|
||||||
if (MultiTenantMonitoringLogLevel != CITUS_LOG_LEVEL_OFF)
|
if (MultiTenantMonitoringLogLevel != CITUS_LOG_LEVEL_OFF)
|
||||||
{
|
{
|
||||||
ereport(NOTICE, (errmsg(
|
ereport(NOTICE, (errmsg(
|
||||||
"attributing query to tenant: %s, colocationGroupId: %d",
|
"attributing query to tenant: %s, colocationGroupId: %d",
|
||||||
quote_literal_cstr(attributeToTenant),
|
quote_literal_cstr(attributeToTenant),
|
||||||
colocationGroupId)));
|
colocationGroupId)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy_s(attributeToTenant, sizeof(attributeToTenant), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*DetachSegment(); */
|
|
||||||
attributeToTenantStart = clock();
|
attributeToTenantStart = clock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue