/** * For the given list of columns, disable "nullable" for those columns that * are primary key columns. * * @param columns the list of columns */ protected void changePrimaryKeysToNotNull(ArrayList<Column> columns) { if (pkColumns != null) { for (Column c : columns) { for (IndexColumn idxCol : pkColumns) { if (c.getName().equals(idxCol.columnName)) { c.setNullable(false); } } } } }
/** * Constructs non-nullable column. * * @param name Column name. * @param type Column data type. * @return {@link GridSqlColumn} with given name and type. */ private static GridSqlColumn cn(String name, int type) { Column col = new Column(name, type); col.setNullable(false); return new GridSqlColumn(col, null, name); }
Column c = new Column(col.name(), DataType.getTypeFromClass(Class.forName(col.typeName()))); c.setNullable(col.isNullable());
Column[] tableColumns = table.getColumns(); for (IndexColumn indexColumn : cols) { tableColumns[indexColumn.column.getColumnId()].setNullable(false);
displaySize, enumerators); if (templateColumn != null) { column.setNullable(templateColumn.isNullable()); column.setDefaultExpression(session, templateColumn.getDefaultExpression());
ArrayList<Column> cols = data.columns; Column columnId = new Column("ID", Value.INT); columnId.setNullable(false); cols.add(columnId); cols.add(new Column("HEAD", Value.INT));
switch (nullConstraint) { case NULL_IS_ALLOWED: column.setNullable(true); break; case NULL_IS_NOT_ALLOWED: column.setNullable(false); break; case NO_NULL_CONSTRAINT_FOUND: column.setNullable(defaultNullable & column.isNullable()); break; default: column.setNullable(false);
oldColumn.setNullable(false); db.updateMeta(session, table); break; oldColumn.setNullable(true); db.updateMeta(session, table); break;
column.setNullable(false);
@Override public Table createTable(CreateTableData data) { if(data.tableEngineParams.isEmpty()) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1); } File filePath = URIUtility.fileFromString(StringUtils.javaDecode(data.tableEngineParams.get(0))); if(!filePath.exists()) { // Do not throw an exception as it will prevent the user from opening the database LOGGER.error("File not found:\n"+filePath.getAbsolutePath()+"\nThe table "+data.tableName+" will be empty."); return new DummyTable(data); } try { Driver driver = createDriver(filePath, data.tableEngineParams); if(data.columns.isEmpty()) { feedCreateTableData(driver, data); // Add primary key column String pkColumnName = getUniqueColumnName(H2TableIndex.PK_COLUMN_NAME, data.columns); Column pk = new Column(pkColumnName, Value.LONG); pk.setPrimaryKey(true); pk.setNullable(false); data.columns.add(0, pk); } H2Table shpTable = new H2Table(driver, data); shpTable.init(data.session); return shpTable; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
@Override public Table createTable(CreateTableData data) { if(data.tableEngineParams.isEmpty()) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1); } File filePath = URIUtilities.fileFromString(StringUtils.javaDecode(data.tableEngineParams.get(0))); if(!filePath.exists()) { // Do not throw an exception as it will prevent the user from opening the database LOGGER.error("File not found:\n"+filePath.getAbsolutePath()+"\nThe table "+data.tableName+" will be empty."); return new DummyTable(data); } try { Driver driver = createDriver(filePath, data.tableEngineParams); if(data.columns.isEmpty()) { feedCreateTableData(driver, data); // Add primary key column String pkColumnName = getUniqueColumnName(H2TableIndex.PK_COLUMN_NAME, data.columns); Column pk = new Column(pkColumnName, Value.LONG); pk.setPrimaryKey(true); pk.setNullable(false); data.columns.add(0, pk); } H2Table shpTable = new H2Table(driver, data); shpTable.init(data.session); return shpTable; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
@Override public Table createTable(CreateTableData data) { if(data.tableEngineParams.isEmpty()) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1); } File filePath = URIUtilities.fileFromString(StringUtils.javaDecode(data.tableEngineParams.get(0))); if(!filePath.exists()) { // Do not throw an exception as it will prevent the user from opening the database LOGGER.error("File not found:\n"+filePath.getAbsolutePath()+"\nThe table "+data.tableName+" will be empty."); return new DummyTable(data); } try { Driver driver = createDriver(filePath, data.tableEngineParams); if(data.columns.isEmpty()) { feedCreateTableData(driver, data); // Add primary key column String pkColumnName = getUniqueColumnName(H2TableIndex.PK_COLUMN_NAME, data.columns); Column pk = new Column(pkColumnName, Value.LONG); pk.setPrimaryKey(true); pk.setNullable(false); data.columns.add(0, pk); } H2Table shpTable = new H2Table(driver, data); shpTable.init(data.session); return shpTable; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
@Override public Table createTable(CreateTableData data) { if(data.tableEngineParams.isEmpty()) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1); } File filePath = URIUtilities.fileFromString(StringUtils.javaDecode(data.tableEngineParams.get(0))); if(!filePath.exists()) { // Do not throw an exception as it will prevent the user from opening the database LOGGER.error("File not found:\n"+filePath.getAbsolutePath()+"\nThe table "+data.tableName+" will be empty."); return new DummyTable(data); } try { Driver driver = createDriver(filePath, data.tableEngineParams); if(data.columns.isEmpty()) { feedCreateTableData(driver, data); // Add primary key column String pkColumnName = getUniqueColumnName(H2TableIndex.PK_COLUMN_NAME, data.columns); Column pk = new Column(pkColumnName, Value.LONG); pk.setPrimaryKey(true); pk.setNullable(false); data.columns.add(0, pk); } H2Table shpTable = new H2Table(driver, data); shpTable.init(data.session); return shpTable; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
Column c = new Column(col.name(), DataType.getTypeFromClass(Class.forName(col.typeName()))); c.setNullable(col.isNullable());
Column[] tableColumns = table.getColumns(); for (IndexColumn indexColumn : cols) { tableColumns[indexColumn.column.getColumnId()].setNullable(false);
Column[] tableColumns = table.getColumns(); for (IndexColumn indexColumn : cols) { tableColumns[indexColumn.column.getColumnId()].setNullable(false);
public ResultTempTable(Session session, SortOrder sort, int columnCount) throws SQLException { this.session = session; this.sort = sort; Schema schema = session.getDatabase().getSchema(Constants.SCHEMA_MAIN); Column column = new Column(COLUMN_NAME, Value.ARRAY); column.setNullable(false); ObjectArray columns = new ObjectArray(); columns.add(column); int tableId = session.getDatabase().allocateObjectId(true, true); String tableName = "TEMP_RESULT_SET_" + tableId; table = schema.createTable(tableName, tableId, columns, false, false); int indexId = session.getDatabase().allocateObjectId(true, true); IndexColumn indexColumn = new IndexColumn(); indexColumn.column = column; indexColumn.columnName = COLUMN_NAME; IndexType indexType; indexType = IndexType.createPrimaryKey(true, false); IndexColumn[] indexCols = new IndexColumn[]{indexColumn}; index = new BtreeIndex(session, table, indexId, tableName, indexCols, indexType, Index.EMPTY_HEAD); table.getIndexes().add(index); }
column.setNullable(false); } else { readIf("NULL"); column.setNullable(true); column.setNullable(false); } else { readIf("NULL");
column.setNullable(false); } else if (readIf("NULL")) { column.setNullable(true); } else { column.setNullable(defaultNullable & column.isNullable()); column.setNullable(false); } else { readIf("NULL");
oldColumn.setNullable(false); db.update(session, table); break; oldColumn.setNullable(true); db.update(session, table); break;