pgsql: Remove unnecessary smgrimmedsync() when creating unlogged table.

2023-09-15 Thread Heikki Linnakangas
Remove unnecessary smgrimmedsync() when creating unlogged table. This became safe after commit 4b4798e138. The smgrcreate() call will now register the segment for syncing at the next checkpoint, so we don't need to sync it here. If a checkpoint happens before the creation is WAL-logged, the record

pgsql: Rename variable for code clarity

2023-09-15 Thread Daniel Gustafsson
Rename variable for code clarity When tracking IO timing for WAL, the duration is what we calculate based on the start and end timestamps, it's not what the variable contains. Rename the timestamp variable to end to better communicate what it contains. Original patch by Krishnakumar with addition

pgsql: Fix get_expr_result_type() to find field names for RECORD Consts

2023-09-15 Thread Tom Lane
Fix get_expr_result_type() to find field names for RECORD Consts. This is a back-patch of commit d57534740 ("Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value") into pre-v14 branches. At the time I'd thought it was not needed in branches that lack the SEARCH/CYCLE feature, but that

pgsql: Fix get_expr_result_type() to find field names for RECORD Consts

2023-09-15 Thread Tom Lane
Fix get_expr_result_type() to find field names for RECORD Consts. This is a back-patch of commit d57534740 ("Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value") into pre-v14 branches. At the time I'd thought it was not needed in branches that lack the SEARCH/CYCLE feature, but that

pgsql: Allow extracting fields from a ROW() expression in more cases.

2023-09-15 Thread Tom Lane
Allow extracting fields from a ROW() expression in more cases. Teach get_expr_result_type() to manufacture a tuple descriptor directly from a RowExpr node. If the RowExpr has type RECORD, this is the only way to get a tupdesc for its result, since even if the rowtype has been blessed, we don't ha

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Fix get_expr_result_type() to find field names for RECORD Consts

2023-09-15 Thread Tom Lane
Fix get_expr_result_type() to find field names for RECORD Consts. This is a back-patch of commit d57534740 ("Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value") into pre-v14 branches. At the time I'd thought it was not needed in branches that lack the SEARCH/CYCLE feature, but that

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()

pgsql: Allow extracting fields from a ROW() expression in more cases.

2023-09-15 Thread Tom Lane
Allow extracting fields from a ROW() expression in more cases. Teach get_expr_result_type() to manufacture a tuple descriptor directly from a RowExpr node. If the RowExpr has type RECORD, this is the only way to get a tupdesc for its result, since even if the rowtype has been blessed, we don't ha

pgsql: Track nesting depth correctly when drilling down into RECORD Var

2023-09-15 Thread Tom Lane
Track nesting depth correctly when drilling down into RECORD Vars. expandRecordVariable() failed to adjust the parse nesting structure correctly when recursing to inspect an outer-level Var. This could result in assertion failures or core dumps in corner cases. Likewise, get_name_for_var_field()