-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to get git version of code base.
- Loading branch information
Showing
7 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ sql/bookend.sql | |
sql/time_bucket.sql | ||
sql/permissions.sql | ||
sql/init.sql | ||
sql/version.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE OR REPLACE FUNCTION _timescaledb_internal.get_git_commit() RETURNS TEXT | ||
AS '$libdir/timescaledb', 'get_git_commit' LANGUAGE C IMMUTABLE STRICT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "postgres.h" | ||
#include <string.h> | ||
#include "fmgr.h" | ||
|
||
const char* git_commit = EXT_GIT_COMMIT; | ||
|
||
PG_FUNCTION_INFO_V1(get_git_commit); | ||
|
||
Datum | ||
get_git_commit(PG_FUNCTION_ARGS) { | ||
int32 var_size = VARHDRSZ + strlen(git_commit); | ||
text *version_text = (text *) palloc(var_size); | ||
|
||
SET_VARSIZE(version_text, var_size); | ||
|
||
memcpy((void *) VARDATA(version_text), | ||
(void *) git_commit, | ||
var_size - VARHDRSZ); | ||
|
||
PG_RETURN_TEXT_P(version_text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Just test that the function does not error out as the output | ||
-- will change. | ||
select count(*) from _timescaledb_internal.get_git_commit(); | ||
count | ||
------- | ||
1 | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Just test that the function does not error out as the output | ||
-- will change. | ||
select count(*) from _timescaledb_internal.get_git_commit(); | ||
|