[Maria-developers] Using C++ features in MariaDB
I just read in Pachev's "MySQL Internals" book that C++ STL and exceptions aren't allowed in the MySQL code. Are those restrictions also in effect for MariaDB? If so, can anyone explain the reason for them? Thanks, Christian
Hi, Christian! On Feb 17, Christian Convey wrote:
I just read in Pachev's "MySQL Internals" book that C++ STL and exceptions aren't allowed in the MySQL code.
Are those restrictions also in effect for MariaDB? If so, can anyone explain the reason for them?
The reason is historical. When Sasha was in MySQL, STL and exceptions just were too buggy for us to use - in a heavily multi-threaded code of MySQL. It's no longer true. We use exceptions - although not in the server code, but OQGraph engine uses them. And STL - MySQL server uses STL now and in 10.0 we're merging this code, so we're getting it now too. Regards, Sergei
Thanks Sergei. So why is it used in some places, but not in the server code? On Mon, Feb 18, 2013 at 3:00 AM, Sergei Golubchik <serg@askmonty.org> wrote:
Hi, Christian!
On Feb 17, Christian Convey wrote:
I just read in Pachev's "MySQL Internals" book that C++ STL and exceptions aren't allowed in the MySQL code.
Are those restrictions also in effect for MariaDB? If so, can anyone explain the reason for them?
The reason is historical. When Sasha was in MySQL, STL and exceptions just were too buggy for us to use - in a heavily multi-threaded code of MySQL.
It's no longer true. We use exceptions - although not in the server code, but OQGraph engine uses them. And STL - MySQL server uses STL now and in 10.0 we're merging this code, so we're getting it now too.
Regards, Sergei
Hi, Christian! On Feb 18, Christian Convey wrote:
Thanks Sergei. So why is it used in some places, but not in the server code?
STL is pretty much ok starting from 10.0. Exceptions - they aren't used in the server yet, we'd need to make a decision that they're ok to use. And we haven't discussed that. Regards, Sergei
On Mon, Feb 18, 2013 at 3:00 AM, Sergei Golubchik <serg@askmonty.org> wrote:
On Feb 17, Christian Convey wrote:
I just read in Pachev's "MySQL Internals" book that C++ STL and exceptions aren't allowed in the MySQL code.
Are those restrictions also in effect for MariaDB? If so, can anyone explain the reason for them?
The reason is historical. When Sasha was in MySQL, STL and exceptions just were too buggy for us to use - in a heavily multi-threaded code of MySQL.
It's no longer true. We use exceptions - although not in the server code, but OQGraph engine uses them. And STL - MySQL server uses STL now and in 10.0 we're merging this code, so we're getting it now too.
While we're on the topic, how does MariaDB decide which language features are mature enough to use in the software? For example, do you look at a list of supported operating systems, and for those operating systems, look at whether or not the supplied version of g++ supports a given language feature well enough? On Mon, Feb 18, 2013 at 12:47 PM, Sergei Golubchik <serg@askmonty.org> wrote:
Hi, Christian!
On Feb 18, Christian Convey wrote:
Thanks Sergei. So why is it used in some places, but not in the server code?
STL is pretty much ok starting from 10.0.
Exceptions - they aren't used in the server yet, we'd need to make a decision that they're ok to use. And we haven't discussed that.
Regards, Sergei
On Mon, Feb 18, 2013 at 3:00 AM, Sergei Golubchik <serg@askmonty.org> wrote:
On Feb 17, Christian Convey wrote:
I just read in Pachev's "MySQL Internals" book that C++ STL and exceptions aren't allowed in the MySQL code.
Are those restrictions also in effect for MariaDB? If so, can anyone explain the reason for them?
The reason is historical. When Sasha was in MySQL, STL and exceptions just were too buggy for us to use - in a heavily multi-threaded code of MySQL.
It's no longer true. We use exceptions - although not in the server code, but OQGraph engine uses them. And STL - MySQL server uses STL now and in 10.0 we're merging this code, so we're getting it now too.
Hi, Christian! On Feb 18, Christian Convey wrote:
While we're on the topic, how does MariaDB decide which language features are mature enough to use in the software?
For example, do you look at a list of supported operating systems, and for those operating systems, look at whether or not the supplied version of g++ supports a given language feature well enough?
No, the answer is much simpler than that - we don't. That is, this question doesn't get asked very often. In MySQL times we've decided on STL. That was once. After I was in MySQL for more than ten years. In MariaDB we've never got around to this at all. Yet. But if we will - yes, this feature needs to be supported by all gcc (g++) versions that are installed on all Linux distributions (and FreeBSD, etc) that we provide binaries for. And by Intel compilers. And by Visual Studio versions that we use. And also we consider the drawbacks of using the feature, for example it might be very expensive at runtime, or makes the executable binary much larger, or may be it's very difficult to use correctly (but easy to misuse), whatever. Anyway, there's nothing magical here, just a common sense. Regards, Sergei
Hi Sergei, The reason I'm asking is that, while I'm generally cautious about new C++ features, there are some features in C++11 which I'm pretty happy about. For example, class enumerations and nullptr ( http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.ht... ). I'm trying to anticipate whether or not a patch would be rejected if it contained those constructs. - Christian On Mon, Feb 18, 2013 at 4:08 PM, Sergei Golubchik <serg@askmonty.org> wrote:
Hi, Christian!
On Feb 18, Christian Convey wrote:
While we're on the topic, how does MariaDB decide which language features are mature enough to use in the software?
For example, do you look at a list of supported operating systems, and for those operating systems, look at whether or not the supplied version of g++ supports a given language feature well enough?
No, the answer is much simpler than that - we don't.
That is, this question doesn't get asked very often. In MySQL times we've decided on STL. That was once. After I was in MySQL for more than ten years.
In MariaDB we've never got around to this at all. Yet.
But if we will - yes, this feature needs to be supported by all gcc (g++) versions that are installed on all Linux distributions (and FreeBSD, etc) that we provide binaries for. And by Intel compilers. And by Visual Studio versions that we use. And also we consider the drawbacks of using the feature, for example it might be very expensive at runtime, or makes the executable binary much larger, or may be it's very difficult to use correctly (but easy to misuse), whatever. Anyway, there's nothing magical here, just a common sense.
Regards, Sergei
Hi, Christian! On Feb 18, Christian Convey wrote:
The reason I'm asking is that, while I'm generally cautious about new C++ features, there are some features in C++11 which I'm pretty happy about. For example, class enumerations and nullptr ( http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.ht... ).
I'm trying to anticipate whether or not a patch would be rejected if it contained those constructs.
That would need testing. At least they introduce no run-time penalty, it's purely a syntactic sugar. But I'm afraid we won't have time to test that now. At the moment we don't compile with -std=c++0x at all, so nullptr keyword is not recognized. You know what, feel free to use these features if you'd like. It's easy to search/replace and remove them it needed later. But anyway, NULL is quite ok in gcc - the compiler will issue a warning if NULL is used as an integer (in that example with overloaded function). Regards, Sergei
Thanks Sergei, I'll keep that in mind. On Tue, Feb 19, 2013 at 12:49 AM, Sergei Golubchik <serg@askmonty.org> wrote:
Hi, Christian!
On Feb 18, Christian Convey wrote:
The reason I'm asking is that, while I'm generally cautious about new C++ features, there are some features in C++11 which I'm pretty happy about. For example, class enumerations and nullptr ( http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.ht... ).
I'm trying to anticipate whether or not a patch would be rejected if it contained those constructs.
That would need testing. At least they introduce no run-time penalty, it's purely a syntactic sugar. But I'm afraid we won't have time to test that now. At the moment we don't compile with -std=c++0x at all, so nullptr keyword is not recognized.
You know what, feel free to use these features if you'd like. It's easy to search/replace and remove them it needed later.
But anyway, NULL is quite ok in gcc - the compiler will issue a warning if NULL is used as an integer (in that example with overloaded function).
Regards, Sergei
participants (2)
-
Christian Convey
-
Sergei Golubchik