This patch makes a number of cleanups to PL/PgSQL:
- replaced all uses of malloc/strdup with palloc/pstrdup. Each PL/PgSQL
function now has its own memory context (stored in PLpgSQL_function).
All the compile-time storage for the function is allocated in this
memory context (including the FmgrInfo), so to reclaim that memory we
need only delete/reset the context. This means we can do away with
perm_fmgr_info(), and some other hackery.
(This was surprisingly easy, btw, so I am suspect that I've missed
something fundamental -- hence the patch is marked WIP. Guidance would
- Replaced the PLpgSQL_stmts and PLpgSQL_exceptions types with List.
This makes for more manageable code, and we get palloc'd storage for
free. On the other hand we lose compile-time type checking, but I think
it's a net win. This can be done in a few more places (e.g. PLpgSQL_ns),
but I think this is good enough for now.
- Remove some redundant code in plpgsql_compile(): there ought to be no
need to check that the plpgsql_HashTable is initialized, since that is
done in plpgsql_init_all() (which is always called before we reach
- Refactor some duplicated code in pl_exec.c for copying datum values;
instead create a function, copy_plpgsql_datum(), and call it when needed
- Made plpgsql_DumpExecTree a boolean, not an integer (since it was only
assigned 0 or 1)
- Made plpgsql_build_variable() copy its first argument. In practice,
practically every call site of plpgsql_build_variable() was doing a
strdup() to copy the first argument -- this way we can just do a single
pstrdup() in plpgsql_build_variable() itself.
- Fixed a few typos in comments, various other minor cleanups
pgsql-patches by date
|Next:||From: Neil Conway||Date: 2005-01-18 05:15:57|
|Subject: Re: transformExpr() refactor|
|Previous:||From: Alin Vaida||Date: 2005-01-18 00:51:15|
|Subject: Updated translation for Romanian (8.0)|