|
From: Robert T. <ro...@xz...> - 2014-02-21 15:30:20
|
Hi Bert,
Thanks for the contribution. Do you mind if I ask what OS / Editor you use?
Robert Treat
On Thu, Feb 20, 2014 at 9:49 AM, Bert Thomas <bt...@br...> wrote:
> Hi,
>
> My team and I use phpPgAdmin on a daily basis. One feature that lacked
> has always been very annoying. Today I decided to dive into it and
> patched it.
>
> The code that reads a function from the database only handles input
> parameters. This is because column proargtypes of pg_proc is used. This
> column only includes input and inout parameters. Even though all
> parameter names are available in the code, only the ones with a type are
> shown in the phpPgAdmin pages.
>
> pg_proc includes a column named 'proallargtypes' that includes the types
> for all parameters, but only in case outputparameters are used. When
> only inputparameters are available, this column contains a NULL value.
>
> First patch I made was a change to the getFunction() function in
> Postgres.php to include all types and the parameter 'modes' (in, out,
> inout, etc):
>
> function getFunction($function_oid) {
> $this->clean($function_oid);
>
> $sql = "
> SELECT
> pc.oid AS prooid, proname, pg_catalog.pg_get_userbyid(proowner)
> AS proowner,
> nspname as proschema, lanname as prolanguage, procost, prorows,
> pg_catalog.format_type(prorettype, NULL) as proresult, prosrc,
> probin, proretset, proisstrict, provolatile, prosecdef,
> pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments,
> proargnames AS proargnames,
> pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment,
> proconfig,
> (select array_agg( (select typname from pg_type pt where pt.oid
> = p.oid) ) from unnest(proallargtypes) p) proallarguments,
> proargmodes
> FROM
> pg_catalog.pg_proc pc, pg_catalog.pg_language pl,
> pg_catalog.pg_namespace pn
> WHERE
> pc.oid = '{$function_oid}'::oid AND pc.prolang = pl.oid
> AND pc.pronamespace = pn.oid
> ";
>
> return $this->selectSet($sql);
> }
>
> (replaced tab with 2 spaces for email readability)
>
> Then, in functions.php I updated the named parameter handling in doEdit
> and doProperties. The later uses a slightly other variable name, but the
> pattern is exactly the same:
>
> if ($data->hasNamedParams()) {
> if( isset($fndata->fields['proallarguments']) ) {
> $args_arr = $data->phpArray($fndata->fields['proallarguments']);
> } else {
> $args_arr = explode(', ', $fndata->fields['proarguments']);
> }
>
> $names_arr = $data->phpArray($fndata->fields['proargnames']);
> $modes_arr = $data->phpArray($fndata->fields['proargmodes']);
> $args = '';
> $i = 0;
> for ($i = 0; $i < sizeof($args_arr); $i++) {
> if ($i != 0) $args .= ', ';
> switch($modes_arr[$i]) {
> case 'i' : $args .= " IN "; break;
> case 'o' : $args .= " OUT "; break;
> case 'b' : $args .= " INOUT "; break;
> case 'v' : $args .= " VARIADIC "; break;
> case 't' : $args .= " TABLE "; break;
> }
> if (isset($names_arr[$i]) && $names_arr[$i] != '') {
> $data->fieldClean($names_arr[$i]);
> $args .= '"' . $names_arr[$i] . '" ';
> }
> $args .= $args_arr[$i];
> }
> }
>
> I don't understand git, it's too difficult for me. Therefore I post my
> patch this way.
>
> Regards,
> Bert
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> phpPgAdmin-devel mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/phppgadmin-devel
|