如何查找应用程序的哪一部分将空白数据插入表中?

时间:2019-03-21 04:25:08

标签: mysql node.js orm

我遇到了这个问题。我们的应用程序数据库中的一张表不断插入空白数据。它是一个主表,因此通常不添加任何新数据。现在,我想知道插入操作的来源。我无法在源代码中找到任何参考,在该参考中我们可以向该特定表中插入数据。

因此,我创建了一个触发器,以便每当表进行插入操作时,它将失败。希望我能抓住造成插入的一切。

昨天我在日志中看到以下内容:

Error (E_UNKNOWN) :: Encountered an unexpected error
        : ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG: Can't update table 'provinces' in stored function/trigger because it is already used by statement which inv
        oked this stored function/trigger.
            at Query.Sequence._packetToError (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:48:14)
            at Query.ErrorPacket (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:83:18)
            at Protocol._parsePacket (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:280:23)
            at Parser.write (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:73:12)
            at Protocol.write (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:39:16)
            at Socket.<anonymous> (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js:96:28)
            at emitOne (events.js:96:13)
            at Socket.emit (events.js:188:7)
            at readableAddChunk (_stream_readable.js:176:18)
            at Socket.Readable.push (_stream_readable.js:134:10)
            at TCP.onread (net.js:559:20)
            --------------------
            at Protocol._enqueue (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:141:48)
            at PoolConnection.query (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js:201:25)
            at Object.f.dynatraceRegularInvoke [as doInvoke] (/opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:9243:20)
            at Object.a.safeInvoke (/opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:9316:29)
            at PoolConnection.query (/opt/dynatrace/oneagent/agent/res/nodeagent/nodejsagent.js:6104:15)
            at __CREATE__ (/home/ubuntu/apps/brambang/node_modules/sails-mysql/lib/adapter.js:394:20)
            at afterwards (/home/ubuntu/apps/brambang/node_modules/sails-mysql/lib/connections/spawn.js:84:5)
            at /home/ubuntu/apps/brambang/node_modules/sails-mysql/lib/connections/spawn.js:40:7
            at Ping.onOperationComplete [as _callback] (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/Pool.js:99:5)
            at Ping.Sequence.end (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
            at Ping.Sequence.OkPacket (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:105:8)
            at Protocol._parsePacket (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:280:23)
            at Parser.write (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:73:12)
            at Protocol.write (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:39:16)
            at Socket.<anonymous> (/home/ubuntu/apps/brambang/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js:96:28)
            at emitOne (events.js:96:13)
            at Socket.emit (events.js:188:7)
            at readableAddChunk (_stream_readable.js:176:18)
            at Socket.Readable.push (_stream_readable.js:134:10)
            at TCP.onread (net.js:559:20)

Details:  Error: ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG: Can't update table 'provinces' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

好吧,现在我知道该应用程序的一部分正在向表中插入内容,现在的问题是如何确定我的应用程序的哪一部分正在执行此操作?

有人知道我应该如何进行吗?我没有发现代码的哪一部分正在执行此操作。

谢谢。

  • 我已经在表上放置了Not Null复选框,但是(在创建触发器之前)空白数据不断输入,不是null,而是空白。
  • 我什至创建了一个调度程序来删除ID> 94的所有内容,因为表中存在空白数据,因此部分Web应用程序会出错。
  • 我想深入了解一下,是什么在创建那些空白数据。

0 个答案:

没有答案