Skip to content

keep rb_exsit definition for backward compatible with verion less tha…#63

Merged
ChenHuajun merged 1 commit into
ChenHuajun:masterfrom
harry-leq:master
Jun 17, 2026
Merged

keep rb_exsit definition for backward compatible with verion less tha…#63
ChenHuajun merged 1 commit into
ChenHuajun:masterfrom
harry-leq:master

Conversation

@harry-leq

Copy link
Copy Markdown

Function rb_exsit is renamed to rb_exists in v1.0.

Even though there is an attempt to replace the function definition in roaringbitmap--0.5--1.0.sql for migration, it still cause problem if user specifically install with a version less than 1.0 as shown below:

postgres=# create extension roaringbitmap with version '0.2';
ERROR:  could not find function "rb_exsit" in file "/opt/homebrew/lib/postgresql@18/roaringbitmap.dylib"
CONTEXT:  SQL statement "CREATE OR REPLACE FUNCTION rb_contains(roaringbitmap, integer)
  RETURNS bool 
  AS '$libdir/roaringbitmap', 'rb_exsit'
  LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE"
extension script file "roaringbitmap--0.2.sql", near line 93

This commit retains the definition of rb_exsit for backward compatibility that allow user to successfully create roaringbitmap with old version and migrate to newer version without error during installation or runtime.

postgres=# create extension roaringbitmap with version '0.2';
CREATE EXTENSION
postgres=# select * from pg_available_extensions where name = 'roaringbitmap';
     name      | default_version | installed_version |           comment           
---------------+-----------------+-------------------+-----------------------------
 roaringbitmap | 1.2             | 0.2               | support for Roaring Bitmaps
(1 row)

@ChenHuajun

Copy link
Copy Markdown
Owner

Why use a higher-version .so file to create a lower-version extension? This behavior is not supported.

@harry-leq

Copy link
Copy Markdown
Author

While the default version of roaringbitmap listed in pg_available_extensions is 1.2, older versions are listed under pg_available_extension_versions as well.

postgres=# select * from pg_available_extensions where name = 'roaringbitmap';
     name      | default_version | installed_version |           comment
---------------+-----------------+-------------------+-----------------------------
 roaringbitmap | 1.2             |                   | support for Roaring Bitmaps
(1 row)

postgres=# select * from pg_available_extension_versions where name = 'roaringbitmap';
     name      | version | installed | superuser | trusted | relocatable | schema | requires |           comment
---------------+---------+-----------+-----------+---------+-------------+--------+----------+-----------------------------
 roaringbitmap | 0.2     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 0.3     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 0.4     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 0.5     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 1.0     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 1.1     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
 roaringbitmap | 1.2     | f         | t         | f       | t           |        |          | support for Roaring Bitmaps
(7 rows)

It might not be a good practice to install older version against later .so file. But the fact that old versions are listed in system catalogue implies that they are supported. This also happens in many other extensions. There are a couple of ways to fix it:

  1. Prevent the older versions from being listed by removing the migration .sql files -> this might cause unforeseen problems when users perform upgrading.
  2. Keep the migration files and maintain the backward compatibility of the function, which is done by this commit. Besides that, it's always a good practice for higher version to keep compatibility with lower as much as it can.

@ChenHuajun

Copy link
Copy Markdown
Owner

There is indeed a real-world scenario where upgrading the PostgreSQL major version while simultaneously upgrading the pg_roaringbitmapextension causes the upgrade to fail. During the upgrade process, pg_dumpand pg_restoreare used to back up and restore user-defined functions. Incompatibility in pg_roaringbitmapleads to the failure of creating the rb_containsfunction.

@ChenHuajun ChenHuajun merged commit 98c0f2a into ChenHuajun:master Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants