Re: [BUGS] timestamps cannot be created without time zones

2001-08-24 Thread Peter Eisentraut

Tom Lane writes:

> Timezone handling in PG is dependent on the underlying OS' timezone
> database, which doesn't go back further than 1901 in any Unix that
> I've heard of.  You should realize of course that the very notion of
> timezone was only standardized in the 1800s, so attaching a timezone
> to dates much older than that would be a dubious practice anyway...

Thus Rainer's point is that when having times both before and after 1901
in the same data set you get inconsistencies.  This seems like a good
reason to introduce a true 'timestamp without time zone' type.

-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[BUGS] Bug #427: joining views

2001-08-24 Thread pgsql-bugs

Vladimir Bezak  ([EMAIL PROTECTED]) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
joining views

Long Description
 PostgreSQL 7.0.2 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66

 wrong results when joining views.

Sample Code
 
table ORDER_ITEM 

 IDSTATE   ORDER_ID
  -- --
 11  1
 21  1
 32  1
 41  2
 52  2

Now i will create two views:

P1V: 
select order_id as id1, count(*) as count1 from order_item where state=1 group by 
order_id;

P2V:
select order_id as id2, count(*) as count2 from order_item where state=2 group by 
order_id;


SQL> select * from p1v;

   ID1 COUNT1
-- --
 1  2
 2  1

SQL> select * from p2v;

   ID2 COUNT2
-- --
 1  1
 2  1

Here is the problem:

SQL> select id1, count1, count2 from p1v, p2v where id1 = id2;

   ID1 COUNT1 COUNT2
-- -- --
 1  2  2
 2  1  1

there shouldn't be any 2's in column COUNT2 

In other database systems it works ok.




No file was uploaded with this report


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



[BUGS] Bug #426:

2001-08-24 Thread pgsql-bugs

Vladimir  () reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description


Long Description


Sample Code


No file was uploaded with this report


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [BUGS] Bug #427: joining views

2001-08-24 Thread Peter Eisentraut

>  PostgreSQL 7.0.2 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66
>
>  wrong results when joining views.

Upgrade to the latest version (7.1.3).

-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [BUGS] Bug #427: joining views

2001-08-24 Thread Tom Lane

[EMAIL PROTECTED] writes:
> Now i will create two views:

> P1V: 
> select order_id as id1, count(*) as count1 from order_item where state=1 group by 
>order_id;

> P2V:
> select order_id as id2, count(*) as count2 from order_item where state=2 group by 
>order_id;

Grouped views don't work very well in Postgres versions before 7.1.
Time to update ... 7.1.3 is the current release.

regards, tom lane

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[BUGS] Strange deadlock problem on simple concurrent SELECT/LOCK TABLE transactions

2001-08-24 Thread Tomasz Zielonka

Hi!

I'm using PostgreSQL 7.1.3 on Intel PIII, Linux 2.4.8, Slackware 8.0,
compiled with egcs 2.91.66 (the same on 7.1.2 / 2.95.3).

I'm encountering very strange deadlock situation. Strange, because after
this deadlock occurs, even with no active postgres processes (postmaster only),
when I connect with psql I can't select anything from affected table.

Here is a (almost) minimal test:

CREATE TABLE items (
id  INTEGER NOT NULL,
amount  FLOAT   NOT NULL,
PRIMARY KEY (id)
);

-- amount field is probably no longer necessary, but I haven't tested without
-- it

And run this in TWO concurrent sessions:

$ yes 'begin; select * from items; lock table items; commit;' | psql

I get deadlock here quite fast.
Both processes freeze on next select.
Stop them (ctrl-c).

ps xa shows only postmaster process, no postgres ones.

Now connect which psql and try to 'SELECT * FROM items'.
Freeze again.


What do you think?


Have a nice weekend :)
Greetings,
Tom

-- 
.signature: Too many levels of symbolic links

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[BUGS] Re: Strange deadlock problem on simple concurrent SELECT/LOCK TABLE transactions

2001-08-24 Thread Tomasz Zielonka

Hi!

I forgot to add:

It DOESN'T happen in PostgreSQL 7.1beta3
It DOEShappen in PostgreSQL 7.1beta4 (but on a different machine)

Greetings,
tom

-- 
.signature: Too many levels of symbolic links

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [BUGS] timestamps cannot be created without time zones

2001-08-24 Thread Bruce Momjian

> Tom Lane writes:
> 
> > Timezone handling in PG is dependent on the underlying OS' timezone
> > database, which doesn't go back further than 1901 in any Unix that
> > I've heard of.  You should realize of course that the very notion of
> > timezone was only standardized in the 1800s, so attaching a timezone
> > to dates much older than that would be a dubious practice anyway...
> 
> Thus Rainer's point is that when having times both before and after 1901
> in the same data set you get inconsistencies.  This seems like a good
> reason to introduce a true 'timestamp without time zone' type.

Let me see if I follow here.  If I am in the Eastern timezone and enter
a time for 9pm, 1/1/1850, and someone else in the Central timezone
enters the same time, if I look at the two dates from the Eastern
timezone I will see mine as 9pm and the other as 10pm?

Wow, I wonder if that is bad? 

It seems I would mix these in a table so it is the underlying data
representation that may be the problem.  Yikes.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



Re: [BUGS] Bug #424: JDBC driver security issue.

2001-08-24 Thread Bruce Momjian


Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> David Daney ([EMAIL PROTECTED]) reports a bug with a severity of 3
> The lower the number the more severe it is.
> 
> Short Description
> JDBC driver security issue.
> 
> Long Description
> The JDBC driver requires 
> 
>permission java.lang.RuntimePermission "shutdownHooks";
> 
> in the policy file in order to function.  However the driver does not protect the 
>shutdown hooks call in an AccessController.doPrivileged() call, so these permissions 
>must be granted to all code not just the postgres JDBC driver.
> 
> 
> Sample Code
> Here is a diff that fixes the problem.
> 
> *** ConnectionHook.java.orig  Mon Mar  5 01:17:43 2001
> --- ConnectionHook.java   Thu Aug 23 16:51:49 2001
> ***
> *** 1,6 
> --- 1,9 
>   package org.postgresql.core;
>   
>   import java.sql.SQLException;
> + import java.security.AccessController;
> + import java.security.PrivilegedAction;
> + 
>   import java.util.ArrayList;
>   import java.util.Iterator;
>   import org.postgresql.Connection;
> ***
> *** 51,57 
>  */
> private ConnectionHook() {
>   super();
> ! Runtime.getRuntime().addShutdownHook(new Thread(this));
> }
>   
> /**
> --- 54,65 
>  */
> private ConnectionHook() {
>   super();
> ! AccessController.doPrivileged(new PrivilegedAction() {
> !   public Object run() {
> !  Runtime.getRuntime().addShutdownHook(new Thread(ConnectionHook.this));
> !  return null; // nothing to return
> !   }
> !});
> }
>   
> /**
> 
> 
> No file was uploaded with this report
> 
> 
> ---(end of broadcast)---
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
> 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [BUGS] timestamps cannot be created without time zones

2001-08-24 Thread Peter Eisentraut

Bruce Momjian writes:

> Let me see if I follow here.  If I am in the Eastern timezone and enter
> a time for 9pm, 1/1/1850, and someone else in the Central timezone
> enters the same time, if I look at the two dates from the Eastern
> timezone I will see mine as 9pm and the other as 10pm?

That's exactly what happens, only that the central time would probably
show 8pm.

> Wow, I wonder if that is bad?

Depends on the application.  I do wonder how the backend gets to know the
time zone from the front end.  export PGTZ seems to do that, but not
export TZ, which is the standard variable.

-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[BUGS] Bug #428: Another security issue with the JDBC driver.

2001-08-24 Thread pgsql-bugs

David Daney ([EMAIL PROTECTED]) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Another security issue with the JDBC driver.

Long Description
The JDBC driver requires

  permission java.net.SocketPermission "host:port", "connect";

in the policy file of the application using the JDBC driver 
in the postgresql.jar file.  Since the Socket() call in the
driver is not protected by AccessController.doPrivileged() this
permission must also be granted to the entire application.

The attached diff fixes it so that the connect permission can be
restricted just the the postgresql.jar codeBase if desired.

Sample Code
*** PG_Stream.java.orig Fri Aug 24 09:27:40 2001
--- PG_Stream.java  Fri Aug 24 09:42:14 2001
***
*** 5,10 
--- 5,11 
  import java.net.*;
  import java.util.*;
  import java.sql.*;
+ import java.security.*;
  import org.postgresql.*;
  import org.postgresql.core.*;
  import org.postgresql.util.*;
***
*** 27,32 
--- 28,52 
  BytePoolDim1 bytePoolDim1 = new BytePoolDim1();
  BytePoolDim2 bytePoolDim2 = new BytePoolDim2();
  
+private static class PrivilegedSocket
+   implements PrivilegedExceptionAction
+{
+   private String host;
+   private int port;
+   
+   PrivilegedSocket(String host, int port)
+   {
+  this.host = host;
+  this.port = port;
+   }
+ 
+   public Object run() throws Exception
+   {
+  return new Socket(host, port);
+   }
+}
+
+ 
/**
 * Constructor:  Connect to the PostgreSQL back end and return
 * a stream connection.
***
*** 37,43 
 */
public PG_Stream(String host, int port) throws IOException
{
! connection = new Socket(host, port);
  
  // Submitted by Jason Venner <[EMAIL PROTECTED]> adds a 10x speed
  // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
--- 57,69 
 */
public PG_Stream(String host, int port) throws IOException
{
!  PrivilegedSocket ps = new PrivilegedSocket(host, port);
!  try {
! connection = (Socket)AccessController.doPrivileged(ps);
!  }
!  catch(PrivilegedActionException pae){
! throw (IOException)pae.getException();
!  }
  
  // Submitted by Jason Venner <[EMAIL PROTECTED]> adds a 10x speed
  // improvement on FreeBSD machines (caused by a bug in their TCP Stack)


No file was uploaded with this report


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [BUGS] Bug #428: Another security issue with the JDBC driver.

2001-08-24 Thread Bruce Momjian


Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> David Daney ([EMAIL PROTECTED]) reports a bug with a severity of 3
> The lower the number the more severe it is.
> 
> Short Description
> Another security issue with the JDBC driver.
> 
> Long Description
> The JDBC driver requires
> 
>   permission java.net.SocketPermission "host:port", "connect";
> 
> in the policy file of the application using the JDBC driver 
> in the postgresql.jar file.  Since the Socket() call in the
> driver is not protected by AccessController.doPrivileged() this
> permission must also be granted to the entire application.
> 
> The attached diff fixes it so that the connect permission can be
> restricted just the the postgresql.jar codeBase if desired.
> 
> Sample Code
> *** PG_Stream.java.orig   Fri Aug 24 09:27:40 2001
> --- PG_Stream.javaFri Aug 24 09:42:14 2001
> ***
> *** 5,10 
> --- 5,11 
>   import java.net.*;
>   import java.util.*;
>   import java.sql.*;
> + import java.security.*;
>   import org.postgresql.*;
>   import org.postgresql.core.*;
>   import org.postgresql.util.*;
> ***
> *** 27,32 
> --- 28,52 
>   BytePoolDim1 bytePoolDim1 = new BytePoolDim1();
>   BytePoolDim2 bytePoolDim2 = new BytePoolDim2();
>   
> +private static class PrivilegedSocket
> +   implements PrivilegedExceptionAction
> +{
> +   private String host;
> +   private int port;
> +   
> +   PrivilegedSocket(String host, int port)
> +   {
> +  this.host = host;
> +  this.port = port;
> +   }
> + 
> +   public Object run() throws Exception
> +   {
> +  return new Socket(host, port);
> +   }
> +}
> +
> + 
> /**
>  * Constructor:  Connect to the PostgreSQL back end and return
>  * a stream connection.
> ***
> *** 37,43 
>  */
> public PG_Stream(String host, int port) throws IOException
> {
> ! connection = new Socket(host, port);
>   
>   // Submitted by Jason Venner <[EMAIL PROTECTED]> adds a 10x speed
>   // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
> --- 57,69 
>  */
> public PG_Stream(String host, int port) throws IOException
> {
> !  PrivilegedSocket ps = new PrivilegedSocket(host, port);
> !  try {
> ! connection = (Socket)AccessController.doPrivileged(ps);
> !  }
> !  catch(PrivilegedActionException pae){
> ! throw (IOException)pae.getException();
> !  }
>   
>   // Submitted by Jason Venner <[EMAIL PROTECTED]> adds a 10x speed
>   // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
> 
> 
> No file was uploaded with this report
> 
> 
> ---(end of broadcast)---
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster