Summary:
Re-evaluate all YB changes against upstream PG and reduce differences or
discrepancies. In addition, add "YB" comments where useful, and collect
YB items to the bottom or top away from PG items where possible (no
guarantee I fixed all of them, and some of them I left alone because
changing them are questionable).
I list the major changes in order of significance. "YB PG 15.2 initial
merge" refers to 55782d561e55ef972f2470a4ae887dd791bb4a97.
- jsonapi.c: YB cc698525a8ff23c46fde7c64247aac2224d8204a incorrectly
misses that YB commit 20e75df2d3f0bad4f2140f3014868395fa2cf67b imports
upstream PG commits 3838fa269c15706df2b85ce2d6af8aacd5611655 and
d3117fc1a3e87717a57be0153408e5387e265e1b. Do a proper re-merge by
applying those changes to the right location.
- extension.c: upstream PG 919ebb023e74546c6293352556365091c5402366 was
point-imported by YB d18aaa5115a3948cdc13ea7f9723da61d6a6b6a0.
919ebb023e74546c6293352556365091c5402366 is the PG 11 backpatch
version; de494ec14f6bd7f2676623a5934723a6c8ba51c2 is the PG 15
backpatch version. The difference is that the PG 15 backpatch version
has extra code. Add this code.
- StoreQueryTuple: YB a2bfda31b157b5acfe9ffefc4b8b079277bf5dd7 imports
upstream PG commit but comments out pg_log_warning code since that
macro didn't exist back then. Now, it exists, so uncomment the code.
- get_tablespace_page_costs: YB 080e745d0264801143685854229c99491ebd4f15
intends to revert code from bebd181fd39c2c8e01f24b10c717c614542fd0d9,
but it also reverts an upstream PG Assert. Bring that back.
- itemptr.c: replace StaticAssertStmt with StaticAssertDecl to better
align with upstream PG.
- cost_index: YB 7d3f6895c8f8d0deb094e9a102d56a09d9fe0af1 initializes
indexCorrelation to 0. Not clear why. My guess is that it is to
avoid garbage for lsm indexes since lsm indexes use ybcincostestimate,
which doesn't set indexCorrelation. The proper fix is to fill
indexCorrelation in ybcincostestimate. Also find indexPages should be
filled as well, and hypopg indexes should also fill fields. Fill all
to zero.
- help.c: simplify helpSQL's YB changes by using #ifdef YB_DISABLED.
This changes behavior slightly by building url now, but that is a
minor cost in favor of making comparison with upstream PG esier.
- trigger.c: YB 489b47a5b9065e160119136965f4f12216c4c709 reverts
upstream PG a9c35cf85ca1ff72f16f0f10d7ddee6e582b62b8 supposedly to fix
integration with PostGIS. YB PG 15.2 initial merge and orafce version
upgrade mostly overrides this effort by bringing those changes back,
but it doesn't do it properly for ExecCallTriggerFunc in trigger.c.
Do it now.
- plpy_exec.c: (same as above for PLy_function_build_args)
- fe-protocol3.c: YB bdb3fd06a22d1fc5c410c5336db072e153ec4284 imports PG
89a5499ef9e477beb97d742d4df6fc8f601d87d5. The PG 15 version of that
is 42f94f56bf9559f0a3cf5f3ffde50655834694ee, which instead of using
macro define does function define. YB PG 15.2 initial merge brings in
the function define but does not delete the macro define. Delete the
macro define now.
- cash_numeric: YB PG 15.2 initial merge fails to properly merge YB
master 2f6872fa2294340156c1c176dd77029ec7c01b7f importing upstream PG
b9d2c5c7ac800bf20ea6cd4c556b6b3305863a8e and later upstream PG
0aa8f764088ea0f36620ae2955fa6c54ec736c46. Take later upstream PG
0aa8f764088ea0f36620ae2955fa6c54ec736c46.
- libpq.h: YB PG 15.2 initial merge incorrectly duplicates
pq_buffer_has_data (out of confusion with YB
61a6b48f45c4ce96391a0e96ffd24e17d40bbea2) and fails to remove
pq_putbytes (which was deleted by upstream PG
3174d69fb96a66173224e60ec7053b988d5ed4d9). Fix.
- miscadmin.h: YB d10c20c94c70035d3928aa89a1fd3ece6c881326 and
73ae4051d7ec41383aa7b4ae7621b87628aeef9d duplicate lots of variable
declarations. Dedup and move YB items to bottom.
- slot.h: YB 2a000837150c37006507f1a6fe46c70508bf039f adds duplicate
PG_OUTPUT_PLUGIN declaration. Remove the dup.
- progress.h: YB ced7c32846e4adbe2a93ca20fc64fd648bec8851 imports some
code from upstream PG 13. YB PG 15.2 initial merge does not merge
this properly, duplicating the code. Deduplicate and remove the todo
comment.
- 002_pg_dump.pl: YB PG 15.2 initial merge duplicates code due to YB
89f5d1aaad9d23c5d2f505565c9359df5f258101 doing an import that brings
in that same code. Remove the duplicate.
- pg_stat_get_progress_info: YB PG 15.2 initial merge misses removing
duplicate "CREATE INDEX" case. Remove it now.
- ProcessStartupPacket: some errmsg code starting with comment "At this
point we should have no data already buffered." are duplicated. This
appears to be the fault of YB master commit
61a6b48f45c4ce96391a0e96ffd24e17d40bbea2 importing this code to the
wrong area, and YB PG 15.2 initial merge 55782d561e5 not properly
fixing it and instead doing more odd duplication.
- execute_extension_script: remove duplicate code added by YB PG 15.2
initial merge.
- sinvaladt.h: YB 70fbb382e1a913c651a6dbc85a75bcf2e25d32a8 adds SISeg
and shmInvalBuffer to sinvaladt.h for no reason. Remove it from the
header.
- load_relcache_init_file: YB ca30a3ab5252858103cf6f3f92697821e9b718df
introduces local vars num_critical_shared_indexes and
num_critical_local_indexes. After
ed4fd9ec8d4e3a445c8852288f6b70cf27412359, there is no need for them.
Remove them.
- ExecCheckPlanOutput: Upstream 86dc90056dfdbd9d1b891718d2e5614e3e432f35
replaces if with Assert. YB PG 15.2 initial merge adds assert but
doesn't remove if. Remove if.
- pg_indexam_progress_phasename: YB PG 15.2 initial merge incorrectly
changed PG_RETURN_DATUM to PG_RETURN_TEXT_P. It reverted YB
8b6ab8c942f403d3b80339e5353a30d78668fb9c's effort of importing
upstream PG 6bcda4a72123c3aa29fa3f03d952095675ad4468. Change it back.
- ResourceOwnerReleaseInternal: looks like YB PG 15.2 initial merge
typo'd DatumGetPointer to PointerGetDatum. Fix.
- RelationBuildTupleDesc: change "RelationGetDescr(relation)" to
"relation->rd_att" to match upstream PG better. They are defined to
the same thing.
- tsquery_phrase: fix PG_RETURN_POINTER to PG_RETURN_DATUM.
- text_to_array: fix PG_RETURN_ARRAYTYPE_P to PG_RETURN_DATUM.
- xpath: fix PG_RETURN_ARRAYTYPE_P to PG_RETURN_DATUM.
- regexp_split_to_array: fix PG_RETURN_ARRAYTYPE_P to PG_RETURN_DATUM.
- multirange_intersect_agg_transfn: YB PG 15.2 initial merge appears to
have changed PG_RETURN_MULTIRANGE_P to PG_RETURN_RANGE_P for no
reason. Both are defined to the same thing. Fix.
- pg_lsn.c: YB PG 15.2 merge incorrectly wraps "num" var with
NumericGetDatum. "num" is already a datum. Fix.
- pg_stats_ext_mcvlist_items: remove PointerGetDatum wrapper around
makeArrayResult since makeArrayResult returns Datum anyway.
- brin_bloom_summary_out: change PG_DETOAST_DATUM to
PG_DETOAST_DATUM_PACKED. This code is not exercised by YB (except,
perhaps, temp tables).
- brin_range_deserialize: remove DatumGetPointer and DatumGetCString
wrappers on ptr.
- brin_minmax_multi_summary_out: change PG_DETOAST_DATUM to
PG_DETOAST_DATUM_PACKED, and remove PointerGetDatum wrapper on
makeArrayResult which returns Datum anyway.
- describeOneTableDetails: YB PG 15.2 initial merge incorrectly adds YB
code in wrong location. Fix location.
- array.h: Not sure how it became like this, but the order of MAXDIM and
MaxArraySize definitions is swapped. Fix the order.
- typedefs.list: YB 715eb578ed84cfbb7c927055563daca8e3216e21 incorrectly
adds RelStatsInfo to typedefs.list. Such a type is not used anywhere.
Remove it.
- Solution.pm: For some odd reason, this file is missing a brace. It's
got to be unexercised code, but good to fix anyway.
- miscadmin.h: InitPostgres definition has param named yb_session_id,
but declaration in header has session_id. Fix to yb_session_id.
- tuptable.h: After YB b263910ba90dd273d10a8ecffa90b8affcdea529, comment
in tuptable.h is outdated. Remove that text.
- execnodes.h: SplitOptions comment was added in YB
0909995634e4367774f119ac9d19d488a8a935e5. It doesn't make sense since
such a field was not added to IndexInfo. Remove now.
- sampling.h: YB 055f04e40877c7cdcd274281b1af9e3906ba0917 removes
comment incorrectly. Bring it back.
- itemptr.h: Remove outdated comment by YB
b263910ba90dd273d10a8ecffa90b8affcdea529.
- RelationBuildTriggers: revert todo comment change on PG comment. Got
permission from Kai.
- ATExecDropColumn: YB PG 15.2 initial merge forgets to update this
comment updated by upstream PG
578b229718e8f15fa779e20f086c4b6bb3776106.
- ResetSequence: upstream PG d25f519107bff602e1ebc81853fe592d020c118d
changes comment, but YB PG 15.2 initial merge fails to take that into
account. Do it now.
- ExplainNode: remove outdated comment.
- .gitattributes: replace with upstream PG's version.
- .gitignore: replace with upstream PG's version.
- Replace all original upstream PG regress test files with upstream PG's
version. Don't touch the ported copies of these tests, if any.
- Change some "NEIL", "YB_DEEPTHI", etc. to "YB_TODO". "YB_TODO" is
used to track todo items related to upstream PG merge.
- For most Makefiles, place YB objects at top of OBJS list. Some
Makefiles are not structured with one object per line, so don't make
that transformation for those.
- func.sgml: delete yb_servers description. It doesn't seem to be used
anywhere, and it's not consistent to only add that function's
description but omit other YB function's description. Note that other
doc changes for grammar related things are needed because they are
used in `\h` output.
- Several places replace upstream PG's switch fallthrough comment with
yb_switch_fallthrough();. Bring back the comment.
- There are a lot of newline-related differences. Fix all of them.
- (Leave pgbench.c untouched as that will be covered by Fizaa.)
This effort reduces the number of hunks YB introduces against PG from
4643 to 4436. That's nearly a 5% reduction of potential areas for merge
conflicts.
Jira: DB-16295
Test Plan:
jenkins
Close: #26881
Reviewers: smishra
Reviewed By: smishra
Subscribers: smishra, yql
Differential Revision: https://phorge.dev.yugabyte.com/D43347