Patch to remove connection hook and JDK 1.3 dependencies

Поиск
Список
Период
Сортировка
Искать

Patch to remove connection hook and JDK 1.3 dependencies

От:
Barry Lind <barry@xythos.com>
Дата:

Attached is a patch to remove the ConnectionHook functionality and thus 
the JDK 1.3 dependency.  For a further explanation see my posting to the 
JDBC list on Friday, explaining why this is being done.

thanks,
--Barry

PS.  In addition to the diffs in this patch, the file 
src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java is obsoleted 
and needs to be removed from 7.2, but of course the file is still needed 
for 7.1 builds.
*** ./interfaces/jdbc/build.xml.orig	Fri Jun 29 19:06:30 2001
--- ./interfaces/jdbc/build.xml	Fri Jun 29 19:09:20 2001
***************
*** 37,43 ****
    -->
    
      
-     
      
      
    
--- 37,42 ----
***************
*** 58,68 ****
      
      
  
-     
-     
-     
-     
- 
      
      
      
--- 57,62 ----
***************
*** 104,110 ****
    
      
        
-       
        
        
        
--- 98,103 ----
*** ./interfaces/jdbc/org/postgresql/Driver.java.in.orig	Fri Jun 29 19:13:40 2001
--- ./interfaces/jdbc/org/postgresql/Driver.java.in	Fri Jun 29 19:16:58 2001
***************
*** 36,44 ****
        // Placing it here, means that the driver is registered once only.
        java.sql.DriverManager.registerDriver(new Driver());
  
-       // New in 7.1 - register ourselves with the JVM - JDK1.3+ only
-       @JDK1.3ONLY@org.postgresql.core.ConnectionHook.init();
- 
      } catch (SQLException e) {
        e.printStackTrace();
      }
--- 36,41 ----

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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.

> 
> Attached is a patch to remove the ConnectionHook functionality and thus 
> the JDK 1.3 dependency.  For a further explanation see my posting to the 
> JDBC list on Friday, explaining why this is being done.
> 
> thanks,
> --Barry
> 
> PS.  In addition to the diffs in this patch, the file 
> src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java is obsoleted 
> and needs to be removed from 7.2, but of course the file is still needed 
> for 7.1 builds.

> *** ./interfaces/jdbc/build.xml.orig	Fri Jun 29 19:06:30 2001
> --- ./interfaces/jdbc/build.xml	Fri Jun 29 19:09:20 2001
> ***************
> *** 37,43 ****
>     -->
>     
>       
> -     
>       
>       
>     
> --- 37,42 ----
> ***************
> *** 58,68 ****
>       
>       
>   
> -     
> -     
> -     
> -     
> - 
>       
>       
>       
> --- 57,62 ----
> ***************
> *** 104,110 ****
>     
>       
>         
> -       
>         
>         
>         
> --- 98,103 ----
> *** ./interfaces/jdbc/org/postgresql/Driver.java.in.orig	Fri Jun 29 19:13:40 2001
> --- ./interfaces/jdbc/org/postgresql/Driver.java.in	Fri Jun 29 19:16:58 2001
> ***************
> *** 36,44 ****
>         // Placing it here, means that the driver is registered once only.
>         java.sql.DriverManager.registerDriver(new Driver());
>   
> -       // New in 7.1 - register ourselves with the JVM - JDK1.3+ only
> -       @JDK1.3ONLY@org.postgresql.core.ConnectionHook.init();
> - 
>       } catch (SQLException e) {
>         e.printStackTrace();
>       }
> --- 36,41 ----

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

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

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Patch applied.  Thanks.

> 
> Attached is a patch to remove the ConnectionHook functionality and thus 
> the JDK 1.3 dependency.  For a further explanation see my posting to the 
> JDBC list on Friday, explaining why this is being done.
> 
> thanks,
> --Barry
> 
> PS.  In addition to the diffs in this patch, the file 
> src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java is obsoleted 
> and needs to be removed from 7.2, but of course the file is still needed 
> for 7.1 builds.

