Thread: [BUGS] Missing "E'" in pltcl_loadmod

[BUGS] Missing "E'" in pltcl_loadmod

From
mestan@dix.cz
Date:
Hi,

in lates version script pltcl_loadmod missed E' in insert
command. Resul is, that module loading not work alt all. Yes,
module is loaded, but loaded code is maformed.

Example on module unknown.pltcl:

Beginning of function "unknown":
In psql: select modsrc from pltcl_modules;

Malformed code:

 proc unknown {proname args} {                                                            +
     upvar #0    __PLTcl_unknown_support_plan_modname    p_mod                            +
     upvar #0    __PLTcl_unknown_support_plan_modsrc     p_src                            +
                                                                                          +
     #-----------------------------------------------------------                         +
     # On first call prepare the plans                                                    +
     #-----------------------------------------------------------                         +
     if {![info exists p_mod]} {                                                          +
         set p_mod [spi_prepare                                  \\                       +
                 "select modname from pltcl_modfuncs             \\                       +
                  where funcname = \\$1" name]                                            +
         set p_src [spi_prepare                                  \\                       +
                 "select modseq, modsrc from pltcl_modules       \\                       +
                  where modname = \\$1                           \\                       +
                  order by modseq" name]                                                  +
     }                                                                                    +


Good code after fix:

 proc unknown {proname args} {                                                            +
     upvar #0    __PLTcl_unknown_support_plan_modname    p_mod                            +
     upvar #0    __PLTcl_unknown_support_plan_modsrc     p_src                            +
                                                                                          +
     #-----------------------------------------------------------                         +
     # On first call prepare the plans                                                    +
     #-----------------------------------------------------------                         +
     if {![info exists p_mod]} {                                                          +
         set p_mod [spi_prepare                                  \                        +
                 "select modname from pltcl_modfuncs             \                        +
                  where funcname = \$1" name]                                             +
         set p_src [spi_prepare                                  \                        +
                 "select modseq, modsrc from pltcl_modules       \                        +
                  where modname = \$1                            \                        +
                  order by modseq" name]                                                  +
     }                                                                                    +


There is simple patch:

mestan@forest:/usr/lib/postgresql/9.6/bin$ diff pltcl_loadmod-original pltcl_loadmod
453c453
<                       '$xname', $i, '$xpart')"
\
---
>                       '$xname', $i, E'$xpart')"
\

After that, thinks work well.


Thanks Mestan



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] Missing "E'" in pltcl_loadmod

From
Tom Lane
Date:
mestan@dix.cz writes:
> in lates version script pltcl_loadmod missed E' in insert
> command. Resul is, that module loading not work alt all. Yes,
> module is loaded, but loaded code is maformed.

This is clearly a bug of long standing, but I do not think the patch
you propose is adequate --- there are a lot of places where those
scripts would need 'E' added in order to be safe.

Seeing that this has evidently been broken for more than five years
and nobody has noticed, I'm inclined to think that nobody is using
the PL/Tcl "modules" support at all, and we should remove it rather
than spend effort to fix it.  I've proposed that to pgsql-hackers at
https://www.postgresql.org/message-id/22067.1488046447@sss.pgh.pa.us

If you think that's a bad answer, please follow up in that thread
and explain why you think we should keep this code.

            regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs