[BUGS] Missing "E'" in pltcl_loadmod - Mailing list pgsql-bugs

From mestan@dix.cz
Subject [BUGS] Missing "E'" in pltcl_loadmod
Date
Msg-id alpine.DEB.2.11.1702251701030.3920@Sandal.Woodpecker
Whole thread Raw
Responses Re: [BUGS] Missing "E'" in pltcl_loadmod  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14568: timezone WIT is not support
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] Missing "E'" in pltcl_loadmod