1212import sqlancer .common .query .Query ;
1313import sqlancer .common .query .QueryAdapter ;
1414import sqlancer .mysql .MySQLBugs ;
15+ import sqlancer .mysql .MySQLGlobalState ;
1516import sqlancer .mysql .MySQLSchema ;
1617import sqlancer .mysql .MySQLSchema .MySQLDataType ;
1718import sqlancer .mysql .MySQLSchema .MySQLTable .MySQLEngine ;
@@ -30,16 +31,18 @@ public class MySQLTableGenerator {
3031 private int keysSpecified ;
3132 private final List <String > columns = new ArrayList <>();
3233 private final MySQLSchema schema ;
34+ private final MySQLGlobalState globalState ;
3335
34- public MySQLTableGenerator (String tableName , Randomly r , MySQLSchema schema ) {
36+ public MySQLTableGenerator (MySQLGlobalState globalState , String tableName ) {
3537 this .tableName = tableName ;
36- this .r = r ;
37- this .schema = schema ;
38+ this .r = globalState . getRandomly () ;
39+ this .schema = globalState . getSchema () ;
3840 allowPrimaryKey = Randomly .getBoolean ();
41+ this .globalState = globalState ;
3942 }
4043
41- public static Query generate (String tableName , Randomly r , MySQLSchema schema ) {
42- return new MySQLTableGenerator (tableName , r , schema ).create ();
44+ public static Query generate (MySQLGlobalState globalState , String tableName ) {
45+ return new MySQLTableGenerator (globalState , tableName ).create ();
4346 }
4447
4548 private Query create () {
@@ -257,7 +260,7 @@ private enum ColumnOptions {
257260
258261 private void appendColumnDefinition () {
259262 sb .append (" " );
260- MySQLDataType randomType = MySQLDataType .getRandom ();
263+ MySQLDataType randomType = MySQLDataType .getRandom (globalState );
261264 boolean isTextType = randomType == MySQLDataType .VARCHAR ;
262265 appendTypeString (randomType );
263266 sb .append (" " );
0 commit comments