Richard Broersma | 16 May 19:28
Picon

Pre-built binary packages of PostgreSQL 9.2 Beta

I've seen the following statement made several places.

"Pre-built binary packages of PostgreSQL 9.2 Beta are available from
the project's downloads page for Windows, Mac OS X, Linux, FreeBSD and
Solaris."

But I looking in the following links does not produce any results:

http://www.postgresql.org/download/
or
http://www.postgresql.org/download/windows/
or
http://www.enterprisedb.com/products-services-training/pgdownload#windows

Are we waiting for a refresh on the download page?

-- 
Regards,
Richard Broersma Jr.

--

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

John Townsend | 16 May 17:21
Favicon

Libpq question

It appears that some developers (Davart) are by-passing the standard 
client library, “libpq.dll”, and directly accessing the server using 
Delphi or FPC. I am not sure of the advantage here. All libpq.dll 
functions can be called from Delphi or FPC by simply using the following 
example pascal coding:
const

LIBPQ_PATH = 'C:\PG\libpq.dll'; // or wherever

type

PGconn = Pointer;
PPGresult = Pointer;

var
Conn: PGconn;
ResultSet: PPGresult;

function PQconnectdbParams(keywords, values: PChar; expand_dbname: 
integer): PGconn; cdecl;

external LIBPQ_PATH name 'PQconnectdbParams';

function PQconnectdb(conninfo: PChar): PGConn; cdecl;

external LIBPQ_PATH name 'PQconnectdb';

function PQsetdbLogin(Host, Port, Options, Tty, Db, User, Passwd: 
PChar): PGconn; cdecl;

(Continue reading)

Ajit Pradnyavant | 16 May 08:57
Picon

Query regarding Intersect clause

Sir,

I have created the following tables,

Create table abc (srno int, name varchar(32))
Create table def (srno int, name varchar(32))

    abc
srno	name
1	Aaaa
2	Bbbb

    def
srno	name
1	Aaaa
2	Cccc

each having two tuples.

If I run the following query I get the following result.
(Select name from abc) intersect (select name from def)

Srno	Name
1	Aaaa

If I run the following query I get the following result.
(Select name from abc) intersect all (select name from def)

Srno	Name
1	Aaaa
(Continue reading)

Gauthier, Dave | 16 May 15:54
Picon
Favicon

maybe incorrect regexp_replace behavior in v8.3.4 ?

Hi:

 

bi_hsx_a0_latest=# select regexp_replace('xxx','^xxx$','abc');

regexp_replace

----------------

abc

(1 row)

expected behavior because there's a match

 

 

bi_hsx_a0_latest=# select regexp_replace('xxx','^xxxy$','abc');

regexp_replace

----------------

xxx

(1 row)

expected because there is no match (the 'y' in 'xxxy')

 

 

 

bi_hsx_a0_latest=# select regexp_replace('xxx','^xxxy$',null);

regexp_replace

----------------

 

(1 row)

But why did it return null in this case?  I would think no match would leave it 'xxx'.

 

Thanks in Advance for any help and/or explanation.

 

 

salah jubeh | 16 May 15:20
Picon
Favicon

casting behavior of oids and relation names

Hello guys,

In some cases when I cast the oid to relation names ('xxxx'::regclass::text)  I get  schemaname.tablename and in some cases I just get tablename. I thought at the beginning, this is due name duplication of tables in different schemas but it seems not.  Also, this seems as a schema option because it happen only in certain schemas.  How I can get a consistent names of the casting ? 

Thanks in advance
Picon

missing pg_clog files after pg_upgrade


Hey all,

I have a problem which I speculate to be due to the pg_upgrade bug [1]:

ERROR: could not access status of transaction 13636
DETAIL: could not open file "pg_clog/0000": No such file or directory

The pg_clog directory contains files with names in the range from 004A
to 0105. 004A dates January 2012, 0105 is as of today. my version of
postgresql is 9.1.3-1PGDG.rhel6.x86_64 running on CentOS 6.2.
We pg_upgraded from 8.4.2 to 9.0.2 (Feb 2011) and then to 9.1.1 (Oct
2011). Unfortunately, I do not have backups of the pg_clog before
upgrading to 9.1. I immediately stopped the database when encountering
these errors above.

To me (naive) it looks like the pg_clog file names "wrapped around" and
now start to re-use from 0000 on (which does not exist). Is there any
chance I can fix this (and avoid data loss)? I did not apply the VACUUM
FREEZE fix suggested in [1] because I could not restore missing pg_clog
files. What can I do?

Thanks in advance,
Chris

[1]: http://wiki.postgresql.org/wiki/20110408pg_upgrade_fix

-- 
Christian J. Dietrich
Institute for Internet Security - if(is)
Westfaelische Hochschule University of Applied Sciences
https://www.internet-sicherheit.de

--

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

seiliki | 16 May 08:53
Picon
Favicon

Reserve one row for every distinct value in a column

Hi! I am trying to implement a mechanism to reserve the last row for every distinct value in column "c1".

CREATE TABLE table1 (c1	INTEGER,c2 INTEGER, PRIMARY KEY (c1,c2));

CREATE OR REPLACE FUNCTION keep1() RETURNS TRIGGER AS $$
BEGIN
	IF (SELECT COUNT(*) FROM table1 WHERE c1=OLD.c1) = 1 THEN
		RAISE EXCEPTION 'The last row for c1 = % must be kept!',OLD.c1;
	END IF;
	RETURN OLD;
END $$ LANGUAGE PLPGSQL STABLE;

CREATE TRIGGER test BEFORE DELETE ON table1 FOR EACH ROW EXECUTE PROCEDURE keep1();

INSERT INTO table1 VALUES (1,1),(1,2),(1,3);

With above rows inserted, my desired effect follows:

(1) allowed user operations:

DELETE FROM table1 WHERE c2 IN (1,2); /* Row (1,3) is still kept */

DELETE FROM table1 WHERE c2=2; DELETE FROM table1 WHERE c2=3; /* Row (1,1) is still kept */

DELETE FROM table1 WHERE c1=9; /* We have at least one row with c1=1 that is kept intact */

(2) disallowed user operations:

DELETE FROM table1 WHERE c1=1; /* Exception wanted. Every row for c1=1 would be deleted otherwise. */

DELETE FROM table1 WHERE c2 IN (1,2); DELETE FROM table1 WHERE c2=3; /* The second DELETE must raise
exception. */

The above trigger:

(1) It raises exception if table1 has only one row (1,1) and I delete it. This gives expected effect.

(2) When table1 contains 3 rows (1,1),(1,2),(1,3), then all of the following SQL yields unwanted result -
they do not raise exception and I can not figure out why the trigger is silenced:

DELETE FROM table1;
DELETE FROM table1 WHERE c1=1;
DELETE FROM table1 WHERE c2 IN (1,2,3);

Would someone please provide me some idea for a working implementation?

Thank you in advance!
CN

--

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

Evan Martin | 16 May 06:35

Slow queries when functions are inlined

I've run into a weird query performance problem. I have a large, complex 
query which joins the results of several set-returning functions with 
some tables and filters them by calling another function, which involves 
PostGIS calls (ST_DWithin). This used to run in about 10 seconds until I 
changed the functions to allow them to be inlined. (They previously had 
"SET search_path FROM current", which prevented inlining.) Now the query 
doesn't return in 10 minutes! If I again prevent the filtering function 
from being inlined (eg. by adding STRICT or SECURITY DEFINER or SET) the 
time goes down to 20 seconds. If I do the same to one of the 
set-returning functions it goes down to 15 seconds. It seems to change 
the query plan at the top level: without inlining it picks a Hash Join 
or Merge Join (fast), but with inlining it picks a Nested Loop (slow).

I can reproduce the problem with the following simplified test case, 
running on PostgreSQL 9.1.3 with PostGIS 2.0.0. (Couldn't get it to 
happen without PostGIS, unfortunately.)

CREATE EXTENSION postgis;

CREATE DOMAIN my_timestamp AS timestamp;

CREATE TABLE _test_pos (
     id serial,
     pos geography(Point,4326)
);

CREATE TABLE _test_time (
     id integer,
     some_time my_timestamp
);

-- Don't automatically run ANALYZE
ALTER TABLE _test_pos SET (autovacuum_enabled = false, 
toast.autovacuum_enabled = false);
ALTER TABLE _test_time SET (autovacuum_enabled = false, 
toast.autovacuum_enabled = false);

-- Insert some dummy data

WITH rand AS
(
     SELECT generate_series(1, 20000)::float / 1000 AS x
)

INSERT INTO _test_pos(pos)
SELECT ST_MakePoint(x, x)::geography
FROM rand;

INSERT INTO _test_time (id, some_time)
SELECT id, '2012-05-04'::my_timestamp
FROM _test_pos;

CREATE OR REPLACE FUNCTION __test_get_ids(some_time my_timestamp)
RETURNS SETOF _test_time
AS $BODY$
     SELECT *
     FROM _test_time
     WHERE some_time <= $1
$BODY$ LANGUAGE SQL STABLE;

CREATE OR REPLACE FUNCTION __test_points_are_near(p1 geography, p2 
geography)
RETURNS boolean AS
$BODY$
     SELECT ST_DWithin($1, $2, 300000) OR ST_DWithin($1, $2, 400000);
$BODY$ LANGUAGE SQL IMMUTABLE;

/*
-- It only becomes slow after analyzing
ANALYZE VERBOSE;
*/

/*
-- Delete all stats and it's fast again (must be user "postgres" for 
this to work)
DELETE FROM pg_statistic s
USING pg_class c
WHERE c.oid = s.starelid AND c.relname IN ('_test_time', '_test_pos');
*/

-- The prolematic query
with cte AS
(
     select id
     from __test_get_ids('2012-05-15'::my_timestamp)
     join _test_pos USING (id)
)
select id
from cte
join _test_pos USING (id)
where __test_points_are_near('POINT(7 7)', pos);

This query is initially fast (140 ms), but after running ANALYZE the 
query plan changes from Hash Join to Nested Loop and it takes 15000 ms. 
If I delete the table statistics  again it goes back to the fast plan. 
(This doesn't help on the original complex query, though.) If I mark 
__test_points_are_near as STRICT it uses the fast plan. If I remove one 
of the ST_DWithin calls it uses the fast plan. Even if I use the 
"timestamp" type directly instead of a domain it uses the fast plan. But 
with this exact combination of factors it uses the slow plan.

This is the "slow" plan (with inlining):

Nested Loop  (cost=1162.01..12106.68 rows=1 width=4)
   Join Filter: (cte.id = public._test_pos.id)
   CTE cte
     ->  Hash Join  (cost=442.34..1162.01 rows=6667 width=4)
           Hash Cond: (public._test_pos.id = _test_time.id)
           ->  Seq Scan on _test_pos  (cost=0.00..428.00 rows=20000 width=4)
           ->  Hash  (cost=359.00..359.00 rows=6667 width=4)
                 ->  Seq Scan on _test_time  (cost=0.00..359.00 
rows=6667 width=4)
                       Filter: ((some_time)::timestamp without time zone 
<= (('2012-05-15 00:00:00'::timestamp without time 
zone)::my_timestamp)::timestamp without time zone)
   ->  Seq Scan on _test_pos  (cost=0.00..10728.00 rows=1 width=4)
         Filter: 
((('0101000020E61000000000000000001C400000000000001C40'::geography && 
_st_expand(pos, 300000::double precision)) AND (pos && 
'0101000020E61000000000000000001C400000000000001C40'::geography) AND 
_st_dwithin('0101000020E61000000000000000001C400000000000001C40'::geography, 
pos, 300000::double precision, true)) OR 
(('0101000020E61000000000000000001C400000000000001C40'::geography && 
_st_expand(pos, 400000::double precision)) AND (pos && 
'0101000020E61000000000000000001C400000000000001C40'::geography) AND 
_st_dwithin('0101000020E61000000000000000001C400000000000001C40'::geography, 
pos, 400000::double precision, true)))
   ->  CTE Scan on cte  (cost=0.00..133.34 rows=6667 width=4)

This is the "fast" plan (without inlining):

Hash Join  (cost=6673.34..6903.91 rows=2222 width=4)
   Hash Cond: (cte.id = public._test_pos.id)
   CTE cte
     ->  Hash Join  (cost=442.34..1162.01 rows=6667 width=4)
           Hash Cond: (public._test_pos.id = _test_time.id)
           ->  Seq Scan on _test_pos  (cost=0.00..428.00 rows=20000 width=4)
           ->  Hash  (cost=359.00..359.00 rows=6667 width=4)
                 ->  Seq Scan on _test_time  (cost=0.00..359.00 
rows=6667 width=4)
                       Filter: ((some_time)::timestamp without time zone 
<= (('2012-05-15 00:00:00'::timestamp without time 
zone)::my_timestamp)::timestamp without time zone)
   ->  CTE Scan on cte  (cost=0.00..133.34 rows=6667 width=4)
   ->  Hash  (cost=5428.00..5428.00 rows=6667 width=4)
         ->  Seq Scan on _test_pos  (cost=0.00..5428.00 rows=6667 width=4)
               Filter: 
__test_points_are_near('0101000020E61000000000000000001C400000000000001C40'::geography, 
pos)

Can anyone figure out what is going on here and how I can work around 
this properly, ie. while still allowing functions to be inlined (which 
is good in other scenarios)?

Thanks,

Evan

--

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

Scott Briggs | 15 May 23:50
Picon

Naming conventions

So this is purely anecdotal but I'm curious, what's with all the
different naming conventions?  There's psql (for database
connections), pgsql (used for some dirs like /usr/pgsql-9.1 and this
mailing list), postgres (user and other references), and postgresql
(startup scripts).

Cheers,
Scott

--

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

Scott Briggs | 15 May 23:40
Picon

archive_command and streaming replication

Hi, can someone please explain the purpose of archive_command on both
the master and slave when it comes to streaming replication?  From
what I understand so far, what really matters is how many pg_xlog
files are kept when it comes to reestablishing replication when it
breaks for some reason.

Let's say I shutdown one slave to create a second slave by copying all
the files to that new slave.  If I want to guarantee that the original
slave is able to reestablish replication, I just need to make sure
that the master keeps enough pg_xlog files (defined by the setting
"checkpoint_segments") around in order for that to happen (especially
in the event that the database is large).

Thanks,
Scott

--

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

Robert James | 15 May 23:02
Picon

Disadvantage to CLUSTER?

Besides the one time spent CLUSTERing, do I loose anything by doing it
for every table?  Does a CLUSTER slow anything down?

It would seem to me that a) a CLUSTER should never have worse
performance than a random order b) may have better performance and c)
has the benefits of a VACUUM and REINDEX.  So, I may as well cluster
every table, if only by the primary key.

--

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


Gmane