You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Rick Hillegas (JIRA)" <ji...@apache.org> on 2008/05/15 18:21:55 UTC

[jira] Created: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
--------------------------------------------------------------------------------------------------------------------------------------------

                 Key: DERBY-3676
                 URL: https://issues.apache.org/jira/browse/DERBY-3676
             Project: Derby
          Issue Type: New Feature
          Components: JDBC
            Reporter: Rick Hillegas


This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 

"In mysql, a toString() on a PreparedStatement will do this, eg "select x
from foo where x.a = ?" will become "select x from foo where x.a = 1" with
the appropriate setValue() call."

At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598208#action_12598208 ] 

mike bell commented on DERBY-3676:
----------------------------------

Originally I wanted to do it like will did, but it looked....tricky to actually get the lexically parsed quoted version...

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750730#action_12750730 ] 

Dag H. Wanvik commented on DERBY-3676:
--------------------------------------

Hi Mark,
Thanks for the patch!
Unfortunately we can't use the java.utl.regexp package in this Derby class (EmbedPreparedStatement),
since the Derby code base can only use the subset of Java afforded by Java ME Connected Device Configuration (CDC) profile Foundation 1.1, and that API does not include java.utl.regexp. I just had to rewrite some code for the same reason.. :(
On the upside, it should be fairly easy to do the quoting logic "manually".

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi,

I've had to make some modifications to the tests; aside from StatementPlanCacheTest then suites.All was all clear;

the new modifications alter StatementPlanCacheTest so it gives the all clear too;

so unless you need to see more test results / a repeat of the suites.All then I'd say the patch is ready from my point of view

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas updated DERBY-3676:
---------------------------------

    Component/s: Newcomer

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598328#action_12598328 ] 

mike bell commented on DERBY-3676:
----------------------------------

1. Also, If I understand correctly, you are saying there's no way to expose this info if runnning the client driver (I guess that makes some sense sadly, the info would be on the server side)? 

2. And if it were moved to EmbeddedDriver, how would one make it thread safe (before I was following the other methods in the class and syncing on connection)? I mean those are ugly public thingies? I know a Connection isn't thread safe by JDBC, and I guess that implies PreparedStatements aren't either, too though. But assumedly there was good reason for syncing on Connection? Or was this an abortive attempt to achieve a thread-safe driver?

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

it needs the parameter increment in the client implementation that seems to have hidden :o)

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Thomas Nielsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597197#action_12597197 ] 

Thomas Nielsen commented on DERBY-3676:
---------------------------------------

This incompatability could possibly be avoided by printing the current parameter set after the current statement?
Something along the lines of :
--
SELECT * FROM T WHERE t.a > ? AND t.b LIKE ?;
[ 2, "DERBY" ] 
---

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi,

thinking more carefully, I suppose it needs the Interface to advertise the public API; it now compiles; I'm happy that it's handling the strings correctly; I'll see what junit has to say then report back

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598205#action_12598205 ] 

mike bell commented on DERBY-3676:
----------------------------------

Boy, I'm a java newbie, but I was inspired to look at the code after Rick's encouraging comments on the list. . It looks easy to do, but the BUILDING looks......painful, judging from BUILDING.txt

Comment 1. Isn't it bad practice in general to do what Daniel says the code is doing, eg rely on toString() for ANY formal meaning? I don't mean this as criticism, just curious.

Comment 2. If toString is being used anyway, why not just use toHumanString()

Comment 3. Ok, I dare expose myself to be made fun of :). The following seemed to work fine with my primitive tests

   	 public String toHumanString() {  
  // I guess this is how you are making it threadsafe? Otherwise I am vague on this and in fact the publicness of the Object[] _parameters to begin with! Boy all those publics make my recently weened JCIP head feel scared. I want my mama.
	       synchronized(connection) {
	               if ((parameters_.length>0)) {
	            	   StringBuffer sb = new StringBuffer(sql_);
	            	   sb.append("\r\n ");
	            	   	for (int i=0;i<parameters_.length;i++) {
	            	   		if (i>0) sb.append(", ");
	            	   		sb.append("[");
	            	   		sb.append((i+1)+"]=");
	            	   		sb.append(parameters_[i]==null ? "uninitialized" : parameters_[i].toString());
	            	   	} 
	            	   	
	            	   	return sb.toString();
	               } else {
	            	   return sql_;
	               }
	               
	       }
   	 }

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597182#action_12597182 ] 

