Difference between “execute” and “statement” in postgres logs in transaction context
我收到"警告:没有正在进行的事务"错误,如此处所述。 当我查看日志时,我看到我的风帆水线ORM导致"声明"字出现在日志中如果我使用其Model.query方法并且"执行"字出现在通过其模型方法发出的查询前面 比如.insert,.update等。它们之间在交易中的行为方式有什么区别吗? 或者,日志中"声明"和"执行"之间的区别是什么?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 2015-02-18 21:31:03 UTC [6810-35] vdsr@sails LOG: statement: START TRANSACTION 2015-02-18 21:31:03 UTC [6813-33] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"groups" ("name","notes","isCompany","parentGroupRef","companyRef","createdAt","updatedAt") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING * 2015-02-18 21:31:03 UTC [6813-34] vdsr@sails DETAIL: parameters: $1 = 'bbbb', $2 = 'fdf', $3 = 't', $4 = '1', $5 = '1', $6 = '2015-02-18 21:31:03+00', $7 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6814-33] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"users" ("firstName","lastName","email","companyRef","isMainUser","password","middleName","createdAt","updatedAt") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING * 2015-02-18 21:31:03 UTC [6814-34] vdsr@sails DETAIL: parameters: $1 = 'ffff', $2 = 'ffdd', $3 = '[email protected]', $4 = '19', $5 = 't', $6 = 'cc5ce3a7addcb4512c7af12a6594af91', $7 = '', $8 = '2015-02-18 21:31:03+00', $9 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6805-53] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"roles" ("name","companyRef","createdAt","updatedAt") VALUES ($1, $2, $3, $4) RETURNING * 2015-02-18 21:31:03 UTC [6805-54] vdsr@sails DETAIL: parameters: $1 = 'Master', $2 = '19', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6809-37] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"userroles" ("roleRef","userRef","createdAt","updatedAt") VALUES ($1, $2, $3, $4) RETURNING * 2015-02-18 21:31:03 UTC [6809-38] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '16', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6808-37] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"rolepermissions" ("roleRef","permissionRef","createdAt","updatedAt") VALUES ($1, $2, $3, $4) RETURNING * 2015-02-18 21:31:03 UTC [6808-38] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '24', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6811-35] vdsr@sails LOG: EXECUTE <unnamed>: INSERT INTO"rolepermissions" ("roleRef","permissionRef","createdAt","updatedAt") VALUES ($1, $2, $3, $4) RETURNING * 2015-02-18 21:31:03 UTC [6811-36] vdsr@sails DETAIL: parameters: $1 = '12', $2 = '22', $3 = '2015-02-18 21:31:03+00', $4 = '2015-02-18 21:31:03+00' 2015-02-18 21:31:03 UTC [6806-41] vdsr@sails LOG: EXECUTE <unnamed>: SELECT"groups"."name","groups"."notes","groups"."parentGroupRef","groups"."isCompany","groups"."hierPos","groups"."companyRef","groups"."id","groups"."createdAt","groups"."updatedAt" FROM"groups" AS"groups" WHERE"groups"."companyRef" = $1 2015-02-18 21:31:03 UTC [6806-42] vdsr@sails DETAIL: parameters: $1 = '1' 2015-02-18 21:31:03 UTC [6807-41] vdsr@sails LOG: statement: UPDATE groups SET"hierPos" = CASE id WHEN 2 THEN '1' WHEN 3 THEN '2' WHEN 4 THEN '3' WHEN 5 THEN '4' WHEN 6 THEN '4.1' WHEN 10 THEN '4.1.1' WHEN 18 THEN '4.2' WHEN 13 THEN '5' WHEN 17 THEN '6' WHEN 19 THEN '7' ELSE"hierPos" END WHERE id IN (2,3,4,5,6,10,18,13,17,19) 2015-02-18 21:31:03 UTC [6812-35] vdsr@sails LOG: statement: commit 2015-02-18 21:31:03 UTC [6812-36] vdsr@sails WARNING: there IS no TRANSACTION IN progress |
您最有可能在自动提交模式下运行查询。 在此模式下,每个语句都有自己的小事务。 发出
至于"执行"与"声明":其中一个似乎是带参数的预备语句。 另一个只是一个没有附加参数的简单查询。