[SQL] execute system command from storage procedure
Hi there, Is it possible to execute a system command from a function ? (e.g. bash ) TIA, Sabin ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [SQL] execute system command from storage procedure
On Dec 6, 2007, at 10:32 AM, Sabin Coanda wrote: Hi there, Is it possible to execute a system command from a function ? (e.g. bash ) If you use one of the untrusted procedural languages (e.g. plperlu, plpythonu, ...) you can. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [SQL] execute system command from storage procedure
Sabin Coanda <[EMAIL PROTECTED]> schrieb: > Hi there, > > Is it possible to execute a system command from a function ? (e.g. bash ) Yes, of course, but you need an untrusted language like pl/perlU oder plsh. http://plsh.projects.postgresql.org/ Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly."(unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889° ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] polymorphic functions and domains
When I define two polymorpic functions, one taking varchar and one bytea, there seems to be no confusion choosing the varchar version when called with the untyped literal 'abc'. I really want two polymorphic functions, one taking a domain data type using varchar and one bytea. In that case, postgres complains that it cannot decide which one to use when called with the untyped literal 'abc'. I thought I might could force the domain varchar version to be chosen by casting the domain as varchar, but this does not help. The situation is explained in SQL below. Can someone help me get qtest('abc') to use the qtest(astring) function without having to explicitly cast 'abc'::astring; I'm using 8.2.5 and Linux.k Thanks, TJ O'Donnell www.gnova.com -- Drop Function ztest(Character Varying); Drop Function ztest(bytea); Drop Function qtest(astring); Drop Function qtest(Bytea); Drop Cast (astring as Character Varying); Drop Domain astring; Create Or Replace Function ztest(Character Varying) Returns Integer As $EOSQL$ Select length($1); $EOSQL$ Language SQL; Create Or Replace Function ztest(Bytea) Returns Integer As $EOSQL$ Select -(length($1)); $EOSQL$ Language SQL; Select ztest('abc'::Character Varying); -- worked as expected Select ztest('abc'::Bytea); -- worked as expected Select ztest('abc'); -- worked as expected Create Domain astring as Character Varying; Create Or Replace Function qtest(astring) Returns Integer As $EOSQL$ Select length($1); $EOSQL$ Language SQL; Create Or Replace Function qtest(Bytea) Returns Integer As $EOSQL$ Select -(length($1)); $EOSQL$ Language SQL; Select qtest('abc'::astring); -- worked as expected Select qtest('abc'::Bytea); -- worked as expected Select qtest('abc'); -- why did this not cause qtest(astring) to be chosen? Create Cast (astring As Character Varying) Without Function As Implicit; Select qtest('abc'); -- why did this not force qtest(astring) to be chosen? ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate
[SQL] Rule rewrite to possible union?
Here's what I'd like to happen, but I'm not seeing how it can be done. Say we have this simple table: CREATE TABLE foo ( id integer, foo varchar ); and then many tables along these lines: CREATE TABLE ud1_foo (LIKE foo); CREATE TABLE ud2_foo (LIKE foo); What I'd like is to do is select against foo and if there is an id in the where clause equal to 1 or 2 add a union with the appropriate table. I could easily do this at the application level, but this is for a migration (the ud tables are going away) and I'd like to minimize the number of transient application code changes wherever possible. Is there any way I can make this happen? Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [SQL] polymorphic functions and domains
"TJ O'Donnell" <[EMAIL PROTECTED]> writes: > I really want two polymorphic functions, one taking > a domain data type using varchar and one bytea. These aren't polymorphic functions, actually; they're just overloaded. > In that case, postgres complains that it cannot decide > which one to use when called with the > untyped literal 'abc'. Yeah, functions taking domains as arguments are problematic. I believe that with the current resolution rules, a function taking a domain can only "win" an ambiguous-function comparison if it's an exact match to the input types --- which in this case means you have to cast the literal to the domain type. There's been some talk of trying to rejigger the resolution rules to make them more friendly to functions that're declared to take domains, but no one's put forward any concrete proposal. It's not at all clear to me how to do it without introducing a lot of surprising behavior :-( regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match