From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Subject: | plpgsql_check_function - implementation |
Date: | 2013-02-17 09:35:02 |
Message-ID: | CAFj8pRAKuJmVjPjzfSryE7+uB8jF8Wtz5rkxK-0ykXme-k81kA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
I try to play with different implementations of plpgsql deep checking.
The most important task of deep checking is creating plans for all
queries and expressions in function. The prerequisite for this task is
knowledge of data types of all variables. Record and row types is
break, but there is workaround - we are able to derive data types from
plans and we can assign with high success rate valid types to this
kind variables. We are not able to do with result of dynamic SQL and
temporary tables still - just we are not able to detect possible
errors for dynamic queries ever.
There are four possible implementations:
0) special recursive check routine + derivation data types from plans:
+ zero impact on current code, readability, - one other long recursive
routine
a) enhance parser + derivation data types from plans: + no new
recursive routine, - order of check depends on bison processing order,
result needs a final sort
b) enhance executor nodes + take data types from fake execution: +
relative less new code, - decrease readability of executor code, 20%
slowdown of CPU bottle neck code (new code is on critical path)
I tested code (this is a worst situation) - patch is in attachment (it
is WIP - just for test of impact new code to performance)
CREATE OR REPLACE FUNCTION public.test()
RETURNS integer
LANGUAGE plpgsql
IMMUTABLE
AS $function$
declare i int;
declare j int;
begin
i := 1;
while i < 10000 loop
j := 1;
while j < 1000 loop
j := j + 1;
end loop;
i := i + 1;
end loop;
return i;
end;
$function$
c) merge checking and dumping and derivation data from plans: + zero
impact on current code, readability, - some new code
my @0 works well, but was repeatedly rejected by Tom and Heikki, @a
needs final sort - so it needs more complex infrastructure for
creating result tuplestore, @b has mensurable performance impact
(from 9454 to 11274 ms), so there are only @c.
comments, notices?
Regards
Pavel
Attachment | Content-Type | Size |
---|---|---|
plpgsql_check_implementation.patch | application/octet-stream | 12.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Joachim Wieland | 2013-02-17 12:55:46 | posix_fadvise missing in the walsender |
Previous Message | Amit kapila | 2013-02-17 06:35:05 | Re: [PATCH] Add PQconninfoParseParams and PQconninfodefaultsMerge to libpq |