/** * @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 * @param array $params * * @return Result * @throws PDOException */ public function executeRead(QueryInterface $query, array $params = []) { $cursor = null; try { $reader = $this->connection; $tabletType = $this->clusterConfig->getReadFrom(); if ($this->isInTransaction()) { $reader = $this->getTransaction(); $tabletType = TabletType::MASTER; } $cursor = $reader->execute($this->ctx, $query->getSql(), $params, $tabletType); } catch (VitessException $e) { $this->handleException($e); return new Result(null, $e); } return new Result(new Cursor($cursor)); }