mysql 脚本行拒绝执行(没有错误/警告)

发布于 2024-12-08 12:07:49 字数 578 浏览 1 评论 0原文

我有一个很长的脚本,它将 csv 文件导入到保存表中,进行一些处理,然后将数据从保存表复制到最终表中。

当我运行脚本时,除了第 494 行:

UPDATE `database`.`holding` 
SET `rcnt_rslts`=TRUE 
WHERE `test_rcnt`=TRUE 
  AND (`rcntrslt`='pos' OR `rcntrslt`='neg' OR `rcntrslt`='indeterminate');

两个表中的 rcnt_rslts 都是 BOOL/TINYINT(1) 以及上面和下面的行 之外,所有内容都会执行几乎相同并且执行得很好。脚本中的其他任何地方都没有对 rcnt_rslts 的其他引用(通过查找/替换进行验证)。

如果我将该行直接输入到 CMI 中,它就可以工作。

是否存在行/大小限制并且 mysql 只是随机选择一行来忽略?

编辑:如果重要的话,脚本运行后,rcnt_rslts 中的所有值都为NULL

I have a very long script that imports a csv file into a holding table, does some massaging, then copies the data from the holding table into the final table.

When I run the script, everything executes except line 494:

UPDATE `database`.`holding` 
SET `rcnt_rslts`=TRUE 
WHERE `test_rcnt`=TRUE 
  AND (`rcntrslt`='pos' OR `rcntrslt`='neg' OR `rcntrslt`='indeterminate');

rcnt_rslts in both tables is BOOL/TINYINT(1) and the lines above an below are nearly identical and are executed just fine. There are no other references to rcnt_rslts anywhere else in the script (verified with find/replace).

If I past that line directly into the CMI, it works.

Is there a line/size limit and mysql just randomly picked a line to ignore?

edit: if it matters, all values in rcnt_rslts are NULL after the script runs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香草可樂 2024-12-15 12:07:49

好的,我会尝试一下:

1- 也许您在 rcntrslt 中输入错误,这样做,您只列出一次。

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt IN ('pos','neg','indeterminate'));

2- = 可以区分大小写,LIKE 从来不区分大小写,尝试:

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt LIKE 'pos' OR rcntrslt LIKE 'neg' OR rcntrslt LIKE 'indeterminate');

3- rcntrslt 还可以有哪些其他值,您不能反转所有测试?

UPDATE `database`.holding 
SET rcnt_rslts = TRUE 
WHERE test_rcnt<>FALSE AND test_rcnt IS NOT NULL 
  AND (rcntrslt NOT IN ('othervalue','test1','gdsd')
  AND rcntrslt IS NOT NULL;

4- 也许 rcntrslt 中存在一些污染,导致出现空格或其他不可打印的字符。

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt LIKE '%pos%' OR rcntrslt LIKE '%neg%' 
       OR rcntrslt LIKE '%indeterminate%');

5-如果你想调试,你总是可以在那里做一些诊断选择来看看发生了什么。

CREATE TABLE log (
  id integer auto_increment not null primary key,
  logtime timestamp,
  reason varchar(255) not null,
  tablename varchar(255) not null,
  fieldnames varchar(10000) not null,
  values varchar(10000) not null,
  INDEX log_time (logtime),
  INDEX log_table (tablename),
  INDEX log_reason (tablename, reason)) ENGINE = InnoDB;

INSERT INTO log (reason, tablename, fieldnames, values)
  SELECT 
    'all values','holding', 'test_rcnt,rcntrslt'
    , CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
  FROM holding;

INSERT INTO log (reason, tablename, fieldnames, values)
  SELECT 
    'test_rcnt = TRUE','holding', 'test_rcnt,rcntrslt'
    , CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
  FROM holding 
  WHERE test_rcnt = TRUE;

等等。

现在检查日志看看出了什么问题。

OK I'll give it a try:

1- Maybe you made a typo in rcntrslt, do it like this and you only list it once.

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt IN ('pos','neg','indeterminate'));

2- = can be case sensitive, LIKE never is, try:

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt LIKE 'pos' OR rcntrslt LIKE 'neg' OR rcntrslt LIKE 'indeterminate');

3- What other values can rcntrslt have, you not reverse all the tests?

UPDATE `database`.holding 
SET rcnt_rslts = TRUE 
WHERE test_rcnt<>FALSE AND test_rcnt IS NOT NULL 
  AND (rcntrslt NOT IN ('othervalue','test1','gdsd')
  AND rcntrslt IS NOT NULL;

4- Maybe there is some pollution in rcntrslt causing spaces or other non-printable chars to be there.

UPDATE `database`.holding 
SET rcnt_rslts=TRUE 
WHERE test_rcnt=TRUE 
  AND (rcntrslt LIKE '%pos%' OR rcntrslt LIKE '%neg%' 
       OR rcntrslt LIKE '%indeterminate%');

5- If you want to debug, you can always do some diagnosic SELECTS in there to see what's going on.

CREATE TABLE log (
  id integer auto_increment not null primary key,
  logtime timestamp,
  reason varchar(255) not null,
  tablename varchar(255) not null,
  fieldnames varchar(10000) not null,
  values varchar(10000) not null,
  INDEX log_time (logtime),
  INDEX log_table (tablename),
  INDEX log_reason (tablename, reason)) ENGINE = InnoDB;

INSERT INTO log (reason, tablename, fieldnames, values)
  SELECT 
    'all values','holding', 'test_rcnt,rcntrslt'
    , CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
  FROM holding;

INSERT INTO log (reason, tablename, fieldnames, values)
  SELECT 
    'test_rcnt = TRUE','holding', 'test_rcnt,rcntrslt'
    , CONCAT(IFNULL(test_rcnt,'NULL'), ',' ,IFNULL(rcntrslt,'NULL')
  FROM holding 
  WHERE test_rcnt = TRUE;

etc.

Now check the log to see what's wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文