Skip to content

binary statement protocols #9

@oovm

Description

@oovm

I don't quite understand this part:

wasi-sql/wit/types.wit

Lines 25 to 29 in d14174a

/// allows parameterized queries
/// e.g., prepare("SELECT * FROM users WHERE name = ? AND age = ?", vec!["John Doe", "32"])
resource statement {
prepare: static func(query: string, params: list<string>) -> result<statement, error>;
}

As far as I know, many sql prepare protocols support binary, so it should not be converted to string here, as there will be too many extra allocations.

And the binary solution can also solve the problem of custom data types in pgsql.


I think prepare should be a (prepare-)statement constructor that accepts a sql string with slots.

At constructor time, a binary ArgumentBuffer will be constructed inside the statement.

Then a write method is provided to write the binary encoding of the parameter.

Maybe also provide an is-finish to determine if all slots have been filled. Because it is possible to have dynamic construction based on if else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions