Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions parser/typerecover.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"Timestamp": "Timestamp",
"TimestampTz": "TimestampTz",
"H3Index": "uint64_t",
"Quadbin": "uint64_t",
"text": "text",
"GSERIALIZED": "GSERIALIZED",
"Interval": "Interval",
Expand Down Expand Up @@ -75,7 +76,8 @@ def _recovery(fragment):
suffix = (" " + stars) if stars else ""
collapsed = f"{const}int{suffix}"
recovered = f"{const}{_TYPE_MAP[m.group('base')]}{suffix}"
return collapsed, recovered
original = f"{const}{m.group('base')}{suffix}"
return collapsed, recovered, original


def _parse_header_decls(headers_dir):
Expand Down Expand Up @@ -123,12 +125,17 @@ def _apply(slot, recovery):
"""Rewrite a return/param slot in place; return 1 if rewritten."""
if not (recovery and isinstance(slot, dict)):
return 0
collapsed, recovered = recovery
collapsed, recovered, original = recovery
key = "c" if "c" in slot else "cType"
if _nospace(slot.get(key)) != _nospace(collapsed):
# The base name is either erased to int by the host-collision prefix
# rename (slot spells `collapsed`), or it survives while only the
# canonical collapses (slot spells `original`, e.g. a MobilityDB typedef
# such as Quadbin whose uint64 underlying type was the part that erased).
recoverable = (_nospace(collapsed), _nospace(original))
if _nospace(slot.get(key)) not in recoverable:
return 0
slot[key] = recovered
if _nospace(slot.get("canonical")) == _nospace(collapsed):
if _nospace(slot.get("canonical")) in recoverable:
slot["canonical"] = recovered
return 1

Expand Down