Hi,
I have a problem that occurs with doing an insert with a serial/sequence value on Postgres 9.0.13 and this problem only occurs when I upgrade my application from SmartGWT Power 3.0p to 3.1p (4/16 nightly).
The string that is created as the parameter to the nextval() built-in function has the last letter of the table name truncated and then when the sequence name is appended to it, the result string is invalid and therefore PGSQL complains that "The relation does not exist". The data source that this occurs on is created with "autoDeriveSchema" set to true, so I do not explicitly name the sequence in the ds.xml file.
For example, in my log fragment below you can see that my schema, table name, and sequenced column name are all correctly formatted at the beginning of the INSERT statement ("beari_application_beari_test_2013_01_15","schema_state_history", and "history_id" respectively), but when those values are appended together to form the value passed to nextval(), things get mangled into:
Log:
On 3.0p, the INSERT statement does *not* create the nextval() invocation as part of the INSERT statement but Postgres does the right thing because it knows what sequence to call implicitly when a new record is added and the sequenced column name is not specified.
Log:
I am curious about the difference in the way this is handled between 3.0p and 3.1p and the logic used to determine the sequence name. For example, the real name of the sequence in my Postgres DB is actually:
So if SmartGWT generated what I assume would be the result without the truncation:
Then the value for nextval() would still be incorrect. Any thoughts on this?
If needed I can create a separate test case for this and repost, however I was hoping that in the case that this might be something simple and/or obvious that you would consider looking into with the information I have provided in this post.
Thanks for your consideration,
Mike
I have a problem that occurs with doing an insert with a serial/sequence value on Postgres 9.0.13 and this problem only occurs when I upgrade my application from SmartGWT Power 3.0p to 3.1p (4/16 nightly).
The string that is created as the parameter to the nextval() built-in function has the last letter of the table name truncated and then when the sequence name is appended to it, the result string is invalid and therefore PGSQL complains that "The relation does not exist". The data source that this occurs on is created with "autoDeriveSchema" set to true, so I do not explicitly name the sequence in the ds.xml file.
For example, in my log fragment below you can see that my schema, table name, and sequenced column name are all correctly formatted at the beginning of the INSERT statement ("beari_application_beari_test_2013_01_15","schema_state_history", and "history_id" respectively), but when those values are appended together to form the value passed to nextval(), things get mangled into:
Code:
INSERT INTO beari_application_beari_test_2013_01_15.schema_state_history (comments, state_code, updated_by, history_id) VALUES ('', 2, 'beari_tester', nextval('beari_application_beari_test_2013_01_15.schema_state_histor_history_id'))
Code:
=== 2013-04-16 19:32:53,205 [c-25] INFO IDACall - Performing 1 operation(s) === 2013-04-16 19:32:53,205 [c-25] INFO SQLDataSource - [builtinApplication.bemanager_beari_application_beari_test_2013_01_15:schema_state_history_add] Performing add operation with criteria: {state_code:2,comments:"",updated_by:"beari_tester"} values: {state_code:2,comments:"",updated_by:"beari_tester"} === 2013-04-16 19:32:53,220 [c-25] INFO SQLDriver - [builtinApplication.bemanager_beari_application_beari_test_2013_01_15:schema_state_history_add] Executing SQL update on 'v3_sandbox': INSERT INTO beari_application_beari_test_2013_01_15.schema_state_history (comments, state_code, updated_by, history_id) VALUES ('', 2, 'beari_tester', nextval('beari_application_beari_test_2013_01_15.schema_state_histor_history_id')) === 2013-04-16 19:32:53,267 [c-25] WARN RequestContext - dsRequest.execute() failed: org.postgresql.util.PSQLException: ERROR: relation "beari_application_beari_test_2013_01_15.schema_state_histor_history_id" does not exist Position: 165 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334) at com.isomorphic.sql.SQLDriver.doUpdate(SQLDriver.java:750) at com.isomorphic.sql.SQLDriver.update(SQLDriver.java:700) at com.isomorphic.sql.SQLDriver.executeUpdate(SQLDriver.java:824) at com.isomorphic.sql.SQLDataSource.executeNativeUpdate(SQLDataSource.java:419) at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1464) at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:306) at com.isomorphic.sql.SQLDataSource.executeAdd(SQLDataSource.java:258) at com.isomorphic.datasource.DataSource.execute(DataSource.java:1370) at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726) at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658) at com.isomorphic.application.AppBase.execute(AppBase.java:491) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2031) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:216) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:173) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:138) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:74) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
On 3.0p, the INSERT statement does *not* create the nextval() invocation as part of the INSERT statement but Postgres does the right thing because it knows what sequence to call implicitly when a new record is added and the sequenced column name is not specified.
Code:
INSERT INTO beari_application_beari_test_2013_01_15.schema_state_history (comments, state_code, updated_by) VALUES ('', 1, 'beari_tester')
Code:
=== 2013-04-16 20:21:55,679 [c-18] INFO IDACall - Performing 1 operation(s) === 2013-04-16 20:21:55,679 [c-18] INFO SQLDataSource - [builtinApplication.bemanager_beari_application_beari_test_2013_01_15:schema_state_history_add] Performing add operation with criteria: {state_code:1,comments:"",updated_by:"beari_tester"} values: {state_code:1,comments:"",updated_by:"beari_mail_tester"} === 2013-04-16 20:21:55,710 [c-18] INFO SQLDriver - [builtinApplication.bemanager_beari_application_beari_test_2013_01_15:schema_state_history_add] Executing SQL update on 'v3_sandbox': INSERT INTO beari_application_beari_test_2013_01_15.schema_state_history (comments, state_code, updated_by) VALUES ('', 1, 'beari_tester')
Code:
beari_application_beari_test_2013_01_15.schema_state_history_history_id_seq
Code:
beari_application_beari_test_2013_01_15.schema_state_history_history_id
If needed I can create a separate test case for this and repost, however I was hoping that in the case that this might be something simple and/or obvious that you would consider looking into with the information I have provided in this post.
Thanks for your consideration,
Mike
Comment