Open akalend opened 1 month ago
So, see pg_rw_register.teardown () method: assert(self.con:execute("INSERT INTO log_register VALUES(1)"))
For 5 open connections must be 5 records, is only one.
The simple corutine model have 5 connections constantly:
function testdb(n) local luasql = require "luasql.postgres" local env = assert (luasql.postgres()) local con = assert (env:connect('test2', 'postgres', nil, "127.0.0.1", 5432))
coroutine.yield(n)
local query = string.format("SELECT * FROM rw_register where val=%d", n) local cur = assert(con:execute(query)) print(query) coroutine.yield(query)
local row = cur:fetch ({}, "a") local count = 0 while row do print(string.format("%d %d", row.val, row.ver )) row = cur:fetch (row, "a") count = count + 1 end
coroutine.yield(count)
cur:close() con:close() env:close()
end
The code of postgresql rw-test usingmolly. After first or second call method invoike the connection was closed. It can check parallel sql command:
SELECT client_addr,pid,usename,application_name FROM pg_stat_activity;
So, it can look in output trace: