protected function readFields(string $sql): array
    {
        if (trim($sql) === '') {
            throw new Exception\EmptyQueryException('Cannot read fields for an empty query');
        }

        $sql = $this->getEmptiedQuery($sql);

        $stmt = $this->pdo->prepare($sql);
        if ($stmt->execute() !== true) {
            throw new Exception\InvalidQueryException(
                sprintf('Invalid query: %s', $sql)
            );
        }

        $column_count = $stmt->columnCount();
        $metaFields = [];
        for ($i = 0; $i < $column_count; ++$i) {
            $meta = $stmt->getColumnMeta($i);
            $metaFields[$i] = $meta;
        }

        $stmt->closeCursor();
        unset($stmt);

        return $metaFields;
    }