-
Notifications
You must be signed in to change notification settings - Fork 88
[Feature Request] Make helio_api.drop_indexes
less weird
#49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@AlekSi Thanks Alexey for bring this to our attention. Just to understand your requirement, can you tell us a bit more about how are you using or the intended use of the drop_index API? As you know FUNCTIONs can't start/commit/roll back transactions from within, and we need that capability in drop index, which involves marking the index being deleted and committing that information before proceeding with the delete. So we chose PROCEDURE organically. We are looking into the output type/formatting issue. |
I did not actually know that. 😬 But why the last parameter is INOUT instead of just OUT, then? After trying all possible ways, I still can't get the output as binary BSON instead of BSONHEX. PostgreSQL just does not provide a syntax for using type conversions in procedure calls, I think? |
OUT params for procedures must still be added in the CALL (just put in as NULL). INOUT can have default values which means it makes the CALL less weird as you don't need to specify the out params in the CALL. |
That's how we call this procedure (see FerretDB/FerretDB#5114): // DropIndexes is a wrapper for
//
// documentdb_api.drop_indexes(p_database_name text, p_arg documentdb_core.bson, INOUT retval documentdb_core.bson DEFAULT NULL).
func DropIndexes(ctx context.Context, conn *pgx.Conn, l *slog.Logger, databaseName string, arg wirebson.RawDocument) (outRetVal wirebson.RawDocument, err error) {
row := conn.QueryRow(ctx, "CALL documentdb_api.drop_indexes($1, $2::bytea)", databaseName, arg)
var res []byte
if err = row.Scan(&res); err != nil {
err = mongoerrors.Make(ctx, err, "documentdb_api.drop_indexes", l)
}
spew.Dump(res)
outRetVal = res
return
} Note how the second argument uses
Similarly, the output is returned as text BSON (BSONHEX):
With functions, we use something like My understanding is that all this happens because BSON's desired format is text. Can it be made binary with some feature toggle, for example? |
Purpose of the feature.
helio_api.drop_indexes
is the only procedure with the INOUT parameter. All other functions are… functions. That creates problems for us: FerretDB/FerretDB#4730. This parameter seems to return BSON in the BSONHEX text representation?.. Or something. In any case, having a single function (that is not a function) that stands out that much is bad for API consistency.It would be nice to have it as a regular function we could use.
Describe the solution you'd like
There is a "normal" function to drop an index.
Describe alternatives you've considered
Add more hacks to support this procedure.
Additional context
N/A.
The text was updated successfully, but these errors were encountered: