pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedPatch to implement Connection.nativeSQL
2+ messages / 2 participants
[nested] [flat]
* Patch to implement Connection.nativeSQL
@ 2005-01-24 15:35 Xavier Poinsard <xpoinsard@free.fr>
2005-01-25 07:27 ` Re: Patch to implement Connection.nativeSQL Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 2+ messages in thread
From: Xavier Poinsard @ 2005-01-24 15:35 UTC (permalink / raw)
To: pgsql-jdbc
Thanks to Kris remark, here is a tiny patch implementing
Connection.nativeSQL
Attachments:
patchNativeSql.txt (text/plain, 2.7K) download
Index: jdbc2/AbstractJdbc2Connection.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v
retrieving revision 1.25
diff -u -r1.25 AbstractJdbc2Connection.java
--- jdbc2/AbstractJdbc2Connection.java 14 Jan 2005 01:20:19 -0000 1.25
+++ jdbc2/AbstractJdbc2Connection.java 24 Jan 2005 15:27:36 -0000
@@ -502,7 +502,9 @@
*/
public String nativeSQL(String sql) throws SQLException
{
- return sql;
+ StringBuffer buf = new StringBuffer(sql.length());
+ AbstractJdbc2Statement.parseSql(sql,0,buf,false);
+ return buf.toString();
}
/*
Index: jdbc2/AbstractJdbc2Statement.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v
retrieving revision 1.64
diff -u -r1.64 AbstractJdbc2Statement.java
--- jdbc2/AbstractJdbc2Statement.java 18 Jan 2005 21:33:17 -0000 1.64
+++ jdbc2/AbstractJdbc2Statement.java 24 Jan 2005 15:27:42 -0000
@@ -718,7 +718,7 @@
* @param stopOnComma should we stop after hitting the first comma in sql text?
* @return the position we stopped processing at
*/
- private int parseSql(String p_sql,int i,StringBuffer newsql, boolean stopOnComma)throws SQLException{
+ protected static int parseSql(String p_sql,int i,StringBuffer newsql, boolean stopOnComma)throws SQLException{
short state = IN_SQLCODE;
int len = p_sql.length();
int nestedParenthesis=0;
@@ -848,7 +848,7 @@
* @param args the arguments for this functin
* @return the right postgreSql sql
*/
- protected String escapeFunction(String functionName, String args) throws SQLException{
+ protected static String escapeFunction(String functionName, String args) throws SQLException{
// parse function arguments
int len = args.length();
int i=0;
Index: test/jdbc2/ConnectionTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/ConnectionTest.java,v
retrieving revision 1.19
diff -u -r1.19 ConnectionTest.java
--- test/jdbc2/ConnectionTest.java 11 Jan 2005 08:25:48 -0000 1.19
+++ test/jdbc2/ConnectionTest.java 24 Jan 2005 15:27:44 -0000
@@ -100,9 +100,11 @@
/*
* Test nativeSQL
*/
- public void testNativeSQL()
+ public void testNativeSQL() throws SQLException
{
- // For now do nothing as it returns itself
+ // test a simple escape
+ Connection con = TestUtil.openDB();
+ assertEquals("DATE '2005-01-24'",con.nativeSQL("{d '2005-01-24'}"));
}
/*
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Patch to implement Connection.nativeSQL
2005-01-24 15:35 Patch to implement Connection.nativeSQL Xavier Poinsard <xpoinsard@free.fr>
@ 2005-01-25 07:27 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 2+ messages in thread
From: Kris Jurka @ 2005-01-25 07:27 UTC (permalink / raw)
To: Xavier Poinsard <xpoinsard@free.fr>; +Cc: pgsql-jdbc
On Mon, 24 Jan 2005, Xavier Poinsard wrote:
> Thanks to Kris remark, here is a tiny patch implementing
> Connection.nativeSQL
>
Applied.
Also I've removed the mapping for the difference function. Levenshtein
does sort of the same thing (roughly estimating the similarity of two
strings), but it's not the same. I've submitted a patch to fuzzystrmatch
to implement the soundex difference function, but that won't be widely
available any time soon (or perhaps even ever). In any case if applied
there is no need for a translation process, so it should just work.
http://archives.postgresql.org/pgsql-patches/2005-01/msg00268.php
Kris Jurka
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-01-25 07:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 15:35 Patch to implement Connection.nativeSQL Xavier Poinsard <xpoinsard@free.fr>
2005-01-25 07:27 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox