Thread: an idea, language SPI
Hello, I am thinking about reimplementation PL/pgPSM, where code should be shared with PL/pgSQL. I have idea of some middle language, that should be used for both languages. This language could be based on SPI interface with some procedural elements (if, jmp, return). sample create or replace function sum2(int, int) returns int as $$ spi_connect() qry = spi_prepare("select $1 + $2", 2, [23,23]) spi_execute_plan(qry, [$1,$2],N[$1,$2], true,1) RETURN sp_result[0,0] spi_finish() EXIT $$ language spi; what do you thing about it? regards Pavel Stehule
"Pavel Stehule" <pavel.stehule@gmail.com> writes: > I am thinking about reimplementation PL/pgPSM, where code should be > shared with PL/pgSQL. I have idea of some middle language, that should > be used for both languages. This language could be based on SPI > interface with some procedural elements (if, jmp, return). You mean exposed to the user? Why would anyone want that? By the time you had added enough features to it to be usable, you'd have plpgsql or equivalent. regards, tom lane
2009/1/5 Tom Lane <tgl@sss.pgh.pa.us>: > "Pavel Stehule" <pavel.stehule@gmail.com> writes: >> I am thinking about reimplementation PL/pgPSM, where code should be >> shared with PL/pgSQL. I have idea of some middle language, that should >> be used for both languages. This language could be based on SPI >> interface with some procedural elements (if, jmp, return). > > You mean exposed to the user? Why would anyone want that? yes, minimally it should work like decompiler and test environment for runtime. plpgsql and plpgpsm should be compiled to spi language, and this should be interpreted with spi interpret. I expect really general runtime, that should be used for any purposes - maybe for T-SQL, for some emulation layers. Current runtime is based on fat layer over SPI, where any optimizations are difficult. Next compiler should better generate code based on SPI or DirectFunctionCall interface. I am searching some p-code, for stored procedures, and this only idea, - to define this p-code near SPI. Pavel By the time > you had added enough features to it to be usable, you'd have plpgsql > or equivalent. > > regards, tom lane >