[ https://forge.continuent.org/jira/browse/SEQUOIA-239?page=comments#action_14659 ]
Gilles Rayrat commented on SEQUOIA-239: --------------------------------------- Just a comment to be fully complete on that point, and show how macro replacement in parameters is useless: With jdbc, you must use setXXX() to set a prepared statement parameter, where XXX is the type of column you have. So if you want to use a macro as parameter, you will have to set it using setString() - your macro being a string like "rand()" where your data is eg. of type int. I've checked the behavior on both mysql and postgres: postgres says "org.postgresql.util.PSQLException: ERROR: column "a" is of type double precision but expression is of type character varying" and mysql: "java.sql.SQLException: Data truncated for column 'a' at row 1" with the option jdbcCompliantTruncation=false option set, it will not throw an exception but will insert a "0" (zero) all the time If you're really mazochist, you can force the conversion by using the following prepared statement: ps = conn.prepareStatement(INSERT INTO int_table VALUES((CAST (? AS INT))); ps.setString(1, "rand()"); ps.executeUpdate(); OK, despite the fact that using Java Random would have been a lot easier, that would theoretically work. But this works on very few types with very few macros (eg. rand[om]() doesn't work neither on postgres nor on mysql. Last note: removing this macro replacement should severely improve performance, especially on large data parameters (think blobs) Conclusion: we really should remove that parameter macro replacement and add a note in the doc for the very-unlikely corner cases (and for our peace of mind too) > Macro replacement does not work in PreparedStatement parameters > --------------------------------------------------------------- > > Key: SEQUOIA-239 > URL: https://forge.continuent.org/jira/browse/SEQUOIA-239 > Project: Sequoia > Type: Bug > Components: Core > Versions: Sequoia 2.4 > Reporter: Emmanuel Cecchet > Fix For: sequoia 2.10.11, Sequoia 4.0, Sequoia 2.5 > > > Macro replacement does not process the parameters of PreparedStatement. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://forge.continuent.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira _______________________________________________ Sequoia mailing list [email protected] https://forge.continuent.org/mailman/listinfo/sequoia
