void setColNullability ( ColumnSchema column , boolean nullable ) { Constraint c = null ; int colIndex = table . getColumnIndex ( column . getName ( ) . name ) ; if ( column . isNullable ( ) == nullable ) { return ; } if ( nullable ) { if ( column . isPrimaryKey ( ) ) { throw Error . error ( ErrorCode . X_42526 ) ; } table . checkColumnInFKConstraint ( colIndex , Constraint . SET_NULL ) ; removeColumnNotNullConstraints ( colIndex ) ; } else { HsqlName constName = database . nameManager . newAutoName ( "CT" , table . getSchemaName ( ) , table . getName ( ) , SchemaObject . CONSTRAINT ) ; c = new Constraint ( constName , true , null , Constraint . CHECK ) ; c . check = new ExpressionLogical ( column ) ; c . prepareCheckConstraint ( session , table , true ) ; column . setNullable ( false ) ; table . addConstraint ( c ) ; table . setColumnTypeVars ( colIndex ) ; database . schemaManager . addSchemaObject ( c ) ; } }
performs the work for changing the nullability of a column