mirror of https://github.com/citusdata/citus.git
parent
81953d7ac6
commit
2ac56ef955
|
@ -67,6 +67,7 @@ static int CreateTenantStats(MultiTenantMonitor *monitor, time_t queryTime);
|
|||
static int FindTenantStats(MultiTenantMonitor *monitor);
|
||||
static size_t MultiTenantMonitorshmemSize(void);
|
||||
static char * ExtractTopComment(const char *inputString);
|
||||
static char * Substring(const char *str, int start, int end);
|
||||
static char * EscapeCommentChars(const char *str);
|
||||
static char * UnescapeCommentChars(const char *str);
|
||||
|
||||
|
@ -715,14 +716,7 @@ ExtractTopComment(const char *inputString)
|
|||
|
||||
if (commentEndCharsIndex > commentStartCharsLength)
|
||||
{
|
||||
Datum substringTextDatum = DirectFunctionCall3(text_substr, PointerGetDatum(
|
||||
cstring_to_text(inputString)),
|
||||
Int32GetDatum(
|
||||
commentStartCharsLength + 1),
|
||||
Int32GetDatum(
|
||||
commentEndCharsIndex -
|
||||
commentStartCharsLength));
|
||||
return TextDatumGetCString(substringTextDatum);
|
||||
return Substring(inputString, commentStartCharsLength, commentEndCharsIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -731,6 +725,31 @@ ExtractTopComment(const char *inputString)
|
|||
}
|
||||
|
||||
|
||||
/* Extracts a substring from the input string between the specified start and end indices.*/
|
||||
static char *
|
||||
Substring(const char *str, int start, int end)
|
||||
{
|
||||
int len = strlen(str);
|
||||
|
||||
/* Ensure start and end are within the bounds of the string */
|
||||
if (start < 0 || end > len || start > end)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate memory for the substring */
|
||||
char *substr = (char *) palloc((end - start + 1) * sizeof(char));
|
||||
|
||||
/* Copy the substring to the new memory location */
|
||||
strncpy_s(substr, end - start + 1, str + start, end - start);
|
||||
|
||||
/* Add null terminator to end the substring */
|
||||
substr[end - start] = '\0';
|
||||
|
||||
return substr;
|
||||
}
|
||||
|
||||
|
||||
/* EscapeCommentChars adds a backslash before each occurrence of '*' or '/' in the input string */
|
||||
static char *
|
||||
EscapeCommentChars(const char *str)
|
||||
|
|
Loading…
Reference in New Issue