Daniel John Debrunner commented on DERBY-3676:
----------------------------------------------

FYI - the output of toString() represents the identifier of the compiled plan. It can be used in a query against the virtual table that represents the statement cache. Changing it would affect backwards compatibility and make it harder to see if the statement in use is in the statement cache.

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598319#action_12598319 ] 

Knut Anders Hatlen commented on DERBY-3676:
-------------------------------------------

Since this particular behaviour of EmbedPreparedStatement.toString()
is undocumented and not part of our published API, I would hope that
there aren't too many applications that depend on it. Perhaps it would
make more sense to change it to return more useful information and
warn the users in a release note, and provide a non-standard but
documented way to get the old information through our published
API. For instance, we could use Rick's idea with a static method in
EmbeddedDriver and call it getSQLText(PreparedStatement).

For the record, the client driver doesn't implement
PreparedStatement.toString() and only returns
org.apache.derby.client.am.PreparedStatement40@1e3118a.

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi I noticed the request is marked as suitable for a newbie so I've made a preliminary patch;

I'd make these comments
1 I tend to feel that the idea of making the toString() method return the sql, then documenting a change so that a new method, let's say idString() returned the original toString() id, is more appropriate
2 as currently written, there is no checking for thread-safety
3 a quoted '?' in the PreparedStatement would be replaced, so the replacement routine should be improved
4 I should add client-side / api functionality, as well as Embedded

currently it works as suggested in a cast to ((EmbedPreparedStatement) ps).toHumanString()

I'm just posting the patch for comments / to avoid duplication of work so people notice I'm working at it

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598326#action_12598326 ] 

mike bell commented on DERBY-3676:
----------------------------------

Thanks for Ricks comments. 

Some replies

