Conversation
There was a problem hiding this comment.
PR Summary
The pull request updates the extension version checking logic to ensure compatibility between binary and SQL versions, adding new helper functions for semantic version comparison.
sql/lantern.sql: Introduced_lantern_internalfunctions for version checking and comparison.src/hnsw.c: Addedlantern_internal_get_binary_versionfunction for retrieving binary version.src/hnsw/build.c: ReplacedVersionsMatch()withCmpExtensionVersions()for stricter version checks.src/hnsw/utils.c: Renamed and updatedVersionsMatchtoCmpExtensionVersionswith enhanced logic.test/expected/ext_relocation.out: Added tests for new internal version checking functions.
10 file(s) reviewed, 18 comment(s)
Edit PR Review Bot Settings
sql/lantern.sql
Outdated
| CREATE FUNCTION _lantern_internal.get_binary_version() RETURNS TEXT | ||
| AS 'MODULE_PATHNAME', 'lantern_internal_get_binary_version' LANGUAGE C STABLE STRICT PARALLEL SAFE; |
There was a problem hiding this comment.
Info: Added function to get the binary version of the Lantern extension.
sql/lantern.sql
Outdated
| CREATE OR REPLACE FUNCTION _lantern_internal.get_catalog_version() RETURNS TEXT as $$ | ||
| DECLARE | ||
| cat_version TEXT; | ||
| BEGIN | ||
| SELECT extversion INTO cat_version FROM pg_extension WHERE extname = 'lantern'; | ||
| RETURN cat_version; | ||
| END; | ||
| $$ LANGUAGE plpgsql; |
There was a problem hiding this comment.
Info: Added function to get the catalog version of the Lantern extension.
sql/lantern.sql
Outdated
| END; | ||
| $$ LANGUAGE plpgsql; | ||
|
|
||
| CREATE OR REPLACE FUNCTION _lantern_internal.parse_semver(semver text) |
There was a problem hiding this comment.
Info: Added function to parse semantic versioning (semver) strings.
sql/lantern.sql
Outdated
| -- 0 if versions are matching | ||
| -- 1 if binary version is bigger than catalog version | ||
| -- -1 if binary version is smaller than catalog version | ||
| CREATE OR REPLACE FUNCTION _lantern_internal.compare_extension_versions(catalog_version TEXT, binary_version TEXT) RETURNS INT as $$ |
There was a problem hiding this comment.
Info: Added function to compare the binary and catalog versions of the Lantern extension.
| #include <utils/selfuncs.h> | ||
| #include <utils/spccache.h> | ||
|
|
||
| #include "version.h" |
There was a problem hiding this comment.
Info: Included version.h to access version information.
src/hnsw/utils.h
Outdated
| void label2ItemPointer(usearch_label_t label, ItemPointer itemPtr); | ||
| float4 *ToFloat4Array(ArrayType *arr, int *dim_out); | ||
| bool VersionsMatch(); | ||
| int CmpExtensionVersions(); |
There was a problem hiding this comment.
Info: Renamed VersionsMatch to CmpExtensionVersions to implement stricter version checking.
test/expected/ext_relocation.out
Outdated
| extschema | proname | proschema | ||
| -----------+--------------------------------+------------------- | ||
| schema1 | _create_ldb_operator_classes | _lantern_internal | ||
| schema1 | compare_extension_versions | _lantern_internal |
There was a problem hiding this comment.
Info: Added compare_extension_versions function to compare extension versions.
test/expected/ext_relocation.out
Outdated
| schema1 | create_pq_codebook | _lantern_internal | ||
| schema1 | failure_point_enable | _lantern_internal | ||
| schema1 | forbid_table_change | _lantern_internal | ||
| schema1 | get_binary_version | _lantern_internal |
There was a problem hiding this comment.
Info: Added get_binary_version function to retrieve the binary version of the extension.
test/expected/ext_relocation.out
Outdated
| schema1 | failure_point_enable | _lantern_internal | ||
| schema1 | forbid_table_change | _lantern_internal | ||
| schema1 | get_binary_version | _lantern_internal | ||
| schema1 | get_catalog_version | _lantern_internal |
There was a problem hiding this comment.
Info: Added get_catalog_version function to retrieve the catalog version of the extension.
test/expected/ext_relocation.out
Outdated
| schema1 | get_catalog_version | _lantern_internal | ||
| schema1 | mask_arrays | _lantern_internal | ||
| schema1 | mask_order_by_in_plan | _lantern_internal | ||
| schema1 | parse_semver | _lantern_internal |
There was a problem hiding this comment.
Info: Added parse_semver function to parse semantic version strings.
Benchmarks
|
b43ace5 to
5474e79
Compare
…nd use it to check for incompatible sql and binary versions
5474e79 to
fcfb4d9
Compare
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
bb8f4fe to
126cc3f
Compare
126cc3f to
0f8608f
Compare
src/hnsw/utils.c
Outdated
| version_text = DatumGetTextP(val); | ||
| catalog_version = text_to_cstring(version_text); | ||
|
|
||
| if(strlen(catalog_version) == 0) { |
There was a problem hiding this comment.
so, if catalog version has zero length, we assume it is always compatible with any binary version?
is it what we want? I would think we would consider this error in all cases.
src/hnsw/utils.c
Outdated
|
|
||
| // Grab the result and check that it matches the version in the generated header | ||
| version_text = DatumGetTextP(val); | ||
| catalog_version = text_to_cstring(version_text); |
There was a problem hiding this comment.
You are storing version_text in a global variable but I am pretty sure it gets free()ed after the current context is gone, while catalog_version remains available as a freed pointer in the global process scope.
Is catalog_version actually used anywhere/
if so, it should probably be a NAME-sized static array into which you can strncpy the value of version_text
src/hnsw/utils.c
Outdated
| bool versions_match = false; | ||
| bool version_checked = false; | ||
| bool version_checked = false; | ||
| bool versions_match = true; |
There was a problem hiding this comment.
why default versions_match to true here?
…ion string using strncopy instead of using pointer
Generate static array from CMake for compatible version list based on update file names. Use that array to check if current catalog version of extension is compatible with current binary version