Skip to content

Commit 957a614

Browse files
committed
From: Jan Wieck <jwieck@debis.com>
A few minutes ago I sent down the PL/Tcl directory to this list. Look at it and reuse anything that might help to build PL/perl. I really hope that PL/perl and PL/Tcl appear in the 6.3 distribution. I'll do whatever I can to make this happen.
1 parent a71a80b commit 957a614

File tree

5 files changed

+827
-0
lines changed

5 files changed

+827
-0
lines changed

src/pl/tcl/modules/README

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The module support over the unknown command requires, that
3+
the PL/Tcl call handler is compiled with -DPLTCL_UNKNOWN_SUPPORT.
4+
5+
Regular Tcl scripts of any size (over 8K :-) can be loaded into
6+
the table pltcl_modules using the pltcl_loadmod script. The script
7+
checks the modules that the procedure names don't overwrite
8+
existing ones before doing anything. They also check for global
9+
variables created at load time.
10+
11+
All procedures defined in the module files are automatically
12+
added to the table pltcl_modfuncs. This table is used by the
13+
unknown procedure to determine if an unknown command can be
14+
loaded by sourcing a module. In that case the unknonw procedure
15+
will silently source in the module and reexecute the original
16+
command that invoked unknown.
17+
18+
I know, thist readme should be more explanatory - but time.
19+
20+
21+
Jan
22+

