Hi, When I think about how to add a test case for v5 version patch, and I want to test if v5 version patch has memory leak. This thread [1] provided a way how to repeat the memory leak, so I used it to test v5 patch. I didn't found memory leak on v5 patch.
But I found other interesting issue. When changed whereClause in [1], the query reported below error: "ERROR could not find memoization table entry" the query: EXPLAIN analyze select sum(q.id_table1) from ( SELECT t2.* FROM table1 t1 JOIN table2 t2 ON (t2.id_table1 + t2.id_table1) = t1.id) q; But on v5 patch, it didn't report error. I guess it is the same reason that data in probeslot was reset in Hash function. I debug the above query, and get this: before (gdb) p *(DatumGetNumeric(mstate->probeslot->tts_values[0])) $1 = {vl_len_ = 48, choice = {n_header = 32770, n_long = {n_sign_dscale = 32770, n_weight = 60, n_data = 0x564632ebd708}, n_short = {n_header = 32770, n_data = 0x564632ebd706}}} after (gdb) p *(DatumGetNumeric(mstate->probeslot->tts_values[0])) $2 = {vl_len_ = 264, choice = {n_header = 32639, n_long = {n_sign_dscale = 32639, n_weight = 32639, n_data = 0x564632ebd6a8}, n_short = {n_header = 32639, n_data = 0x564632ebd6a6}}} So after call ResetExprContext() in Hash function, the data in probeslot is corrupted. It is not sure what error will happen when executing on corrupted data. During debug, I learned that numeric_add doesn't have type check like rangetype, so aboved query will not report "type with xxx does not exist". And I realize that the test case added by Andrei Lepikhov in v3 is right. So in v6 patch I add Andrei Lepikhov's test case. Thanks a lot. Now I think the v6 version patch seems to be complete now. [1] https://www.postgresql.org/message-id/83281eed63c74e4f940317186372abfd%40cft.ru -- Tender Wang OpenPie: https://en.openpie.com/
v6-0001-Fix-wrong-used-ResetExprContext-in-ExecMemoize.patch
Description: Binary data