-
Notifications
You must be signed in to change notification settings - Fork 28
Compiling with vibe.d 0.8.3 gives deprecation warning #175
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
Ping me on this once CI is fixed, we need to get these fixed. All my REST routes also need to be safe, and mysql-native in general doesn't make this easy. |
Ok.
Previously, mysqln wasn't worrying too much about pure, safe and such for much the same reason - because vibe and phobos didnt make it very easy. Hopefully that's improved now.
|
Well, considering that vibe.d now requires |
And for the record, I DON'T think a good solution is band-aiding |
So I started working on this. And I get way way deep down into the nitty gritty of mysql-native. Almost everything is easy to mark with First, there's a few places where The second is a lot harder. We could also use TaggedAlgebraic (probably TaggedUnion, as we don't need to be able to forward function calls). This would probably be an improvement anyway, as TaggedUnion provides a cleaner set of mechanisms for basically storing data. Or we could make our own MysqlVariant type or something that only handles the types we care about. Might be slightly more performant than a Variant or TaggedUnion. What do you think? I don't want to go any further without some guidance here. |
Hmm, I seem to be a little out-of-date here, I’ve used TaggedAlgebraic in the past, but it seems there have been changes/enhancements since then, and TaggedUnion is new to me. I just took a quick look at the docs but I’m still a little unclear: What exactly is the difference between TaggedAlgebraic and TaggedUnion. In any case, if using Phobos Variant is fundamentally incompatible with proper @safety in mysqln, and TaggedAlgebraic/TaggedUnion would work, then that sounds reasonable to me. Besides, I agree Variant’s API just isn’t as nice or as modern and it’s maybe more heavyweight than needed. My only concerns:
As for a “MysqlVariant” type, I would tend to shy away from inventing our own algebraic/tagged union type unless there was a very clear, specific reason why existing options weren’t sufficient and we knew we could do better. And even then, I’d still prefer to have it as an external general-purpose lib rather than having it built-into mysql-native. |
I've honestly not used either, but I think the difference that I can see is that TaggedUnion does not forward function calls, and has some different APIs. It appears to me that TaggedUnion is more suited for just storing and retrieving a union item. Whereas TaggedAlgebraic tries to provide a seamless API for all functionality of the union members. In my brief test for this (to see if it forwards
It might be easy to get a SafeVariant into Phobos, I'm actually surprised it's not there. I think it literally needs a copy-paste of VariantN but with
Yes, TaggedUnion would be much more conducive to other attributes, as it's a fully templated call instead of a generated delegate.
It would be pretty simple, except for cases where mysql-native's functions are returning Variant. These would be harder to manage, because you can't call an overloaded function based on the expected return value. For sure, the API calls you would make on the return types are much different. I'll have to look through the code and see how many of these there are. Perhaps it's not that bad.
I'm not sure about this one. I'm sure I can come up with something that works. You definitely can have a TaggedUnion where one of the items is
I agree, but I wanted to throw it out as a possible option. One possible benefit is that we could define specialized functions on such a thing. |
OK, so here are the places we would have to worry about this:
struct Row
{
...
SafeRow safe() { return actualRow; }
} Then you would use it like: auto id = row.safe[id].value!int; Not sure if we can deprecate the API completely, and replace it with the safe stuff, which sucks.
|
Ok, so it looks like there aren't too terribly many places. So, what if we do it like this:
|
OK, I'll start on an implementation using this idea. We'll see how it goes. |
Got stuck on an issue, but so far, I think replacing Variant will be a net benefit. Issue is here: s-ludwig/taggedalgebraic#36 |
@Abscissa getting back onto this, have a bit of time during Thanksgiving since I'm sick and home alone at the moment. I had a question on this code here: https://github.com/mysql-d/mysql-native/blob/master/source/mysql/protocol/comms.d#L127 I'm basically going to recreate this switch for converting existing Variant to new MySQL tagged algebraic type. But I don't have any support for Some guidance on this would be good, I don't love the idea of supporting shared in MySQL in any case, as the multi-threading implications are murky. Given how Walter is going to remove all usage of shared data without a cast in a very community-supported DIP, it might not make any sense to support shared at all. My plan at the moment is to simply cast away the shared, as the pointer itself is not really shared (inside the Variant, it's locked away, and we are about to make a copy of it anyway). In any case, a history of how that got there would be useful. |
OK, doing some testing I've determined that what that switch does doesn't actually work. At all: immutable int x = 5;
Variant v = &x;
const(int)*p = v.get!(const(int*)); // error, incompatible types So, I'm not as worried ;) |
FYI still working on this, haven't tested, but I have something that builds. See https://github.com/schveiguy/mysql-native/tree/safeupdate. I need to get rid of all the deprecations (internal non-safe calls), and then work on the tests. |
Cool.
IIRC, I don't think the "shared immutable" stuff was one of the changes I made. It's possible it might even predate my involvement in the project. So I'm not really sure what the story is there, I'd have to find the commit/pr that introduced it. (I do know it wasn't an especially recent addition, its been in there awhile.) My suspicion is it was probably added together with the "const" and "immutable" cases just as an attempt to be more permissive in what types could be passed in.
|
/facepalm So much for my memory! It WAS me who added that shared immutable stuff, and less than two years ago, even:
#13
With that in mind, I do know I didn't have a specific situation in mind, it was just an attempt to be more permissive. So no worries about nixing that.
|
More updates: I've decided on a different "radical" approach than what we discussed. I can always move back if necessary. I found that I can mimic pretty much all of This is a lot better than what I originally hoped. What tipped the scales for me was that |
We'd also want to be sure to minimize disruptions to user code that SENDS a Variant to mysqln, not just user code that RECIEVES a Variant. So maybe also a fromVariant or asMySqlVal and/or overloads that still accept a Variant FROM the user, to go along with your asVariant.
Also, at this point, if we're offering functionality that converts to/from Variant, do we really even need to use deprecations to make users change their own code to use MySqlVal directly? Maybe we could just leave asVariant/asMySqlVal un-deprecated, and if a user would rather base their own code around Variant and deal with occasional conversions when accessing mysqln and doesnt care about their own code being @safe, then so be it.
Other than that, it all sounds good to me.
|
The calls that accept |
And I do have a Variant -> MySQLVal conversion there, but I don't want to necessarily expose it as public. It's used internally for all the places where Variant is accepted. |
OK, I have updated my branch it's now building tests (haven't run them properly yet). I am waiting on a PR pull for taggedalgebraic, which I very much need to get this to work properly: s-ludwig/taggedalgebraic#40 Going to bed... If I get a chance this weekend, I might do final testing and make a PR. But we still need the taggedalgebraic fix. |
So I have got the tests to build and pass. Still waiting on the TA bug fix. But I realize something that may be a problem with the idea of making auto row = mysql.queryRow(sql);
Variant v = row[0];
if(v != 1) launchMissles(); This compiles with the new system! What happens is I may have to go back to the original plan of making everything |
See my PR at #214 |
I can close this now. Please let me know if you find any issues with the latest rev (v3.2.0) |
mysql\pool.d line: 115 column: 13
The call to ConnectionPool's constructor must use a
@safe
callback.Perhaps createConnection() can just be made
@trusted
?The text was updated successfully, but these errors were encountered: