// Parse CREATE TABLE storage clause bool SqlParser::ParseStorageClause(Token *table_name, int obj_scope, Token **id_start, Token **comment, Token *last_colname, Token *last_colend) { if(_source == SQL_ORACLE && ParseOracleStorageClause(obj_scope) == true) return true; if(_source == SQL_SQL_SERVER && ParseSqlServerStorageClause() == true) return true; if(_source == SQL_MYSQL && ParseMysqlStorageClause(table_name, id_start, comment) == true) return true; if(_source == SQL_DB2 && ParseDb2StorageClause() == true) return true; if(_source == SQL_INFORMIX && ParseInformixStorageClause() == true) return true; if(_source == SQL_TERADATA && ParseTeradataStorageClause(obj_scope, last_colname, last_colend) == true) return true; return false; }
// SQL Server index options WITH (PAD_INDEX = OFF, ...) bool SqlParser::ParseSqlServerIndexOptions(Token *token) { if(token == NULL) return false; bool exists = false; // Start with WITH keyword if(token->Compare("WITH", L"WITH", 4) == false) return false; // ( can be omitted if FILLFACTOR is only specified Token *open = GetNext('(', L'('); while(true) { bool remove = false; Token *option = GetNextToken(); if(option == NULL) break; // = between option name and value /*Token *equal */ (void) GetNext('=', L'='); Token *value = NULL; // ALLOW_PAGE_LOCKS = ON | OFF if(option->Compare("ALLOW_PAGE_LOCKS", L"ALLOW_PAGE_LOCKS", 16) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else // ALLOW_ROW_LOCKS = ON | OFF if(option->Compare("ALLOW_ROW_LOCKS", L"ALLOW_ROW_LOCKS", 15) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else // FILLFACTOR = num if(option->Compare("FILLFACTOR", L"FILLFACTOR", 10) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else // IGNORE_DUP_KEY = ON | OFF if(option->Compare("IGNORE_DUP_KEY", L"IGNORE_DUP_KEY", 14) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else // PAD_INDEX = ON | OFF if(option->Compare("PAD_INDEX", L"PAD_INDEX", 9) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else // STATISTICS_NORECOMPUTE = ON | OFF if(option->Compare("STATISTICS_NORECOMPUTE", L"STATISTICS_NORECOMPUTE", 22) == true) { value = GetNextToken(); if(_target != SQL_SQL_SERVER) remove = true; exists = true; } else { PushBack(option); break; } Token *comma = GetNext(',', L','); // Remove the option if(remove == true) { Token::Remove(option, value); Token::Remove(comma); } if(comma == NULL) break; } if(exists == false) { // PostgreSQL also has WITH ( ... option, so return open token PushBack(open); return false; } Token *close = GetNext(open, ')', L')'); // Remove WITH () if(_target != SQL_SQL_SERVER) { Token::Remove(token); Token::Remove(open); Token::Remove(close); } // Storage clause can follow ParseSqlServerStorageClause(); return exists; }