[GENERAL] Select Command in Procedures

2011-02-03 Thread Adarsh Sharma
Dear all, I am able to execute command successfully through CLI or pgAdmin . *create table user_news_new as select record_id,field_name,field_value,news_date from user_news where field_name in ('SOI','RelLoc','Description','Heading','news_date') and field_value != '' ; * But I don't know wh

[GENERAL] Encoding Conversion

2011-02-03 Thread Wilton Wonrath
Hi, When I´m doing a conversion PostgreSQL returns SCAPES to me besides the desire caracter. Why ? Using Postgresql 8.2: SELECT CONVERT('Rejeição: Duplicidade de NF-e, com diferença na Chave de Acesso [35110100608804000178550010001009471840996034]','UTF8','LATIN1') Result: "Rejeição: Du

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread Thom Brown
On 1 February 2011 23:08, Thom Brown wrote: > On 1 February 2011 21:32, Alban Hertroys > wrote: >> On 1 Feb 2011, at 21:26, Thom Brown wrote: >> >>> On 1 February 2011 01:05, Tom Lane wrote: Thom Brown writes: > I've noticed that if I try to use generate_series to include the upper >>>

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread Thom Brown
On 3 February 2011 11:31, Thom Brown wrote: > On 1 February 2011 23:08, Thom Brown wrote: >> On 1 February 2011 21:32, Alban Hertroys >> wrote: >>> On 1 Feb 2011, at 21:26, Thom Brown wrote: >>> On 1 February 2011 01:05, Tom Lane wrote: > Thom Brown writes: >> I've noticed that if

Re: [GENERAL] Select Command in Procedures

2011-02-03 Thread hubert depesz lubaczewski
On Thu, Feb 03, 2011 at 02:26:10PM +0530, Adarsh Sharma wrote: > globe=# CREATE FUNCTION user10() RETURNS void AS' > globe'# DECLARE > globe'# BEGIN > globe'# create table user_news_new as select > record_id,field_name,field_value,news_date from user_news where > field_name in ('SOI','RelLoc','Desc

Re: [GENERAL] Problem with encode () and hmac() in pgcrypto

2011-02-03 Thread hlcborg
Hi For now, I already can use in my PG database the PL/Python to create functions. But I need a library that can do the: > Plain SHA1, which is signed with RSA signature. Do you known any PL/Python wrapper libraries around OpenSSL (or any other crypto library) that I could use. I have found s

[GENERAL] win Locales - "Arabic, Gum"

2011-02-03 Thread Jasen Betts
What's the deal with locale codes on windows. especially the settings like LC_NUMERIC ansd LC_MONETARY on windows XP in 9.0 "show LC_MONETARY" displays them as "Arabic, Bharain" or "English, UK", "French, Canada" but everything right of the comma seems to be ignored. (resulting in incorrect cur

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread Thom Brown
On 3 February 2011 11:34, Thom Brown wrote: > On 3 February 2011 11:31, Thom Brown wrote: >> On 1 February 2011 23:08, Thom Brown wrote: >>> On 1 February 2011 21:32, Alban Hertroys >>> wrote: On 1 Feb 2011, at 21:26, Thom Brown wrote: > On 1 February 2011 01:05, Tom Lane wrote:

Re: [GENERAL] Database Design Question

2011-02-03 Thread Sim Zacks
Just trying to understand good DBA design practice. This is obviously a very general question but any feedback on what good or bad issues would come from me dumping all my tables for applications in one database or spread out across multiple databases on PostgreSQL. Thank you! As a general rule

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread Thom Brown
On 3 February 2011 13:32, Thom Brown wrote: > Actually, further testing indicates this causes other problems: > > postgres=# SELECT x FROM generate_series(1, 9,-1) AS a(x); >  x > --- >  1 > (1 row) > > Should return no rows. > > postgres=# SELECT x FROM generate_series(1, 9,3) AS a(x); >  x > ---

Re: [GENERAL] Problem with encode () and hmac() in pgcrypto

