@Override public Object getObject() { return new TimestampWithTimeZone(dateValue, timeNanos, timeZoneOffsetMins); }
@Override public void add(Object value) throws SQLException { aggregateFunction.add(value); }
@Override public Object getResult() throws SQLException { return aggregateFunction.getResult(); } }
/** * Get or create a timestamp value for the given timestamp. * * @param timestamp the timestamp * @return the value */ public static ValueTimestampTimeZone get(TimestampWithTimeZone timestamp) { return fromDateValueAndNanos(timestamp.getYMD(), timestamp.getNanosSinceMidnight(), timestamp.getTimeZoneOffsetMins()); }
/** * This method is called after an exception occurred, to inform the database * event listener (if one is set). * * @param e the exception * @param sql the SQL statement */ public void exceptionThrown(SQLException e, String sql) { if (eventListener != null) { try { eventListener.exceptionThrown(e, sql); } catch (Exception e2) { // ignore this (user made) exception } } }
/** * Set the progress of a long running operation. * This method calls the {@link DatabaseEventListener} if one is registered. * * @param state the {@link DatabaseEventListener} state * @param name the object name * @param x the current position * @param max the highest value */ public void setProgress(int state, String name, int x, int max) { if (eventListener != null) { try { eventListener.setProgress(state, name, x, max); } catch (Exception e2) { // ignore this (user made) exception } } }
/** * Called after the database has been opened and initialized. This method * notifies the event listener if one has been set. */ void opened() { if (eventListener != null) { eventListener.opened(); } if (writer != null) { writer.startThread(); } }
/** * Close the trigger. */ public void close() throws SQLException { if (triggerCallback != null) { triggerCallback.close(); } }
@Override public void init(Connection conn) throws SQLException { aggregateFunction.init(conn); }
public void setEventListenerClass(String className) { if (className == null || className.length() == 0) { eventListener = null; } else { try { eventListener = (DatabaseEventListener) JdbcUtils.loadUserClass(className).newInstance(); String url = databaseURL; if (cipher != null) { url += ";CIPHER=" + cipher; } eventListener.init(url); } catch (Throwable e) { throw DbException.get( ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, e, className, e.toString()); } } }
@Override public int getInternalType(int[] inputTypes) throws SQLException { int[] sqlTypes = new int[inputTypes.length]; for (int i = 0; i < inputTypes.length; i++) { sqlTypes[i] = DataType.convertTypeToSQLType(inputTypes[i]); } return DataType.convertSQLTypeToValueType(aggregateFunction.getType(sqlTypes)); }
@Override public void removeChildrenAndResources(Session session) { table.removeTrigger(this); database.removeMeta(session, getId()); if (triggerCallback != null) { try { triggerCallback.remove(); } catch (SQLException e) { throw DbException.convert(e); } } table = null; triggerClassName = null; triggerSource = null; triggerCallback = null; invalidate(); }
private Aggregate getInstance() throws SQLException { Aggregate agg = userAggregate.getInstance(); agg.init(userConnection); return agg; }
/** * Gets the SQL exception object for a specific error code. * * @param errorCode the error code * @param cause the cause of the exception * @param params the list of parameters of the message * @return the SQLException object */ private static JdbcSQLException getJdbcSQLException(int errorCode, Throwable cause, String... params) { String sqlstate = ErrorCode.getState(errorCode); String message = translate(sqlstate, params); return new JdbcSQLException(message, null, sqlstate, errorCode, cause, null); }
/** * Add a table to the schema. * * @param data the create table information * @return the created {@link Table} object */ public Table createTable(CreateTableData data) { synchronized (database) { if (!data.temporary || data.globalTemporary) { database.lockMeta(data.session); } data.schema = this; if (data.tableEngine == null) { DbSettings s = database.getSettings(); if (s.defaultTableEngine != null) { data.tableEngine = s.defaultTableEngine; } else if (s.mvStore) { data.tableEngine = MVTableEngine.class.getName(); } } if (data.tableEngine != null) { if (data.tableEngineParams == null) { data.tableEngineParams = this.tableEngineParams; } return database.getTableEngine(data.tableEngine).createTable(data); } return new RegularTable(data); } }
@Override public Expression optimize(Session session) { userConnection = session.createConnection(false); int len = args.length; argTypes = new int[len]; for (int i = 0; i < len; i++) { Expression expr = args[i]; args[i] = expr.optimize(session); int type = expr.getType(); argTypes[i] = type; } try { Aggregate aggregate = getInstance(); dataType = aggregate.getInternalType(argTypes); } catch (SQLException e) { throw DbException.convert(e); } if (filterCondition != null) { filterCondition = filterCondition.optimize(session); } return this; }
default: if (JdbcUtils.customDataTypesHandler != null) { return JdbcUtils.customDataTypesHandler.supportsAdd(type);
default: if (JdbcUtils.customDataTypesHandler != null) { return JdbcUtils.customDataTypesHandler.getAddProofType(type);
/** * Get a data type object from a type name. * * @param s the type name * @param mode database mode * @return the data type object */ public static DataType getTypeByName(String s, Mode mode) { DataType result = mode.typeByNameMap.get(s); if (result == null) { result = TYPES_BY_NAME.get(s); if (result == null && JdbcUtils.customDataTypesHandler != null) { result = JdbcUtils.customDataTypesHandler.getDataTypeByName(s); } } return result; }
/** * Get the data type object for the given value type. * * @param type the value type * @return the data type object */ public static DataType getDataType(int type) { if (type == Value.UNKNOWN) { throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1, "?"); } DataType dt = TYPES_BY_VALUE_TYPE.get(type); if (dt == null && JdbcUtils.customDataTypesHandler != null) { dt = JdbcUtils.customDataTypesHandler.getDataTypeById(type); } if (dt == null) { dt = TYPES_BY_VALUE_TYPE.get(Value.NULL); } return dt; }