/** * Get or generate a default value for the given column. * * @param session the session * @param column the column * @return the value */ public Value getDefaultValue(Session session, Column column) { return getGeneratedValue(session, column, column.getDefaultExpression()); }
/** * @return Default value. */ public Object defaultValue() { Expression dfltExpr = col.getDefaultExpression(); return dfltExpr != null ? col.convert(dfltExpr.getValue(null)).getObject() : null; }
private Prepared prepare(Session session, String sql, ConstraintActionType action) { Prepared command = session.prepare(sql); if (action != ConstraintActionType.CASCADE) { ArrayList<Parameter> params = command.getParameters(); for (int i = 0, len = columns.length; i < len; i++) { Column column = columns[i].column; Parameter param = params.get(i); Value value; if (action == ConstraintActionType.SET_NULL) { value = ValueNull.INSTANCE; } else { Expression expr = column.getDefaultExpression(); if (expr == null) { throw DbException.get(ErrorCode.NO_DEFAULT_SET_1, column.getName()); } value = expr.getValue(session); } param.setValue(value); } } return command; }
Column col = h2NewCols.get(i); if (col.getDefaultExpression() != null) throw new IgniteSQLException("ALTER TABLE ADD COLUMN with DEFAULT value is not supported " + "[col=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
Expression def = nc.getDefaultExpression(); columnList.append(def == null ? "NULL" : def.getSQL()); } else {
IgniteQueryErrorCode.UNSUPPORTED_OPERATION); if (col.getDefaultExpression() != null) { if (!col.getDefaultExpression().isConstant()) { throw new IgniteSQLException("Non-constant DEFAULT expressions are not supported [colName=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION); DataType dfltType = DataType.getDataType(col.getDefaultExpression().getType());
Expression dfltExpr = h2Col.getDefaultExpression();
column.setNullable(templateColumn.isNullable()); column.setDefaultExpression(session, templateColumn.getDefaultExpression()); int selectivity = templateColumn.getSelectivity(); if (selectivity != Constants.SELECTIVITY_DEFAULT) {
table.lock(session, true, true); if (newColumn != null) { checkDefaultReferencesTable(table, newColumn.getDefaultExpression()); checkClustering(newColumn); checkDefaultReferencesTable(table, column.getDefaultExpression()); checkClustering(column);
/** * @return Default value. */ public Object defaultValue() { Expression dfltExpr = col.getDefaultExpression(); return dfltExpr != null ? col.convert(dfltExpr.getValue(null)).getObject() : null; }
/** * Get or generate a default value for the given column. * * @param session the session * @param column the column * @return the value */ public Value getDefaultValue(Session session, Column column) { Expression defaultExpr = column.getDefaultExpression(); Value v; if (defaultExpr == null) { v = column.validateConvertUpdateSequence(session, null); } else { v = defaultExpr.getValue(session); } return column.convert(v); }
/** * Get or generate a default value for the given column. * * @param session the session * @param column the column * @return the value */ public Value getDefaultValue(Session session, Column column) { Expression defaultExpr = column.getDefaultExpression(); Value v; if (defaultExpr == null) { v = column.validateConvertUpdateSequence(session, null); } else { v = defaultExpr.getValue(session); } return column.convert(v); }
private Prepared prepare(Session session, String sql, int action) { Prepared command = session.prepare(sql); if (action != CASCADE) { ArrayList<Parameter> params = command.getParameters(); for (int i = 0, len = columns.length; i < len; i++) { Column column = columns[i].column; Parameter param = params.get(i); Value value; if (action == SET_NULL) { value = ValueNull.INSTANCE; } else { Expression expr = column.getDefaultExpression(); if (expr == null) { throw DbException.get(ErrorCode.NO_DEFAULT_SET_1, column.getName()); } value = expr.getValue(session); } param.setValue(value); } } return command; }
private Prepared prepare(Session session, String sql, int action) { Prepared command = session.prepare(sql); if (action != CASCADE) { ArrayList<Parameter> params = command.getParameters(); for (int i = 0, len = columns.length; i < len; i++) { Column column = columns[i].column; Parameter param = params.get(i); Value value; if (action == SET_NULL) { value = ValueNull.INSTANCE; } else { Expression expr = column.getDefaultExpression(); if (expr == null) { throw DbException.get(ErrorCode.NO_DEFAULT_SET_1, column.getName()); } value = expr.getValue(session); } param.setValue(value); } } return command; }
private Prepared prepare(Session session, String sql, int action) throws SQLException { Prepared command = session.prepare(sql); if (action != CASCADE) { ObjectArray params = command.getParameters(); for (int i = 0; i < columns.length; i++) { Column column = columns[i].column; Parameter param = (Parameter) params.get(i); Value value; if (action == SET_NULL) { value = ValueNull.INSTANCE; } else { Expression expr = column.getDefaultExpression(); if (expr == null) { throw Message.getSQLException(ErrorCode.NO_DEFAULT_SET_1, column.getName()); } value = expr.getValue(session); } param.setValue(value); } } return command; }
Column col = h2NewCols.get(i); if (col.getDefaultExpression() != null) throw new IgniteSQLException("ALTER TABLE ADD COLUMN with DEFAULT value is not supported " + "[col=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
IgniteQueryErrorCode.UNSUPPORTED_OPERATION); if (col.getDefaultExpression() != null) { if (!col.getDefaultExpression().isConstant()) { throw new IgniteSQLException("Non-constant DEFAULT expressions are not supported [colName=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION); DataType dfltType = DataType.getDataType(col.getDefaultExpression().getType());
Expression dfltExpr = h2Col.getDefaultExpression();
table.lock(session, true, true); if (newColumn != null) { checkDefaultReferencesTable(table, newColumn.getDefaultExpression()); checkClustering(newColumn); checkDefaultReferencesTable(table, column.getDefaultExpression()); checkClustering(column);
} else if (newExpr == ValueExpression.DEFAULT) { Column column = table.getColumn(i); Expression defaultExpr = column.getDefaultExpression(); Value v; if (defaultExpr == null) {