sqlparser/helpers.cpp
// Compare only existing parts in identifiers (schema.tab and tab i.e.)
Compare only existing parts in identifiers (schema.tab and tab i.e.)
Compare only existing parts in identifiers ( schema . tab and tab i . e . )
bool SqlParser::CompareIdentifiersExistingParts(Token *first, Token *second)
{
	if(first == NULL || second == NULL)
		return false;
	int num1 = GetIdentPartsCount(first);
	int num2 = GetIdentPartsCount(second);
	int num = 0;
	int equal_num = 0;
	bool equal = true;
	TokenStr part1;
	TokenStr part2;
	size_t len1 = 0;
	size_t len2 = 0;
	if(num1 > num2)
	{
		num = num2;
		for(int i = 0; i < num1 - num2; i++)
			GetNextIdentItem(first, part1, &len1);
	}
	else
	if(num2 > num1)
	{
		num = num1;
		for(int i = 0; i < num2 - num1; i++)
			GetNextIdentItem(second, part2, &len2);
	}
	if(num == 0)
	{
		equal = Token::Compare(first, second);
		equal_num++;
	}
	else
	{
		for(int i = 0; i < num; i++)
		{
			part1.Clear();
			part2.Clear();
			GetNextIdentItem(first, part1, &len1);
			GetNextIdentItem(second, part2, &len2);
			if(CompareIdentifierPart(part1, part2) == false)
			{
				equal = false;
				break;
			}
			equal_num++;
		}
	}
	return (equal == true && equal_num > 0) ? true : false;
}
bool SqlParser :: CompareIdentifiersExistingParts ( Token * first , Token * second ) { if ( first == NULL || second == NULL ) return false ; int num1 = GetIdentPartsCount ( first ) ; int num2 = GetIdentPartsCount ( second ) ; int num = 0 ; int equal_num = 0 ; bool equal = true ; TokenStr part1 ; TokenStr part2 ; size_t len1 = 0 ; size_t len2 = 0 ; if ( num1 > num2 ) { num = num2 ; for ( int i = 0 ; i < num1 - num2 ; i ++ ) GetNextIdentItem ( first , part1 , & len1 ) ; } else if ( num2 > num1 ) { num = num1 ; for ( int i = 0 ; i < num2 - num1 ; i ++ ) GetNextIdentItem ( second , part2 , & len2 ) ; } if ( num == 0 ) { equal = Token :: Compare ( first , second ) ; equal_num ++ ; } else { for ( int i = 0 ; i < num ; i ++ ) { part1 . Clear ( ) ; part2 . Clear ( ) ; GetNextIdentItem ( first , part1 , & len1 ) ; GetNextIdentItem ( second , part2 , & len2 ) ; if ( CompareIdentifierPart ( part1 , part2 ) == false ) { equal = false ; break ; } equal_num ++ ; } } return ( equal == true && equal_num > 0 ) ? true : false ; }
Compare only existing parts in identifiers (schema.tab and tab i.e.)
Compare only existing parts in identifiers ( schema . tab and tab i . e . )
// Define the number of parts in each identifier // Skip exceeding first identifier parts // Skip exceeding second identifier parts // Single part identifier // All parts must be equal