• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

babelfish-for-postgresql / babelfish_extensions / 23540795565
77%
BABEL_5_X_DEV: 77%

Build:
Build:
LAST BUILD BRANCH: BABEL_6_X_DEV
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 25 Mar 2026 01:03PM UTC
Jobs 1
Files 121
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

25 Mar 2026 12:23PM UTC coverage: 77.07% (-0.003%) from 77.073%
23540795565

push

github

web-flow
[PART-1] Figure and Shape Parser support (#4681)

Fix geography validation bugs, replace ad-hoc CLR binary metadata parsing with spec-compliant implementation, and fix polygon Valid flag in properties byte.

**Currently**, Babelfish has the following issues in `spatialtypes.c`:

1. **Geography accepts out-of-range longitude values.** `geography::Point(45, 20000, 4326)` succeeds silently. T-SQL enforces longitude bounds of −15069 to +15069 degrees and rejects this input.

2. **Geometry/geography accepts Infinity coordinates.** Binary data containing `±Infinity` coordinate values passes all validation because only `isnan()` is checked, not `isinf()`. T-SQL rejects both NaN and Infinity.

3. **CLR binary metadata (Figure/Shape arrays) is parsed incorrectly.** The old `check_geom_end_metadata()` reads 4 bytes at a time across 5-byte figure entry boundaries. It works only because the attribute byte happens to produce the expected uint32 value when the following offset bytes are zeros. No bounds checking exists on metadata reads.

4. **Polygon properties byte missing Valid flag.** Babelfish outputs `0x00` for valid 2D polygons while T-SQL outputs `0x04` (V flag set). Linestrings already handled valid/invalid variants correctly.

5. **`set_dimension_flag()` prematurely guesses geometry type.** Properties byte `0x04` was hardcoded as `LINE_TYPE`, creating a latent bug where valid polygons from T-SQL would be misidentified.

**With this change:**

1. New `validate_longitude_range()` and `validate_not_inf_nan()` functions added and integrated into all validation paths (text input, binary input, direct point creation). Geography objects with longitude outside ±15069° are now rejected.

2. `check_nan_coordinates()` now checks both `isnan()` and `isinf()`. All geography validation paths also check for infinity.

3. New `parse_figures_and_shapes()` replaces `check_geom_end_metadata()`. Reads figure entries as 1+4 bytes and shape entries as 4+4+1 bytes per the T-SQL... (continued)

353 of 388 new or added lines in 1 file covered. (90.98%)

11 existing lines in 2 files now uncovered.

53045 of 68827 relevant lines covered (77.07%)

631238.77 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
35
94.76
-2.64% contrib/babelfishpg_common/src/spatialtypes.c

Uncovered Existing Lines

Lines Coverage ∆ File
1
79.23
-0.2% contrib/babelfishpg_tds/src/backend/tds/tdsutils.c
10
94.76
-2.64% contrib/babelfishpg_common/src/spatialtypes.c
Jobs
ID Job ID Ran Files Coverage
1 23540795565.1 25 Mar 2026 01:03PM UTC 121
77.07
GitHub Action Run
Source Files on build 23540795565
  • Tree
  • List 121
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #23540795565
  • c50c6623 on github
  • Prev Build on BABEL_6_X_DEV (#23423361140)
  • Next Build on BABEL_6_X_DEV (#23634879219)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc