/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_COLLATION) { return null; } return $this->getResultFromData(self::$data, self::$fields); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof AlterQuery || $query->getObject() !== AlterQuery::EXPRESSION_TABLE) { return null; } $command = new ApplySchema($query->getSql()); $this->client->executeCommand($command); return new EmptyResult(); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_DATABASES) { return null; } $command = new GetKeyspaces(); /* @var $vtCtldResult GetKeyspacesResult */ $vtCtldResult = $this->client->executeCommand($command); return new Databases($vtCtldResult); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_TABLES) { return null; } $tablet = $this->tablet->getTablet(); $command = new GetSchema($tablet->getAlias()); /* @var $vtCtldResult GetSchemaResult */ $vtCtldResult = $this->client->executeCommand($command); return new Tables($vtCtldResult); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_CREATE_DATABASE) { return null; } $database = $query->getCreateObjectExpression(ShowQuery::EXPRESSION_CREATE_DATABASE); $newData = []; $newData[] = array_map(function ($row) use($database) { return str_replace('{DB}', $database, $row); }, self::$data); return $this->getResultFromData($newData, self::$fields); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_INDEX) { return null; } $fromExpr = $query->getFromExpression(); if (!$fromExpr) { throw new Exception('From expression missing.'); } $tablet = $this->tablet->getTablet(); $schemaCmd = new GetSchema($tablet->getAlias()); /* @var $result GetSchemaResult */ $result = $this->client->executeCommand($schemaCmd); return new IndexFrom($result, $fromExpr); }
/** * @param QueryInterface $query * * @return Result|null * @throws Exception */ public function process(QueryInterface $query) { if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_CREATE_TABLE) { return null; } $table = $query->getCreateObjectExpression(ShowQuery::EXPRESSION_CREATE_TABLE); if (!$table) { throw new Exception('Table missing.'); } $tablet = $this->tablet->getTablet(); $schemaCmd = new GetSchema($tablet->getAlias()); /* @var $result GetSchemaResult */ $result = $this->client->executeCommand($schemaCmd); return new CreateTable($result, $table); }