enabling access from stored procedure to host variables
I am trying to join two different worlds - stored procedures (server side) and host environment (client side). Why? We have a good server side language - plpgsql, and we have good script environment - psql console. Console has own environment, but it is not accessible from plpgsql. I wrote two functions, that enables it:
postgres /home/pavel $ psql postgres -v myvar=hello psql (9.3devel) Type "help" for help. postgres=# \echo :myvar hello postgres=# do $$begin raise notice 'myvar=>>%<<', get_hostvar_text('myvar'); end; $$ language plpgsql; NOTICE: myvar=>>hello<< DO postgres=# do $$begin perform set_hostvar_text('myvar', 'hello world'); end $$ language plpgsql; DO postgres=# \echo :myvar hello worldThis is just concept without any optimization. It can be cached on server side, it can be better integrated to language.
5 Comments:
So what is the benefit of this? Honest question, curios how you intend to use this.
This comment has been removed by the author.
So, this will be in 9.3?
to Bob
A expected benefit is simplification of implementation of simple applications based on psql. Other possible benefit is emulation of 3G databases - you can do request to client for data inside stored procedure execution - similar functionality is SQL+
To Igor: No this is just proof concept and it will not be (probably in any future version in postgres), but this idea was not rejected
Post a Comment
Subscribe to Post Comments [Atom]
<< Home