Skip to content

Conversation

@jcflack
Copy link
Contributor

@jcflack jcflack commented May 28, 2025

PostgreSQL itself has been requiring a C compiler that has uintptr_t since 9.0 (postgres/postgres@85d02a6). The PL/Java 1.6.x branch only supports back to PG 9.5, so there is no question the type is supported.

An existing static assert in DualState.c is hereby changed to assert that sizeof(uintptr_t) <= sizeof(jlong); this is also assured for the present by a comment upstream in postgres.h section 1: "we require: sizeof(Datum) == sizeof(void *) == 4 or 8" (where Datum is uintptr_t).

In passing, specifically type as SPIPlanPtr some variables that had been typed void *. That was once their actual type in the SPI docs, but not since PG 8.2.

The few sites that ended up as PointerGetDatum(JLongGet(Pointer,...)) are effectively a longwinded way of doing nothing, but I left them that way to clearly reflect that a pointer is involved, and avoid assuming PointerGetDatum will always be as simple as it currently is.

jcflack added 2 commits May 27, 2025 20:14
PostgreSQL itself has been requiring a C compiler that has uintptr_t
since 9.0 (postgres/postgres@85d02a6). The PL/Java 1.6.x branch only
supports back to PG 9.5, so there is no question the type is supported.

An existing static assert in DualState.c is hereby changed to assert
that sizeof(uintptr_t) <= sizeof(jlong); this is also assured for the
present by a comment upstream in postgres.h section 1: "we require:
sizeof(Datum) == sizeof(void *) == 4 or 8" (where Datum is uintptr_t).

In passing, specifically type as SPIPlanPtr some variables that had
been typed void *. That was once their actual type in the SPI docs,
but not since PG 8.2.

The few sites that ended up as PointerGetDatum(JLongGet(Pointer,...))
are effectively a longwinded way of doing nothing, but I left them
that way to clearly reflect that a pointer is involved, and avoid
assuming PointerGetDatum will always be as simple as it is.
While void * works, mistakes are more easily caught with the intended
pointer type.
@jcflack jcflack merged commit e68610f into REL1_6_STABLE May 29, 2025
16 checks passed
jcflack added a commit that referenced this pull request May 30, 2025
The merged work includes PR #533, which does away with the old Ptr2Long
union in favor of new PointerGetJLong and JlongGet(... conversions.
In merging, also convert the uses of Ptr2Long that were added on this
branch.
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