Skip to content

Commit 2dffdce

Browse files
committed
Ported pgpro_build function from the PGPRO9_6 standard
1 parent a49e7ed commit 2dffdce

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
@@ -834,6 +834,10 @@ include $(top_srcdir)/src/nls-global.mk
834834
endif # nls.mk
835835
endif # enable_nls
836836

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

838842
##########################################################################
839843
#

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)
@@ -33,4 +34,10 @@ Datum
3334
pgpro_edition(PG_FUNCTION_ARGS)
3435
{
3536
PG_RETURN_TEXT_P(cstring_to_text(PGPRO_EDITION));
37+
}
38+
39+
Datum
40+
pgpro_build(PG_FUNCTION_ARGS)
41+
{
42+
PG_RETURN_TEXT_P(cstring_to_text(COMMIT_ID));
3643
}

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
@@ -5324,6 +5324,8 @@ DESCR("PostgresPro version string");
53245324
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_ ));
53255325
DESCR("PostgresPro edition");
53265326

5327+
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_ ));
5328+
DESCR("PostgresPro edition");
53275329
/* rls */
53285330
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_ ));
53295331
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
@@ -899,6 +899,7 @@ extern Datum text_format_nv(PG_FUNCTION_ARGS);
899899
extern Datum pgsql_version(PG_FUNCTION_ARGS);
900900
extern Datum pgpro_version(PG_FUNCTION_ARGS);
901901
extern Datum pgpro_edition(PG_FUNCTION_ARGS);
902+
extern Datum pgpro_build(PG_FUNCTION_ARGS);
902903

903904
/* xid.c */
904905
extern Datum xidin(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)