Re: [GENERAL] Foreign keys and permissions oddity

2010-08-07 Thread Richard Huxton

On 07/08/10 01:13, Joshua Tolley wrote:

Is there some justification for this behavior that I should know already? It
seemed awfully strange when some folkds here stumbled on it:

[snip]

The key point seems to be that the owner of the referenced table has no
permissions on the table, although the referencing user does.


Presumably the underlying trigger functions are executing as the owner 
of the table. This would make sense in the (more common) case that you 
want to reference a table you don't necessarily have full read access 
for (e.g. member-id vs the whole row including address/phone).


You should be able to track the table's OID from pg_class through to 
tgrelid on pg_trigger and then tdfoid to the relevant OIDs in pg_proc. 
The functions are all named as RI_FKey_xxx.


Hmm - not sure if they execute as the table owner or the creator of the 
constraint. You could justify either, but of course they're frequently 
the same (as in your case).


--
  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


Re: [GENERAL] MySQL versus Postgres

2010-08-07 Thread Alban Hertroys
On 7 Aug 2010, at 5:19, Sandeep Srinivasa wrote:

 +1 on this.
 This is very interesting from the point-of-view of transitioning MySQL 
 webapps to Postgres. The truth is that for a lot of people, MySQL is their 
 first DB (because of loads of pre-existing software. Refer to my thread 
 Which CMS/Ecommerce/shopping cart). When we are ready to move to PG, we are 
 already used to the MySQL way of doing things.

Oh gosh, you make me remember my first MySQL experience! I had just started a 
small company that was starting their main project on a MySQL/PHP environment 
on Windows. We ran into some trouble with Windows IIRC and the sysadmin was 
happier running stuff on Linux too, so we switched our early code and database 
over to Linux. Turns out that in MySQL, going from a case-insensitive 
file-system to a case-sensitive one means that all your table names are now 
case-sensitive as well!

That, and the struggle getting MySQL to actually use InnoDB and relational 
integrity on tables instead of just claiming that it did, made it a really easy 
case for me to convince my colleagues and boss to switch to Postgres. They 
haven't looked back since.

That was back in the days of MySQL 4, but the scars it left are still there. 
That company has gone bankrupt in the meantime (core developers moved away), 
but I run into some of my old colleagues every now and then and they're almost 
all still doing their stuff on Postgres - or at least not on MySQL. One 
exception is the guy who has to use one of their real-time engines for 
telecommunication, where data-integrity apparently isn't considered critical.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4c5d30a7286211834955988!



-- 
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] MySQL versus Postgres

2010-08-07 Thread சிவகுமார் மா
2010/8/7 Alban Hertroys dal...@solfertje.student.utwente.nl:
 On 7 Aug 2010, at 5:19, Sandeep Srinivasa wrote:

 +1 on this.
 This is very interesting from the point-of-view of transitioning MySQL 
 webapps to Postgres. The truth is that for a lot of people, MySQL is their 
 first DB (because of loads of pre-existing software. Refer to my thread 
 Which CMS/Ecommerce/shopping cart). When we are ready to move to PG, we 
 are already used to the MySQL way of doing things.


As it was happening in the last 10 years, PostgreSQL will slowly
gather more acceptance and MySQL will reduce in popularity down the
years. But, we should help the process along.

1. Almost all webhosting providers have MySQL support, but PostgreSQL
support is available from only a few who also have MySQL support.
Hence MySQL is universal and PostgreSQL is present as also available.

2. Books.
In a book store (where I live), technical sections have SQL, SQL
Server, PHP and MySQL, Oracle racks. There is no PostgreSQL rack.

3. Name
It is difficult to bring up the name in conversation.

To break these circles:

1. Study a typical web hosting set up and work on supporting
everything (Wordpress, Drupal, OS Commerce) with PostgreSQL.
PostgreSQL only servers should be made possible.

2. Bring out more books

a. Documentation is already available (PostgreSQL User Manual,
PostgreSQL Technical Documentation). Re-package them and publish as
books targeting different user levels.

b. Cook Books can be created from the discussions in this mailing list.

c. More PHP+PostgreSQL books should be created. Professional PHP6
from Wrox uses PostgreSQL as the default db.

3. The default configuration settings for PostgreSQL are not optimal
for performance. Can there be a recommended configuration file in the
installation (assuming certain amount of RAM and processor type) ?