1. I must embarassedly admit (I thought I had been clear, but  I wasn't!) I DID NOT actually manage to get a build of derby, a building. My test was merely to make a mock object, which is of course inadequate in the end. I have no idea if I'll ever have time to get through the durn building process, since um, regular work calls. That was a late night "treat" for me after 16 hours of work. I'm pretty sure I can generate the diff regardless, but of course I wouldn't except a patch without the contributor running the unit tests either.

2. As a consequence I guess I've missed something obvious - this would have been a Patch to PreparedStatement.java. I'm not quite  following yours and Knuts comments about EmbedPreparedStatement, probably because I in fact "cowboy-programmed" it (just searched for PreparedStatement.java in fact.

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598363#action_12598363 ] 

Rick Hillegas commented on DERBY-3676:
--------------------------------------

>2. As a consequence I guess I've missed something obvious - this would have been a Patch to PreparedStatement.java. I'm not quite following yours and Knuts comments about EmbedPreparedStatement, probably because I in fact "cowboy-programmed" it (just searched for PreparedStatement.java in fact.

Ah, it sounds like your changes were intended for org.apache.derby.client.am.PreparedStatement. That's the PreparedStatement implementation in Derby's client driver. Derby also has an embedded driver. For some reason I thought you were working in the embedded driver. That may just be because the original email thread talked about embedded usage.

>1. Also, If I understand correctly, you are saying there's no way to expose this info if runnning the client driver (I guess that makes some sense sadly, the info would be on the server side)?

Happily for you, you are already working in the client driver. So instead of EmbeddedDriver, you could put a forwarding method in ClientDriver.

>2. And if it were moved to EmbeddedDriver, how would one make it thread safe (before I was following the other methods in the class and syncing on connection)? I mean those are ugly public thingies? I know a Connection isn't thread safe by JDBC, and I guess that implies PreparedStatements aren't either, too though. But assumedly there was good reason for syncing on Connection? Or was this an abortive attempt to achieve a thread-safe driver?

After forwarding, couldn't you rely on the synchronization you have already coded? I would follow the pattern that's already in the code. If there's something wrong with the synchronization, then regularity will help the fixer find all instances of the problem.


> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597513#action_12597513 ] 

Rick Hillegas commented on DERBY-3676:
--------------------------------------

Maybe we could add a static method to EmbeddedDriver. Something like this:

public static String toString( PreparedStatement ps ) { ... }


> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597193#action_12597193 ] 

Rick Hillegas commented on DERBY-3676:
--------------------------------------

Thanks for the quick feedback, Dan. That would be a nasty incompatibility. Perhaps users would be satisifed with some other api to retrieve this information.

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752301#action_12752301 ] 

Mark B commented on DERBY-3676:
-------------------------------

Hi Dag,

My understanding - I'll try to check in more detail, the javadoc is a touch ambiguous - is that lobs / streams return a coherent getString() even so, so that aspect *should* work reasonably;

the reason I've been - for what it's worth - favouring the toString() / idString() arrangement is that the OP was comparing to the "intuitive" behaviour in MySQL; 

Even though naturally as you say there's the question of compatibility, there are no signs of more general breakages from the change;

[what would henceforth be] idString() really is very 'internal' from the looks of it, most noticeably the fact that the client had no implementation of it;

I hope, too, that I've correctly read the initial opinions people had, that seemed to weigh generally in favour of giving toString() its new effect

I'm very ready to listen to the voice/s of experience though, it's definitely worth reviewing :-)

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

make logic consistent Embedded <-> client

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas updated DERBY-3676:
---------------------------------

    Attachment: statementCacheVTI.sql

Thanks for the new patch, Mark.

I agree that

  String sqlText = ps.toString();

is more elegant than

  String sqlText ((DerbyPreparedStatement) ps).getFullSQLText();

However, like Dag, I am reluctant to change the meaning of toString(). Technically it's true that we haven't documented anywhere that PreparedStatement.toString() matches the SQL_TEXT column of the StatementCache vti. Still, PreparedStatement.toString() has had that meaning for more than a decade and I have no idea who depends on that fact. (For an example of using the StatementCache vti, see the attached ij script, statementCacheVTI.sql.)

I think that it's fine to add a new method which has the desired MySQL-like behavior and document that new method in the DerbyPreparedStatement interface. 

Concerning Dag's other comments:

1) Yes, please let us know what getFullSQLText() will return when the parameter is a stream or Blob/Clob.

2) We will need you to fill out an ICLA. See http://www.apache.org/licenses/#clas

Thanks,
-Rick

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt, statementCacheVTI.sql
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598303#action_12598303 ] 

Rick Hillegas commented on DERBY-3676:
--------------------------------------

Hi Mike,

Thanks for submitting this code and for adding the extra check for uninitialized parameters. Just as a heads up, the community likes to see patches which reviewers can easily apply using the subversion tools. Please don't take this as a criticism or be put off by the process. It's really easy and it really helps the committers do their work. The process for generating a patch is described in the section titled "Contribute Code or Documentation" on this web page: http://db.apache.org/derby/derby_comm.html

Some responses to your comments:

>Boy, I'm a java newbie, but I was inspired to look at the code after Rick's encouraging comments on the list. . It looks easy to do, but the BUILDING looks......painful, judging from BUILDING.txt

Right. The Derby build is too complicated. The complexity discourages newcomers and the community needs to put more effort into simplifying the build. Thanks for sticking with it!

>Comment 1. Isn't it bad practice in general to do what Daniel says the code is doing, eg rely on toString() for ANY formal meaning? I don't mean this as criticism, just curious.

Yes, I think that's what the textbooks recommend. As  you dig into Derby, you will discover some old code that dates from the period when people were learning these lessons the hard way.

>Comment 2. If toString is being used anyway, why not just use toHumanString()

Sounds good to me.

Now for a little more conversation about the problem and the patch. It looks like you've coded Thomas' suggestion. What you've coded looks good and can be used by an application which does something like this:

  String queryText = ((EmbedPreparedStatement) preparedStatement).toHumanString();

That's well and fine for a piece of internal code. I think it's great incremental improvement.

A follow-on patch could be one which wires this internal api into Derby's public api. If you're interested, please read on...

To help developers understand what api's are stable and can't change from release to release, Derby collects all of its public api into the classes visible in the JDBC3 and JDBC4 javadoc. You can see what's in the public api by building the following target after building the Derby classes:

  ant publishedapi

If you want applications to be able to rely on your code, then you will want to add some forwarding method to the public api. I've made a suggestion about what this forwarding method might look like (see my May 16 comment). So far that's the only suggestion. You may come up with a better idea.

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752279#action_12752279 ] 

Dag H. Wanvik commented on DERBY-3676:
--------------------------------------

Thanks for the revised patch, Mark!

The present patch changes the semantics of toString() for an embedded prepared statement instead of
using a new method. Instead the old semantics are made available as EmbedPreparedStatement.idString, which is OK for
the test that uses it (StatementPlanCacheTest).

What happens to lobs and stream arguments? 

The purpose of the new interface is only to document the semantics of toString, I gather.

What do people think, is it ok to change toString to let it print the text of the prepared statement with the filled in arguments?
Cf discussion about breaking compatibility earlier on this thread.

I wonder if it would not be safer to let toString be unchanged and use a new method in the introduced API interface
with a name like "getExpandedSQLText" or some such (I think toHumanReadbleString isn't very good - mostly strings are readable..)

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

mike bell updated DERBY-3676:
-----------------------------

    Attachment: ick.txt

Oh, I see why people ATTACH things. Geez the formatting looked awful

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750440#action_12750440 ] 

Rick Hillegas commented on DERBY-3676:
--------------------------------------

Hi Mark,

Thanks for looking at this issue and posting a patch. I think that your code will work in most cases. However, it will do the wrong thing if there is an embedded ? in a literal inside the SQL text or inside a delimited identifier. For instance, it will produce odd output for the following queries:

  select * from T where a like 'Am I blue?%' and b = ?

  select "foo?" from T where b = ?

My gut feeling is that these edge cases are important enough that we should handle them. I think that the problems are handled by Thomas' approach, which Mike coded in his ick.txt patch: just append a bracketed parameter list at the end of the sql text.

The public API issue will need to be addressed too. We don't want to put EmbedPreparedStatement in the public API. Maybe we could add a new interface to the public API: org.apache.derby.jdbc.DerbyPreparedStatement. Then, regardless of whether you are working with an embedded or network connection, the following code would work:

  String sqlText = ((DerbyPreparedStatement) ps).toHumanReadableString();

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "mike bell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

mike bell updated DERBY-3676:
-----------------------------

    Attachment: ick.txt

	 Sorry missed that handy parameterset boolean....

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: New Feature
>          Components: JDBC, Newcomer
>            Reporter: Rick Hillegas
>         Attachments: ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi,

the patch is virtually ready now; the toString() /idString() change that I favour would need documenting;

the question of quoting substitutions needs addressing in more detail; currently it quotes all values when Embedded, unquotes nulls from the client; as well as  improving the consistency, there are questions such as how to substitute binary data, whether to unquote more types, etc;

it seems to me that DerbyPreparedStatement must be an Interface to allow the multiple inheritance connection; currently I'm trying to see precisely what the ants are doing :o) so it'll compile properly

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: prepared.diff

Hi Rick,

the new patch includes the naming update that you both favour then;

I've already sent in the ICLA, I'm just waiting now

I'll check the lob/stream aspect then report back

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt, prepared.diff, statementCacheVTI.sql
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750444#action_12750444 ] 

Mark B commented on DERBY-3676:
-------------------------------

Hi Rick,

I've now addressed that quoted '?' business;

I'm adding the client functionality now;

the only real 'policy' question now is how to handle quotes - a string substitution should be quoted, while a null substitution should perhaps not be;

I need to look into the public API aspect, I'm just picking up the feel for the way the code is arranged; the suggestions sound good though

I'll post the patch when it's virtually complete rather than as a regular update

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

Posted by "Mark B (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi Dag,

Understood :-)

so the newer implementation seems to work so far, though a touch less elegant :D ; I notice that as a result of the way toString() is inherited, there's no particular need for DerbyPreparedStatement after all, as long as people who were accessing EmbedPreparedStatement.toString() now change to EmbedPreparedStatement.idString(); unless it is felt appropriate to add the idString() method to the client api?

Best regards

Mark

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.