Обсуждение: PL/TCL Unkown module

Поиск
Список
Период
Сортировка

PL/TCL Unkown module

От
"Carlo Stonebanks"
Дата:
Can anyone ta;lk to me about the PL/TCL implementation of the Unkown
function?

The docs are nice, but more of a tease.
http://www.postgresql.org/docs/8.3/static/pltcl-unknown.html

I have to make this work on Windows and Linux. I'm the Windows guy, I'll
have to explain this to the Linux guy!

I have the folder contents of postgresql-8.3.10\src\pl\tcl from a Linux
build. From what I see it looks like I need to run the pltcl_loadmod.in as
tcl script after every server start or bounce - could that be right?


Re: PL/TCL Unkown module

От
Tom Lane
Дата:
"Carlo Stonebanks" <stonec.register@sympatico.ca> writes:
> I have the folder contents of postgresql-8.3.10\src\pl\tcl from a Linux
> build. From what I see it looks like I need to run the pltcl_loadmod.in as
> tcl script after every server start or bounce - could that be right?

No, you would run that once and it would put information into the
pltcl_modules table.  In particular you'd want to use it to install the
"unknown" function from unknown.pltcl.  After that, the "unknown"
function will be loaded automatically into new pltcl interpreters.

            regards, tom lane

Re: PL/TCL Unkown module

От
"Carlo Stonebanks"
Дата:
> In particular you'd want to use it to install the
> "unknown" function from unknown.pltcl.  After that, the "unknown"
> function will be loaded automatically into new pltcl interpreters.

Is there a way to install my own "unkown" function, and to have it become
permanant with no startup required? I don't think the loadmods functionality
is what I need.

Right now, every PL/TCL proc loads libs using the source... command. This
caused problems when we had to move them to another folder. If we had a
single point of maintenance we wouldn't have had a problem. I think that the
"unkown" command is the logical place to put such lib loading.

Sorry, don't know where to look in the docs for this sort PL/TCL stuff - I
have various PG manuals and texts, but the docs on this level of PL/TCL is
thin. Feel free to say, "Google XYZ and read it, then come back to me".


Re: PL/TCL Unkown module

От
Tom Lane
Дата:
"Carlo Stonebanks" <stonec.register@sympatico.ca> writes:
>> In particular you'd want to use it to install the
>> "unknown" function from unknown.pltcl.  After that, the "unknown"
>> function will be loaded automatically into new pltcl interpreters.

> Is there a way to install my own "unkown" function, and to have it become
> permanant with no startup required? I don't think the loadmods functionality
> is what I need.

Well, you can use whatever "unknown" function you want, but it has to be
loaded from that table; and if you want this to be for pltcl not pltclu,
it's not immediately clear that some other "unknown" function is going
to be more useful.  You're not going to be able to source random files
from the filesystem.

            regards, tom lane

Re: PL/TCL Unkown module

От
"Carlo Stonebanks"
Дата:
>> if you want this to be for pltcl not pltclu...  You're not going to be
>> able
>> to source random files from the filesystem.

Thanks - we're doing this using pltclu and have been using "source..." for 4
years with no trouble.

> Well, you can use whatever "unknown" function you want, but it has to be
> loaded from that table;

Then I have to figure out what to do next - so here's my checklist:

1) Since PL/TCL always looks for pltcl_modules automatically all
interpreters that hit an unknown command will find the entry for "unkown"
which I can rewrite to load my libs keeping in mind the limitations of the
type of interpreter pltcl or pltclu.
2) For our LINUX people, I would guess that they need to run from a shell:
   pltcl_loadmod.in myDb unknown.pltcl -host myHost
3) For Windows, I guess I would have to comment out: exec @TCLSH@ "$0" "$@"
then run from the command window:
   tclsh pltcl_loadmod.in myDb unknown.pltcl -host myHost

Is this right?

Is there any way for a sub prc to know whether it is running within a pltclu
or pltcl interpreter? I wrote a test proc showing the globals within a
pltclu proc and I don't see anything obvious.