Skip to content

Commit a5f9cbd

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 94817d9 commit a5f9cbd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/pl/tcl/pltcl.c

Lines changed: 10 additions & 6 deletions
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")
@@ -988,7 +992,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
988992
HeapTuple tup;
989993
Tcl_Obj *resultObj;
990994
Tcl_Obj **resultObjv;
991-
int resultObjc;
995+
Tcl_Size resultObjc;
992996

993997
/*
994998
* Set up data about result type. XXX it's tempting to consider
@@ -1064,7 +1068,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
10641068
int tcl_rc;
10651069
int i;
10661070
const char *result;
1067-
int result_Objc;
1071+
Tcl_Size result_Objc;
10681072
Tcl_Obj **result_Objv;
10691073
int rc PG_USED_FOR_ASSERTS_ONLY;
10701074

@@ -2012,7 +2016,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp,
20122016
char *tmp;
20132017
const char *cp1;
20142018
char *cp2;
2015-
int length;
2019+
Tcl_Size length;
20162020

20172021
/************************************************************
20182022
* Check call syntax
@@ -2206,7 +2210,7 @@ pltcl_returnnext(ClientData cdata, Tcl_Interp *interp,
22062210
if (prodesc->fn_retistuple)
22072211
{
22082212
Tcl_Obj **rowObjv;
2209-
int rowObjc;
2213+
Tcl_Size rowObjc;
22102214

22112215
/* result should be a list, so break it down */
22122216
if (Tcl_ListObjGetElements(interp, objv[1], &rowObjc, &rowObjv) == TCL_ERROR)
@@ -2547,7 +2551,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
25472551
int objc, Tcl_Obj *const objv[])
25482552
{
25492553
volatile MemoryContext plan_cxt = NULL;
2550-
int nargs;
2554+
Tcl_Size nargs;
25512555
Tcl_Obj **argsObj;
25522556
pltcl_query_desc *qdesc;
25532557
int i;
@@ -2684,7 +2688,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
26842688
const char *arrayname = NULL;
26852689
Tcl_Obj *loop_body = NULL;
26862690
int count = 0;
2687-
int callObjc;
2691+
Tcl_Size callObjc;
26882692
Tcl_Obj **callObjv = NULL;
26892693
Datum *argvalues;
26902694
MemoryContext oldcontext = CurrentMemoryContext;

0 commit comments

Comments
 (0)