Skip to content

[ISSUE-10] Implemented propagation of pg sphere version. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ TESTS = init_test tables points euler circle line ellipse poly path box in
contains_ops contains_ops_compat bounding_box_gist gnomo healpix \
moc mocautocast epochprop

PG_CFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
PG_CPPFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)

ifndef CXXFLAGS
# no support for CXXFLAGS in PGXS before v11
CXXFLAGS = -Wall -Wpointer-arith -Wendif-labels \
Expand Down
6 changes: 6 additions & 0 deletions expected/init.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
-- does not depend on contents of pg_sphere.sql.
--
CREATE EXTENSION pg_sphere;
select pg_sphere_version();
pg_sphere_version
-------------------
1.2.1
(1 row)

2 changes: 2 additions & 0 deletions sql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
-- does not depend on contents of pg_sphere.sql.
--
CREATE EXTENSION pg_sphere;

select pg_sphere_version();
14 changes: 11 additions & 3 deletions src/output.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#include "types.h"

#if !defined(PGSPHERE_VERSION)
#error "PGSPHERE_VERSION macro is not set"
#endif

#define PGSPHERE_STRINGIFY_INTERNAL(x) #x
#define PGSPHERE_STRINGIFY(x) PGSPHERE_STRINGIFY_INTERNAL(x)

/* Output functions */


Expand Down Expand Up @@ -527,7 +534,8 @@ spherebox_out(PG_FUNCTION_ARGS)
Datum
pg_sphere_version(PG_FUNCTION_ARGS)
{
char *buffer = (char *) palloc(20);
sprintf(buffer, "1.1.5");
PG_RETURN_CSTRING(buffer);
const char *s = PGSPHERE_STRINGIFY(PGSPHERE_VERSION);
char *p = (char *)palloc(strlen(s) + 1);
strcpy(p, s);
PG_RETURN_CSTRING(p);
}