> *** ./interfaces/jdbc/build.xml.orig	Fri Jun 29 19:06:30 2001
> --- ./interfaces/jdbc/build.xml	Fri Jun 29 19:09:20 2001
> ***************
> *** 37,43 ****
>     -->
>     
>       
> -     
>       
>       
>     
> --- 37,42 ----
> ***************
> *** 58,68 ****
>       
>       
>   
> -     
> -     
> -     
> -     
> - 
>       
>       
>       
> --- 57,62 ----
> ***************
> *** 104,110 ****
>     
>       
>         
> -       
>         
>         
>         
> --- 98,103 ----
> *** ./interfaces/jdbc/org/postgresql/Driver.java.in.orig	Fri Jun 29 19:13:40 2001
> --- ./interfaces/jdbc/org/postgresql/Driver.java.in	Fri Jun 29 19:16:58 2001
> ***************
> *** 36,44 ****
>         // Placing it here, means that the driver is registered once only.
>         java.sql.DriverManager.registerDriver(new Driver());
>   
> -       // New in 7.1 - register ourselves with the JVM - JDK1.3+ only
> -       @JDK1.3ONLY@org.postgresql.core.ConnectionHook.init();
> - 
>       } catch (SQLException e) {
>         e.printStackTrace();
>       }
> --- 36,41 ----

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

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

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Joseph Shraibman <jks@selectacast.net>
Дата:
Barry Lind wrote:
> 
> Attached is a patch to remove the ConnectionHook functionality and thus
> the JDK 1.3 dependency.  For a further explanation see my posting to the
> JDBC list on Friday, explaining why this is being done.
> 
I don't see any post on Friday.  Why is this being done?  Now I'll have
to code my own shutdown hooks.

-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Barry Lind wrote:
> > 
> > Attached is a patch to remove the ConnectionHook functionality and thus
> > the JDK 1.3 dependency.  For a further explanation see my posting to the
> > JDBC list on Friday, explaining why this is being done.
> > 
> I don't see any post on Friday.  Why is this being done?  Now I'll have
> to code my own shutdown hooks.

The consensus was that the function didn't work or wasn't needed.  We
can always re-add it.  I will wait for a discussion.

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

Re: Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Joseph Shraibman <jks@selectacast.net>
Дата:
Bruce Momjian wrote:
> 
> > Barry Lind wrote:
> > >
> > > Attached is a patch to remove the ConnectionHook functionality and thus
> > > the JDK 1.3 dependency.  For a further explanation see my posting to the
> > > JDBC list on Friday, explaining why this is being done.
> > >
> > I don't see any post on Friday.  Why is this being done?  Now I'll have
> > to code my own shutdown hooks.
> 
> The consensus was that the function didn't work or wasn't needed.  We
> can always re-add it.  I will wait for a discussion.
> 
If it doesn't work that's one thing but I think it is needed.  Whenever
I shut down my java programs I get 'pq_recvbuf: unexpected EOF on client
connection  ' in my postgres log.  I was going to make my own shutdown
hooks when I moved to java 1.3 but I noticed that there were ones in the
jdbc driver so I thought I didn't have to.  And when I kept getting
those messages I just thought I built the driver wrong.



-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> > The consensus was that the function didn't work or wasn't needed.  We
> > can always re-add it.  I will wait for a discussion.
> > 
> If it doesn't work that's one thing but I think it is needed.  Whenever
> I shut down my java programs I get 'pq_recvbuf: unexpected EOF on client
> connection  ' in my postgres log.  I was going to make my own shutdown
> hooks when I moved to java 1.3 but I noticed that there were ones in the
> jdbc driver so I thought I didn't have to.  And when I kept getting
> those messages I just thought I built the driver wrong.

Are you using the current CVS jdbc driver from:

	http://jdbc.fastcrypt.com

or an older version?  I hope it is at least 7.1.X.

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

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Joseph Shraibman <jks@selectacast.net>
Дата:
I'm using the 7.1.2 driver.

BTW having to add a line to your permission file for shutdown hooks is
not a good reason to get rid of this feature.  It most cases it would be
extremely unlikely for an attacker to get a chance to add a shutdown
hook to your jvm and if they do they've probably already got the means
to do Bad Things.  The java.policy file can have an entry to allow only
code in org.postgres to add shutdown hooks (maybe we should put this in
the documentation).  

