MCPcopy Create free account
hub / github.com/PostHog/duckgres / interpolateArgs

Function interpolateArgs

server/flightclient/flight_executor.go:897–948  ·  view source on GitHub ↗

interpolateArgs performs simple positional argument interpolation for Flight SQL. Flight SQL's Execute doesn't support $1-style parameters natively, so we interpolate them into the query string. Safety: args come from PostgreSQL wire protocol typed parameter binding, not raw user strings. The calle

(query string, args []any)

Source from the content-addressed store, hash-verified

895 if r.done && r.err == nil {
896 r.captureProfiling()
897 }
898 if r.waitForClosed != nil && (!r.done || r.err != nil) {
899 r.closeErr = r.waitForClosed()
900 }
901 })
902 return r.closeErr
903}
904
905func (r *FlightRowSet) Err() error {
906 return r.err
907}
908
909// emptyRowSet is returned when a query produces no endpoints and no schema.
910type emptyRowSet struct{}
911
912func (e *emptyRowSet) Columns() ([]string, error) { return nil, nil }
913func (e *emptyRowSet) ColumnTypes() ([]sqlcore.ColumnTyper, error) { return nil, nil }
914func (e *emptyRowSet) Next() bool { return false }
915func (e *emptyRowSet) Scan(dest ...any) error { return fmt.Errorf("no rows") }
916func (e *emptyRowSet) Close() error { return nil }
917func (e *emptyRowSet) Err() error { return nil }
918
919// emptySchemaRowSet is returned when a query produces no data rows but does
920// have schema information (e.g., SELECT ... LIMIT 0). This preserves column
921// names and types for callers like COPY FROM STDIN that need to inspect the
922// target table schema.
923type emptySchemaRowSet struct {
924 schema *arrow.Schema
925}
926
927func (e *emptySchemaRowSet) Columns() ([]string, error) {
928 cols := make([]string, e.schema.NumFields())
929 for i := 0; i < e.schema.NumFields(); i++ {
930 cols[i] = e.schema.Field(i).Name
931 }
932 return cols, nil
933}
934
935func (e *emptySchemaRowSet) ColumnTypes() ([]sqlcore.ColumnTyper, error) {
936 types := make([]sqlcore.ColumnTyper, e.schema.NumFields())
937 for i := 0; i < e.schema.NumFields(); i++ {
938 types[i] = newArrowColumnType(e.schema.Field(i))
939 }
940 return types, nil
941}
942
943func (e *emptySchemaRowSet) Next() bool { return false }
944func (e *emptySchemaRowSet) Scan(...any) error { return fmt.Errorf("no rows") }
945func (e *emptySchemaRowSet) Close() error { return nil }
946func (e *emptySchemaRowSet) Err() error { return nil }
947
948// flightExecResult implements ExecResult for Flight SQL updates.
949type flightExecResult struct {
950 rowsAffected int64
951}

Callers 4

QueryContextMethod · 0.85
ExecContextMethod · 0.85
TestInterpolateArgsFunction · 0.85

Calls 5

scanQuotedFunction · 0.85
indexOrEndFunction · 0.85
blockCommentEndFunction · 0.85
formatArgValueFunction · 0.85
StringMethod · 0.45

Tested by 2

TestInterpolateArgsFunction · 0.68