2011-02-03 Thread Marko Kreen
On Thu, Feb 3, 2011 at 2:38 PM, hlcborg wrote: > For now, I already can use in my PG database the PL/Python to create > functions. > But I need a library that  can do the: >> Plain SHA1, which is signed with RSA signature. > > Do you known any PL/Python wrapper libraries > around OpenSSL (or any o

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread David Johnston
The proposed generate_series(1,9,-1) behavior seems unusual. I think it should throw a warning if the step direction and the start-end directions do not match. Alternatively, the series generated could go from 9 -> 1 instead of returning an empty series (basically the first two arguments are simp

[GENERAL] PostgreSQL For Beginners

2011-02-03 Thread Kenneth Buckler
One of the programmers I work with is interested in migrating from Oracle to PostgreSQL as the backend for his applications. Is there a PostgreSQL "beginners" guide available somewhere, which might help him understand setting up a test database on his Windows system? I may also be performing a 30

Re: [GENERAL] Issues with generate_series using integer boundaries

2011-02-03 Thread Thom Brown
On 3 February 2011 14:37, David Johnston wrote: > The proposed generate_series(1,9,-1) behavior seems unusual. I haven't proposed this behaviour as it already occurs. I just include it for testing to ensure no other part of generate series is affected by such changes. Whether or not that is des

Re: [GENERAL] Database Design Question

2011-02-03 Thread Carlos Mennens
Thanks for all the suggestions and everyone appears to agree that if the applications don't need to share data, then I should split them up into separate database and nothing more. I appreciate your input and explanations as well. -Carlos -- Sent via pgsql-general mailing list (pgsql-general@po

Re: [GENERAL] PostgreSQL For Beginners

2011-02-03 Thread Andy Colson
On 2/3/2011 8:40 AM, Kenneth Buckler wrote: One of the programmers I work with is interested in migrating from Oracle to PostgreSQL as the backend for his applications. Is there a PostgreSQL "beginners" guide available somewhere, which might help him understand setting up a test database on his

Re: [GENERAL] set theory question

2011-02-03 Thread Andy Colson
On 2/2/2011 4:58 PM, matty jones wrote: I am looking for a good book on the math and/or theory behind relational databases and associated topics.. I am looking some works on set theory, algebra, or any other books/papers on the mechanics that databases are built on. I found one book online, htt

Re: [GENERAL] Why does a normally fast query run so slow when the table is in a partition?

2011-02-03 Thread Bill Thoen
Got it solved! The problem was one of two things,or maybe both. I had somehow gotten over 15 million records into the master table and even though I "deleted" them and run VACUUM ANALYZE over the table, they were still taking up space in the table. Perhaps even just opening a table with that

Re: [GENERAL] PostgreSQL For Beginners

2011-02-03 Thread Andy Colson
On 2/3/2011 9:31 AM, Kenneth Buckler wrote: I'm probably going to be presenting to a mixed audience, some of the developers will have extensive Oracle knowledge, some will have MS SQL Server experience. Plus, I'm not extremely familiar with Oracle, so trying to compare the two would not work wel

Re: [GENERAL] set theory question

2011-02-03 Thread Rich Shepard
On Thu, 3 Feb 2011, Andy Colson wrote: I am looking for a good book on the math and/or theory behind relational databases and associated topics. Dont know any books, but have you read the wikipedia page? Try any book by Edgar F. Codd. While at IBM he developed the concept of relational da

Re: [GENERAL] effective_io_concurrency

2011-02-03 Thread Greg Smith
Yves Weißig wrote: I was wondering if there is more information about this switch in the configuration. Does it really work? Where in the source code can I follow how it works? "sgmgr.c" seems to be an entry point, but where exactly is it used? Currently the code only kicks in when you're do

Re: [GENERAL] PostgreSQL For Beginners

2011-02-03 Thread rick chu
I think an intro presentation for Oracle developers should include: -- sqlplus to psql comparison -- how to setup OS authenticated users in PostgreSQL -- purpose of pg_hba.conf -- schemas and search_path. -- where to find things in the catalog. information_schema or pg_tables Rick

Re: [GENERAL] Why does a normally fast query run so slow when the table is in a partition?

2011-02-03 Thread Steve Crawford
On 02/03/2011 07:29 AM, Bill Thoen wrote: Got it solved! Great. The problem was one of two things,or maybe both. I had somehow gotten over 15 million records into the master table and even though I "deleted" them and run VACUUM ANALYZE over the table, they were still taking up space in the t

Re: [GENERAL] Encoding Conversion

2011-02-03 Thread Tom Lane
Wilton Wonrath writes: > When I´m doing a conversion PostgreSQL returns SCAPES to me besides the > desire > caracter. Why ? Somewhere between 8.2 and 9.0 convert() was redefined to take and return bytea, not text, to reflect the fact that the data it deals in isn't necessarily encoded in the da

[GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Bob Price
I have been searching through the docs and mailing list and haven't found a way to do this, so I thought I would ask the community. I would like to know if there is a way in PostgreSQL to avoid repeating an expensive computation in a SELECT where the result is needed both as a returned value an

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Bill Moran
In response to Bob Price : > I have been searching through the docs and mailing list and haven't found a > way to do this, so I thought I would ask the community. > > I would like to know if there is a way in PostgreSQL to avoid repeating an > expensive computation in a SELECT where the result

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread David Johnston
Is using a pl/pgsql function a viable option. Within or without the use of a function you can create a temporary table to hold the needed intermediate results. You can even use a permanent working table and write functions to perform the needed queries against it. Especially for expensive calcul

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Tom Lane
Bob Price writes: > I would like to know if there is a way in PostgreSQL to avoid repeating an > expensive computation in a SELECT where the result is needed both as a > returned value and as an expression in the WHERE clause. Use a subselect. You might need OFFSET 0 to prevent the planner fro

Re: [GENERAL] set theory question

2011-02-03 Thread Wappler, Robert
On 2011-02-02, matty jones wrote: > I am looking for a good book on the math and/or theory behind > relational databases and associated topics.. I am looking > some works on set theory, algebra, or any other books/papers > on the mechanics that databases are built on. I found one > book online,

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Pavel Stehule
Hello 2011/2/3 Tom Lane : > Bob Price writes: >> I would like to know if there is a way in PostgreSQL to avoid repeating an >> expensive computation in a SELECT where the result is needed both as a >> returned value and as an expression in the WHERE clause. > > Use a subselect.  You might need

Re: [GENERAL] upgrade

2011-02-03 Thread Alan Hodgson
On February 2, 2011, "William Bruton" wrote: > How do I know which version to upgrade to from 8.1.4? > Well, 8.1 is no longer supported, it seems. So an upgrade to any supported version will likely require application changes, or at least thorough testing. You might as well go right to 9.0.3 t

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread Mage
On 02/03/2011 08:13 AM, Alban Hertroys wrote: On 3 Feb 2011, at 2:17, Mage wrote: The trigger looks like: create or replace function trf_chat_room_users_insert() returns trigger as $$ begin if NEW.active_at is null then insert into chat_room_users (user_id, chat_room_id

Re: [GENERAL] upgrade

2011-02-03 Thread Scott Marlowe
On Thu, Feb 3, 2011 at 11:50 AM, Alan Hodgson wrote: > On February 2, 2011, "William Bruton" wrote: > >> How do I know which version to upgrade to from 8.1.4? > >> > > Well, 8.1 is no longer supported, it seems. So an upgrade to any supported > version will likely require application changes, or

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread Tom Lane
Mage writes: > The main question is that isn't "insert into ... select ... where not > exists" atomic? No, it isn't: it *will* fail in the presence of other transactions doing the same thing, because the EXISTS test will only see rows that committed before the command started. You might care to

[GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Bob Price
I have been searching through the docs and mailing list and haven't found a way to do this, so I thought I would ask the community. I would like to know if there is a way in PostgreSQL to avoid repeating an expensive computation in a SELECT where the result is needed both as a returned value an

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Bob Price
Thanks for all of the responses. If the IMMUTABLE flag on a function does what the docs say then it might satisfy my needs. Here is a more specific example of what I need to do, with a new custom data type and a new function: - define new complex data type X - create table mytable ( id varchar

[GENERAL] Tip: Transposing rows using generate_series()

2011-02-03 Thread Alban Hertroys
Hi all, The recent discussion about generate_series() made me realise you can use it to transpose rows; meaning you can turn columns of each row into separate rows. Here's an example: CREATE TABLE foobarbaz( foo text, bar text, baz int ); INSERT INTO foobarbaz (foo, bar, baz) VALUES ('Foo', 'B

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread pasman pasmański
Your trigger is wrong. You try to insert the same row twice. -- 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] Tip: Transposing rows using generate_series()

2011-02-03 Thread pasman pasmański
Look at unnest function. -- 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] how to avoid repeating expensive computation in select

2011-02-03 Thread Nicklas Avén
That's interesting Tom. This is a discussion coming up sometimes at PostGIS lists since PostGIS often handles "expensive" calculations. Regina wrote a blog post about it: http://postgresonline.com/journal/archives/113-How-to-force-PostgreSQL-to-use-a-pre-calculated-value.html I thought the "off

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Tom Lane
Bob Price writes: > If I set the COST of expensivefunc high, and label it IMMUTABLE, will the > query executor note that the two invocations to expensivefunc have the same > inputs so it can only call it once and re-use the result the second time? No. There is a myth prevalent among certain wi

Re: [GENERAL] how to avoid repeating expensive computation in select

2011-02-03 Thread Tom Lane
Nicklas =?ISO-8859-1?Q?Av=E9n?= writes: > I thought the "offset 0" trick was just a dirty hack, but coming from > you, Tom, I assume it is a robust way of doing it. Well, I can't deny it's a dirty hack ... but it's not something we'll break until we have a better solution. > I also tried some of

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread Mage
On 02/03/2011 10:35 PM, pasman pasmański wrote: Your trigger is wrong. You try to insert the same row twice. I assume you didn't try it. If active_at field is null then the trigger does another insert instead of the original one. This avoids looping or inserting twice. The only mistake is th

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread Mage
On 02/03/2011 08:23 PM, Tom Lane wrote: Mage writes: The main question is that isn't "insert into ... select ... where not exists" atomic? No, it isn't: it *will* fail in the presence of other transactions doing the same thing, because the EXISTS test will only see rows that committed before t

[GENERAL] tuning postgresql writes to disk

2011-02-03 Thread Vinubalaji Gopal
Hi,   I was wondering if Postgresql can be tuned such that it writes to disk every n seconds or until the buffer reaches a certain threshold to tune the performance . This is a special case where the application wouldn't care if there is a data loss of 1 seconds or less. I would be interested  to k

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread Tom Lane
Mage writes: > On 02/03/2011 08:23 PM, Tom Lane wrote: >> No, it isn't: it *will* fail in the presence of other transactions doing >> the same thing, because the EXISTS test will only see rows that >> committed before the command started. You might care to read the >> manual's chapter about concu

Re: [GENERAL] isn't "insert into where not exists" atomic?

2011-02-03 Thread pasman pasmański
Mage, add "raise notice" at the begin of your buggy trigger. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general