src/pl/tcl/modules/pltcl_delmod

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/sh
2+
# Start tclsh \
3+
exec tclsh "$0" $@
4+
5+
#
6+
# Code still has to be documented
7+
#
8+
9+
#load /usr/local/pgsql/lib/libpgtcl.so
10+
package require Pgtcl
11+
12+
13+
#
14+
# Check for minimum arguments
15+
#
16+
if {$argc < 1} {
17+
puts stderr ""
18+
puts stderr "usage: pltcl_delmod dbname \[options\] modulename \[...\]"
19+
puts stderr ""
20+
puts stderr "options:"
21+
puts stderr " -host hostname"
22+
puts stderr " -port portnumber"
23+
puts stderr ""
24+
exit 1
25+
}
26+
27+
#
28+
# Remember database name and initialize options
29+
#
30+
set dbname [lindex $argv 0]
31+
set options ""
32+
set errors 0
33+
set opt ""
34+
set val ""
35+
36+
set i 1
37+
while {$i < $argc} {
38+
if {[string compare [string index [lindex $argv $i] 0] "-"] != 0} {
39+
break;
40+
}
41+
42+
set opt [lindex $argv $i]
43+
incr i
44+
if {$i >= $argc} {
45+
puts stderr "no value given for option $opt"
46+
incr errors
47+
continue
48+
}
49+
set val [lindex $argv $i]
50+
incr i
51+
52+
switch -- $opt {
53+
-host {
54+
append options "-host \"$val\" "
55+
}
56+
-port {
57+
append options "-port $val "
58+
}
59+
default {
60+
puts stderr "unknown option '$opt'"
61+
incr errors
62+
}
63+
}
64+
}
65+
66+
#
67+
# Final syntax check
68+
#
69+
if {$i >= $argc || $errors > 0} {
70+
puts stderr ""
71+
puts stderr "usage: pltcl_delmod dbname \[options\] modulename \[...\]"
72+
puts stderr ""
73+
puts stderr "options:"
74+
puts stderr " -host hostname"
75+
puts stderr " -port portnumber"
76+
puts stderr ""
77+
exit 1
78+
}
79+
80+
proc delmodule {conn modname} {
81+
set xname $modname
82+
regsub -all {\\} $xname {\\} xname
83+
regsub -all {'} $xname {''} xname
84+
85+
set found 0
86+
pg_select $conn "select * from pltcl_modules where modname = '$xname'" \
87+
MOD {
88+
set found 1
89+
break;
90+
}
91+
92+
if {!$found} {
93+
puts "Module $modname not found in pltcl_modules"
94+
puts ""
95+
return
96+
}
97+
98+
pg_result \
99+
[pg_exec $conn "delete from pltcl_modules where modname = '$xname'"] \
100+
-clear
101+
pg_result \
102+
[pg_exec $conn "delete from pltcl_modfuncs where modname = '$xname'"] \
103+
-clear
104+
105+
puts "Module $modname removed"
106+
}
107+
108+
set conn [eval pg_connect $dbname $options]
109+
110+
while {$i < $argc} {
111+
delmodule $conn [lindex $argv $i]
112+
incr i
113+
}
114+
115+
pg_disconnect $conn
116+

src/pl/tcl/modules/pltcl_listmod

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/sh
2+
# Start tclsh \
3+
exec tclsh "$0" $@
4+
5+
#
6+
# Code still has to be documented
7+
#
8+
9+
#load /usr/local/pgsql/lib/libpgtcl.so
10+
package require Pgtcl
11+
12+
13+
#
14+
# Check for minimum arguments
15+
#
16+
if {$argc < 1} {
17+
puts stderr ""
18+
puts stderr "usage: pltcl_listmod dbname \[options\] \[modulename \[...\]\]"
19+
puts stderr ""
20+
puts stderr "options:"
21+
puts stderr " -host hostname"
22+
puts stderr " -port portnumber"
23+
puts stderr ""
24+
exit 1
25+
}
26+
27+
#
28+
# Remember database name and initialize options
29+
#
30+
set dbname [lindex $argv 0]
31+
set options ""
32+
set errors 0
33+
set opt ""
34+
set val ""
35+
36+
set i 1
37+
while {$i < $argc} {
38+
if {[string compare [string index [lindex $argv $i] 0] "-"] != 0} {
39+
break;
40+
}
41+
42+
set opt [lindex $argv $i]
43+
incr i
44+
if {$i >= $argc} {
45+
puts stderr "no value given for option $opt"
46+
incr errors
47+
continue
48+
}
49+
set val [lindex $argv $i]
50+
incr i
51+
52+
switch -- $opt {
53+
-host {
54+
append options "-host \"$val\" "
55+
}
56+
-port {
57+
append options "-port $val "
58+
}
59+
default {
60+
puts stderr "unknown option '$opt'"
61+
incr errors
62+
}
63+
}
64+
}
65+
66+
#
67+
# Final syntax check
68+
#
69+
if {$errors > 0} {
70+
puts stderr ""
71+
puts stderr "usage: pltcl_listmod dbname \[options\] \[modulename \[...\]\]"
72+
puts stderr ""
73+
puts stderr "options:"
74+
puts stderr " -host hostname"
75+
puts stderr " -port portnumber"
76+
puts stderr ""
77+
exit 1
78+
}
79+
80+
proc listmodule {conn modname} {
81+
set xname $modname
82+
regsub -all {\\} $xname {\\} xname
83+
regsub -all {'} $xname {''} xname
84+
85+
set found 0
86+
pg_select $conn "select * from pltcl_modules where modname = '$xname'" \
87+
MOD {
88+
set found 1
89+
break;
90+
}
91+
92+
if {!$found} {
93+
puts "Module $modname not found in pltcl_modules"
94+
puts ""
95+
return
96+
}
97+
98+
puts "Module $modname defines procedures:"
99+
pg_select $conn "select funcname from pltcl_modfuncs \
100+
where modname = '$xname' order by funcname" FUNC {
101+
puts " $FUNC(funcname)"
102+
}
103+
puts ""
104+
}
105+
106+
set conn [eval pg_connect $dbname $options]
107+
108+
if {$i == $argc} {
109+
pg_select $conn "select distinct modname from pltcl_modules \
110+
order by modname" \
111+
MOD {
112+
listmodule $conn $MOD(modname)
113+
}
114+
} else {
115+
while {$i < $argc} {
116+
listmodule $conn [lindex $argv $i]
117+
incr i
118+
}
119+
}
120+
121+
pg_disconnect $conn
122+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy