![]() | |
#41
| |||
| |||
|
|
Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. |
|
Will this work on Windows as well? |
|
And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? |
#42
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#43
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#44
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#45
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#46
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#47
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#48
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#49
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
#50
| |||
| |||
|
|
Silvio Bierman <sbierman (AT) jambo-software (DOT) com> wrote: Thanks a lot, I tried defining an implicit cast in terms of a select that does the conversion but ended up with an infinite recursion, off course :-( This looks great but I have never added external C code to PG and am afraid to compromise server stability. For instance, I see a memory allocation call 'str = palloc(...)' and it is not immediately clear to me where that memory will be freed. Memory allocated by palloc() will be freed when the transaction ends, that is usually after the SQL statement is completed. Will this work on Windows as well? Ugh, Windows. Yes, it will work, but you'd need to get a build environment for Windows, which is quite a hassle. And finally: since Postgresql supports implicit string to UUID conversions internally and only the JDBC driver does not seem to be aware of this, does that cast not already exist? The error messages are not from JDBC, but from the database server. There is no typecast from any data type to uuid. All that PostgreSQL can do is convert string literals to uuid. You can make use of this by using the data type org.postgresql.util.PGobject, which is a general class used to represent data types unknown to JDBC. You can define a helper class: public class UUID extends org.postgresql.util.PGobject { public static final long serialVersionUID = 668353936136517917L; public UUID(String s) throws java.sql.SQLException { super(); this.setType("uuid"); this.setValue(s); } } Then the following piece of code will succeed: java.sql.PreparedStatement stmt = conn.prepareStatement("UPDATE t SET uid = ? WHERE id = 1"); stmt.setObject(1, new UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")); stmt.executeUpdate(); Will that help you? Yours, Laurenz Albe |
![]() |
| Thread Tools | |
| Display Modes | |
| |