Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite260932

Browse files
committed
Make PL/Tcl require Tcl 8.4 or later.
As of commit2878220, PL/Tcl will notcompile against pre-8.0 Tcl, whereas it used to work (more or less anyway)with quite prehistoric versions. As long as we're moving these goalposts,let's reinstall them at someplace that has some thought behind it. Thiscommit sets the minimum allowed Tcl version at 8.4, and rips out some bitsof compatibility cruft that are in consequence no longer needed. Reasonsfor requiring 8.4 include:* 8.4 was released in 2002; there seems little reason to believe thatanyone would want to use older versions with Postgres 9.6+.* We have no buildfarm members testing anything older than 8.4, andthus no way to know if it's broken.* We need at least 8.1 to allow enforcement of database encodingsecurity (8.1 standardized Tcl on using UTF8 internally, before thatit was pretty unpredictable).* Some versions between 8.1 and 8.4 allowed the backend to becomemultithreaded, which is disastrous. We need at least 8.4 to be ableto disable the Tcl notifier subsystem to prevent that.A small side benefit is that we can make the code more readable bydoing s/CONST84/const/g.
1 parent2878220 commite260932

File tree

1 file changed

+40
-55
lines changed

1 file changed

+40
-55
lines changed

‎src/pl/tcl/pltcl.c

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313
#include<unistd.h>
1414
#include<fcntl.h>
1515

16-
/* Hack to deal with Tcl 8.4 const-ification without losing compatibility */
17-
#ifndefCONST84
18-
#defineCONST84
19-
#endif
20-
21-
/* ... and for Tcl 8.6. */
22-
#ifndefCONST86
23-
#defineCONST86
24-
#endif
25-
2616
#include"access/htup_details.h"
2717
#include"access/xact.h"
2818
#include"catalog/pg_proc.h"
@@ -47,16 +37,21 @@
4737
((TCL_MAJOR_VERSION > maj) || \
4838
(TCL_MAJOR_VERSION == maj && TCL_MINOR_VERSION >= min))
4939

50-
/* Insist on Tcl >= 8.0 */
51-
#if !HAVE_TCL_VERSION(8,0)
52-
#error PostgreSQL only supports Tcl 8.0 or later.
40+
/* Insist on Tcl >= 8.4 */
41+
#if !HAVE_TCL_VERSION(8,4)
42+
#error PostgreSQL only supports Tcl 8.4 or later.
43+
#endif
44+
45+
/* Hack to deal with Tcl 8.6 const-ification without losing compatibility */
46+
#ifndefCONST86
47+
#defineCONST86
5348
#endif
5449

5550
/* define our text domain for translations */
5651
#undef TEXTDOMAIN
5752
#defineTEXTDOMAIN PG_TEXTDOMAIN("pltcl")
5853

59-
#if defined(UNICODE_CONVERSION)&&HAVE_TCL_VERSION(8,1)
54+
#if defined(UNICODE_CONVERSION)
6055

6156
#include"mb/pg_wchar.h"
6257

@@ -223,7 +218,7 @@ static int pltcl_returnnull(ClientData cdata, Tcl_Interp *interp,
223218
staticintpltcl_SPI_execute(ClientDatacdata,Tcl_Interp*interp,
224219
intobjc,Tcl_Obj*constobjv[]);
225220
staticintpltcl_process_SPI_result(Tcl_Interp*interp,
226-
CONST84char*arrayname,
221+
constchar*arrayname,
227222
Tcl_Obj*loop_body,
228223
intspi_rc,
229224
SPITupleTable*tuptable,
@@ -235,7 +230,7 @@ static int pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
235230
staticintpltcl_SPI_lastoid(ClientDatacdata,Tcl_Interp*interp,
236231
intobjc,Tcl_Obj*constobjv[]);
237232

238-
staticvoidpltcl_set_tuple_values(Tcl_Interp*interp,CONST84char*arrayname,
233+
staticvoidpltcl_set_tuple_values(Tcl_Interp*interp,constchar*arrayname,
239234
inttupno,HeapTupletuple,TupleDesctupdesc);
240235
staticTcl_Obj*pltcl_build_tuple_argument(HeapTupletuple,TupleDesctupdesc);
241236

@@ -250,10 +245,7 @@ static Tcl_Obj *pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc);
250245
* from Postgres, so the notifier capabilities are initialized, but never
251246
* used. Only InitNotifier and DeleteFileHandler ever seem to get called
252247
* within Postgres, but we implement all the functions for completeness.
253-
* We can only fix this with Tcl >= 8.4, when Tcl_SetNotifier() appeared.
254248
*/
255-
#ifHAVE_TCL_VERSION(8,4)
256-
257249
staticClientData
258250
pltcl_InitNotifier(void)
259251
{
@@ -298,7 +290,6 @@ pltcl_WaitForEvent(CONST86 Tcl_Time *timePtr)
298290
{
299291
return0;
300292
}
301-
#endif/* HAVE_TCL_VERSION(8,4) */
302293

303294

304295
/*
@@ -329,6 +320,7 @@ perm_fmgr_info(Oid functionId, FmgrInfo *finfo)
329320
void
330321
_PG_init(void)
331322
{
323+
Tcl_NotifierProcsnotifier;
332324
HASHCTLhash_ctl;
333325

334326
/* Be sure we do initialization only once (should be redundant now) */
@@ -342,25 +334,18 @@ _PG_init(void)
342334
Tcl_FindExecutable("");
343335
#endif
344336

345-
#ifHAVE_TCL_VERSION(8,4)
346-
347337
/*
348338
* Override the functions in the Notifier subsystem. See comments above.
349339
*/
350-
{
351-
Tcl_NotifierProcsnotifier;
352-
353-
notifier.setTimerProc=pltcl_SetTimer;
354-
notifier.waitForEventProc=pltcl_WaitForEvent;
355-
notifier.createFileHandlerProc=pltcl_CreateFileHandler;
356-
notifier.deleteFileHandlerProc=pltcl_DeleteFileHandler;
357-
notifier.initNotifierProc=pltcl_InitNotifier;
358-
notifier.finalizeNotifierProc=pltcl_FinalizeNotifier;
359-
notifier.alertNotifierProc=pltcl_AlertNotifier;
360-
notifier.serviceModeHookProc=pltcl_ServiceModeHook;
361-
Tcl_SetNotifier(&notifier);
362-
}
363-
#endif
340+
notifier.setTimerProc=pltcl_SetTimer;
341+
notifier.waitForEventProc=pltcl_WaitForEvent;
342+
notifier.createFileHandlerProc=pltcl_CreateFileHandler;
343+
notifier.deleteFileHandlerProc=pltcl_DeleteFileHandler;
344+
notifier.initNotifierProc=pltcl_InitNotifier;
345+
notifier.finalizeNotifierProc=pltcl_FinalizeNotifier;
346+
notifier.alertNotifierProc=pltcl_AlertNotifier;
347+
notifier.serviceModeHookProc=pltcl_ServiceModeHook;
348+
Tcl_SetNotifier(&notifier);
364349

365350
/************************************************************
366351
* Create the dummy hold interpreter to prevent close of
@@ -853,8 +838,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, bool pltrusted)
853838
Datum*modvalues;
854839
char*modnulls;
855840
intret_numvals;
856-
CONST84char*result;
857-
CONST84char**ret_values;
841+
constchar*result;
842+
constchar**ret_values;
858843

859844
/* Connect to SPI manager */
860845
if (SPI_connect()!=SPI_OK_CONNECT)
@@ -1093,8 +1078,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS, bool pltrusted)
10931078

10941079
for (i=0;i<ret_numvals;i+=2)
10951080
{
1096-
CONST84char*ret_name=ret_values[i];
1097-
CONST84char*ret_value=ret_values[i+1];
1081+
constchar*ret_name=ret_values[i];
1082+
constchar*ret_value=ret_values[i+1];
10981083
intattnum;
10991084
Oidtypinput;
11001085
Oidtypioparam;
@@ -1620,12 +1605,12 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
16201605
MemoryContextoldcontext;
16211606
intpriIndex;
16221607

1623-
staticCONST84char*logpriorities[]= {
1608+
staticconstchar*logpriorities[]= {
16241609
"DEBUG","LOG","INFO","NOTICE",
1625-
"WARNING","ERROR","FATAL", (char*)NULL
1610+
"WARNING","ERROR","FATAL", (constchar*)NULL
16261611
};
16271612

1628-
staticCONST84intloglevels[]= {
1613+
staticconstintloglevels[]= {
16291614
DEBUG2,LOG,INFO,NOTICE,
16301615
WARNING,ERROR,FATAL
16311616
};
@@ -1934,7 +1919,7 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
19341919
inti;
19351920
intoptIndex;
19361921
intcount=0;
1937-
CONST84char*volatilearrayname=NULL;
1922+
constchar*volatilearrayname=NULL;
19381923
Tcl_Obj*volatileloop_body=NULL;
19391924
MemoryContextoldcontext=CurrentMemoryContext;
19401925
ResourceOwneroldowner=CurrentResourceOwner;
@@ -1944,8 +1929,8 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
19441929
OPT_ARRAY,OPT_COUNT
19451930
};
19461931

1947-
staticCONST84char*options[]= {
1948-
"-array","-count", (char*)NULL
1932+
staticconstchar*options[]= {
1933+
"-array","-count", (constchar*)NULL
19491934
};
19501935

19511936
/************************************************************
@@ -2035,7 +2020,7 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
20352020
*/
20362021
staticint
20372022
pltcl_process_SPI_result(Tcl_Interp*interp,
2038-
CONST84char*arrayname,
2023+
constchar*arrayname,
20392024
Tcl_Obj*loop_body,
20402025
intspi_rc,
20412026
SPITupleTable*tuptable,
@@ -2282,7 +2267,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
22822267
Tcl_HashEntry*hashent;
22832268
pltcl_query_desc*qdesc;
22842269
constchar*nulls=NULL;
2285-
CONST84char*arrayname=NULL;
2270+
constchar*arrayname=NULL;
22862271
Tcl_Obj*loop_body=NULL;
22872272
intcount=0;
22882273
intcallObjc;
@@ -2297,8 +2282,8 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
22972282
OPT_ARRAY,OPT_COUNT,OPT_NULLS
22982283
};
22992284

2300-
staticCONST84char*options[]= {
2301-
"-array","-count","-nulls", (char*)NULL
2285+
staticconstchar*options[]= {
2286+
"-array","-count","-nulls", (constchar*)NULL
23022287
};
23032288

23042289
/************************************************************
@@ -2500,19 +2485,19 @@ pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
25002485
* of a given tuple
25012486
**********************************************************************/
25022487
staticvoid
2503-
pltcl_set_tuple_values(Tcl_Interp*interp,CONST84char*arrayname,
2488+
pltcl_set_tuple_values(Tcl_Interp*interp,constchar*arrayname,
25042489
inttupno,HeapTupletuple,TupleDesctupdesc)
25052490
{
25062491
inti;
25072492
char*outputstr;
25082493
Datumattr;
25092494
boolisnull;
2510-
CONST84char*attname;
2495+
constchar*attname;
25112496
Oidtypoutput;
25122497
booltypisvarlena;
2513-
CONST84char**arrptr;
2514-
CONST84char**nameptr;
2515-
CONST84char*nullname=NULL;
2498+
constchar**arrptr;
2499+
constchar**nameptr;
2500+
constchar*nullname=NULL;
25162501

25172502
/************************************************************
25182503
* Prepare pointers for Tcl_SetVar2() below and in array

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp