Re: [GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) - additional

2008-07-21 Thread el dorado
 
 Hello.
 Thank you very much for your answer.
 I found an option Configuration Properties\C/C++/General/Detect 64-bit 
Portability Issues. It was set to 'Yes'. I made it 'No'.
 Now I don't get these warnings about 'type cast'.
 The result:
 1Compiling...
 1getstring.c
 1d:\pgsql83\getstring\c_getstring.c(10) : warning C4273: 'Pg_magic_func' : 
inconsistent dll linkage
 1d:\pgsql83\getstring\c_getstring.c(10) : see previous definition of 
'Pg_magic_func'
 1d:\pgsql83\getstring\c_getstring.c(24) : warning C4273: 
'pg_finfo_getTimeFromApplication' : inconsistent dll linkage
 1d:\pgsql83\getstring\c_getstring.c(24) : see previous definition of 
'pg_finfo_getTimeFromApplication'
 1Compiling manifest to resources...
 1Linking...
 1LINK : D:\pgsql83\c_getstring\Debug\getstring.dll not found or not built by 
the last incremental link; performing full link
 1   Creating library D:\pgsql83\getstring\Debug\getstring.lib and object 
D:\pgsql83\getstring\Debug\getstring.exp
 1Embedding manifest...
 1Build log was saved at 
file://d:\pgsql83\getstring\getstring\Debug\BuildLog.htm
 1c_synctime - 0 error(s), 2 warning(s)
 == Rebuild All: 1 succeeded, 0 failed, 0 skipped ==
 
 But the function doesn't work as well :(
ERROR:  invalid memory alloc request size 4294967293
 

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Fw: Re: [GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text'variable (WinXP) - additional

2008-07-21 Thread el dorado
Yes, I use a Microsoft Visual Studio compiler, but the full version - not 
Express Edition. Just in case I quote the code again ( it's short):

--
include postgres.h
#include fmgr.h
#include executor/executor.h 
#include utils/timestamp.h
#include utils/builtins.h
#include utils/formatting.h

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

#define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, 
CStringGetDatum(cstrp)))

PG_FUNCTION_INFO_V1(getTimeFromApplication);
Datum
getTimeFromApplication(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P(GET_TEXT(success));
}
--
Preprocessor definitions:WIN32;_DEBUG;_WINDOWS;_USRDLL;C_SYNCTIME_EXPORTS
Postgres 8.3.3 (standard binaries - so built by means of MSVC), WinXP SP2.
Error while using the function in PG - invalid memory alloc request size 
4294967293

It seems to me I must change some other options in Configuration Properties - 
but I can't guess what exactly...
Or maybe I should use Visual Studio 2005 Express Edition necessarily?

Redards, Marina.


 
 el dorado wrote:
   
   Hello.
   Thank you very much for your answer.
 
   1d:\pgsql83\getstring\c_getstring.c(10) : warning C4273: 'Pg_magic_func' 
  : inconsistent dll linkage
   1d:\pgsql83\getstring\c_getstring.c(10) : see previous definition 
  of 'Pg_magic_func'
 
 This should be a big red flag to you. It suggests that you have issues 
 with __declspec(dllimport) and __declspec(dllexport) annotations.
 
 It looks like you are using a Microsoft Visual Studio compiler. If you 
 are using Visual Studio 2005 Express Edition you must modify the 
 project's preprocessor definitions to set the WIN32 macro, as 2005 
 Express Edition does not do so by default. See earlier discussion in the 
 archives from a few months ago.
 
 Alternately, modify the definition of the default win32 project to set 
 the right macros, then create a new project.
 
 This issue does NOT affect the full version, only the Express edition. 
 It also does not affect 2008 Express Edition. I've just reproduced it on 
 a clean install of Windows and the Express Edition.
 
 --
 Craig Ringer
 

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Problems using Grails with Postgresql

2008-07-21 Thread priyaa

