Re: [GENERAL] Output float number with hex format

2010-01-28 Thread A. Kretschmer
In response to Vincenzo Romano : > 2010/1/29 ?? : > > Hi! > > > > In C Language, there is a way to format float numbers into a hex string by > > using "%a" in printf. > > eg: > > the value: 1.2345 can be expressed as '0x1.3c083126e978dp+0' which is the > > hex representation of a float number.

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Pavel Stehule
2010/1/29 Pierre Chevalier : > Pavel Stehule claviota: >>> >>> Nut... Idea! (careful...) what about if we do, just like in a VIEW, a >>> CREATE >>> OR REPLACE, systematically when we do this kind of function? The only >>> drawback I can think of is that we can't have anything dependant on the >>> V

Re: [GENERAL] Output float number with hex format

2010-01-28 Thread Vincenzo Romano
2010/1/29 沈雷 : > Hi! > > In C Language, there is a way to format float numbers into a hex string by > using "%a" in printf. > eg: > the value: 1.2345 can be expressed as '0x1.3c083126e978dp+0' which is the > hex representation of a float number. > > I have tried this in Postgres: > SELECT '0x1.3c08

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Pierre Chevalier
Andy Colson claviota: ... > be happy to post a little "get you started" code if you wanted. here's some code, its based on Pavel's example, and dumps csv to stdout: Hmm, pretty cryptic to my eyes... Thanks for not writing everything on one line! #!/usr/bin/perl use strict; use warnings; use

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Pierre Chevalier
Andy Colson claviota: Ach! Too bad... Oh but... I used to program in C, long time ago, on HP-UX... How do you feel about a little perl? Hm, I am not too familiar with perl. That's the least I can say. But, after all, why not? It would be pretty simple, and could generate a csv Actually,

[GENERAL] Problem with query using ST_Dwithin

2010-01-28 Thread Nick
The following query's all work fine, select distinct zoa_metar_xml.stn_id, zoa_metar_xml.metar_txt, zoa_metar_xml.time, zoa_metar_xml.flt_cat, zoa_metar_xml.cld_cvr, zoa_metar_xml.cld_base, zoa_metar_xml.lonlat, zoa_metar_xml.geom from zoa_metar_xml; select distinct id, kml, type, min_hgt, max_hg

Re: [GENERAL] Problem with query using ST_Dwithin

2010-01-28 Thread Nick
On Jan 28, 4:32 pm, Nick wrote: > The following query's all work fine, > > select distinct zoa_metar_xml.stn_id, zoa_metar_xml.metar_txt, > zoa_metar_xml.time, zoa_metar_xml.flt_cat, zoa_metar_xml.cld_cvr, > zoa_metar_xml.cld_base, zoa_metar_xml.lonlat, zoa_metar_xml.geom from > zoa_metar_xml; > >

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Pierre Chevalier
Pavel Stehule claviota: Nut... Idea! (careful...) what about if we do, just like in a VIEW, a CREATE OR REPLACE, systematically when we do this kind of function? The only drawback I can think of is that we can't have anything dependant on the VIEW we generate. no, you cannot do it. You cann

[GENERAL] Output float number with hex format

2010-01-28 Thread 沈雷
Hi! In C Language, there is a way to format float numbers into a hex string by using "%a" in printf. eg: the value: 1.2345 can be expressed as '0x1.3c083126e978dp+0' which is the hex representation of a float number. I have tried this in Postgres: SELECT '0x1.3c083126e978dp+0'::float; float8 ---

[GENERAL] is this the correct result for ts_rewrite? reducing tsquery to improve performance?

2010-01-28 Thread Ivan Sergio Borgonovo
select ts_rewrite( to_tsquery('java:A & cola & java:AB'), 'java:AB'::tsquery, 'java:AB'::tsquery); ts_rewrite 'cola' & 'java':AB & 'java':AB Is this the expected (documented) result? I found this while looking for a way to build up a tsquery directly in it

Re: [GENERAL] how to update a view from a table

2010-01-28 Thread Craig Ringer
Vijay Sharma wrote: > How can i update all the fields of a view from a table(this is table > different from the table which has created the view)? > I don't want to specify the name of the columns in the commands > e.g i want to do something like this > > UPDATE any_view SET (SELECT * FROM any_vie

Re: [GENERAL] Problem after installing triggering function

