public override object VisitCreateIndex([NotNull] PostgresParser.CreateIndexContext context) { var res = new CreateIndexQuery(); res.Name = (Identifier)Visit(context.uid()); res.OnTable = (TableRef)Visit(context.tableName()); foreach (var col in context.fullColumnName()) { res.OnColumns.Add((ColumnRef)Visit(col)); } return(res); }
public static string ExecuteCommand(string command) { var commandSplit = command.Split(';'); var executionResponse = ""; switch (commandSplit[0]) { case Commands.GET_ALL_DATABASES: { executionResponse = FetchDatabases(); } break; case Commands.CREATE_DATABASE: { executionResponse = new CreateDatabaseQuery(commandSplit[1]).Execute(); } break; case Commands.DROP_DATABASE: { executionResponse = new DropDatabaseQuery(commandSplit[1]).Execute(); } break; case Commands.CREATE_TABLE: { executionResponse = new CreateTableQuery(commandSplit[1]).Execute(); } break; case Commands.DROP_TABLE: { executionResponse = new DropTableQuery(commandSplit[1], commandSplit[2]).Execute(); } break; case Commands.GET_ALL_TABLES: { executionResponse = FetchTables(commandSplit[1]); } break; case Commands.CREATE_INDEX: { executionResponse = FetchColumns(commandSplit[1], commandSplit[2]); } break; case Commands.CREATE_NONUNIQUE_INDEX: { executionResponse = new CreateIndexQuery(commandSplit[0], false, commandSplit[1], commandSplit[2], commandSplit[3], commandSplit[4]).Execute(); } break; case Commands.CREATE_UNIQUE_INDEX: { executionResponse = new CreateIndexQuery(commandSplit[0], true, commandSplit[1], commandSplit[2], commandSplit[3], commandSplit[4]).Execute(); } break; case Commands.GET_TABLE_INFORMATION: { executionResponse = FetchTableStructureInformation(commandSplit[1], commandSplit[2]); } break; case Commands.GET_TABLE_FOREIGN_KEYS: { executionResponse = FetchTableForeignKeys(commandSplit[1], commandSplit[2]); } break; case Commands.GET_TABLE_COLUMNS: { executionResponse = FetchTableColumns(commandSplit[1], commandSplit[2]); } break; case Commands.INSERT_INTO_TABLE: { executionResponse = new InsertQuery(commandSplit[1], commandSplit[2], commandSplit[3]).Execute(); } break; case Commands.SELECT_RECORDS: { executionResponse = new SelectQuery(commandSplit[1], commandSplit[2]).Execute(); } break; case Commands.SELECT_RECORDS_WITH_JOIN: { executionResponse = new SelectWithJoinQuery(commandSplit[1], commandSplit[2]).Execute(); } break; case Commands.DELETE_RECORD: { executionResponse = new DeleteRowsQuery(commandSplit[1], commandSplit[2], commandSplit[3]).Execute(); } break; } return(executionResponse); }