i am using postgresql instead of mysql ,but while execute i am getting error
like 


Caused by: org.codehaus.groovy.runtime.InvokerInvocationException:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not
execute query; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute query


my codings in datasource:


dataSource {
pooled = false

 driverClassName = org.postgresql.Driver
username =sa
password =
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
   
cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'

}
// environment specific settings
environments {
development {
dataSource {

dbCreate = update // one of 'create', 
'create-drop','update'
  url =jdbc:postgresql://localhost:5432/test
}
}
test {
dataSource {
dbCreate = update
url = jdbc:hsqldb:mem:testDb

}
}
production {
dataSource {
dbCreate = update
url = jdbc:hsqldb:file:prodDb;shutdown=true
   
}
}
}
pls help me to execute
-- 
View this message in context: 
http://www.nabble.com/Problems-using-Grails-with-Postgresql-tp18565587p18565587.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
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] question about performance

2008-07-21 Thread Torsten Zühlsdorff

A. Kretschmer schrieb:

if I have a table, the_table, with a DATE field, i'll call it 'day', and 
I'd like to find all rows whos day falls within a given month, which of the 
following methods is faster/costs less:


1.

SELECT * FROM the_table WHERE day LIKE '2008-01-%';

2.

SELECT * FROM the_table
WHERE ( day BETWEEN '$month_begin' AND '$month_end' );

# where $month_begin is '2008-01-01' and $month_end is '2008-01-31';


Probably the second one, but it depends if you have a propper index.

Other solution: create a functional index based on date_trunc and
rewrite your where-condition also.


Can you give an example?

Greetings,
Torsten

--
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] question about performance

2008-07-21 Thread A. Kretschmer
am  Mon, dem 21.07.2008, um  9:40:19 +0200 mailte Torsten Zühlsdorff folgendes:
 A. Kretschmer schrieb:
 
 if I have a table, the_table, with a DATE field, i'll call it 'day', and 
 I'd like to find all rows whos day falls within a given month, which of 
 the following methods is faster/costs less:
 
 1.
 
 SELECT * FROM the_table WHERE day LIKE '2008-01-%';
 
 2.
 
 SELECT * FROM the_table
 WHERE ( day BETWEEN '$month_begin' AND '$month_end' );
 
 # where $month_begin is '2008-01-01' and $month_end is '2008-01-31';
 
 Probably the second one, but it depends if you have a propper index.
 
 Other solution: create a functional index based on date_trunc and
 rewrite your where-condition also.
 
 Can you give an example?

Sure. For instance, i have a table called 'frachtschein', this table
contains a field 'ts', type timestamp. First, there are no index:

scholl=# explain analyse select * from frachtschein where 
date_trunc('month',ts::timestamp)='2008-02-01 00:00:00'::timestamp;
 QUERY PLAN
-
 Seq Scan on frachtschein  (cost=0.00..243.89 rows=29 width=84) (actual 
time=4.967..10.398 rows=524 loops=1)
   Filter: (date_trunc('month'::text, ts) = '2008-02-01 00:00:00'::timestamp 
without time zone)
 Total runtime: 11.468 ms
(3 rows)


Now i create a index:


scholl=*# create index idx_e on frachtschein(date_trunc('month',ts));
CREATE INDEX


The same select, using the index:


scholl=*# explain analyse select * from frachtschein where 
date_trunc('month',ts::timestamp)='2008-02-01 00:00:00'::timestamp;
QUERY PLAN
---
 Bitmap Heap Scan on frachtschein  (cost=2.10..76.12 rows=29 width=84) (actual 
time=0.336..1.570 rows=524 loops=1)
   Recheck Cond: (date_trunc('month'::text, ts) = '2008-02-01 
00:00:00'::timestamp without time zone)
   -  Bitmap Index Scan on idx_e  (cost=0.00..2.10 rows=29 width=0) (actual 
time=0.316..0.316 rows=524 loops=1)
 Index Cond: (date_trunc('month'::text, ts) = '2008-02-01 
00:00:00'::timestamp without time zone)
 Total runtime: 2.624 ms
(5 rows)




Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: - Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

-- 
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] Field size

2008-07-21 Thread hubert depesz lubaczewski
On Sun, Jul 20, 2008 at 05:50:30PM -0500, Martin wrote:
 Ok, this should be simple. How do I find the defined maximum
 length of a varchar field?

http://www.postgresql.org/docs/faqs.FAQ.html#item4.4

depesz

-- 
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] [Postgresql 8.2.3] autovacuum starting up even after disabling ?

2008-07-21 Thread Dushyanth
Hey,

  They are all under 200 million
 
 Weird 
 
 Could you fetch from pg_stat_activity the table it's processing, and its
 pg_class row and that of its toast table (if any)?

Sorry for the delay. Required details are at
http://pastebin.com/pastebin.php?dl=fd699fbb

Let me know if you need anything else.

TIA
Dushyanth





-- 
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] Problems using Grails with Postgresql

2008-07-21 Thread Richard Huxton

priyaa wrote:

i am using postgresql instead of mysql ,but while execute i am getting error
like 


Caused by: org.codehaus.groovy.runtime.InvokerInvocationException:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not
execute query; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute query


How about providing the error message from the PostgreSQL logs? This 
might mean something to a hibernate expert (although I doubt it), but it 
doesn't tell me anything.


Make sure you are logging statement errors and show us the error. You 
might want to log all statements while getting this to work, that would 
give you some context.


--
  Richard Huxton
  Archonet Ltd

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] How to remove duplicate lines but save one of the lines?

2008-07-21 Thread A B
I have a table with rows like this
A 1
A 1
B 3
B 3
C 44
C 44
and so on.

and I want it to be
A 1
B 3
C 44

so how can I remove the all the duplicate lines but one?

-- 
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread Raymond O'Donnell

On 21/07/2008 16:33, A B wrote:

I have a table with rows like this
A 1
A 1
B 3
B 3
C 44
C 44
and so on.

and I want it to be
A 1
B 3
C 44

so how can I remove the all the duplicate lines but one?


You could copy them into a new table, like so:

CREATE TABLE newtable AS
SELECT DISTINCT * FROM oldtable;


Ray.

--
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
[EMAIL PROTECTED]
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
--

--
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread Said Ramirez
There is probably a more elegant way of doing it, but  a simple way of 
doing it ( depending on the size of the table ) could be:


begin;

insert into foo select distinct * from orig_table;
delete from orig_table;
insert into orig_table select * from foo;

commit;

  -Said

A B wrote:

I have a table with rows like this
A 1
A 1
B 3
B 3
C 44
C 44
and so on.

and I want it to be
A 1
B 3
C 44

so how can I remove the all the duplicate lines but one?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




--
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread Francisco Reyes
On 11:33 am 07/21/08 A B [EMAIL PROTECTED] wrote:
 and I want it to be
 A 1
 B 3
 C 44

The slow way
select distinct field1, field2 from sometable.

The faster way
select field1,fields2 from sometable group by field1, field2.

Distinct should in theory be the same speed, but on several tests I have
done group by was faster. I posted a message to the list and there were
some explanations why group by was faster.. Hopefully someday they should
perform just as  efficiently.


-- 
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread A B
 There is probably a more elegant way of doing it, but  a simple way of doing
 it ( depending on the size of the table ) could be:

 begin;

 insert into foo select distinct * from orig_table;
 delete from orig_table;
 insert into orig_table select * from foo;

 commit;

Just to make it clear to me
Here foo is a table that I have to create  with the command
CREATE TABLE foo (same columns as orig_table);
?

Is it possible to add a unique constraint to the table, with a
delete option so it will delete duplicates?

-- 
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] Field size

2008-07-21 Thread Ludwig Kniprath
On Sun, Jul 20, 2008 at 05:50:30PM -0500, Martin wrote:
 Ok, this should be simple. How do I find the defined maximum
 length of a varchar field?

SELECT 
   character_maximum_length 
FROM 
   information_schema.columns
WHERE
   table_schema = 'name_of_your_schema' and 
   table_name = 'name_of_your_table' and 
   column_name = 'name_of_your_column'

bye...
Ludwig

-- 
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] Field size

2008-07-21 Thread Martin
hubert depesz lubaczewski [EMAIL PROTECTED] write:

 http://www.postgresql.org/docs/faqs.FAQ.html#item4.4

That's not what I'm looking for. I want the size limit defined
for the varchar field not the max size the database system can
handle, e.g. if the field is varchar(4) I want the 4.


-- 
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] Problems using Grails with Postgresql

2008-07-21 Thread Scott Marlowe
On Mon, Jul 21, 2008 at 5:00 AM, priyaa [EMAIL PROTECTED] wrote:

 i am using postgresql instead of mysql ,but while execute i am getting error
 like


 Caused by: org.codehaus.groovy.runtime.InvokerInvocationException:
 org.springframework.dao.InvalidDataAccessResourceUsageException: could not
 execute query; nested exception is
 org.hibernate.exception.SQLGrammarException: could not execute query


 my codings in datasource:


 dataSource {
pooled = false

 driverClassName = org.postgresql.Driver
username =sa
password =
 }
 hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true

 cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'

 }
 // environment specific settings
 environments {
development {
dataSource {

dbCreate = update // one of 'create', 
 'create-drop','update'
  url =jdbc:postgresql://localhost:5432/test
}
}
test {
dataSource {
dbCreate = update
url = jdbc:hsqldb:mem:testDb

}
}
production {
dataSource {
dbCreate = update
url = jdbc:hsqldb:file:prodDb;shutdown=true

Shouldn't that be a pgsql url not hsqldb right there?

It sounds like you're using the wrong db personality with hibernate.
You need hibernate to think in pgsql syntax for it to work right.

-- 
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread Said Ramirez
Yes, here foo is a temp table. As others have pointed out, you could 
probably do a create table foo as select distinct * from orig_table. I 
would move the data back to orig_table, so that constraints and 
privileges are maintainited. After you have done this, you can put a 
uniq constraint on columns A  B.  I am uncertain if you can do 
something like ALTER TABLE orig_table ADD UNIQUE (A,B) ON DUPLICATE DELETE.

  -Said

A B wrote:
  There is probably a more elegant way of doing it, but  a simple way 
of doing

  it ( depending on the size of the table ) could be:
 
  begin;
 
  insert into foo select distinct * from orig_table;
  delete from orig_table;
  insert into orig_table select * from foo;
 
  commit;

Just to make it clear to me
Here foo is a table that I have to create  with the command
CREATE TABLE foo (same columns as orig_table);
?

Is it possible to add a unique constraint to the table, with a
delete option so it will delete duplicates?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Said Ramirez
Super Cool MySQL DBA
cel: 732 425 1929

--
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread Scott Marlowe
On Mon, Jul 21, 2008 at 9:51 AM, A B [EMAIL PROTECTED] wrote:
 There is probably a more elegant way of doing it, but  a simple way of doing
 it ( depending on the size of the table ) could be:

 begin;

 insert into foo select distinct * from orig_table;
 delete from orig_table;
 insert into orig_table select * from foo;

 commit;

 Just to make it clear to me
 Here foo is a table that I have to create  with the command
 CREATE TABLE foo (same columns as orig_table);
 ?

If this is a live table with that you can't use that method on, you
can use this generic methodology to get rid of dups.


-- Create test table
smarlowe=# create table main (i int, t text);
CREATE TABLE
smarlowe=# insert into main values (1,'A');
INSERT 0 1
smarlowe=# insert into main values (1,'A');
INSERT 0 1
smarlowe=# insert into main values (3,'B');
INSERT 0 1
smarlowe=# insert into main values (3,'B');
INSERT 0 1
smarlowe=# insert into main values (44,'C');
INSERT 0 1
smarlowe=# insert into main values (44,'C');
INSERT 0 1
smarlowe=# select * from main;
 i  | t
+---
  1 | A
  1 | A
  3 | B
  3 | B
 44 | C
 44 | C
(6 rows)

Add a new field for an int, set it to a sequence of numbers:

smarlowe=# alter table main add uniq int;
ALTER TABLE
smarlowe=# create sequence t
smarlowe-# ;
CREATE SEQUENCE
smarlowe=# update main set uniq=nextval('t');
UPDATE 6
smarlowe=# select * from main;
 i  | t | uniq
+---+--
  1 | A |1
  1 | A |2
  3 | B |3
  3 | B |4
 44 | C |5
 44 | C |6
(6 rows)

This query will give us a list of extra ids:

smarlowe=# select distinct m1.uniq from main m1 join main m2 on
(m1.t=m2.t and m1.i=m2.i) where m1.uniq  m2.uniq;
 uniq
--
2
4
6
(3 rows)

We use that query as a subselect to a delete:

smarlowe=# begin;
BEGIN
smarlowe=# delete from main where uniq in (select m1.uniq from main m1
join main m2 on (m1.t=m2.t and m1.i=m2.i) where m1.uniq  m2.uniq);
DELETE 3
smarlowe=# select * from main;
 i  | t | uniq
+---+--
  1 | A |1
  3 | B |3
 44 | C |5
(3 rows)
smarlowe=# commit;
COMMIT

 Is it possible to add a unique constraint to the table, with a
 delete option so it will delete duplicates?

It is possible to add a unique constraint.  Having it delete rows
automagically is not normal operation, but I'm sure some kind of user
defined trigger could be written to do that.  But if you've got a
unique constraint on a unique set of data, new non-unique entries will
fail to enter.

smarlowe=# create unique index main_t_i on main (t,i);
CREATE INDEX
smarlowe=# insert into main (i,t) values (1,'A');
ERROR:  duplicate key violates unique constraint main_t_i

-- 
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 remove duplicate lines but save one of the lines?

2008-07-21 Thread btober

A B wrote:

I have a table with rows like this
A 1
A 1
B 3
B 3
C 44
C 44
and so on.

and I want it to be
A 1
B 3
C 44

so how can I remove the all the duplicate lines but one?



CREATE TEMP TABLE tmp AS SELECT DISTINCT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM tmp;



--
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] Calling Python functions with parameters

2008-07-21 Thread brian

Jerry McRae wrote:

I am having a problem with the simplest of Python functions, so I must be
doing something wrong.  After hours of searching and trying many options, I
need the key that my puny brain is missing here.

I cannot pass parameters to a plpythonu function.  I have tried within psql
and with pgAdmin III (which adds IN or INOUT to the parameter list - which I
can't find documented).  I'm an advanced Python programmer but a beginning
PostgreSQL user.

Here is what I have, which I copied almost verbatim from example code:

test_dev-# \p
create or replace function testf5i(a integer,b integer)
 RETURNS integer AS $$
  if a  b:
return a
  return b
$$ language plpythonu


test_dev-# \g
CREATE FUNCTION
test_dev=# select testf5i(1,2);
ERROR:  plpython: function testf5i failed
DETAIL:  exceptions.NameError: global name 'a' is not defined


That looks like the same error I received in my first attempts at 
plpython. After muddling with it for some time (and this  was my first 
practical Python code at all, so you can imagine how confused I was), I 
added (the equivalent to your code) at the beginning:


a = a
b = b

As ridiculous as that looks, it's what worked for me. Although, function 
contained a class with several methods (the function creates slugs on 
the fly from proper names for use in URLs, eg. Élisabeth Carrière - 
elisabeth_carriere). So, maybe my own problems were related to that. 
PlPython remains a mystery to me, in many respects. It's certainly *not* 
the best way to learn Python.



PS.  What I need to do, which I also could find not examples on the mailing
lists or the Internet, is to de-normalize some tables (user, addresses,
phones, emails) into one big view and then update the proper tables upon
updates.  The web application then can just get one row and not have to deal
with all the different tables

...

(And I'm surprised that I could find no examples of anyone already doing
this?  Is there something inherently wrong with this approach?)


Perhaps it's simply not worthwhile. That seems like a great deal of work 
just to avoid having to deal with several tables. (I didn't end up using 
my slug-creator function, myself, and moved that logic into the 
application scripts.)


b



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] COPY between 7.4.x and 8.3.x

2008-07-21 Thread Jack Orenstein

We have a set of 7.4.x databases, and will occasionally copy data between like 
so:

psql -h $SOURCE_HOST ... -c copy $SOURCE_SCHEMA.$SOURCE_TABLE to stdout |\
psql ... -c copy $TARGET_SCHEMA.$TARGET_TABLE from stdin

This is always run on the host containing the target table.

We will now be adding 8.3.x databases to the mix, and will need to copy between 
7.4.x and 8.3.x in both directions. The datatypes we use are:


- bigint
- bytea
- int
- timestamp with time zone
- varchar

Will our copying technique work between 7.4.x and 8.3.x databases in both 
directions?


What if we do a binary copy instead? (We're going to investigate BINARY to see 
if there is a performance improvement.)


Jack Orenstein

--
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] COPY between 7.4.x and 8.3.x

2008-07-21 Thread Francisco Reyes
On 4:05 pm 07/21/08 Jack Orenstein [EMAIL PROTECTED] wrote:
 We will now be adding 8.3.x databases to the mix, and will need to
 copy between 7.4.x and 8.3.x in both directions. The datatypes we use

I believe it should work.
Also, one feature I believe started in the 8.X line (8.2?), is the ability
to have a subquery in the copy command to refine what rows you are getting.

 What if we do a binary copy instead? 
What do you mean by a binary copy?
pg_dump -Fc?

I think a plain pg_dump and copy will likely be more portable. Specially
going from 8.3 to 7.4.

Why will you keep copying data back and forth?
Not possible to setup a new 8.3, migrate to it and then upgrade the other
7.4 machine to 8.3?


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] inconsistent program behavior, fresh eyes needed

2008-07-21 Thread Emil Pedersen


Hello list!

I'll try to keep this short, if any more info is needed just ask.

I have a program that is supposed to parse standard log files
and act on specific lines.
 It mostly does what it's supposed to, but if I run it a couple
of time, using the same input data, some of the results differ.

If someone could find out what is wrong with them I would be most
greatefull.  Due to the length (c version is ~230 lines, python
version ~130) I didn't know if it was ok to post them, so I've put
them and the test data on
   http://83.253.255.25/tmp/


[Some more background]

I wrote a python version with psycopg2 as glue to postgres and
this is where I noticed the behavior.  Since I couldn't spot the
error in my program but did find a bug ubuntu reports regarding
psycopg2 I suspected the debian version might be affected to and
asked on debian-python[1].

While trying to find out what was wrong I re-wrote the program in
c/libpq, and it still behaves the same way so the fault has to be
in my program.
 I don't know if I am using libpq in some wrong way (and I know
that the program is a mess), but I would expect the program to
produce the same result every time given its simplicity.

I have tested on two different computers,  one debian/etch i386
and one debian/etch amd64.  I've also tested with two different
versions os psycopg2 while trying to rule it out or prove it
broken.

[1] 
http://teams.debian.net/lurker/message/20080717.145350.2ba26912.en.html



Sincerely yours,
   Emil


--
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] COPY between 7.4.x and 8.3.x

2008-07-21 Thread Jack Orenstein

Francisco Reyes wrote:

On 4:05 pm 07/21/08 Jack Orenstein [EMAIL PROTECTED] wrote:


What if we do a binary copy instead? 

What do you mean by a binary copy?
pg_dump -Fc?


No, I mean changing this:

psql -h $SOURCE_HOST ... -c copy $SOURCE_SCHEMA.$SOURCE_TABLE to stdout |\
psql ... -c copy $TARGET_SCHEMA.$TARGET_TABLE from stdin

to this:

psql -h $SOURCE_HOST ... -c copy binary $SOURCE_SCHEMA.$SOURCE_TABLE to 
stdout |\

psql ... -c copy binary $TARGET_SCHEMA.$TARGET_TABLE from stdin



Why will you keep copying data back and forth?
Not possible to setup a new 8.3, migrate to it and then upgrade the other
7.4 machine to 8.3?


We're migrating a cluster from 7.4 to 8.3. To maintain availability, we need the 
7.4 and 8.3 databases up at the same time. We're copying data across versions 
for this reason.


Jack

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] ERROR: could not open relation with OID 49152

2008-07-21 Thread Scott Marlowe
OK, I'm getting the above error on one of my fairly new 8.3 production
databases.  It happens when I run a query to see the size of my
tables.

SELECT pg_relation_size(c.relfilenode), n.nspname AS schemaname,
c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner,
t.spcname AS tablespace, c.relhasindex AS hasindexes, c.relhasrules AS
hasrules, c.reltriggers  0 AS hastriggers
   FROM pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
  WHERE n.nspname = 'public';
ERROR:  could not open relation with OID 49152

If I run this query:

SELECT c.relfilenode, n.nspna... same as the above after this...

I get this:

 relfilenode | schemaname | tablename  | tableowner |
tablespace | hasindexes | hasrules | hastriggers
-++++++--+-
   49956 | public | paid_idx_pkey  | dgish  |
  | f  | f| f
   49958 | public | page_access_timestamp  | dgish  |
  | f  | f| f
   49152 | public | page_access| dgish  |
  | t  | f| f

and a few other lines editted out for brevity.

Any ideas what the cause of this is?  What part of my catalogs is borked?

Now, I can backup this db, and restore it with no errors, and the
error will go away.  Same query on the same dataset returns the right
number of rows and their size.

-- 
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] ERROR: could not open relation with OID 49152

2008-07-21 Thread Tom Lane
Scott Marlowe [EMAIL PROTECTED] writes:
 OK, I'm getting the above error on one of my fairly new 8.3 production
 databases.  It happens when I run a query to see the size of my
 tables.

 SELECT pg_relation_size(c.relfilenode),

Pretty sure that should be c.oid.

regards, tom lane

-- 
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] ERROR: could not open relation with OID 49152

2008-07-21 Thread Alvaro Herrera
Scott Marlowe escribió:
 OK, I'm getting the above error on one of my fairly new 8.3 production
 databases.  It happens when I run a query to see the size of my
 tables.
 
 SELECT pg_relation_size(c.relfilenode), n.nspname AS schemaname,
 c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner,
 t.spcname AS tablespace, c.relhasindex AS hasindexes, c.relhasrules AS
 hasrules, c.reltriggers  0 AS hastriggers
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
   WHERE n.nspname = 'public';
 ERROR:  could not open relation with OID 49152

Try pg_relation_size(c.oid) instead.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

-- 
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] ERROR: could not open relation with OID 49152

2008-07-21 Thread Scott Marlowe
On Mon, Jul 21, 2008 at 6:07 PM, Tom Lane [EMAIL PROTECTED] wrote:
 Scott Marlowe [EMAIL PROTECTED] writes:
 OK, I'm getting the above error on one of my fairly new 8.3 production
 databases.  It happens when I run a query to see the size of my
 tables.

 SELECT pg_relation_size(c.relfilenode),

 Pretty sure that should be c.oid.

Thanks.  I'll slink away now...

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general