package sqlancer.cockroachdb.gen;

import java.util.HashSet;
import java.util.Set;

import sqlancer.Query;
import sqlancer.QueryAdapter;
import sqlancer.Randomly;
import sqlancer.cockroachdb.CockroachDBErrors;
import sqlancer.cockroachdb.CockroachDBProvider.CockroachDBGlobalState;

public class CockroachDBViewGenerator {

	public static Query generate(CockroachDBGlobalState globalState) {
		int nrColumns = 1;
		StringBuilder sb = new StringBuilder("CREATE ");
		if (Randomly.getBoolean() && false) {
			sb.append("TEMP ");
		}
		sb.append("VIEW " + Randomly.fromOptions("v0", "v1", "v1"));
		sb.append("(");
		for (int i = 0; i < nrColumns; i++) {
			if (i != 0) {
				sb.append(", ");
			}
			sb.append("c" + i);
		}
		sb.append(") AS ");
		sb.append(CockroachDBRandomQuerySynthesizer.generate(globalState, nrColumns).getQueryString());
		Set<String> errors = new HashSet<>();
		CockroachDBErrors.addExpressionErrors(errors);
		CockroachDBErrors.addTransactionErrors(errors);
		errors.add("value type unknown cannot be used for table columns");
		errors.add("already exists");
		return new QueryAdapter(sb.toString(), errors, true);
	}
	
}

@@ -402,16 +402,41 @@
 olumns =
+ Randomly.smallNumber() +
  1;%0A%09%09St
@@ -486,75 +486,8 @@
 %22);%0A
-%09%09if (Randomly.getBoolean() && false) %7B%0A%09%09%09sb.append(%22TEMP %22);%0A%09%09%7D%0A
 %09%09sb

Remove warning