4. A pet name
Is it possible to have a pet name which can be used in casual
conversation easily?

Ma Sivakumar
http://masivakumar.blogspot.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] MySQL versus Postgres

2010-08-07 Thread David Boreham

On 8/7/2010 4:24 AM, சிவகுமார் மா wrote:


4. A pet name
Is it possible to have a pet name which can be used in casual
conversation easily?
   

PG



--
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] MySQL versus Postgres

2010-08-07 Thread Raymond O'Donnell

On 07/08/2010 11:24, சிவகுமார் மா wrote:

2010/8/7 Alban Hertroysdal...@solfertje.student.utwente.nl:

On 7 Aug 2010, at 5:19, Sandeep Srinivasa wrote:


+1 on this.
This is very interesting from the point-of-view of transitioning MySQL webapps to 
Postgres. The truth is that for a lot of people, MySQL is their first DB (because of 
loads of pre-existing software. Refer to my thread Which CMS/Ecommerce/shopping 
cart). When we are ready to move to PG, we are already used to the MySQL way of 
doing things.




As it was happening in the last 10 years, PostgreSQL will slowly
gather more acceptance and MySQL will reduce in popularity down the
years. But, we should help the process along.

1. Almost all webhosting providers have MySQL support, but PostgreSQL
support is available from only a few who also have MySQL support.
Hence MySQL is universal and PostgreSQL is present as also available.

2. Books.
In a book store (where I live), technical sections have SQL, SQL
Server, PHP and MySQL, Oracle racks. There is no PostgreSQL rack.

3. Name
It is difficult to bring up the name in conversation.

To break these circles:

1. Study a typical web hosting set up and work on supporting
everything (Wordpress, Drupal, OS Commerce) with PostgreSQL.
PostgreSQL only servers should be made possible.

2. Bring out more books

a. Documentation is already available (PostgreSQL User Manual,
PostgreSQL Technical Documentation). Re-package them and publish as
books targeting different user levels.

b. Cook Books can be created from the discussions in this mailing list.

c. More PHP+PostgreSQL books should be created.Professional PHP6
from Wrox uses PostgreSQL as the default db.


Yes, so does Pro PHP from Apress, though it doesn't mention PG on the 
cover. There was a nice warm glow of goes without saying... about it, 
as I remember. :-)



4. A pet name
Is it possible to have a pet name which can be used in casual
conversation easily?


Postgres or PG are the usual, AIUI.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
r...@iol.ie

--
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] Foreign keys and permissions oddity

2010-08-07 Thread Joshua Tolley
On Sat, Aug 07, 2010 at 08:34:12AM +0100, Richard Huxton wrote:
 On 07/08/10 01:13, Joshua Tolley wrote:
 Is there some justification for this behavior that I should know already? It
 seemed awfully strange when some folkds here stumbled on it:
 [snip]
 The key point seems to be that the owner of the referenced table has no
 permissions on the table, although the referencing user does.

 Presumably the underlying trigger functions are executing as the owner  
 of the table. This would make sense in the (more common) case that you  
 want to reference a table you don't necessarily have full read access  
 for (e.g. member-id vs the whole row including address/phone).

Yeah, that appears to be what's happening, based on the code. It's certainly
confusing to look at, and I'm not sure it couldn't be described a bug. I'll
continue to ponder that.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com


signature.asc
Description: Digital signature


Re: [GENERAL] MySQL versus Postgres

2010-08-07 Thread Martin Gainty

Ray--


I would like to see in postgres:
1)Clustering

2)a more user-friendly interface to packages

3)eliminate the requirement to create a postgres user to execute the server 
binaries..I guess i never understood that requirement 

 

I would like to see in MySQL:
A progression back to OpenSource ..i dont see Oracle championing 2 database 
products simultaneously

although under the same roof it would seem the engineering resources currently 
devoted to Oracle features could easily be re-factored to MySQL..

