Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: interface conversion: sqlparser.Statement is nil, not *sqlparser.CreateTable #14

Open
JaisDK opened this issue Feb 18, 2021 · 5 comments

Comments

@JaisDK
Copy link

JaisDK commented Feb 18, 2021

Hello,
I am getting an error when I run dbanon. Do you know what this error could relate to? The dbanon.log file is empty.

root@af1ae37f315b:/app# mysqldump -h mariadb -B oastest | dbanon -config=application/configs/anonymize.yml -log-level=debug > anonymized.sql
panic: interface conversion: sqlparser.Statement is nil, not *sqlparser.CreateTable

goroutine 1 [running]:
github.com/mpchadwick/dbanon/src.findNextTable(0xc00037ae80, 0x39)
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/src/create_table.go:27 +0x417
github.com/mpchadwick/dbanon/src.LineProcessor.ProcessLine(0xaedb67, 0x9, 0xc000272ea0, 0xbb93c0, 0xc0000a8130, 0xc0000839d0, 0xc00037ae80, 0x39, 0xc00037ae40, 0x3b)
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/src/processor.go:25 +0xdd
main.main()
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/main.go:112 +0x706
mysqldump: Got errno 32 on write

I've tried running it on both a MySQL 5.6 and MariaDB 10.4 inside a docker container, same result for both.

@mpchadwick
Copy link
Owner

Would it be possible to share the contents from your mysqldump file that causes this to reproduce? Understand sharing a full dump file could definitely have some privacy concerns but if the specific line(s) where it's choking doesn't have any sensitive data I'd like to take a look.

@mpchadwick
Copy link
Owner

Closing due to inactivity.

@davidegiunchi
Copy link

@mpchadwick I'm having the same problem. I've been able to isolate the error on a small subset of the mysqldump file that doesn't contain any sensitive data. could i share it with you as you previously said?

@mpchadwick
Copy link
Owner

@davidegiunchi - Yes you can definitely share it. I haven't worked on this project for a while, so no promises on the resolution, but if I have some time I'll try to take a look at the issue.

@mpchadwick mpchadwick reopened this Dec 10, 2024
@davidegiunchi
Copy link

davidegiunchi commented Dec 10, 2024

Since is not private at all, i can share it here. with this small .sql file:

DROP TABLE IF EXISTS `my_originator`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `my_originator` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `my_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `my_originator_my_id_foreign` (`my_id`),
  CONSTRAINT `my_originator_my_id_foreign` FOREIGN KEY (`my_id`) REFERENCES `my` (`id`) ON UPDATE CASCADE,
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

if you pipe it throught dbanon 0.7.1:

touch /tmp/a
cat myfile.sql |  dbanon -config=/tmp/a > /tmp/myfile.anon

dbanon crash immediatly with this error:

panic: interface conversion: sqlparser.Statement is nil, not *sqlparser.CreateTable

goroutine 1 [running]:
github.com/mpchadwick/dbanon/src.findNextTable({0xc000040680, 0x39})
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/src/create_table.go:29 +0x34f
github.com/mpchadwick/dbanon/src.LineProcessor.ProcessLine({{0xeb326f, 0x9}, 0xc000128c60, {0x103c540, 0xc00011a0c8}, 0xc0001244b0}, {0xc000040680, 0x39})
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/src/processor.go:25 +0xb7
main.main()
        /Users/maxchadwick/go/src/github.com/mpchadwick/dbanon/main.go:114 +0x86d

it seems to me that the problem is originated by the CONSTRAINT line: if i remove it, dbanon doesn't crash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants