private String withErrorContext(String msg) { return msg + "(Column=" + getName() + ")"; } }
@Override short getColumnNumber(String colName) { for(ColumnBuilder col : _columns) { if(col.getName().equalsIgnoreCase(colName)) { return col.getColumnNumber(); } } return IndexData.COLUMN_UNUSED; }
@Override protected String withErrorContext(String msg) { String objStr = ""; if(_column != null) { objStr = ";Column=" + _column.getName(); } else if(_index != null) { objStr = ";Index=" + _index.getName(); } return msg + "(Table=" + _table.getName() + objStr + ")"; } }
protected void validateColumn(Set<String> colNames, ColumnBuilder column) { // FIXME for now, we can't create complex columns if(column.getType() == DataType.COMPLEX_TYPE) { throw new UnsupportedOperationException(withErrorContext( "Complex column creation is not yet implemented")); } column.validate(getFormat()); if(!colNames.add(DatabaseImpl.toLookupName(column.getName()))) { throw new IllegalArgumentException(withErrorContext( "duplicate column name: " + column.getName())); } setColumnSortOrder(column); }
public void addColumn(String tableName, String columnName, Map<String, String> columnMap, String[] types, String[] defaults, Boolean[] notNulls) throws IOException, SQLException { UcanaccessConnection conn = UcanaccessConnection.getCtxConnection(); Database db = conn.getDbIO(); String tn = escape4Access(tableName); String ntn = escape4Hsqldb(tableName); Metadata mtd = new Metadata(conn.getHSQLDBConnection()); ColumnBuilder cb = this.getColumn(ntn, columnMap, types); Table t = db.getTable(tn); Column cl = cb.addToTable(t); int idTable = mtd.getTableId(ntn.toUpperCase()); mtd.newColumn(cb.getName(), SQLConverter.preEscapingIdentifier(cb.getName()), getUcaMetadataTypeName(0, cb, types), idTable); saveColumnsDefaults(defaults, notNulls, cl, 0); updateNewColumn2Defaut(tableName, columnName, t, cl); setHsqldbNotNull(tableName, columnName, types[0], cl); conn.reloadDbIO(); }
/** * Writes the column definitions into a table definition buffer. * @param buffer Buffer to write to */ protected static void writeDefinitions(TableCreator creator, ByteBuffer buffer) throws IOException { // we specifically put the "long variable" values after the normal // variable length values so that we have a better chance of fitting it // all (because "long variable" values can go in separate pages) int longVariableOffset = creator.countNonLongVariableLength(); creator.setColumnOffsets(0, 0, longVariableOffset); for (ColumnBuilder col : creator.getColumns()) { writeDefinition(creator, col, buffer); } for (ColumnBuilder col : creator.getColumns()) { TableImpl.writeName(buffer, col.getName(), creator.getCharset()); } }
totalTableDefSize += DBMutator.calculateNameLength(col.getName());
Map<String,PropertyMap.Property> colProps = cb.getProperties(); if(colProps != null) { newTable.getColumn(cb.getName()).getProperties() .putAll(colProps.values()); addedProps = true;
getName(), format.MAX_COLUMN_NAME_LENGTH, "column");