a prime example of a much needed requirement for MySQL ..When will MySQL 
implement row-level locking instead of just table-level locking?

Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.



 

 Date: Sat, 7 Aug 2010 14:11:29 +0100
 From: r...@iol.ie
 To: masivaku...@gmail.com
 CC: pgsql-general@postgresql.org
 Subject: Re: [GENERAL] MySQL versus Postgres
 
 On 07/08/2010 11:24, சிவகுமார் மா wrote:
  2010/8/7 Alban Hertroysdal...@solfertje.student.utwente.nl:
  On 7 Aug 2010, at 5:19, Sandeep Srinivasa wrote:
 
  +1 on this.
  This is very interesting from the point-of-view of transitioning MySQL 
  webapps to Postgres. The truth is that for a lot of people, MySQL is 
  their first DB (because of loads of pre-existing software. Refer to my 
  thread Which CMS/Ecommerce/shopping cart). When we are ready to move to 
  PG, we are already used to the MySQL way of doing things.
 
 
  As it was happening in the last 10 years, PostgreSQL will slowly
  gather more acceptance and MySQL will reduce in popularity down the
  years. But, we should help the process along.
 
  1. Almost all webhosting providers have MySQL support, but PostgreSQL
  support is available from only a few who also have MySQL support.
  Hence MySQL is universal and PostgreSQL is present as also available.
 
  2. Books.
  In a book store (where I live), technical sections have SQL, SQL
  Server, PHP and MySQL, Oracle racks. There is no PostgreSQL rack.
 
  3. Name
  It is difficult to bring up the name in conversation.
 
  To break these circles:
 
  1. Study a typical web hosting set up and work on supporting
  everything (Wordpress, Drupal, OS Commerce) with PostgreSQL.
  PostgreSQL only servers should be made possible.
 
  2. Bring out more books
 
  a. Documentation is already available (PostgreSQL User Manual,
  PostgreSQL Technical Documentation). Re-package them and publish as
  books targeting different user levels.
 
  b. Cook Books can be created from the discussions in this mailing list.
 
  c. More PHP+PostgreSQL books should be created.Professional PHP6
  from Wrox uses PostgreSQL as the default db.
 
 Yes, so does Pro PHP from Apress, though it doesn't mention PG on the 
 cover. There was a nice warm glow of goes without saying... about it, 
 as I remember. :-)
 
  4. A pet name
  Is it possible to have a pet name which can be used in casual
  conversation easily?
 
 Postgres or PG are the usual, AIUI.
 
 Ray.
 
 -- 
 Raymond O'Donnell :: Galway :: Ireland
 r...@iol.ie
 
 -- 
 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] MySQL versus Postgres

2010-08-07 Thread Amitabh Kant
2010/8/7 சிவகுமார் மா masivaku...@gmail.com

 3. The default configuration settings for PostgreSQL are not optimal
 for performance. Can there be a recommended configuration file in the
 installation (assuming certain amount of RAM and processor type) ?

 Ma Sivakumar
 http://masivakumar.blogspot.com



pgtune [http://pgfoundry.org/projects/pgtune/]  is already available for
this purpose.


Amitabh Kant


Re: [GENERAL] MySQL versus Postgres

2010-08-07 Thread Pavel Stehule
Hello

2010/8/7 Martin Gainty mgai...@hotmail.com:
 Ray--

 I would like to see in postgres:
 1)Clustering
 2)a more user-friendly interface to packages


 3)eliminate the requirement to create a postgres user to execute the server
 binaries..I guess i never understood that requirement


it is simply - security - when pg run under root and somebody hacks
it, then he has a admin rights. When pg will run under postgres and
somebody hacks it the he have access only to database.

Regards

