Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUBRIDQA-1235] fixed join graph output to print the remaining join graph results when more than one join graphs exist #685

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,18 @@ public static String replaceJoingraph(String queryPlan) {
message = reader.readLine();
continue;
} else if (message.startsWith("Query plan:")) {
break;
}

// ignore
flag = "queryplan";
message = reader.readLine();
continue;
}

// make chageable values hidden.
if ("join".equals(flag)) {
message = message.replaceAll("sel [0-9]+\\.[0-9]+", "sel ?");
message = message.replaceAll("sel [0-9]+\\.[0-9]+", "sel ?");
ret.append(message + separator);
}

ret.append(message + separator);

message = reader.readLine();
}
} catch (Exception e) {
Expand Down
109 changes: 64 additions & 45 deletions CTP/sql_by_cci/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,61 +1183,80 @@ formatjoingraph (FILE * fp, char *joingraph)
{
char *str, *p;
int i, joingraphLen, newline;
bool joingraph_found = false;
int joinflag = 0;

if (joingraph == NULL)
{
return;
}

joingraphLen = strlen (joingraph);
str = (char *) malloc (sizeof (char) * (joingraphLen + 1));
memset (str, 0, sizeof (char) * (joingraphLen + 1));
p = (char *) malloc (sizeof (char) * (joingraphLen + 1));
memset (p, 0, sizeof (char) * (joingraphLen + 1));

if (str == NULL || p == NULL)
{
if (str != NULL)
{
free(str);
}

if (p != NULL)
{
free(p);
}

fprintf(stdout, "formatjoingraph: malloc failure\n");
return;
}

memset(str, 0, sizeof (char) * (joingraphLen + 1));
memset(p, 0, sizeof (char) * (joingraphLen + 1));

newline = 0;

if (joingraph != NULL)
for (i = 0; i < joingraphLen; i++)
{
for (i = 0; i < joingraphLen; i++)
if (joingraph[i] == '\n')
{
if (joingraph[i] == '\n')
strncpy (str, joingraph + newline, i - newline + 1);
strncpy (p, joingraph + newline, i - newline + 1);
str[i - newline + 1] = 0x00;
p[i - newline + 1] = 0x00;
newline = i + 1;

trimline (p);
if (strlen (p) == 0)
{
strncpy (str, joingraph + newline, i - newline + 1);
strncpy (p, joingraph + newline, i - newline + 1);
str[i - newline + 1] = 0x00;
p[i - newline + 1] = 0x00;
newline = i + 1;

trimline (p);
if (strlen (p) == 0)
{
continue;
}

if (startswith (p, "Join graph"))
{
joingraph_found = true;
fprintf (fp, "%s", str);
continue;
}
else if (startswith (p, "Query plan:"))
{
break;
}
else
{
if (joingraph_found)
{
regex_t regex;
// hide selectivity rewriting '?'.
replace_substring (str, "sel [0-9]+\\.[0-9]+", "sel ?");
fprintf (fp, "%s", str);
continue;
}
}
continue;
}

if (startswith (p, "Join graph"))
{
joinflag = 1;
fprintf (fp, "%s", str);
continue;
}
else if (startswith (p, "Query plan:"))
{
joinflag = 0;
continue;
}

if (joinflag == 1)
{
// hide selectivity by rewriting it as 'sel ?'
replace_substring (str, "sel [0-9]+\\.[0-9]+", "sel ?");
fprintf (fp, "%s", str);
}
}
strncpy (str, joingraph + newline, i - newline + 1);
str[i - newline + 1] = 0x00;
fprintf (fp, "%s", str);
free (str);
free (p);
}
strncpy (str, joingraph + newline, i - newline + 1);
str[i - newline + 1] = 0x00;
fprintf (fp, "%s", str);

free (str);
free (p);
junsklee marked this conversation as resolved.
Show resolved Hide resolved
}

int
Expand Down
Loading