The only case where it might matter is if you are trying to access
postgres directly from an applet and you can't finely control the
permissions of the applet sandbox.

Bruce Momjian wrote:
> 
> > > The consensus was that the function didn't work or wasn't needed.  We
> > > can always re-add it.  I will wait for a discussion.
> > >
> > If it doesn't work that's one thing but I think it is needed.  Whenever
> > I shut down my java programs I get 'pq_recvbuf: unexpected EOF on client
> > connection  ' in my postgres log.  I was going to make my own shutdown
> > hooks when I moved to java 1.3 but I noticed that there were ones in the
> > jdbc driver so I thought I didn't have to.  And when I kept getting
> > those messages I just thought I built the driver wrong.
> 
> Are you using the current CVS jdbc driver from:
> 
>         http://jdbc.fastcrypt.com
> 
> or an older version?  I hope it is at least 7.1.X.
> 


-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Barry Lind <barry@xythos.com>
Дата:
See:

http://www.ca.postgresql.org/mhonarc/pgsql-jdbc/2001-06/msg00174.html

thanks,
--Barry


Joseph Shraibman wrote:

> Barry Lind wrote:
> 
>>Attached is a patch to remove the ConnectionHook functionality and thus
>>the JDK 1.3 dependency.  For a further explanation see my posting to the
>>JDBC list on Friday, explaining why this is being done.
>>
>>
> I don't see any post on Friday.  Why is this being done?  Now I'll have
> to code my own shutdown hooks.
> 
> 


Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Barry Lind <barry@xythos.com>
Дата:
If you shutdown the JVM without closing your connections this is the 
behavior I would expect in to see in that case.  Your code should be 
closing any open connections to the database before exiting.

This same behavior can be seen in psql as well.  If psql exits 
unexpectedly (i.e. you kill a psql process) you will get the same 
'unexpected EOF...' message on the server.

thanks,
--Barry



Joseph Shraibman wrote:

> Bruce Momjian wrote:
> 
>>>Barry Lind wrote:
>>>
>>>>Attached is a patch to remove the ConnectionHook functionality and thus
>>>>the JDK 1.3 dependency.  For a further explanation see my posting to the
>>>>JDBC list on Friday, explaining why this is being done.
>>>>
>>>>
>>>I don't see any post on Friday.  Why is this being done?  Now I'll have
>>>to code my own shutdown hooks.
>>>
>>The consensus was that the function didn't work or wasn't needed.  We
>>can always re-add it.  I will wait for a discussion.
>>
>>
> If it doesn't work that's one thing but I think it is needed.  Whenever
> I shut down my java programs I get 'pq_recvbuf: unexpected EOF on client
> connection  ' in my postgres log.  I was going to make my own shutdown
> hooks when I moved to java 1.3 but I noticed that there were ones in the
> jdbc driver so I thought I didn't have to.  And when I kept getting
> those messages I just thought I built the driver wrong.
> 
> 
> 
> 


Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Joseph Shraibman <jks@selectacast.net>
Дата:
Joseph Shraibman wrote:
> 


OK I looked at ConnectionHook in the cvs and there is obviously code
there to close the connections, but where is the code that calls
ConnectionHook.open()?  That's probably the problem.

Also a Vector should be used instead of an ArrayList because there could
be multiple threads accessing the jdbc driver at the same time.  It
could be that open() and close() are only supposed to be called from
code that is locked anyway but I can't verify that.

Also I'm wondering why there is a ConnectionHook class at all.  It seems
to me it would be better to have this stuff in Connection itself and we
wouldn't have to do that strange workaround of calling init().

If I can connect to the cvs I'll try and code it.


-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: Patch to remove connection hook and JDK 1.3 dependencies

От:
Joseph Shraibman <jks@selectacast.net>
Дата:
Joseph Shraibman wrote:
> 


> to do Bad Things.  The java.policy file can have an entry to allow only
> code in org.postgres to add shutdown hooks (maybe we should put this in
> the documentation).
> 

grant codeBase "file:///usr/local/pgsql/share/java/" {
 permission java.lang.RuntimePermission "shutdownHooks";
};

I think there is a way to grant permission based on what package a class
is in (i.e. org.postgres) but I couln't find it.

-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com
FAQ