sqlparser/functions.cpp
// RTRIM in Oracle, SQL Server, DB2, Sybase ASE, Sybase ASA
RTRIM in Oracle, SQL Server, DB2, Sybase ASE, Sybase ASA
RTRIM in Oracle SQL Server DB2 Sybase ASE Sybase ASA
bool SqlParser::ParseFunctionRtrim(Token *name, Token *open)
{
	if(name == NULL)
		return false;
	STATS_DECL
    STATS_SET_DESC(SQL_FUNC_RTRIM_DESC)
	Token *string = GetNextToken();
	if(string == NULL)
		return false;
	ParseExpression(string);
	Token *comma = GetNextCharToken(',', L',');
	Token *set = NULL;
	Token *end_set = NULL;
	if(comma != NULL)
	{
		set = GetNextToken();
		ParseExpression(set);
		end_set = GetLastToken();
	}
	 (void) GetNextCharToken(')', L')');
	if(Target(SQL_MARIADB, SQL_MYSQL) && _source != SQL_MYSQL)
	{
		if(set != NULL)
		{
			Token::Change(name, "TRIM", L"TRIM", 4);
			Append(open, "TRAILING ", L"TRAILING ", 9, name);
			AppendCopy(open, set, end_set);
			Append(open, " FROM ", L"FROM ", 6, name);
			Token::Remove(comma, end_set);
		}
	}
	name->data_type = TOKEN_DT_STRING;
	FUNC_STATS(name);
	return true;
}
bool SqlParser :: ParseFunctionRtrim ( Token * name , Token * open ) { if ( name == NULL ) return false ; STATS_DECL STATS_SET_DESC ( SQL_FUNC_RTRIM_DESC ) Token * string = GetNextToken ( ) ; if ( string == NULL ) return false ; ParseExpression ( string ) ; Token * comma = GetNextCharToken ( ' ' , L' ' ) ; Token * set = NULL ; Token * end_set = NULL ; if ( comma != NULL ) { set = GetNextToken ( ) ; ParseExpression ( set ) ; end_set = GetLastToken ( ) ; } ( void ) GetNextCharToken ( ' ' , L' ' ) ; if ( Target ( SQL_MARIADB , SQL_MYSQL ) && _source != SQL_MYSQL ) { if ( set != NULL ) { Token :: Change ( name , " " , L" " , 4 ) ; Append ( open , " " , L" " , 9 , name ) ; AppendCopy ( open , set , end_set ) ; Append ( open , " " , L" " , 6 , name ) ; Token :: Remove ( comma , end_set ) ; } } name -> data_type = TOKEN_DT_STRING ; FUNC_STATS ( name ) ; return true ; }
RTRIM in Oracle, SQL Server, DB2, Sybase ASE, Sybase ASA
RTRIM in Oracle SQL Server DB2 Sybase ASE Sybase ASA
// Parse string // Set is optional in Oracle, DB2 // Parse set /*Token *close */ // Convert to TRIM in MySQL