Skip to content

Commit 37cbebf

Browse files
committed
Added pgpro_build() function and storing COMMIT_ID in the sources and binary. Fixes PGPRO-590
1 parent 5897ed4 commit 37cbebf

File tree

6 files changed

+16
-1
lines changed

6 files changed

+16
-1
lines changed

GNUmakefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ $(distdir).tar: distdir
9595
distdir-location:
9696
@echo $(distdir)
9797

98-
distdir:
98+
distdir: src/include/commit_id.h
9999
rm -rf $(distdir)* $(dummy)
100100
for x in `cd $(top_srcdir) && find . \( -name CVS -prune \) -o \( -name .git -prune \) -o -print`; do \
101101
file=`expr X$$x : 'X\./\(.*\)'`; \

src/Makefile.global.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,10 @@ include $(top_srcdir)/src/nls-global.mk
833833
endif # nls.mk
834834
endif # enable_nls
835835

836+
.PHONY: $(top_builddir)/src/include/commit_id.h
837+
$(top_builddir)/src/include/commit_id.h:
838+
[ -d .git ] && git log -1 --format='#define COMMIT_ID "%h"' > $@.tmp && mv $@.tmp $@
839+
[ -e $@ ] || echo '#define COMMIT_ID "00000000"' >$@
836840

837841
##########################################################################
838842
#

src/backend/utils/adt/version.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "utils/builtins.h"
1818

19+
#include "commit_id.h"
1920

2021
Datum
2122
pgsql_version(PG_FUNCTION_ARGS)
@@ -34,3 +35,9 @@ pgpro_edition(PG_FUNCTION_ARGS)
3435
{
3536
PG_RETURN_TEXT_P(cstring_to_text(PGPRO_EDITION));
3637
}
38+
39+
Datum
40+
pgpro_build(PG_FUNCTION_ARGS)
41+
{
42+
PG_RETURN_TEXT_P(cstring_to_text(COMMIT_ID));
43+
}

src/include/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/pg_config_ext.h
55
/pg_config_os.h
66
/dynloader.h
7+
/commit_id.h

src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5310,6 +5310,8 @@ DESCR("PostgresPro version string");
53105310
DATA(insert OID = 6019 ( pgpro_edition PGNSP PGUID 12 1 0 0 0 f f f f t f s s 0 0 25 "" _null_ _null_ _null_ _null_ _null_ pgpro_edition _null_ _null_ _null_ ));
53115311
DESCR("PostgresPro edition");
53125312

5313+
DATA(insert OID = 6020 ( pgpro_build PGNSP PGUID 12 1 0 0 0 f f f f t f s s 0 0 25 "" _null_ _null_ _null_ _null_ _null_ pgpro_build _null_ _null_ _null_ ));
5314+
DESCR("PostgresPro edition");
53135315
/* rls */
53145316
DATA(insert OID = 3298 ( row_security_active PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 16 "26" _null_ _null_ _null_ _null_ _null_ row_security_active _null_ _null_ _null_ ));
53155317
DESCR("row security for current context active on table by table oid");

src/include/utils/builtins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ extern Datum text_format_nv(PG_FUNCTION_ARGS);
893893
extern Datum pgsql_version(PG_FUNCTION_ARGS);
894894
extern Datum pgpro_version(PG_FUNCTION_ARGS);
895895
extern Datum pgpro_edition(PG_FUNCTION_ARGS);
896+
extern Datum pgpro_build(PG_FUNCTION_ARGS);
896897

897898
/* xid.c */
898899
extern Datum xidin(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)