Skip to content
Open
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
12 changes: 12 additions & 0 deletions src/sqlancer/postgres/PostgresExpectedValueVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import sqlancer.postgres.ast.PostgresSimilarTo;
import sqlancer.postgres.ast.PostgresTableReference;
import sqlancer.postgres.ast.PostgresWindowFunction;
import sqlancer.postgres.gen.PostgresRowGenerator;

import java.util.List;

public final class PostgresExpectedValueVisitor implements PostgresVisitor {

Expand Down Expand Up @@ -195,4 +198,13 @@ public void visit(PostgresLikeOperation op) {
visit(op.getRight());
}

@Override
public void visit(PostgresRowGenerator rowGenerator) {
print(rowGenerator);
List<PostgresExpression> expressions = rowGenerator.getExpressions();
for (PostgresExpression expr : expressions) {
visit(expr);
}
}

}
14 changes: 14 additions & 0 deletions src/sqlancer/postgres/PostgresToStringVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sqlancer.postgres.ast.PostgresWindowFunction;
import sqlancer.postgres.ast.PostgresWindowFunction.WindowFrame;
import sqlancer.postgres.ast.PostgresWindowFunction.WindowSpecification;
import sqlancer.postgres.gen.PostgresRowGenerator;

public final class PostgresToStringVisitor extends ToStringVisitor<PostgresExpression> implements PostgresVisitor {

Expand Down Expand Up @@ -399,4 +400,17 @@ public void visit(PostgresWindowFunction windowFunction) {

sb.append(")");
}

@Override
public void visit(PostgresRowGenerator rowGenerator) {
sb.append("ROW(");
List<PostgresExpression> expressions = rowGenerator.getExpressions();
for (int i = 0; i < expressions.size(); i++) {
if (i != 0) {
sb.append(", ");
}
visit(expressions.get(i));
}
sb.append(")");
}
}
5 changes: 5 additions & 0 deletions src/sqlancer/postgres/PostgresVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import sqlancer.postgres.ast.PostgresTableReference;
import sqlancer.postgres.ast.PostgresWindowFunction;
import sqlancer.postgres.gen.PostgresExpressionGenerator;
import sqlancer.postgres.gen.PostgresRowGenerator;

public interface PostgresVisitor {

Expand Down Expand Up @@ -75,6 +76,8 @@ public interface PostgresVisitor {

void visit(PostgresWindowFunction windowFunction);

void visit(PostgresRowGenerator rowGenerator);

default void visit(PostgresExpression expression) {
if (expression instanceof PostgresConstant) {
visit((PostgresConstant) expression);
Expand Down Expand Up @@ -116,6 +119,8 @@ default void visit(PostgresExpression expression) {
visit((PostgresColumnReference) expression);
} else if (expression instanceof PostgresTableReference) {
visit((PostgresTableReference) expression);
} else if (expression instanceof PostgresRowGenerator) {
visit((PostgresRowGenerator) expression);
} else if (expression instanceof PostgresWindowFunction) {
visit((PostgresWindowFunction) expression);
} else {
Expand Down
22 changes: 22 additions & 0 deletions src/sqlancer/postgres/gen/PostgresRowGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sqlancer.postgres.gen;

import java.util.List;
import sqlancer.postgres.PostgresSchema.PostgresDataType;
import sqlancer.postgres.ast.PostgresExpression;

public class PostgresRowGenerator implements PostgresExpression {
private final List<PostgresExpression> expressions;

public PostgresRowGenerator(List<PostgresExpression> expressions) {
this.expressions = expressions;
}

public List<PostgresExpression> getExpressions() {
return expressions;
}

@Override
public PostgresDataType getExpressionType() {
return PostgresDataType.INT;
}
}
2 changes: 1 addition & 1 deletion src/sqlancer/postgres/gen/PostgresSetGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private enum ConfigurationOption {
JIT("jit", (r) -> Randomly.fromOptions(1, 0)),
JOIN_COLLAPSE_LIMIT("join_collapse_limit", (r) -> r.getInteger(1, Integer.MAX_VALUE)),
PARALLEL_LEADER_PARTICIPATION("parallel_leader_participation", (r) -> Randomly.fromOptions(1, 0)),
FORCE_PARALLEL_MODE("force_parallel_mode", (r) -> Randomly.fromOptions("off", "on", "regress")),
// FORCE_PARALLEL_MODE("force_parallel_mode", (r) -> Randomly.fromOptions("off", "on", "regress")),
PLAN_CACHE_MODE("plan_cache_mode",
(r) -> Randomly.fromOptions("auto", "force_generic_plan", "force_custom_plan"));

Expand Down
Loading