Thread: Few Simple Questions
HI how can i get user ip, who can only connect by tcp/ip , for example in plpgsql function . ?? how can declare and define my own variables in each connect to db, and read it / or change it in plpgsql function ? is possible to create this same name of users in one postmaster but in different db ? how to change default grant to created objects, (tables ,functions, etc) ? where can i change max length of function's name ? its can be only in one place ? how can i return more then 1 row in one time in function with SETOF same_type; (plpgsql) like : RETURN NEXT SELECT f FROM BIG_TABLE ; how to disallow user to create anything, user for example can select from same function. this user also can not see others databases and objects in actual db .. etc ( it should be default ?? ) ? how set default value of function's args. Can someone help me with this problems ? thx :> bye ivan
On Thursday 27 Feb 2003 8:05 pm, Ivan wrote: > HI > > how can i get user ip, who can only connect by tcp/ip , for example in > plpgsql function . ?? This has come up before - check the archives, I'm afraid I can't remember the solution. > how can declare and define my own variables in each connect to db, and > read it / or change it in plpgsql function ? You can't AFAIK - usual method is to store session variables in the application or in a session-table. > is possible to create this same name of users in one postmaster but in > different db ? Not AFAIK - users are for a cluster of databases, a whole installation. > how to change default grant to created objects, (tables ,functions, etc) ? Sorry, not sure what you mean here. > where can i change max length of function's name ? its can be only in one > place ? Don't know, but it will be in the source code and will probably affect all objects (you'll be redefining the "name" type I'd suspect). > how can i return more then 1 row in one time in function with SETOF > same_type; (plpgsql) like : RETURN NEXT SELECT f FROM BIG_TABLE ; Look up table functions in the 7.3 manuals, and on http://techdocs.postgresql.org - there are some good examples in techdocs. > how to disallow user to create anything, user for example can select from > same function. this user also can not see others databases and objects in > actual db .. etc ( it should be default ?? ) ? Not sure you can stop them seeing other objects. If a user can't read the system tables, they can't see anything. > how set default value of function's args. Well, this depends on the language you write the function in. It won't help much though, because PG's type matching doesn't allow you to leave out function arguments. if it's defined as f(int,int) then it needs two integers passed to it. HTH -- Richard Huxton
> > how can declare and define my own variables in each connect to db, and > > read it / or change it in plpgsql function ? You can do this, I believe, by creating a temporary table holding key/value pairs. Jon
On Fri, 28 Feb 2003, Jonathan Bartlett wrote: tru, bat its not very good idea, because there can be duplicate keys, or what with broken transmision ??? better will be something like SET .. ??? > > > how can declare and define my own variables in each connect to db, and > > > read it / or change it in plpgsql function ? > > You can do this, I believe, by creating a temporary table holding > key/value pairs. > > Jon > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
> tru, bat its not very good idea, because there can be duplicate keys, Create the temporary table with a primary key. > or what with broken transmision ??? How is that different than a normal session variable? > better will be something like SET .. ??? How would it be any different? You could wrap it with functions. create_session() set_variable('name', 'value') get_variable('name') Jon > > > > > how can declare and define my own variables in each connect to db, and > > > > read it / or change it in plpgsql function ? > > > > You can do this, I believe, by creating a temporary table holding > > key/value pairs. > > > > Jon > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > >
On Fri, 28 Feb 2003, Richard Huxton wrote: > On Thursday 27 Feb 2003 8:05 pm, Ivan wrote: > > HI > > > > how can i get user ip, who can only connect by tcp/ip , for example in > > plpgsql function . ?? > > This has come up before - check the archives, I'm afraid I can't remember the > solution. > Yes, i saw it, but there are no solution, "because not all connection can be throught tcp/ip" , but i asking about only tcp/ip transmisions .. ?? > > how can declare and define my own variables in each connect to db, and > > read it / or change it in plpgsql function ? > > You can't AFAIK - usual method is to store session variables in the > application or in a session-table. > > > is possible to create this same name of users in one postmaster but in > > different db ? > > Not AFAIK - users are for a cluster of databases, a whole installation. > > > how to change default grant to created objects, (tables ,functions, etc) ? > > Sorry, not sure what you mean here. > When i created same object like table , function , etc, pg give my object same default perms, like all to owner, for functions execute for all etc, how can i change it ? > > where can i change max length of function's name ? its can be only in one > > place ? > > Don't know, but it will be in the source code and will probably affect all > objects (you'll be redefining the "name" type I'd suspect). > i thing it will be somewhere same static table ( like in C progs.) and then should be only sizeof , bat im not sure , so i asking before starting search. > > how can i return more then 1 row in one time in function with SETOF > > same_type; (plpgsql) like : RETURN NEXT SELECT f FROM BIG_TABLE ; > > Look up table functions in the 7.3 manuals, and on > http://techdocs.postgresql.org - there are some good examples in techdocs. > i've already read man :( > > how to disallow user to create anything, user for example can select from > > same function. this user also can not see others databases and objects in > > actual db .. etc ( it should be default ?? ) ? > > Not sure you can stop them seeing other objects. If a user can't read the > system tables, they can't see anything. > because my simply one user can onle select from same tables , he cant updating , deleteing, etc, but he can do for example create table, :( > > how set default value of function's args. > > Well, this depends on the language you write the function in. It won't help > much though, because PG's type matching doesn't allow you to leave out > function arguments. if it's defined as f(int,int) then it needs two integers > passed to it. > :( > HTH > -- > Richard Huxton > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >