Skip to content

Commit 17d081a

Browse files
committed
Add support for Tcl 9
Tcl 9 changed several API functions to take Tcl_Size, which is ptrdiff_t, instead of int, for 64-bit enablement. We have to change a few local variables to be compatible with that. We also provide a fallback typedef of Tcl_Size for older Tcl versions. The affected variables are used for quantities that will not approach values beyond the range of int, so this doesn't change any functionality. Reviewed-by: Tristan Partin <tristan@partin.io> Discussion: https://www.postgresql.org/message-id/flat/bce0fe54-75b4-438e-b42b-8e84bc7c0e9c%40eisentraut.org
1 parent e087408 commit 17d081a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/pl/tcl/pltcl.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ PG_MODULE_MAGIC;
5656
#define CONST86
5757
#endif
5858

59+
#if !HAVE_TCL_VERSION(8,7)
60+
typedef int Tcl_Size;
61+
#endif
62+
5963
/* define our text domain for translations */
6064
#undef TEXTDOMAIN
6165
#define TEXTDOMAIN PG_TEXTDOMAIN("pltcl")
@@ -981,7 +985,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
981985
HeapTuple tup;
982986
Tcl_Obj *resultObj;
983987
Tcl_Obj **resultObjv;
984-
int resultObjc;
988+
Tcl_Size resultObjc;
985989

986990
/*
987991
* Set up data about result type. XXX it's tempting to consider
@@ -1057,7 +1061,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
10571061
int tcl_rc;
10581062
int i;
10591063
const char *result;
1060-
int result_Objc;
1064+
Tcl_Size result_Objc;
10611065
Tcl_Obj **result_Objv;
10621066
int rc PG_USED_FOR_ASSERTS_ONLY;
10631067

@@ -2006,7 +2010,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp,
20062010
char *tmp;
20072011
const char *cp1;
20082012
char *cp2;
2009-
int length;
2013+
Tcl_Size length;
20102014

20112015
/************************************************************
20122016
* Check call syntax
@@ -2200,7 +2204,7 @@ pltcl_returnnext(ClientData cdata, Tcl_Interp *interp,
22002204
if (prodesc->fn_retistuple)
22012205
{
22022206
Tcl_Obj **rowObjv;
2203-
int rowObjc;
2207+
Tcl_Size rowObjc;
22042208

22052209
/* result should be a list, so break it down */
22062210
if (Tcl_ListObjGetElements(interp, objv[1], &rowObjc, &rowObjv) == TCL_ERROR)
@@ -2540,7 +2544,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
25402544
int objc, Tcl_Obj *const objv[])
25412545
{
25422546
volatile MemoryContext plan_cxt = NULL;
2543-
int nargs;
2547+
Tcl_Size nargs;
25442548
Tcl_Obj **argsObj;
25452549
pltcl_query_desc *qdesc;
25462550
int i;
@@ -2677,7 +2681,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
26772681
const char *arrayname = NULL;
26782682
Tcl_Obj *loop_body = NULL;
26792683
int count = 0;
2680-
int callObjc;
2684+
Tcl_Size callObjc;
26812685
Tcl_Obj **callObjv = NULL;
26822686
Datum *argvalues;
26832687
MemoryContext oldcontext = CurrentMemoryContext;

0 commit comments

Comments
 (0)