From 1b823a03c45abc71207991aee6304f342c58a104 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sat, 21 Nov 2026 19:09:48 +0100 Subject: [PATCH] Read as raster types only the structs whose reader answers a SQL type The generator reads the raster types from the structs of the raster family, each struct naming the function that reads its text form, whose SQL signature answers the type. MobilityDB's catalog gives BandStats a text form, read by bandstats_in, which carries no SQL signature: BandStats is the summarystats record PostGIS defines, which a function answers and no column holds. Such a struct is no raster type and is passed over; a struct whose reader the catalog does not declare at all still stops the generator. Witness: run on the catalog of MobilityDB master 8bd3b60c28, the generator writes 2 raster types, raster and raquet, the set MobilityDB's tools/raster_matrix.py names, and catalog_gen.go and mathops_meos_gen.go are byte-identical to the committed ones. Measured: on MobilityAPI master f7de535, CI stops at the generator with "the struct BandStats reads its text form with bandstats_in, which states no SQL signature answering a type", against the catalog of MobilityDB master that carries the BandStats text form. --- tools/codegen/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/codegen/main.go b/tools/codegen/main.go index b81a40e..b2bf459 100644 --- a/tools/codegen/main.go +++ b/tools/codegen/main.go @@ -176,7 +176,10 @@ const rasterFamily = "RASTER" // The raster types are the SQL types of the structs of the family: a struct // states the function reading its text form, and that function's SQL signature // answers the type, so `raster` and `raquet` are read from the catalog rather -// than listed here. +// than listed here. A struct whose reader states no SQL signature is no type a +// raster collection holds: BandStats is read and written as the summarystats +// record PostGIS defines, which a function answers and no column is, the set +// tools/raster_matrix.py names as RASTER_TYPES. // // The functions are those MobilityDB/MobilityDB tools/raster_matrix.py counts // as the raster surface, by the same rule: the public functions of the family @@ -202,9 +205,12 @@ func rasterFunctions(c catalog) (map[string][]string, error) { continue } in, ok := byName[s.Serialization.In] - if !ok || len(in.SQLSignatures) == 0 || in.SQLSignatures[0].Ret == "" { - return nil, fmt.Errorf("the struct %s reads its text form with %s, which "+ - "states no SQL signature answering a type", s.Name, s.Serialization.In) + if !ok { + return nil, fmt.Errorf("the struct %s reads its text form with %s, which the "+ + "catalog does not declare", s.Name, s.Serialization.In) + } + if len(in.SQLSignatures) == 0 || in.SQLSignatures[0].Ret == "" { + continue } have[in.SQLSignatures[0].Ret] = map[string]bool{} }