PostgreSQL function data types -
how can names , data types of variables usedin in postgresql functions? going through prosrc column in pg_proc 1 way. there better 1 - view stores information in format can queried/filtered? postgresql version 9.0.
no, there no in-built way in postgresql this. function body stored text string without parsing out components. can - - parse variable names , data types out, requires serious parsing.
for pl/pgsql:
- read first word (i.e. first term separated white-space next term); if
declare
read on until wordbegin
. - read next word, name of variable.
- read until comma
,
(separating 1 variable another) or wordbegin
(end of variables), ignore commas inside parentheses()
these associated initialization of variable or data type modifier (suchnumeric(8, 2)
). data type, of it's modifiers , initialization. - from text read in previous step, extract
:=
. before data type , modifiers, after initial value. - repeat step 2 until encounter word
begin
.
there may nested blocks in single procedure, you'd have repeat procedure every block in body.
for other languages pl/perl, pl/tcl , pl/python you'd have parse variables according grammar. , there additional modules procedural languages, pl/r or pl/sh, yet again different grammar.
this not done simple reg_exp
in query, require more advanced logical processing.
Comments
Post a Comment