Thread: JDBC: Wrong type

JDBC: Wrong type

From
Fernando Nasser
Date:
Just to small code fixes, harmless with the current code (I think), but it is
not the right thing to do in any case.

The first case in this patch was already detected by Chris Smith and was part of
  a patch he proposed for streaming data.

The second instance is part of a similar patch with another streaming solution
I've been using.

This is just an oversight that should be corrected regardless of the cited
patches, so I decided to post these changes independently.

--
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v
retrieving revision 1.21
diff -c -p -r1.21 AbstractJdbc1Statement.java
*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003/05/03 20:40:45    1.21
--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003/05/14 05:58:21
*************** public abstract class AbstractJdbc1State
*** 132,138 ****
          v.addElement(l_sql.substring (lastParmEnd, l_sql.length()));

          m_sqlFragments = new String[v.size()];
!         m_binds = new String[v.size() - 1];
          m_bindTypes = new String[v.size() - 1];

          for (i = 0 ; i < m_sqlFragments.length; ++i)
--- 132,138 ----
          v.addElement(l_sql.substring (lastParmEnd, l_sql.length()));

          m_sqlFragments = new String[v.size()];
!         m_binds = new Object[v.size() - 1];
          m_bindTypes = new String[v.size() - 1];

          for (i = 0 ; i < m_sqlFragments.length; ++i)
Index: src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v
retrieving revision 1.13
diff -c -p -r1.13 AbstractJdbc2Statement.java
*** src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java    2003/03/14 01:21:47    1.13
--- src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java    2003/05/14 05:58:22
*************** public abstract class AbstractJdbc2State
*** 175,181 ****
              l_newSqlFragments = new String[m_sqlFragments.length];
              System.arraycopy(m_sqlFragments,0,l_newSqlFragments,0,m_sqlFragments.length);
          }
!         Object[] l_newBinds = new String[m_binds.length];
          System.arraycopy(m_binds,0,l_newBinds,0,m_binds.length);
          String[] l_newBindTypes = new String[m_bindTypes.length];
          System.arraycopy(m_bindTypes,0,l_newBindTypes,0,m_bindTypes.length);
--- 175,181 ----
              l_newSqlFragments = new String[m_sqlFragments.length];
              System.arraycopy(m_sqlFragments,0,l_newSqlFragments,0,m_sqlFragments.length);
          }
!         Object[] l_newBinds = new Object[m_binds.length];
          System.arraycopy(m_binds,0,l_newBinds,0,m_binds.length);
          String[] l_newBindTypes = new String[m_bindTypes.length];
          System.arraycopy(m_bindTypes,0,l_newBindTypes,0,m_bindTypes.length);

Re: [PATCHES] JDBC: Wrong type

From
Barry Lind
Date:
Fernando,

Patch applied.

thanks,
--Barry


Fernando Nasser wrote:
> Just to small code fixes, harmless with the current code (I think), but
> it is not the right thing to do in any case.
>
> The first case in this patch was already detected by Chris Smith and was
> part of  a patch he proposed for streaming data.
>
> The second instance is part of a similar patch with another streaming
> solution I've been using.
>
> This is just an oversight that should be corrected regardless of the
> cited patches, so I decided to post these changes independently.
>
>
> ------------------------------------------------------------------------
>
> Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v
> retrieving revision 1.21
> diff -c -p -r1.21 AbstractJdbc1Statement.java
> *** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003/05/03 20:40:45    1.21
> --- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003/05/14 05:58:21
> *************** public abstract class AbstractJdbc1State
> *** 132,138 ****
>           v.addElement(l_sql.substring (lastParmEnd, l_sql.length()));
>
>           m_sqlFragments = new String[v.size()];
> !         m_binds = new String[v.size() - 1];
>           m_bindTypes = new String[v.size() - 1];
>
>           for (i = 0 ; i < m_sqlFragments.length; ++i)
> --- 132,138 ----
>           v.addElement(l_sql.substring (lastParmEnd, l_sql.length()));
>
>           m_sqlFragments = new String[v.size()];
> !         m_binds = new Object[v.size() - 1];
>           m_bindTypes = new String[v.size() - 1];
>
>           for (i = 0 ; i < m_sqlFragments.length; ++i)
> Index: src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v
> retrieving revision 1.13
> diff -c -p -r1.13 AbstractJdbc2Statement.java
> *** src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java    2003/03/14 01:21:47    1.13
> --- src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java    2003/05/14 05:58:22
> *************** public abstract class AbstractJdbc2State
> *** 175,181 ****
>               l_newSqlFragments = new String[m_sqlFragments.length];
>               System.arraycopy(m_sqlFragments,0,l_newSqlFragments,0,m_sqlFragments.length);
>           }
> !         Object[] l_newBinds = new String[m_binds.length];
>           System.arraycopy(m_binds,0,l_newBinds,0,m_binds.length);
>           String[] l_newBindTypes = new String[m_bindTypes.length];
>           System.arraycopy(m_bindTypes,0,l_newBindTypes,0,m_bindTypes.length);
> --- 175,181 ----
>               l_newSqlFragments = new String[m_sqlFragments.length];
>               System.arraycopy(m_sqlFragments,0,l_newSqlFragments,0,m_sqlFragments.length);
>           }
> !         Object[] l_newBinds = new Object[m_binds.length];
>           System.arraycopy(m_binds,0,l_newBinds,0,m_binds.length);
>           String[] l_newBindTypes = new String[m_bindTypes.length];
>           System.arraycopy(m_bindTypes,0,l_newBindTypes,0,m_bindTypes.length);
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html