Pavel Stehule


 I would like to see in MySQL:
 A progression back to OpenSource ..i dont see Oracle championing 2 database
 products simultaneously
 although under the same roof it would seem the engineering resources
 currently devoted to Oracle features could easily be re-factored to MySQL..
 a prime example of a much needed requirement for MySQL ..When will MySQL
 implement row-level locking instead of just table-level locking?

 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
 Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
 Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
 dient lediglich dem Austausch von Informationen und entfaltet keine
 rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
 E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
 destinataire prévu, nous te demandons avec bonté que pour satisfaire
 informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
 de ceci est interdite. Ce message sert à l'information seulement et n'aura
 pas n'importe quel effet légalement obligatoire. Étant donné que les email
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
 aucune responsabilité pour le contenu fourni.




 Date: Sat, 7 Aug 2010 14:11:29 +0100
 From: r...@iol.ie
 To: masivaku...@gmail.com
 CC: pgsql-general@postgresql.org
 Subject: Re: [GENERAL] MySQL versus Postgres

 On 07/08/2010 11:24, சிவகுமார் மா wrote:
  2010/8/7 Alban Hertroysdal...@solfertje.student.utwente.nl:
  On 7 Aug 2010, at 5:19, Sandeep Srinivasa wrote:
 
  +1 on this.
  This is very interesting from the point-of-view of transitioning MySQL
  webapps to Postgres. The truth is that for a lot of people, MySQL is 
  their
  first DB (because of loads of pre-existing software. Refer to my thread
  Which CMS/Ecommerce/shopping cart). When we are ready to move to PG, we
  are already used to the MySQL way of doing things.
 
 
  As it was happening in the last 10 years, PostgreSQL will slowly
  gather more acceptance and MySQL will reduce in popularity down the
  years. But, we should help the process along.
 
  1. Almost all webhosting providers have MySQL support, but PostgreSQL
  support is available from only a few who also have MySQL support.
  Hence MySQL is universal and PostgreSQL is present as also available.
 
  2. Books.
  In a book store (where I live), technical sections have SQL, SQL
  Server, PHP and MySQL, Oracle racks. There is no PostgreSQL rack.
 
  3. Name
  It is difficult to bring up the name in conversation.
 
  To break these circles:
 
  1. Study a typical web hosting set up and work on supporting
  everything (Wordpress, Drupal, OS Commerce) with PostgreSQL.
  PostgreSQL only servers should be made possible.
 
  2. Bring out more books
 
  a. Documentation is already available (PostgreSQL User Manual,
  PostgreSQL Technical Documentation). Re-package them and publish as
  books targeting different user levels.
 
  b. Cook Books can be created from the discussions in this mailing list.
 
  c. More PHP+PostgreSQL books should be created.Professional PHP6
  from Wrox uses PostgreSQL as the default db.

 Yes, so does Pro PHP from Apress, though it doesn't mention PG on the
 cover. There was a nice warm glow of goes without saying... about it,
 as I remember. :-)

  4. A pet name
  Is it possible to have a pet name which can be used in casual
  conversation easily?

 Postgres or PG are the usual, AIUI.

 Ray.

 --
 Raymond O'Donnell :: Galway :: Ireland
 r...@iol.ie

 --
 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


[GENERAL] 2010 International Conference on Progress in Informatics and Computing(PIC-2010 )

2010-08-07 Thread PIC2010
Remind: PIC-2010 last Call for Papers - few days left-deadline August 10th! 
Please subimit your papers before August 10th.
-
2010 International Conference on Progress in Informatics and Computing(PIC-2010 
)

Important Dates
Full paper submission: August 10, 2010 Acceptance notification: Sept. 20, 
2010
Final registration: Sept. 30, 2010 Final papers submissions: Sept. 30, 
2010

2010 International Conference on Progress in Informatics and Computing 
(PIC-2010, http://pic.sjtu.edu.cn) will be held on Dec 10-12, 2010, in 
Shanghai, the largest city in China, which is located on China's central 
eastern coast just at the mouth of the Yangtze River. It is one of the largest 
metropolitan areas in the world, with over 20 million people. This Year, the 
forty-first World Expo is held in Shanghai, which is one of the famous events 
in the world, and it provides an extra reason why shanghai worth visiting this 
year.


PIC-2010 provides a forum for researchers and practitioners in academia and 
industry to discuss the progress, challenges, experiences and trends of the 
theoretical and application issues in computing science, software technology, 
information system, to exchange ideas, share knowledge and promote future 
cooperation. The conference also welcome papers of infomation system 
applications in biomedical, healthcare, engineering, economics, social science 
and management domains.
All papers accepted will be published in the IEEE categorized conference 
proceedings, and will be included in IEEE Xplore and indexed by Ei Compendex 
and ISTP. Top 10 % of the accepted papers will be recommended to and published 
in several international Journals.

Paper Submission
Prospective authors are encouraged to submit full papers for review by August 
10st, 2010, in PDF -format. Only original papers that have not been published 
or submitted for publication elsewhere will be considered, written in English, 
should be no more than 5 pages (If your final camera-ready paper exceed 5 
pages, each extra page will be charged accordingly, details can be found at the 
conference website), Please submit your papers using the online submission 
system in http://pic.sjtu.edu.cn. 

Organizing Committee 

General Conference Chairs
Mengqi Zhou, IEEE Beijing Section, China
Yinglin Wang, Shanghai Jiao Tong University, China

Steering committee Chair
Katsuro Inoue, Osaka University, Japan

Steering committee
Chengfei Liu, Swinburne University of Technology, Australia
Pedro Antunes, University of Lisboa, Portugal
Jiacun Wang, Monmouth University, USA 
Gongzhu Hu, Central Michigan University, USA
Du Zhang, California State University, Sacramento, USA 

Organization Co-Chairs
Jun Dong,Suzhou Institute of Nano-Tech and Nano-Bionics, Chinese Academy of 
Sciences, China
Michael Sheng, The University of Adelaide, Australia

Technical Program Committee Co-Chairs
Xuelong Li, Chinese Academy of Sciences, China
Yuan Luo, Shanghai Jiao Tong University, China
Jyrki Nummenmaa, Tampere University, Finland
Yaoru Sun, Tongji University, China

Publication Chair
Mengqi Zhou, IEEE Beijing Section, China

Publicity Chair
DachengTao, Nanyang Technological University,Singapore
Organized By: Shanghai Jiao Tong University
Co-Sponsored by:IEEE Beijing Section, Shanghai Jiao Tong University, The 
University of Texas at Dallas, Osaka University  
Note: The detail information may be subject to change, please find the latest 
information via http://pic.sjtu.edu.cn
E-mail:  p...@sjtu.edu.cn
Tel: (0086)21-37826993
-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Using AND in query

2010-08-07 Thread aravind chandu
Hello every one, 

I have encountered a problem while working .I have a sample table with the 
following data


TID Date Item 
T100 8/1/2010 Laptop 
T100 8/1/2010 Desktop 
T101 8/1/2010 Laptop 
T102 8/1/2010 Desktop 
T103 8/2/2010 Laptop 
T103 8/2/2010 Desktop 
T104 8/2/2010 Laptop 
 
need the data when a person bought laptop  desktop on the sameday.I 
used a condition in where clause but its not working,it is returning no 
rows.Can 
any one please help me to resolve this issue ?

condition in where clause :
table.date in date() to date() and table.item = laptop and table.item = 
Desktop



  

Re: [GENERAL] Using AND in query

2010-08-07 Thread Raymond O'Donnell

On 07/08/2010 20:40, aravind chandu wrote:


condition in where clause :
table.date in date() to date() and table.item = laptop and table.item
= Desktop


I don't think this is correct - you need BETWEEN.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
r...@iol.ie

--
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 AND in query

2010-08-07 Thread Thomas Kellerer

aravind chandu wrote on 07.08.2010 21:40:

Hello every one,
I have encountered a problem while working .I have a sample table with
the following data
*TID*   *Date*  *Item*
T1008/1/2010Laptop
T1008/1/2010Desktop
T1018/1/2010Laptop
T1028/1/2010Desktop
T1038/2/2010Laptop
T1038/2/2010Desktop
T1048/2/2010Laptop

need the data when a person bought laptop  desktop on the sameday.I
used a condition in where clause but its not working,it is returning no
rows.Can any one please help me to resolve this issue ?

condition in where clause :
table.date in date() to date() and table.item = laptop and table.item
= Desktop


You should first understand why your query is not working.

The condition

   and table.item = 'laptop' and table.item = 'Desktop'

says: I want all rows where the column item has the value 'Laptop' and *at the 
same time* has the value 'Desktop'
Which clearly cannot be the case (a column can only have a single value)

So you need to join all Laptop rows to all Desktop rows to get what you 
want.

SELECT l.tid, l.purchase_date
FROM the_table_with_no_name l
  JOIN the_table_with_no_name d
   ON l.tid = d.tid AND l.purchase_date = d.purchase_date AND d.item = 
'Desktop'
WHERE l.item = 'Laptop'

Or as an alternative:

SELECT tid, purchase_date
FROM orders
WHERE item in ('Laptop', 'Desktop')
GROUP BY tid, purchase_date
HAVING count(*) = 2

Regards
Thomas


--
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 AND in query

2010-08-07 Thread David Fetter
On Sat, Aug 07, 2010 at 12:40:41PM -0700, aravind chandu wrote:
 Hello every one, 
 
 I have encountered a problem while working .I have a sample table with the 
 following data
 
 
 TID Date Item 
 T100 8/1/2010 Laptop 
 T100 8/1/2010 Desktop 
 T101 8/1/2010 Laptop 
 T102 8/1/2010 Desktop 
 T103 8/2/2010 Laptop 
 T103 8/2/2010 Desktop 
 T104 8/2/2010 Laptop 
  
 need the data when a person bought laptop  desktop on the sameday.

This is actually relatively straight-forward using modern PostgreSQL.
Rather than counting, use direct aggregation to compare, so:

SELECT TID, Date
FROM table
GROUP BY TID, Date
HAVING ARRAY['Laptop','Desktop'] @ array_agg(item);

That last line checks whether the array created by array_agg contains
at least the elements Laptop and Desktop.  If you need an equals
comparison rather than the above contains or equals, you can sort
both arrays canonically using the array_sort function below and then
compare them with =.

CREATE OR REPLACE FUNCTION array_sort(ANYARRAY)
RETURNS ANYARRAY
LANGUAGE SQL
AS $$
SELECT ARRAY(SELECT * FROM unnest($1) ORDER BY 1);
$$;

The = query would look like this:

SELECT TID, Date
FROM table
GROUP BY TID, Date
HAVING array_sort(ARRAY['Laptop','Desktop']) = array_sort(array_agg(item));

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

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


[GENERAL] Accessing a database via AJAX scripts

2010-08-07 Thread Glen Eustace
I am not sure where my issue lies - apache, perl or postgresql, but as 
they say, one has to start somewhere.


My goal is to have a perl cgi script (that is accessed using AJAX) 
perform some operations in a database using DBI.  Some of the actions 
are likely to take a while so my intent was to have a table that the 
backend process periodically writes status messages into.  The front end 
web page then uses another AJAX script to watch this table.


I am coming unstuck, the monitoring script works but the backend 
processing doesn't.


My first attempts would not show anything at the front end as the 
initial response from the backend was not getting through the system 
until the backend completely finished (even having set no buffering on 
STDOUT).  After googling abit, it would appear that the way around this 
is to fork the back-end to allow apache to complete the initial response 
and then carry on the processing in the forked child process.
I have opted to use Proc::Daemon to do this. Now I am getting a Pg error 
could not receive data from server: Bad file descriptor.


I have attempted re-opening STDOUT and STDERR in the forked process but 
that didn't make any difference.


I am obviously missing something here.  If anyone has done something 
similar and has it working I'd appreciate any help I can get.


Glen
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Glen and Rosanne Eustace,
GodZone Internet Services, a division of AGRE Enterprises Ltd.,
P.O. Box 8020, Palmerston North, New Zealand 4446
Ph: +64 6 357 8168, Fax: +64 6 357 8165, Mob: +64 27 542 4015

A Ministry specialising in providing low-cost professional Internet
Services to NZ Christian Churches, Ministries and Organisations

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


[GENERAL] Howto only select secific lines from a result?

2010-08-07 Thread Clemens Eisserer
Hi,

I am working on a graphical table display widget which should be able
to display huge amounts of data, by lazy-loading database values. It
already works well if the primary-key and line-number are equal.
However I don't have any idea howto handle the case where the
primary-key contains holes, caused e.g. by deleting a few entries.

What I would need is a LIMIT command, which allows to LIMIT the
results in two ways.
Is there some way to select only specific lines from a result, something like:
Select * from table Where RESULNR BETWEEN 1000 and 1040?

Or do you have any other ideas howto solve this problem?

Thank you in advance, Clemens

-- 
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] Howto only select secific lines from a result?

2010-08-07 Thread Thom Brown
On 8 August 2010 02:37, Clemens Eisserer linuxhi...@gmail.com wrote:
 Hi,

 I am working on a graphical table display widget which should be able
 to display huge amounts of data, by lazy-loading database values. It
 already works well if the primary-key and line-number are equal.
 However I don't have any idea howto handle the case where the
 primary-key contains holes, caused e.g. by deleting a few entries.

 What I would need is a LIMIT command, which allows to LIMIT the
 results in two ways.
 Is there some way to select only specific lines from a result, something like:
 Select * from table Where RESULNR BETWEEN 1000 and 1040?

 Or do you have any other ideas howto solve this problem?

 Thank you in advance, Clemens

 --

http://www.postgresql.org/docs/8.4/static/queries-limit.html

-- 
Thom Brown
Registered Linux user: #516935

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