Top Description Fields Constructors Methods
org.h2.mode

public final Class FunctionsMySQL

extends ModeFunction
Class Inheritance
Imports
java.text.SimpleDateFormat, java.util.Date, .HashMap, .Locale, org.h2.api.ErrorCode, org.h2.engine.SessionLocal, org.h2.expression.Expression, .ValueExpression, org.h2.message.DbException, org.h2.util.DateTimeUtils, .StringUtils, org.h2.value.TypeInfo, .Value, .ValueBigint, .ValueInteger, .ValueNull, .ValueTimestamp, .ValueTimestampTimeZone, .ValueVarchar

This class implements some MySQL-specific functions.
Authors
Jason Brittain, Thomas Mueller

Field Summary

Modifier and TypeField and Description
private static final int
private static final String
DATE_TIME_FORMAT

The date format of a MySQL formatted date/time.

private static final String[]
FORMAT_REPLACE

Format replacements for MySQL date formats.

private static final int
private static final HashMap<String, FunctionInfo>
private static final int
private static final int
Inherited from org.h2.mode.ModeFunction:
infoVAR_ARGS

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
checkParameterCount(int
the number of parameters set
len
)

Overrides org.h2.mode.ModeFunction.checkParameterCount.

Check if the parameter count is correct.

private static String
public static String

Returns:

a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".
fromUnixTime
(int
The current timestamp in seconds.
seconds
)

See https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

public static String

Returns:

a formatted date/time String in the given format.
fromUnixTime
(int
The current timestamp in seconds.
seconds
,
String
The format of the date/time String to return.
format
)

See https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

public static FunctionsMySQL

Returns:

the function with specified name or null
getFunction
(String
the upper-case name of a function
upperName
)

Returns mode-specific function for a given name, or null.

public Value
getValue(SessionLocal
the session
session
)

Overrides org.h2.expression.function.FunctionN.getValue.

Return the resulting value for the current row.

public Expression
optimize(SessionLocal
the session
session
)

Implements abstract org.h2.expression.Expression.optimize.

Try to optimize the expression.

public static int

Returns:

the timestamp in seconds since EPOCH
unixTimestamp
(SessionLocal
the session
session
,
Value
the timestamp
value
)

Get the seconds since 1970-01-01 00:00:00 UTC of the given timestamp.

Inherited from org.h2.mode.ModeFunction:
doneWithParametersgetArgumentsValuesgetCompatibilityDateTimeValueFunctiongetFunctiongetNamegetNullOrValueisEverythingoptimizeArguments

Field Detail

DATEback to summary
private static final int DATE
DATE_TIME_FORMATback to summary
private static final String DATE_TIME_FORMAT

The date format of a MySQL formatted date/time. Example: 2008-09-25 08:40:59

FORMAT_REPLACEback to summary
private static final String[] FORMAT_REPLACE

Format replacements for MySQL date formats. See https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

FROM_UNIXTIMEback to summary
private static final int FROM_UNIXTIME
FUNCTIONSback to summary
private static final HashMap<String, FunctionInfo> FUNCTIONS
LAST_INSERT_IDback to summary
private static final int LAST_INSERT_ID
UNIX_TIMESTAMPback to summary
private static final int UNIX_TIMESTAMP

Constructor Detail

FunctionsMySQLback to summary
pack-priv FunctionsMySQL(FunctionInfo info)

Method Detail

checkParameterCountback to summary
protected void checkParameterCount(int len)

Overrides org.h2.mode.ModeFunction.checkParameterCount.

Doc from org.h2.mode.ModeFunction.checkParameterCount.

Check if the parameter count is correct.

Parameters
len:int

the number of parameters set

Annotations
@Override
convertToSimpleDateFormatback to summary
private static String convertToSimpleDateFormat(String format)
fromUnixTimeback to summary
public static String fromUnixTime(int seconds)

See https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

Parameters
seconds:int

The current timestamp in seconds.

Returns:String

a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".

fromUnixTimeback to summary
public static String fromUnixTime(int seconds, String format)

See https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

Parameters
seconds:int

The current timestamp in seconds.

format:String

The format of the date/time String to return.

Returns:String

a formatted date/time String in the given format.

getFunctionback to summary
public static FunctionsMySQL getFunction(String upperName)

Returns mode-specific function for a given name, or null.

Parameters
upperName:String

the upper-case name of a function

Returns:FunctionsMySQL

the function with specified name or null

getValueback to summary
public Value getValue(SessionLocal session)

Overrides org.h2.expression.function.FunctionN.getValue.

Doc from org.h2.expression.Expression.getValue.

Return the resulting value for the current row.

Parameters
session:SessionLocal

the session

Returns:Value

the result

Annotations
@Override
optimizeback to summary
public Expression optimize(SessionLocal session)

Implements abstract org.h2.expression.Expression.optimize.

Doc from org.h2.expression.Expression.optimize.

Try to optimize the expression.

Parameters
session:SessionLocal

the session

Returns:Expression

the optimized expression

Annotations
@Override
unixTimestampback to summary
public static int unixTimestamp(SessionLocal session, Value value)

Get the seconds since 1970-01-01 00:00:00 UTC of the given timestamp. See https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_unix-timestamp

Parameters
session:SessionLocal

the session

value:Value

the timestamp

Returns:int

the timestamp in seconds since EPOCH