Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Following example 11: https://sql.datapage.app/component.sql?component=form I've created a sql script that creates a temporary table, copies to it, and then merges from the temporary table to the permanent table. Typically, I use 'ON COMMIT DROP' when making temporary tables. On my second upload, sqlpage throws the error that my temporary table already exists. I kill the server, then put Finally, I add How should users work with sqlpage transactions? Is there a way to align transactions with request lifecycles? This pseudo code seems to work: COMMIT;
BEGIN;
CREATE TEMPORARY TABLE example_temp (
LIKE example
) ONCOMMIT DROP;
COPY example_temp (my_id)
FROM'example_form_input' (FORMAT 'csv', HEADER);
MERGE INTO example from example_temp;
SELECT'redirect'AS component,
'/example'AS link;
COMMIT;Judiciously beginning and ending every sqlpage script with begin and commit negates the need for commit;begin; and commit; in some files. Not sure which is best. |
Replies: 2 comments 2 replies
Hello and thank you for the well-written report and reproduction. Currently, SQLPage does connection pooling, but does not do anything special at the end of an HTTP request, so it can put back a connection with an open transaction to the pool. I do agree that this behavior is not desirable. I opened issue #711 to track this. In the meantime, I think what you are currently doing ( |
@lovasoa thanks for your continued support. Sqlpage is a real delight |
Hello and thank you for the well-written report and reproduction.
Currently, SQLPage does connection pooling, but does not do anything special at the end of an HTTP request, so it can put back a connection with an open transaction to the pool.
I do agree that this behavior is not desirable. I opened issue #711 to track this.
In the meantime, I think what you are currently doing (
commit; begin;at the beginning thencommitat the end) is the best solution.