Re: [GENERAL] PLPython function and multiple line insert

2009-06-06 Thread Igor Katson
Andi Klapper wrote: sql = "("INSERT INTO table1 (field1, field2, field3) VALUES ('abc', 'abc', TRUE), ('def', 'def', FALSE), ('ghi', 'ghi', TRUE");" pypl.execute(sql) . . $$ LANGUAGE 'plpythonu' VOLATILE I ran into trouble with quoting this

[GENERAL] Add a serial column to a table based on a sort clause

2009-09-02 Thread Igor Katson
I have a table, which has a creation_ts (timestamp) column, but does not have a id (serial) column. I want to add such a one, but, AFAIK, if I enter ALTER TABLE table ADD COLUMN id serial it will randomly put the sequence numbers. I wrote a function, which uses a cursor and UPDATE WHERE CURRENT

[GENERAL] pl/proxy and sequence generation

2008-12-24 Thread Igor Katson
n PL/Proxy to remove the sequence from the argument list and to call the sequence generator? Is there a better way to do that? Thanks in advance, Igor Katson. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.or

Re: [GENERAL] How can I display the contents of a function?

2009-01-19 Thread Igor Katson
Thom Brown wrote: I would like to see what's in a function. I can do this if I use pgAdmin III just by clicking on the function, and it appears in the SQL pane opposite. But how is this done? Is there a command like DESCRIBE FUNCTION logging.do_stuff; ? And if possible, doing this without

[GENERAL] How can I look at a recursive table dependency tree?

2009-01-19 Thread Igor Katson
I want to DROP CASCADE a table, but I am afraid that amoung numerous recursive dependencies there will be smth, that I don't want to drop. Is there a way to watch all dependencies recursively without doing a drop? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make cha

Re: [GENERAL] How can I display the contents of a function?

2009-01-19 Thread Igor Katson
Thom Brown wrote: I would like to see what's in a function. I can do this if I use pgAdmin III just by clicking on the function, and it appears in the SQL pane opposite. But how is this done? Is there a command like DESCRIBE FUNCTION logging.do_stuff; ? And if possible, doing this without

[GENERAL] Get object creation sql script in psql client

2009-01-20 Thread Igor Katson
Is there a way to get i.e. table creation sql script from an existing table in psql (not postgresql, but psql client), like it is in pgAdmin? I.e. i point it to existing table 'foo', and it writes: CREATE TABLE foo ( bar int ); -- Sent via pgsql-general mailing list (pgsql-general@postgresql.

Re: [GENERAL] Get object creation sql script in psql client

2009-01-20 Thread Igor Katson
Grzegorz Jaśkiewicz wrote: pg_dump -t foo database Thanks, but pg_dump is not psql client (i meant the */bin/psql interactive shell), and there is only an option for table objects, and no one for i.e. indices. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make ch

Re: [GENERAL] Get object creation sql script in psql client

2009-01-20 Thread Igor Katson
Grzegorz Jaśkiewicz wrote: pg_dump -t ANYOBJECT database afaik., try it - play with it. that does not work for indices. But the index creation is shown when placing it's parent table into -t. Thanks for the help, Grzegorz, the issue is solved. -- Sent via pgsql-general mailing list (pgsq

Re: [GENERAL] How can I look at a recursive table dependency tree?

2009-01-20 Thread Igor Katson
Richard Huxton wrote: Igor Katson wrote: I want to DROP CASCADE a table, but I am afraid that amoung numerous recursive dependencies there will be smth, that I don't want to drop. Is there a way to watch all dependencies recursively without doing a drop? BEGIN; DROP CA

[GENERAL] A complex plproxy query

2009-01-21 Thread Igor Katson
vidual, which are in a given group. That seems ok without plproxy, but with using it, I can't imagine how can I form a nice query, or a function (or a set of plpgsql + plproxy functions) to do the job. Thanks in advance and regards, Igor Katson. -- Sent via pgsql-general mailing list

Re: [GENERAL] [Plproxy-users] A complex plproxy query

2009-01-22 Thread Igor Katson
Hannu Krosing wrote: On Thu, 2009-01-22 at 02:33 +0300, Igor Katson wrote: So to say, give me the list of friends (not only their ID's, but all the needed columns!) of given individual, which are in a given group. That seems ok without plproxy, but with using it, I can't imagine

Re: [GENERAL] [Plproxy-users] A complex plproxy query

2009-01-22 Thread Igor Katson
Marko Kreen wrote: On 1/22/09, Igor Katson wrote: Hannu Krosing wrote: > On Thu, 2009-01-22 at 02:33 +0300, Igor Katson wrote: > > >> So to say, give me the list of friends (not only their ID's, but all the >> needed columns!) of given individual, which

Re: [GENERAL] [Plproxy-users] A complex plproxy query

2009-01-22 Thread Igor Katson
Hannu Krosing wrote: On Thu, 2009-01-22 at 15:10 +0300, Igor Katson wrote: Ok, thank you, guys. What is the best way to make an array out of a column? I didn't make up anything better then writing a function: CREATE OR REPLACE FUNCTION int_column_to_array(query text) RETURNS int[

Re: [GENERAL] [Plproxy-users] A complex plproxy query

2009-01-22 Thread Igor Katson
Hannu Krosing wrote: On Thu, 2009-01-22 at 16:13 +0200, Hannu Krosing wrote: On Thu, 2009-01-22 at 15:10 +0300, Igor Katson wrote: Ok, thank you, guys. What is the best way to make an array out of a column? I didn't make up anything better then writing a function: CREATE OR RE

[GENERAL] Using null or not null in function arguments

2009-01-23 Thread Igor Katson
statement will be removed, so if it was not written. I think, this is a common problem. Thanks in advance and regards, Igor Katson. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Using null or not null in function arguments

2009-01-23 Thread Igor Katson
Raymond O'Donnell wrote: On 23/01/2009 11:16, Igor Katson wrote: How do I write a function without complex logic, which will do: a) If the input argument is NULL, then the corresponding select statement will change from column = arg to column IS NULL You could build your stat

Re: [GENERAL] Using null or not null in function arguments

2009-01-23 Thread Igor Katson
Sam Mason wrote: On Fri, Jan 23, 2009 at 02:16:34PM +0300, Igor Katson wrote: a) If the input argument is NULL, then the corresponding select statement will change from column = arg to column IS NULL I think you want to use the IS [NOT] DISTINCT FROM operator. It works like the

Re: [GENERAL] Using null or not null in function arguments

2009-01-23 Thread Igor Katson
Michael Glaesemann wrote: On Jan 23, 2009, at 10:11 , Igor Katson wrote: That one is awesome, thanks, I completely forgot about CASE statement. The search func now looks as follows, and works perfectly: CREATE OR REPLACE FUNCTION isocial_user_func.search_users (i_city_id int, i_edu_id int

[GENERAL] Storing a result of a select in a variable

2009-01-23 Thread Igor Katson
FROM isocial_user_func.get_users_from_array(arr) a, >>friend_func.get_friends_short(i_user_id, limit_, offset_) b WHERE a.id = b.friend_id LOOP RETURN NEXT rec; END LOOP; RETURN; END; $$ language plpgsql; Regards, Ig

[GENERAL] Text search name and name synonims dictionary

2009-01-29 Thread Igor Katson
postgres' full-text search capabilities? 2. Does anyone know, if there is a Russian dictionary of these names? 3. What is the name of such kind of dictionary, to know, what to google for? Thanks in advance, and regards Igor Katson. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.or

Re: [GENERAL] Text search name and name synonims dictionary

2009-01-29 Thread Igor Katson
Oleg Bartunov wrote: On Thu, 29 Jan 2009, Igor Katson wrote: I have a column, containing the name of the user and there is a need to organize an indexed search on this column. As far as I understand, I need to use the full-text search capabilities of postgres. I would like to attach a

[GENERAL] Plproxy functions inside transactions and Pl/pgsql exception handling

2009-01-30 Thread Igor Katson
As far as I understand, it is a known problem of using plproxy, that it cannot be rolled back if used inside transactions. But I need something similar to this functionality. I have some data, that is duplicated across the DB partitions, and to be exact, there is i.e. a plproxy-partitioned DB,

[GENERAL] Re: [Plproxy-users] Plproxy functions inside transactions and Pl/pgsql exception handling

2009-01-30 Thread Igor Katson
Hannu Krosing wrote: On Fri, 2009-01-30 at 14:09 +0300, Igor Katson wrote: As far as I understand, it is a known problem of using plproxy, that it cannot be rolled back if used inside transactions. But I need something similar to this functionality. I have some data, that is duplicated

Re: [GENERAL] dict-xsyn converts word to synlist, what about backwards?

2009-02-03 Thread Igor Katson
Oleg Bartunov wrote: On Tue, 3 Feb 2009, Igor Katson wrote: On my question about doing a first name search by it's synonyms, like William Will Bill Billy James Jim Jimmy Oleg answered, that I can use dict_xsyn for that. In the dict_xsyn manual, it is said that: "This dicti

Re: [GENERAL] dict-xsyn converts word to synlist, what about backwards?

2009-02-03 Thread Igor Katson
Oleg Bartunov wrote: I contacted with author of dict_xsyn, so probably, he'll add option to support what you want. Thanks for cooperation, Oleg. By now, I will use that workaround. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http:/

[GENERAL] dict-xsyn converts word to synlist, what about backwards?

2009-02-03 Thread Igor Katson
On my question about doing a first name search by it's synonyms, like William Will Bill Billy James Jim Jimmy Oleg answered, that I can use dict_xsyn for that. In the dict_xsyn manual, it is said that: "This dictionary type replaces words with groups of their synonyms, and so makes it possibl

[GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-10 Thread Igor Katson
I am doing an ALTER TABLE to create a foreign key, however with some rows i get: insert or update on table "name" violates foreign key constraint "name_fkey" How can I just drop the conflicting rows while doing that? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-11 Thread Igor Katson
Craig Ringer wrote: Richard Huxton wrote: DELETE FROM table1 WHERE col1 NOT IN (SELECT id from table2); Just as a side note: If you have a large number of missing IDs and don't want to wait a long time, you may be better off with something like (untested, but I think it's right - TEST

[GENERAL] Two-phase commmit, plpgsql and plproxy

2009-02-11 Thread Igor Katson
I would like to call several plproxy functions one after another (which will call plpgsql functions in different target partitions), and in case one of them fails, i want to roll back changes in every one. That is exactly how two-phase-commit (2PC) should work. As far as I understand, the post

[GENERAL] Making a result of transaction visible to everyone, saving the ability for a rollback

2009-02-11 Thread Igor Katson
I need to execute a rather complex plpgsql function on a production server, the result of which is hard to test by myself. I want to make the result of a transaction, in which this function is executed, visible to the outer clients, but to have the ability of making a rollback in case one of t

Re: [GENERAL] Two-phase commmit, plpgsql and plproxy

2009-02-11 Thread Igor Katson
Jeff Davis wrote: On Wed, 2009-02-11 at 12:43 +0300, Igor Katson wrote: ERROR: XX000: SPI_execute_plan failed executing query "PREPARE TRANSACTION '2pctest'": SPI_ERROR_TRANSACTION It's probably treating the word PREPARE specially. You can avoid this pro

Re: [GENERAL] Two-phase commmit, plpgsql and plproxy

2009-02-11 Thread Igor Katson
Jeff Davis wrote: On Thu, 2009-02-12 at 00:57 +0300, Igor Katson wrote: Thanks, Jeff. That's not good news, cause I am not able to do that. There may be some creative solution, but I don't know plproxy well enough to suggest one. The postgres manual says, that &quo

[GENERAL] Accessing array elements in a FOR PL/pgsql loop

2009-02-19 Thread Igor Katson
For each element in the array, I need to make some operation with plpgsql. I usually use the syntax: DECLARE array_len int; BEGIN array_len := array_upper(i_array, 1); FOR i IN 1 .. array_len LOOP SOME OPERATION (i_array[i]) END LOOP; But I don't like that. Is there any built-in way to

Re: [GENERAL] Accessing array elements in a FOR PL/pgsql loop

2009-02-19 Thread Igor Katson
A. Kretschmer wrote: In response to Igor Katson : I think I need a built-in function to make a column from an array, like in the backwards operation SELECT ARRAY(column) By David Fetter: CREATE OR REPLACE FUNCTION unnest(ANYARRAY) RETURNS SETOF ANYELEMENT LANGUAGE SQL AS $$SELECT $1

[GENERAL] Parallel postgres client

2009-04-17 Thread Igor Katson
Is there any kind of a parallel psql client, to control a cluster of databases, without the need to write a plproxy function for each request? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-gene