Bug #99486 Too many work doing in class construct function in Buf_fetch_normal
| Submitted: | 8 May 2020 10:19 | Modified: | 9 May 2020 7:58 |
|---|---|---|---|
| Reporter: | Zongzhi Chen (OCA) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
| Version: | 8.0.20 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[8 May 2020 13:27]
MySQL Verification Team
Hi Mr. zongzhi, Thank you for your bug report. I fully understand what you are writing about and I have stuck to that paradigm in my own C++ code. However, this is not the only place in our code where constructor sets the object to NULL. What you asking for would necessitate a very large redesign of very large part of our code, with the sole objective of maintaining the object purity. That would be a huge undertaking without adding any feature, or fixing a bug or improving performance. However, I will inform our Development of your code purity request.
[9 May 2020 2:52]
Sunny Bains
I think the bug reporter is confused. There is no get() call from within the constructor.
[9 May 2020 7:58]
Zongzhi Chen
Yes, Sunny. That is my mistake.. You are right.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: In the new code, InnoDB refactor the long function buf_page_get_gen() However, I find in the constructor function of Buf_fetch_normal, it call dberr_t Buf_fetch_normal::get(buf_block_t *&block); we know that in cpp code coding paradigm, it better only doing some light work in constructor function, such as assign variables default value. Because the constructor don't return the result, and if the constructor fail, the object it construct is NULL. so It's better to put the large function outside the constructor function, add a function call Init(). ``` struct Buf_fetch_normal : public Buf_fetch<Buf_fetch_normal> { Buf_fetch_normal(const page_id_t &page_id, const page_size_t &page_size) : Buf_fetch(page_id, page_size) {} dberr_t get(buf_block_t *&block); }; ``` How to repeat: read the code