public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Add support for Tcl 9
Date: Fri, 15 Nov 2024 11:24:04 +0100
Message-ID: <[email protected]> (raw)

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.  Here is a patch 
for that.

The affected variables are used for quantities that will not approach
values beyond the range of int (usually number of columns), so this 
doesn't change any functionality, AFAICT.

From 42ccfddb24536a863e8df92d9f6348bf319d55b3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 15 Nov 2024 10:45:32 +0100
Subject: [PATCH] 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 typdef 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.
---
 src/pl/tcl/pltcl.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 80de0db40de..e2d9246a678 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -55,6 +55,10 @@ PG_MODULE_MAGIC;
 #define CONST86
 #endif
 
+#if !HAVE_TCL_VERSION(8,7)
+typedef int Tcl_Size;
+#endif
+
 /* define our text domain for translations */
 #undef TEXTDOMAIN
 #define TEXTDOMAIN PG_TEXTDOMAIN("pltcl")
@@ -987,7 +991,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
 		HeapTuple	tup;
 		Tcl_Obj    *resultObj;
 		Tcl_Obj   **resultObjv;
-		int			resultObjc;
+		Tcl_Size	resultObjc;
 
 		/*
 		 * Set up data about result type.  XXX it's tempting to consider
@@ -1063,7 +1067,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
 	int			tcl_rc;
 	int			i;
 	const char *result;
-	int			result_Objc;
+	Tcl_Size	result_Objc;
 	Tcl_Obj   **result_Objv;
 	int			rc PG_USED_FOR_ASSERTS_ONLY;
 
@@ -2089,7 +2093,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp,
 	char	   *tmp;
 	const char *cp1;
 	char	   *cp2;
-	int			length;
+	Tcl_Size	length;
 
 	/************************************************************
 	 * Check call syntax
@@ -2283,7 +2287,7 @@ pltcl_returnnext(ClientData cdata, Tcl_Interp *interp,
 		if (prodesc->fn_retistuple)
 		{
 			Tcl_Obj   **rowObjv;
-			int			rowObjc;
+			Tcl_Size	rowObjc;
 
 			/* result should be a list, so break it down */
 			if (Tcl_ListObjGetElements(interp, objv[1], &rowObjc, &rowObjv) == TCL_ERROR)
@@ -2625,7 +2629,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
 				  int objc, Tcl_Obj *const objv[])
 {
 	volatile MemoryContext plan_cxt = NULL;
-	int			nargs;
+	Tcl_Size	nargs;
 	Tcl_Obj   **argsObj;
 	pltcl_query_desc *qdesc;
 	int			i;
@@ -2763,7 +2767,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
 	const char *arrayname = NULL;
 	Tcl_Obj    *loop_body = NULL;
 	int			count = 0;
-	int			callObjc;
+	Tcl_Size	callObjc;
 	Tcl_Obj   **callObjv = NULL;
 	Datum	   *argvalues;
 	MemoryContext oldcontext = CurrentMemoryContext;
-- 
2.47.0



Attachments:

  [text/plain] 0001-Add-support-for-Tcl-9.patch (2.7K, ../[email protected]/2-0001-Add-support-for-Tcl-9.patch)
  download | inline diff:
From 42ccfddb24536a863e8df92d9f6348bf319d55b3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 15 Nov 2024 10:45:32 +0100
Subject: [PATCH] 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 typdef 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.
---
 src/pl/tcl/pltcl.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 80de0db40de..e2d9246a678 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -55,6 +55,10 @@ PG_MODULE_MAGIC;
 #define CONST86
 #endif
 
+#if !HAVE_TCL_VERSION(8,7)
+typedef int Tcl_Size;
+#endif
+
 /* define our text domain for translations */
 #undef TEXTDOMAIN
 #define TEXTDOMAIN PG_TEXTDOMAIN("pltcl")
@@ -987,7 +991,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
 		HeapTuple	tup;
 		Tcl_Obj    *resultObj;
 		Tcl_Obj   **resultObjv;
-		int			resultObjc;
+		Tcl_Size	resultObjc;
 
 		/*
 		 * Set up data about result type.  XXX it's tempting to consider
@@ -1063,7 +1067,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, pltcl_call_state *call_state,
 	int			tcl_rc;
 	int			i;
 	const char *result;
-	int			result_Objc;
+	Tcl_Size	result_Objc;
 	Tcl_Obj   **result_Objv;
 	int			rc PG_USED_FOR_ASSERTS_ONLY;
 
@@ -2089,7 +2093,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp,
 	char	   *tmp;
 	const char *cp1;
 	char	   *cp2;
-	int			length;
+	Tcl_Size	length;
 
 	/************************************************************
 	 * Check call syntax
@@ -2283,7 +2287,7 @@ pltcl_returnnext(ClientData cdata, Tcl_Interp *interp,
 		if (prodesc->fn_retistuple)
 		{
 			Tcl_Obj   **rowObjv;
-			int			rowObjc;
+			Tcl_Size	rowObjc;
 
 			/* result should be a list, so break it down */
 			if (Tcl_ListObjGetElements(interp, objv[1], &rowObjc, &rowObjv) == TCL_ERROR)
@@ -2625,7 +2629,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
 				  int objc, Tcl_Obj *const objv[])
 {
 	volatile MemoryContext plan_cxt = NULL;
-	int			nargs;
+	Tcl_Size	nargs;
 	Tcl_Obj   **argsObj;
 	pltcl_query_desc *qdesc;
 	int			i;
@@ -2763,7 +2767,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
 	const char *arrayname = NULL;
 	Tcl_Obj    *loop_body = NULL;
 	int			count = 0;
-	int			callObjc;
+	Tcl_Size	callObjc;
 	Tcl_Obj   **callObjv = NULL;
 	Datum	   *argvalues;
 	MemoryContext oldcontext = CurrentMemoryContext;
-- 
2.47.0



view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Add support for Tcl 9
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox