Skip to content

Commit 817f2a5

Browse files
committed
Remove PL/Tcl's "module" facility.
PL/Tcl has long had a facility whereby Tcl code could be autoloaded from a database table named "pltcl_modules". However, nobody is using it, as evidenced by the recent discovery that it's never been fixed to work with standard_conforming_strings turned on. Moreover, it's rather shaky from a security standpoint, and the table design is very old and crufty (partly because it dates from before we had TOAST). A final problem is that because the table-population scripts depend on the Tcl client library Pgtcl, which we removed from the core distribution in 2004, it's impossible to create a self-contained regression test for the feature. Rather than try to surmount these problems, let's just remove it. A follow-on patch will provide a way to execute user-defined initialization code, similar to features that exist in plperl and plv8. With that, it will be possible to implement this feature or similar ones entirely in userspace, which is where it belongs. Discussion: https://postgr.es/m/22067.1488046447@sss.pgh.pa.us
1 parent 2ed193c commit 817f2a5

File tree

10 files changed

+0
-1029
lines changed

10 files changed

+0
-1029
lines changed

doc/src/sgml/pltcl.sgml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -902,51 +902,6 @@ if {[catch { spi_exec $sql_command }]} {
902902
</para>
903903
</sect1>
904904

905-
<sect1 id="pltcl-unknown">
906-
<title>Modules and the <function>unknown</> Command</title>
907-
<para>
908-
PL/Tcl has support for autoloading Tcl code when used.
909-
It recognizes a special table, <literal>pltcl_modules</>, which
910-
is presumed to contain modules of Tcl code. If this table
911-
exists, the module <literal>unknown</> is fetched from the table
912-
and loaded into the Tcl interpreter immediately before the first
913-
execution of a PL/Tcl function in a database session. (This
914-
happens separately for each Tcl interpreter, if more than one is
915-
used in a session; see <xref linkend="pltcl-global">.)
916-
</para>
917-
<para>
918-
While the <literal>unknown</> module could actually contain any
919-
initialization script you need, it normally defines a Tcl
920-
<function>unknown</> procedure that is invoked whenever Tcl does
921-
not recognize an invoked procedure name. <application>PL/Tcl</>'s standard version
922-
of this procedure tries to find a module in <literal>pltcl_modules</>
923-
that will define the required procedure. If one is found, it is
924-
loaded into the interpreter, and then execution is allowed to
925-
proceed with the originally attempted procedure call. A
926-
secondary table <literal>pltcl_modfuncs</> provides an index of
927-
which functions are defined by which modules, so that the lookup
928-
is reasonably quick.
929-
</para>
930-
<para>
931-
The <productname>PostgreSQL</productname> distribution includes
932-
support scripts to maintain these tables:
933-
<command>pltcl_loadmod</>, <command>pltcl_listmod</>,
934-
<command>pltcl_delmod</>, as well as source for the standard
935-
<literal>unknown</> module in <filename>share/unknown.pltcl</>. This module
936-
must be loaded
937-
into each database initially to support the autoloading mechanism.
938-
</para>
939-
<para>
940-
The tables <literal>pltcl_modules</> and <literal>pltcl_modfuncs</>
941-
must be readable by all, but it is wise to make them owned and
942-
writable only by the database administrator. As a security
943-
precaution, PL/Tcl will ignore <literal>pltcl_modules</> (and thus,
944-
not attempt to load the <literal>unknown</> module) unless it is
945-
owned by a superuser. But update privileges on this table can be
946-
granted to other users, if you trust them sufficiently.
947-
</para>
948-
</sect1>
949-
950905
<sect1 id="pltcl-procnames">
951906
<title>Tcl Procedure Names</title>
952907

src/pl/tcl/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ include $(top_srcdir)/src/Makefile.shlib
5353

5454

5555
all: all-lib
56-
$(MAKE) -C modules $@
5756

5857
# Force this dependency to be known even without dependency info built:
5958
pltcl.o: pltclerrcodes.h
@@ -65,14 +64,11 @@ pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrc
6564
distprep: pltclerrcodes.h
6665

6766
install: all install-lib install-data
68-
$(MAKE) -C modules $@
6967

7068
installdirs: installdirs-lib
7169
$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
72-
$(MAKE) -C modules $@
7370

7471
uninstall: uninstall-lib uninstall-data
75-
$(MAKE) -C modules $@
7672

7773
install-data: installdirs
7874
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
@@ -100,7 +96,6 @@ clean distclean: clean-lib
10096
ifeq ($(PORTNAME), win32)
10197
rm -f $(tclwithver).def
10298
endif
103-
$(MAKE) -C modules $@
10499

105100
maintainer-clean: distclean
106101
rm -f pltclerrcodes.h

src/pl/tcl/modules/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/pl/tcl/modules/Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/pl/tcl/modules/README

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/pl/tcl/modules/pltcl_delmod.in

Lines changed: 0 additions & 117 deletions
This file was deleted.

src/pl/tcl/modules/pltcl_listmod.in

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)