2010-01-28 Thread Yan Cheng Cheok
To reproduce the problem, here is some simple steps to follow : (1) create database named "tutorial" (2) perform the following SQL query : CREATE TABLE impressions_by_day ( advertiser_id SERIAL NOT NULL, day DATE NOT NULL DEFAULT CURRENT_DATE, impressions INTEGER NOT NULL

Re: [GENERAL] Primary Key Increment Doesn't Seem Correct Under Table Partition

2010-01-28 Thread Yan Cheng Cheok
Sorry. I didn't get all your points. "defining a primary key constraint implicitly creates an index" - Yup. I agree on this. But what is the purpose, for author to explicitly define index for day? CREATE INDEX impressions_by_day_y2012m3ms2_day ON impressions_by_day_y2012m3ms2 (day); Isn't the

[GENERAL] how to update a view from a table

2010-01-28 Thread Vijay Sharma
How can i update all the fields of a view from a table(this is table different from the table which has created the view)? I don't want to specify the name of the columns in the commands e.g i want to do something like this UPDATE any_view SET (SELECT * FROM any_view) = (SELECT * FROM another_ta

Re: [GENERAL] Amazon EC2 CPU Utilization

2010-01-28 Thread Jeff Davis
On Thu, 2010-01-28 at 22:45 +, Mike Bresnahan wrote: > I can understand that I will not get as much performance out of a EC2 instance > as a dedicated server, but I don't understand why top(1) is showing 50% CPU > utilization. One possible cause is lock contention, but I don't know if that exp

[GENERAL] SET statement_timeout problem

2010-01-28 Thread Hardwick, Joe
I have a problem with fetching from cursors sometimes taking an extremely long time to run. I am attempting to use the statement_timeout parameter to limit the runtime on these. PostgreSQL 8.2.4 Linux 2.6.22.14-72.fc6 #1 SMP Wed Nov 21 13:44:07 EST 2007 i686 i686 i386 GNU/Linux begin; set searc

Re: [GENERAL] Amazon EC2 CPU Utilization

2010-01-28 Thread Mike Bresnahan
Greg Smith 2ndquadrant.com> writes: > Looks to me like you're running into a general memory bandwidth issue > here, possibly one that's made a bit worse by how pgbench works. It's a > somewhat funky workload Linux systems aren't always happy with, although > one of your tests had the right co

Re: [GENERAL] SQL question re aggregates & joins

2010-01-28 Thread Tom Lane
Scott Ribe writes: > Given that t2.id is the primary key, grouping by any other column of t2 is > really redundant. I know *what* SQL won't allow me to do, I'm interested in > knowing if there's some reason *why* other than historical... SQL92 says so. More recent versions of the SQL spec descri

Re: [GENERAL] SQL question re aggregates & joins

2010-01-28 Thread Dann Corbit
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Scott Ribe > Sent: Thursday, January 28, 2010 2:10 PM > To: Thom Brown > Cc: pgsql-general > Subject: Re: [GENERAL] SQL question re aggregates & joins > > > You can't

Re: [GENERAL] Is there a builtin function for formatting time values?

2010-01-28 Thread Adrian Klaver
On Thursday 28 January 2010 2:23:26 pm Frank Church wrote: > I have to this to extract formated times from timestamps, but I > suspect there is something much better, even if it uses a stored > procedure. The lpad command to is also funny because I have to > concatenate it with an empty quote to c

[GENERAL] Is there a builtin function for formatting time values?

2010-01-28 Thread Frank Church
I have to this to extract formated times from timestamps, but I suspect there is something much better, even if it uses a stored procedure. The lpad command to is also funny because I have to concatenate it with an empty quote to convert the output to a string. select lpad(extract(hour from calld

Re: [GENERAL] SQL question re aggregates & joins

2010-01-28 Thread Scott Ribe
> You can't include an aggregate in the select if you don't group by > non-aggregates, so it should be: > > select max(t1."When"), t1."Pt_Id", t2."DateOfBirth" > from "PtStaffAccess" t1, "Person" t2 > where t1."Pt_Id" = t2.id > group by t1."Pt_Id", t2."DateOfBirth"; I was aware that I could alter

Re: [GENERAL] Amazon EC2 CPU Utilization

2010-01-28 Thread Greg Smith
Mike Bresnahan wrote: I have deployed PostgresSQL 8.4.1 on a Fedora 9 c1.xlarge (8x1 cores) instance in the Amazon E2 Cloud. When I run pgbench in read-only mode (-S) on a small database, I am unable to peg the CPUs no matter how many clients I throw at it. In fact, the CPU utilization never drop

Re: [GENERAL] SQL question re aggregates & joins

2010-01-28 Thread Thom Brown
On 28 January 2010 21:32, Scott Ribe wrote: > OK, this does not work: > > select max(t1."When"), t1."Pt_Id", t2."DateOfBirth" > from "PtStaffAccess" t1, "Person" t2 > where t1."Pt_Id" = t2.id > group by t1."Pt_Id"; > > But this does: > > select max(t1."When"), t1."Pt_Id", min(t2."DateOfBirth") >

[GENERAL] SQL question re aggregates & joins

2010-01-28 Thread Scott Ribe
OK, this does not work: select max(t1."When"), t1."Pt_Id", t2."DateOfBirth" from "PtStaffAccess" t1, "Person" t2 where t1."Pt_Id" = t2.id group by t1."Pt_Id"; But this does: select max(t1."When"), t1."Pt_Id", min(t2."DateOfBirth") from "PtStaffAccess" t1, "Person" t2 where t1."Pt_Id" = t2.id gro

Re: [GENERAL] Amazon EC2 CPU Utilization

2010-01-28 Thread Mike Bresnahan
Jim Mlodgenski gmail.com> writes: > Let's start from the beginning. Have you tuned your postgresql.conf file? What do you have shared_buffers set to? That would have the biggest effect on a test like this.  shared_buffers = 128MB maintenance_work_mem = 256MB checkpoint_segments = 20 -- Sent v

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Joe Conway
On 01/28/2010 08:57 AM, Andy Colson wrote: >> >> How do you feel about a little perl? It would be pretty simple, and >> could generate a csv based on any resultset (any number of columns). I'd >> be happy to post a little get you started code if you wanted. If you're going to go through all that,

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Andy Colson
On 1/28/2010 9:11 AM, Andy Colson wrote: On 1/27/2010 3:49 AM, Pierre Chevalier wrote: Pavel Stehule claviota: ... But what I would like to do is to redirect the output of the function (that is, the 'result' cursor) to a view, which will be used in other places. I thought something like FETCH I

[GENERAL] emedded SQL in C to get the record type from plpgsql

2010-01-28 Thread 孙多忠
So how can emedded SQL in C to get the record type which returning from plpgsql function? I have tested as following code: CREATE OR REPLACE FUNCTION test4(IN a integer, OUT b int,OUT c int) AS $BODY$ Declare begin b:=100; c:=200; return; END $BODY$ LANGUAGE 'plpgsql' VOLATILE

[GENERAL] Add XATMI C API

2010-01-28 Thread Juergen Weber
Hi, an XATMI C API should be added to the PostgresQL C client, so one could run XA transactions under control of a TX monitor. An interesting usecase would be to use PostgresQL together with the LGPL open source JBoss Blacktie transaction manager (http://www.jboss.org/blacktie.html) c.f. http://

Re: [GENERAL] logtrigger/denyaccess triggers removed from master/slave

2010-01-28 Thread Tamanna
any other clue about this problem ?? Have anybody seen the same problem ?? Greg Stark-5 wrote: > > On Fri, Dec 18, 2009 at 6:59 PM, tamanna madaan > wrote: >> I am using postgres-8.1.2 and slony-1.1.5 for replication. >> > > I don't know about your Slony problems but the current bug-fix rele

Re: [GENERAL] query a table from one database to another

2010-01-28 Thread Joshua Tolley
On Thu, Jan 28, 2010 at 11:36:55AM +0600, AI Rumman wrote: >I am getting the error: > > >LINE 1: select dblink_connect('dbname=postgres'); > ^ >HINT: No function matches the given name an

Re: [GENERAL] Function nesting issue

2010-01-28 Thread Tom Lane
=?GB2312?B?1cW6o7fl?= writes: > And i call function a by jdbc: > ... > conn.setAutoCommit(false); > CallableStatement cs = conn.prepareCall("{ call a( ?, ? ) }"); > cs.registerOutParameter(1, Types.INTEGER); > cs.registerOutParameter(2, Types.OTHER); > cs.execute(); That's not the approved syntax

Re: [GENERAL] dynamic crosstab

2010-01-28 Thread Andy Colson
On 1/27/2010 3:49 AM, Pierre Chevalier wrote: Pavel Stehule claviota: ... But what I would like to do is to redirect the output of the function (that is, the 'result' cursor) to a view, which will be used in other places. I thought something like FETCH INTO would do the trick, but it doesn't.

Re: [GENERAL] Function nesting issue

2010-01-28 Thread 张海峰
Actually, the real function name is t_outer and t_inner, a and b is just for convenience. So you can see them as CREATE OR REPLACE FUNCTION a (out ... and CREATE OR REPLACE FUNCTION b (out ... And i call function a by jdbc: ... conn.setAutoCommit(false); CallableStatement cs = conn.prepareCall("{

[GENERAL] tsvector minimum match using index

2010-01-28 Thread Ivan Sergio Borgonovo
Would it be possible without writing a very long tsquery to exploit the index to retrieve the tsvectors that contain at least N lexemes? If not exploiting the index... any suggestion to improve performance of such a query? computing rank still requires retrieving a lot of tsvectors and compute th

Re: [GENERAL] Function nesting issue

2010-01-28 Thread Raymond O'Donnell
On 28/01/2010 07:32, 张海峰 wrote: > i have 2 functions, naming a and b, both outputing a resultset(cursor) > and a integer. > a calls b > > a: > CREATE OR REPLACE FUNCTION "public"."t_outer" (out o_rs > "pg_catalog"."refcursor", out o_i integer) RETURNS record AS > ... > select t_inner(o_rs, o_i); >

Re: [GENERAL] Primary Key Increment Doesn't Seem Correct Under Table Partition

2010-01-28 Thread Alban Hertroys
On 28 Jan 2010, at 2:10, Yan Cheng Cheok wrote: >>> EXECUTE 'CREATE TABLE ' || >> quote_ident(measurement_table_name) || ' >>> ( >>> CONSTRAINT >> pk_measurement_id_' || measurement_table_index || ' PRIMARY >> KEY (measurement_id), >>> CONSTRAINT >> fk_unit_id_'