Skip to content

Commit 472b209

Browse files
authored
Merge pull request #23 from vitcpp/10-pgsphere-version
[ISSUE-10] Implemented propagation of pg sphere version.
2 parents 001cee8 + 894f9bb commit 472b209

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

Diff for: Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ TESTS = init_test tables points euler circle line ellipse poly path box in
3232
contains_ops contains_ops_compat bounding_box_gist gnomo healpix \
3333
moc mocautocast epochprop
3434

35+
PG_CFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
36+
PG_CPPFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
37+
3538
ifndef CXXFLAGS
3639
# no support for CXXFLAGS in PGXS before v11
3740
CXXFLAGS = -Wall -Wpointer-arith -Wendif-labels \

Diff for: expected/init.out

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
-- does not depend on contents of pg_sphere.sql.
44
--
55
CREATE EXTENSION pg_sphere;
6+
select pg_sphere_version();
7+
pg_sphere_version
8+
-------------------
9+
1.2.1
10+
(1 row)
11+

Diff for: sql/init.sql

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
-- does not depend on contents of pg_sphere.sql.
44
--
55
CREATE EXTENSION pg_sphere;
6+
7+
select pg_sphere_version();

Diff for: src/output.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#include "types.h"
22

3+
#if !defined(PGSPHERE_VERSION)
4+
#error "PGSPHERE_VERSION macro is not set"
5+
#endif
6+
7+
#define PGSPHERE_STRINGIFY_INTERNAL(x) #x
8+
#define PGSPHERE_STRINGIFY(x) PGSPHERE_STRINGIFY_INTERNAL(x)
9+
310
/* Output functions */
411

512

@@ -527,7 +534,8 @@ spherebox_out(PG_FUNCTION_ARGS)
527534
Datum
528535
pg_sphere_version(PG_FUNCTION_ARGS)
529536
{
530-
char *buffer = (char *) palloc(20);
531-
sprintf(buffer, "1.1.5");
532-
PG_RETURN_CSTRING(buffer);
537+
const char *s = PGSPHERE_STRINGIFY(PGSPHERE_VERSION);
538+
char *p = (char *)palloc(strlen(s) + 1);
539+
strcpy(p, s);
540+
PG_RETURN_CSTRING(p);
533541
}

0 commit comments

Comments
 (0)