Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions parser/altsqlfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
from parser.sqlfn import _CSQLFN_END, _meos_to_mdb, _wrapper_sql_sigs
from parser.typescope import SQL_ALIASES, TypeFacts

# A doxygen block closing right before the wrapper's `Datum Name(PG_FUNCTION_ARGS)`.
_WRAPPER_BLOCK = re.compile(r"/\*\*((?:(?!\*/).)*)\*/\s*Datum\s+(\w+)\s*\(\s*PG_FUNCTION_ARGS",
re.S)
# A doxygen block closing right before the wrapper's `Datum Name(PG_FUNCTION_ARGS)`, which the
# wrapper may declare `inline` or `static`, as #_DATUM of parser/sqlfn.py reads it.
_WRAPPER_BLOCK = re.compile(r"/\*\*((?:(?!\*/).)*)\*/\s*(?:(?:static|inline)\s+)*Datum\s+(\w+)"
r"\s*\(\s*PG_FUNCTION_ARGS", re.S)
_NAME = re.compile(r"(\w+)\s*\(\)")
# The MEOS spelling of a type PostgreSQL spells otherwise (`integer` is `int4`).
_MEOS_SPELLING = {sql: meos for meos, sql in SQL_ALIASES.items()}
Expand Down
30 changes: 30 additions & 0 deletions tests/test_altsqlfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,36 @@ def test_unpaired_and_conflicting_names_are_errors(self):
self.assertIn("Span_union_finalfn", errors[0])
self.assertIn("Tfloat_tmin_transfn", errors[1])

def test_a_wrapper_declared_inline_states_its_names(self):
# The wrappers of #WRAPPERS, declared `inline` and `static inline` as MobilityDB
# declares many of its wrappers
text = """
/**
* @sqlfn wAvgTransition()
* @sqlaggfn wAvg()
* @altsqlfn wAvgAgg()
*/
inline Datum
Tnumber_wavg_transfn(PG_FUNCTION_ARGS)
{
}

/**
* @sqlfn abs()
* @altsqlfn intAbs(), floatAbs()
*/
static inline Datum
Tnumber_abs(PG_FUNCTION_ARGS)
{
}
"""
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "w.c").write_text(text)
names, errors = aggregate_alt_names(tmp)
wrappers = wrapper_names(tmp)
self.assertEqual((names, errors), ({"wAvg": "wAvgAgg"}, []))
self.assertEqual(wrappers, {"Tnumber_abs": (["abs"], ["intAbs", "floatAbs"])})


class AltSqlNameContractTests(unittest.TestCase):
"""Over the generated catalog."""
Expand Down
Loading