// QueryRawJSON will execute a query for the influxql.Compiler type against an influxdb 1.x endpoint,
// and return the body of the response as a byte array.
547708
func (s *Service) QueryRawJSON(ctx context.Context, req *query.Request) ([]byte, error) {
	span, ctx := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	resp, err := s.query(ctx, req)
	if err != nil {
		return nil, tracing.LogError(span, err)
	}

	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, tracing.LogError(span, err)
	}

	return b, nil
}
848041
func (h *QueryHandler) handlePostQuery(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	var req query.Request
	req.WithCompilerMappings(h.CompilerMappings)
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		EncodeError(ctx, err, w)
		return
	}

	results, err := h.QueryService.Query(ctx, &req)
	if err != nil {
		EncodeError(ctx, err, w)
		return
	}
	// Always cancel the results to free resources.
	// If all results were consumed cancelling does nothing.
	defer results.Release()

	// Setup headers
	stats, hasStats := results.(flux.Statisticser)
	if hasStats {
		w.Header().Set("Trailer", queryStatisticsTrailer)
	}

	// NOTE: We do not write out the headers here.
	// It is possible that if the encoding step fails
	// that we can write an error header so long as
	// the encoder did not write anything.
	// As such we rely on the http.ResponseWriter behavior
	// to write an StatusOK header with the first write.

	switch r.Header.Get("Accept") {
	case "text/csv":
		fallthrough
	default:
		h.csvDialect.SetHeaders(w)
		encoder := h.csvDialect.Encoder()
		n, err := encoder.Encode(w, results)
		if err != nil {
			if n == 0 {
				// If the encoder did not write anything, we can write an error header.
				EncodeError(ctx, err, w)
			} else {
				h.Logger.Info("Failed to encode client response",
					zap.Error(err),
				)
			}
		}
	}

	if hasStats {
		data, err := json.Marshal(stats.Statistics())
		if err != nil {
			h.Logger.Info("Failed to encode statistics", zap.Error(err))
			return
		}
		// Write statisitcs trailer
		w.Header().Set(queryStatisticsTrailer, string(data))
	}
}
446556
func (tx *Tx) QueryRowEx(ctx context.Context, sql string, options *QueryExOptions, args ...interface{}) *Row {
	rows, _ := tx.QueryEx(ctx, sql, options, args...)
	return (*Row)(rows)
}
80581
func (v *Paging) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson692db02bDecodeGithubComMailgunMailgunGoEvents4(&r, v)
	return r.Error()
}
801655
func (me *TxDatabase) QueryRow(query string, args ...interface{}) *sql.Row {
	me.Trace("QUERY ROW", query, args...)
	return me.Tx.QueryRow(query, args...)
}
72908
func (h *FluxHandler) postQueryAnalyze(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	var req QueryRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		EncodeError(ctx, errors.MalformedDataf("invalid json: %v", err), w)
		return
	}

	a, err := req.Analyze()
	if err != nil {
		EncodeError(ctx, err, w)
		return
	}
	if err := encodeResponse(ctx, w, http.StatusOK, a); err != nil {
		logEncodingError(h.Logger, r, err)
		return
	}
}
79149
func (c *Connection) RawQuery(stmt string, args ...interface{}) *Query {
	return Q(c).RawQuery(stmt, args...)
}
1013610
func (obj *Global) GetDatabasesFromConnectionStringRaw(ctx context.Context, connection interface{}) (json.RawMessage, error) {
	result := &struct {
		Databases json.RawMessage	`json:"qDatabases"`
	} {}
	err := obj.rpc(ctx, "GetDatabasesFromConnectionString", result, ensureEncodable(connection))
	return result.Databases, err 
}
53866
func Query(query url.Values) RequestOption {
	return func(req *http.Request) error {
		req.URL.RawQuery = query.Encode()
		return nil
	}
}
1153159
func (r *Request) MarshalJSON() (rawData []byte, err error) {
	var signatureString, dataString string
	if r.Signature != nil {
		signatureString = hexutil.Encode(r.Signature[:])
	}
	if r.data != nil {
		dataString = hexutil.Encode(r.data)
	}

	requestJSON := &updateRequestJSON{
		ID:              r.ID,
		ProtocolVersion: r.Header.Version,
		Data:            dataString,
		Signature:       signatureString,
	}

	return json.Marshal(requestJSON)
}
698984
func (db *Database) commonRawQuery(query string, args ...interface{}) *sql.Stmt {
	// Replace ? with $n
	query = db.replaceMarks(query)
	// Append args content to current values
	db.whereValues = append(db.whereValues, args...)

	db.printLog(query)
	// Compile query
	var stmt *sql.Stmt
	var err error
	if stmt, err = db.db.Prepare(query + ";"); err != nil {
		db.panicLog(err.Error())
	}
	return stmt
}
971089
func (c *Client) QueryBuffer(num int32) (*Buffer, error) {
	if err := c.oscConn.Send(osc.Message{
		Address: bufferQueryAddress,
		Arguments: osc.Arguments{
			osc.Int(num),
		},
	}); err != nil {
		return nil, errors.Wrap(err, "sending buffer query message")
	}
	return c.awaitBufInfoReply()
}
1157452
func (sink *influxdbSink) runQuery(queryStr string) ([]influxdb.Result, error) {
	// ensure we have a valid client handle before attempting to use it
	if err := sink.ensureClient(); err != nil {
		glog.Errorf("Unable to ensure InfluxDB client is present: %v", err)
		return nil, fmt.Errorf("unable to run query: unable to connect to database")
	}

	q := influxdb.Query{
		Command:  queryStr,
		Database: sink.c.DbName,
	}

	glog.V(4).Infof("Executing query %q against database %q", q.Command, q.Database)

	resp, err := sink.client.Query(q)
	if err != nil {
		glog.Errorf("Unable to perform query %q against database %q: %v", q.Command, q.Database, err)
		return nil, err
	} else if resp.Error() != nil {
		glog.Errorf("Unable to perform query %q against database %q: %v", q.Command, q.Database, resp.Error())
		return nil, resp.Error()
	}

	if len(resp.Results) < 1 {
		glog.Errorf("Unable to perform query %q against database %q: no results returned", q.Command, q.Database)
		return nil, fmt.Errorf("No results returned")
	}

	return resp.Results, nil
}
914140
func buildRespJSON(b []byte, response, data interface{}) error {
	var err error

	err = json.Unmarshal(b, response)
	if err != nil {
		return err
	}

	switch rt := response.(type) {
	case *ApiResp:
		if len(rt.Data) > 0 {
			err = json.Unmarshal(rt.Data, &data)
			if err != nil {
				return err
			}
		}
	}

	return nil
}
1359879
func (r Network_Monitor_Version1_Query_Host) GetQueryType() (resp datatypes.Network_Monitor_Version1_Query_Type, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Monitor_Version1_Query_Host", "getQueryType", nil, &r.Options, &resp)
	return
}
696509
func (q *Query) RawQuery(stmt string, args ...interface{}) *Query {
	q.RawSQL = &clause{stmt, args}
	return q
}
212771
func (engine *Engine) QueryString(sqlorArgs ...interface{}) ([]map[string]string, error) {
	session := engine.NewSession()
	defer session.Close()
	return session.QueryString(sqlorArgs...)
}