Skip to content

Commit

Permalink
Fix PASSEDBYVALUE handling for uint8 type
Browse files Browse the repository at this point in the history
Previously, we tried to parse pg_config.h to find out whether we need
to declare the uint8 type as PASSEDBYVALUE.  This turned out to be
very fragile on Red Hat-based systems, because the pg_config.h file is
in unusual places and split across several files.  The
non-PASSEDBYVALUE case is only applicable to 32-bit systems, which are
very rare nowadays.  So to simplify all this and make it more robust,
just hardcode PASSEDBYVALUE and thus drop support for 32-bit systems.

fixes #17
  • Loading branch information
petere committed May 26, 2022
1 parent e3eddc3 commit e483dc0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ ifneq (,$(indexonlyscan_supported))
export PGOPTIONS = -c enable_indexonlyscan=off
endif

pg_config_h := $(shell $(PG_CONFIG) --includedir-server)/pg_config.h
use_float8_byval := $(shell if grep -q 'USE_FLOAT8_BYVAL 1' $(pg_config_h) || grep -q 'SIZEOF_VOID_P 8' $(pg_config_h); then echo yes; fi)
comma = ,

extension_version = 0

EXTENSION = uint
Expand All @@ -29,7 +25,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

uint--$(extension_version).sql: uint.sql hash.sql hex.sql operators.sql
cat $^ | sed 's/@UINT8_PASSEDBYVALUE@/$(if $(use_float8_byval),PASSEDBYVALUE$(comma))/' >$@
cat $^ >$@

PYTHON ?= python

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ This extension provides additional integer types for PostgreSQL:
Installation
------------

PostgreSQL version 9.1 or later is required.
PostgreSQL version 9.1 or later is required. Currently, only 64-bit
builds are supported.

To build and install this module:

Expand Down
2 changes: 1 addition & 1 deletion uint.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CREATE TYPE uint8 (
INPUT = uint8in,
OUTPUT = uint8out,
INTERNALLENGTH = 8,
@UINT8_PASSEDBYVALUE@
PASSEDBYVALUE, -- requires 64-bit
ALIGNMENT = double
);

Expand Down

0 comments on commit e483dc0

Please sign in to comment.