Thread: 7.3 compability, select * from myfunc();
Hi!
The other day when i tried to call a function that returns a set, and i got some error that bla bla context bla bla error =)
After i checked the sources i found that the driver is calling "select myfunc()"(<7.3) instead of "select * from myfunc()"(<=7.3)
So i wrote myself the following patch, now i wonder why this havent been done earlier?
Patch:"
? pgsql-7.3-jdbc-driver-update.patch
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.12.2.2
diff -c -r1.12.2.2 AbstractJdbc1Statement.java
*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java 2002/11/20 07:54:27 1.12.2.2
--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java 2003/01/29 20:43:50
***************
*** 1832,1837 ****
--- 1832,1838 ----
* {? = call <some_function> (?, [?,..]) }
* into the PostgreSQL format which is
* select <some_function> (?, [?, ...]) as result
+ * or select * from <some_function> (?, [?, ...]) as result (7.3)
*
*/
private String modifyJdbcCall(String p_sql) throws SQLException
***************
*** 1876,1882 ****
// sql we add a dummy parameter in this case
l_sql = (isFunction ? "?" : "") + l_sql.substring (index + 4);
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.12.2.2
diff -c -r1.12.2.2 AbstractJdbc1Statement.java
*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java 2002/11/20 07:54:27 1.12.2.2
--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java 2003/01/29 20:43:50
***************
*** 1832,1837 ****
--- 1832,1838 ----
* {? = call <some_function> (?, [?,..]) }
* into the PostgreSQL format which is
* select <some_function> (?, [?, ...]) as result
+ * or select * from <some_function> (?, [?, ...]) as result (7.3)
*
*/
private String modifyJdbcCall(String p_sql) throws SQLException
***************
*** 1876,1882 ****
// sql we add a dummy parameter in this case
l_sql = (isFunction ? "?" : "") + l_sql.substring (index + 4);
! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + ";";
return l_sql;
}
return l_sql;
}
--- 1877,1887 ----
// sql we add a dummy parameter in this case
l_sql = (isFunction ? "?" : "") + l_sql.substring (index + 4);
// sql we add a dummy parameter in this case
l_sql = (isFunction ? "?" : "") + l_sql.substring (index + 4);
! if (connection.haveMinimumServerVersion("7.3")) {
! l_sql = "select * from " + l_sql + " as " + RESULT_COLUMN + ";";
! } else {
! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + ";";
! }
return l_sql;
}
"
! l_sql = "select * from " + l_sql + " as " + RESULT_COLUMN + ";";
! } else {
! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + ";";
! }
return l_sql;
}
"
Mvh
Lars Stenberg
Lars, Before I apply this patch, I would like it to include an addition to the test suite that actually tests that the behavior is correct when a function returns a set. thanks, --Barry Lars Stenberg wrote: > Hi! > > The other day when i tried to call a function that returns a set, and i > got some error that bla bla context bla bla error =) > > After i checked the sources i found that the driver is calling "select > myfunc()"(<7.3) instead of "select * from myfunc()"(<=7.3) > > So i wrote myself the following patch, now i wonder why this havent been > done earlier? > > Patch:" > ? pgsql-7.3-jdbc-driver-update.patch > 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.12.2.2 > diff -c -r1.12.2.2 AbstractJdbc1Statement.java > *** > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > 2002/11/20 07:54:27 1.12.2.2 > --- > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > 2003/01/29 20:43:50 > *************** > *** 1832,1837 **** > --- 1832,1838 ---- > * {? = call <some_function> (?, [?,..]) } > * into the PostgreSQL format which is > * select <some_function> (?, [?, ...]) as result > + * or select * from <some_function> (?, [?, ...]) as result (7.3) > * > */ > private String modifyJdbcCall(String p_sql) throws SQLException > *************** > *** 1876,1882 **** > // sql we add a dummy parameter in this case > l_sql = (isFunction ? "?" : "") + l_sql.substring (index > + 4); > > ! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + ";"; > return l_sql; > } > > --- 1877,1887 ---- > // sql we add a dummy parameter in this case > l_sql = (isFunction ? "?" : "") + l_sql.substring (index > + 4); > > ! if (connection.haveMinimumServerVersion("7.3")) { > ! l_sql = "select * from " + l_sql + " as " + > RESULT_COLUMN + ";"; > ! } else { > ! l_sql = "select " + l_sql + " as " + > RESULT_COLUMN + ";"; > ! } > return l_sql; > } > " > > Mvh > Lars Stenberg >
Hi! Of course i could make the patch include some tests, if i only new how =) Im a new developer of the jdbc-driver and i dont have any exprerience in "include an addition to the test suite", so if anyone could help me with that ill be very glad. Also includint the patch-file as an attachment so that my mail client dosnt add ^M to it =) Mvh Lars ----- Original Message ----- From: "Barry Lind" <blind@xythos.com> To: "Lars Stenberg" <lars.stenberg@psycat.net> Cc: <pgsql-jdbc@postgresql.org> Sent: Tuesday, February 04, 2003 6:00 PM Subject: Re: [JDBC] 7.3 compability, select * from myfunc(); > Lars, > > Before I apply this patch, I would like it to include an addition to the > test suite that actually tests that the behavior is correct when a > function returns a set. > > thanks, > --Barry > > Lars Stenberg wrote: > > Hi! > > > > The other day when i tried to call a function that returns a set, and i > > got some error that bla bla context bla bla error =) > > > > After i checked the sources i found that the driver is calling "select > > myfunc()"(<7.3) instead of "select * from myfunc()"(<=7.3) > > > > So i wrote myself the following patch, now i wonder why this havent been > > done earlier? > > > > Patch:" > > ? pgsql-7.3-jdbc-driver-update.patch > > Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > > =================================================================== > > RCS file: > > /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Abst ractJdbc1Statement.java,v > > retrieving revision 1.12.2.2 > > diff -c -r1.12.2.2 AbstractJdbc1Statement.java > > *** > > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > > 2002/11/20 07:54:27 1.12.2.2 > > --- > > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > > 2003/01/29 20:43:50 > > *************** > > *** 1832,1837 **** > > --- 1832,1838 ---- > > * {? = call <some_function> (?, [?,..]) } > > * into the PostgreSQL format which is > > * select <some_function> (?, [?, ...]) as result > > + * or select * from <some_function> (?, [?, ...]) as result (7.3) > > * > > */ > > private String modifyJdbcCall(String p_sql) throws SQLException > > *************** > > *** 1876,1882 **** > > // sql we add a dummy parameter in this case > > l_sql = (isFunction ? "?" : "") + l_sql.substring (index > > + 4); > > > > ! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + ";"; > > return l_sql; > > } > > > > --- 1877,1887 ---- > > // sql we add a dummy parameter in this case > > l_sql = (isFunction ? "?" : "") + l_sql.substring (index > > + 4); > > > > ! if (connection.haveMinimumServerVersion("7.3")) { > > ! l_sql = "select * from " + l_sql + " as " + > > RESULT_COLUMN + ";"; > > ! } else { > > ! l_sql = "select " + l_sql + " as " + > > RESULT_COLUMN + ";"; > > ! } > > return l_sql; > > } > > " > > > > Mvh > > Lars Stenberg > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >
Attachment
Lars, If you have the source code for the jdbc driver you should take a look at the file in org/postgresql/test named README. It contains instructions for how to build, run and develop tests. Start by just getting the test suite running. Then once you have done that, I think you will find adding test cases pretty straight forward. thanks, --Barry Lars Stenberg wrote: > Hi! > > Of course i could make the patch include some tests, if i only new how =) > Im a new developer of the jdbc-driver and i dont have any exprerience in > "include an addition to the test suite", so if anyone could help me with > that ill be very glad. > > Also includint the patch-file as an attachment so that my mail client dosnt > add ^M to it =) > > Mvh > Lars > ----- Original Message ----- > From: "Barry Lind" <blind@xythos.com> > To: "Lars Stenberg" <lars.stenberg@psycat.net> > Cc: <pgsql-jdbc@postgresql.org> > Sent: Tuesday, February 04, 2003 6:00 PM > Subject: Re: [JDBC] 7.3 compability, select * from myfunc(); > > > >>Lars, >> >>Before I apply this patch, I would like it to include an addition to the >>test suite that actually tests that the behavior is correct when a >>function returns a set. >> >>thanks, >>--Barry >> >>Lars Stenberg wrote: >> >>>Hi! >>> >>>The other day when i tried to call a function that returns a set, and i >>>got some error that bla bla context bla bla error =) >>> >>>After i checked the sources i found that the driver is calling "select >>>myfunc()"(<7.3) instead of "select * from myfunc()"(<=7.3) >>> >>>So i wrote myself the following patch, now i wonder why this havent been >>>done earlier? >>> >>>Patch:" >>>? pgsql-7.3-jdbc-driver-update.patch >>>Index: > > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > >>>=================================================================== >>>RCS file: >>> > > /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Abst > ractJdbc1Statement.java,v > >>>retrieving revision 1.12.2.2 >>>diff -c -r1.12.2.2 AbstractJdbc1Statement.java >>>*** >>>src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java >>>2002/11/20 07:54:27 1.12.2.2 >>>--- >>>src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java >>>2003/01/29 20:43:50 >>>*************** >>>*** 1832,1837 **** >>>--- 1832,1838 ---- >>> * {? = call <some_function> (?, [?,..]) } >>> * into the PostgreSQL format which is >>> * select <some_function> (?, [?, ...]) as result >>>+ * or select * from <some_function> (?, [?, ...]) as result > > (7.3) > >>> * >>> */ >>> private String modifyJdbcCall(String p_sql) throws SQLException >>>*************** >>>*** 1876,1882 **** >>> // sql we add a dummy parameter in this case >>> l_sql = (isFunction ? "?" : "") + l_sql.substring (index >>>+ 4); >>> >>>! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + > > ";"; > >>> return l_sql; >>> } >>> >>>--- 1877,1887 ---- >>> // sql we add a dummy parameter in this case >>> l_sql = (isFunction ? "?" : "") + l_sql.substring (index >>>+ 4); >>> >>>! if (connection.haveMinimumServerVersion("7.3")) { >>>! l_sql = "select * from " + l_sql + " as " + >>>RESULT_COLUMN + ";"; >>>! } else { >>>! l_sql = "select " + l_sql + " as " + >>>RESULT_COLUMN + ";"; >>>! } >>> return l_sql; >>> } >>>" >>> >>>Mvh >>>Lars Stenberg >>> >> >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 6: Have you searched our list archives? >> >>http://archives.postgresql.org >> >> >> >>------------------------------------------------------------------------ >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 3: if posting/reading through Usenet, please send an appropriate >>subscribe-nomail command to majordomo@postgresql.org so that your >>message can get through to the mailing list cleanly
Lars, I applied this patch to cvs head. But I would still like to see a test case added. Have you made any progress on that? thanks, --Barry Lars Stenberg wrote: > Hi! > > Of course i could make the patch include some tests, if i only new how =) > Im a new developer of the jdbc-driver and i dont have any exprerience in > "include an addition to the test suite", so if anyone could help me with > that ill be very glad. > > Also includint the patch-file as an attachment so that my mail client dosnt > add ^M to it =) > > Mvh > Lars > ----- Original Message ----- > From: "Barry Lind" <blind@xythos.com> > To: "Lars Stenberg" <lars.stenberg@psycat.net> > Cc: <pgsql-jdbc@postgresql.org> > Sent: Tuesday, February 04, 2003 6:00 PM > Subject: Re: [JDBC] 7.3 compability, select * from myfunc(); > > > >>Lars, >> >>Before I apply this patch, I would like it to include an addition to the >>test suite that actually tests that the behavior is correct when a >>function returns a set. >> >>thanks, >>--Barry >> >>Lars Stenberg wrote: >> >>>Hi! >>> >>>The other day when i tried to call a function that returns a set, and i >>>got some error that bla bla context bla bla error =) >>> >>>After i checked the sources i found that the driver is calling "select >>>myfunc()"(<7.3) instead of "select * from myfunc()"(<=7.3) >>> >>>So i wrote myself the following patch, now i wonder why this havent been >>>done earlier? >>> >>>Patch:" >>>? pgsql-7.3-jdbc-driver-update.patch >>>Index: > > src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java > >>>=================================================================== >>>RCS file: >>> > > /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Abst > ractJdbc1Statement.java,v > >>>retrieving revision 1.12.2.2 >>>diff -c -r1.12.2.2 AbstractJdbc1Statement.java >>>*** >>>src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java >>>2002/11/20 07:54:27 1.12.2.2 >>>--- >>>src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java >>>2003/01/29 20:43:50 >>>*************** >>>*** 1832,1837 **** >>>--- 1832,1838 ---- >>> * {? = call <some_function> (?, [?,..]) } >>> * into the PostgreSQL format which is >>> * select <some_function> (?, [?, ...]) as result >>>+ * or select * from <some_function> (?, [?, ...]) as result > > (7.3) > >>> * >>> */ >>> private String modifyJdbcCall(String p_sql) throws SQLException >>>*************** >>>*** 1876,1882 **** >>> // sql we add a dummy parameter in this case >>> l_sql = (isFunction ? "?" : "") + l_sql.substring (index >>>+ 4); >>> >>>! l_sql = "select " + l_sql + " as " + RESULT_COLUMN + > > ";"; > >>> return l_sql; >>> } >>> >>>--- 1877,1887 ---- >>> // sql we add a dummy parameter in this case >>> l_sql = (isFunction ? "?" : "") + l_sql.substring (index >>>+ 4); >>> >>>! if (connection.haveMinimumServerVersion("7.3")) { >>>! l_sql = "select * from " + l_sql + " as " + >>>RESULT_COLUMN + ";"; >>>! } else { >>>! l_sql = "select " + l_sql + " as " + >>>RESULT_COLUMN + ";"; >>>! } >>> return l_sql; >>> } >>>" >>> >>>Mvh >>>Lars Stenberg >>> >> >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 6: Have you searched our list archives? >> >>http://archives.postgresql.org >> >> >> >>------------------------------------------------------------------------ >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 3: if posting/reading through Usenet, please send an appropriate >>subscribe-nomail command to majordomo@postgresql.org so that your >>message can get through to the mailing list cleanly