Skip to content

Commit ae0241a

Browse files
committed
feat: add version to drv and patch instead of postPatch rewrite
1 parent 975f414 commit ae0241a

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

nix/ext/pg_cron-1.3.1-pg15.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/src/pg_cron.c b/src/pg_cron.c
2+
index e0ca973..4d51b2c 100644
3+
--- a/src/pg_cron.c
4+
+++ b/src/pg_cron.c
5+
@@ -14,6 +14,8 @@
6+
#include <sys/resource.h>
7+
8+
#include "postgres.h"
9+
+#include "commands/async.h"
10+
+#include "miscadmin.h"
11+
#include "fmgr.h"
12+
13+
/* these are always necessary for a bgworker */
14+
@@ -1908,7 +1910,7 @@ CronBackgroundWorker(Datum main_arg)
15+
/* Post-execution cleanup. */
16+
disable_timeout(STATEMENT_TIMEOUT, false);
17+
CommitTransactionCommand();
18+
- ProcessCompletedNotifies();
19+
+ /* ProcessCompletedNotifies removed */
20+
pgstat_report_activity(STATE_IDLE, command);
21+
pgstat_report_stat(true);
22+
23+
@@ -2025,7 +2027,7 @@ ExecuteSqlString(const char *sql)
24+
*/
25+
oldcontext = MemoryContextSwitchTo(parsecontext);
26+
#if PG_VERSION_NUM >= 100000
27+
- querytree_list = pg_analyze_and_rewrite(parsetree, sql, NULL, 0,NULL);
28+
+ querytree_list = pg_analyze_and_rewrite_fixedparams(parsetree, sql, NULL, 0, NULL);
29+
#else
30+
querytree_list = pg_analyze_and_rewrite(parsetree, sql, NULL, 0);
31+
#endif

nix/ext/pg_cron.nix

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@ let
55
"1.3.1" = {
66
rev = "v1.3.1";
77
hash = "sha256-rXotNOtQNmA55ErNxGoNSKZ0pP1uxEVlDGITFHuqGG4=";
8-
postPatch = ''
9-
# Add necessary includes
10-
substituteInPlace src/pg_cron.c \
11-
--replace '#include "postgres.h"' '#include "postgres.h"
12-
#include "commands/async.h"
13-
#include "miscadmin.h"'
14-
15-
# Update function calls to use PostgreSQL 15 APIs
16-
substituteInPlace src/pg_cron.c \
17-
--replace 'ProcessCompletedNotifies();' '/* ProcessCompletedNotifies removed */' \
18-
--replace 'pg_analyze_and_rewrite(parsetree, sql, NULL, 0,NULL);' 'pg_analyze_and_rewrite_fixedparams(parsetree, sql, NULL, 0, NULL);'
19-
'';
8+
patches = [ ./pg_cron-1.3.1-pg15.patch ];
209
};
2110
"1.4.2" = {
2211
rev = "v1.4.2";
@@ -32,12 +21,12 @@ let
3221
};
3322
};
3423

35-
mkPgCron = pgCronVersion: { rev, hash, postPatch ? "" }: stdenv.mkDerivation {
24+
mkPgCron = pgCronVersion: { rev, hash, patches ? [] }: stdenv.mkDerivation {
3625
pname = "pg_cron";
3726
version = "${pgCronVersion}-pg${lib.versions.major postgresql.version}";
3827

3928
buildInputs = [ postgresql ];
40-
inherit postPatch;
29+
inherit patches;
4130

4231
src = fetchFromGitHub {
4332
owner = "citusdata";
@@ -82,7 +71,7 @@ let
8271
in
8372
stdenv.mkDerivation {
8473
pname = "pg_cron-all";
85-
version = "multi";
74+
version = "multi-001"; #increment this if you change this package in any way
8675

8776
buildInputs = lib.attrValues allVersionsForPg;
8877

0 commit comments

Comments
 (0)