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

AWS Redshift has no trigger #103

Closed
watarukura opened this issue May 13, 2019 · 1 comment · Fixed by #105
Closed

AWS Redshift has no trigger #103

watarukura opened this issue May 13, 2019 · 1 comment · Fixed by #105

Comments

@watarukura
Copy link

watarukura commented May 13, 2019

https://docs.aws.amazon.com/ja_jp/redshift/latest/dg/c_unsupported-postgresql-features.html
↑公式ドキュメントに記載の通り、AWS Redshiftにはトリガーがありません。
そのため、直近のバージョンのtblsを実行するとpanicが発生するようです。

$ tbls version
dev
$ DEBUG=1 tbls doc --force --er-format svg
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x41e5af6]

goroutine 1 [running]:
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
        /usr/local/opt/go/libexec/src/database/sql/sql.go:2955 +0x66
database/sql.(*Rows).Close(0x0, 0xc0002d9880, 0x2)
        /usr/local/opt/go/libexec/src/database/sql/sql.go:2951 +0x33
github.com/k1LoW/tbls/drivers/postgres.(*Postgres).Analyze(0x49d6558, 0xc0000e6180, 0xc0000a31d0, 0x468ee00, 0xc00035bc00)
        /Users/watarukura/src/github.com/k1LoW/tbls/drivers/postgres/postgres.go:158 +0x233f
github.com/k1LoW/tbls/datasource.Analyze(0xc0000b6360, 0x5c, 0x0, 0x0, 0x0)
        /Users/watarukura/src/github.com/k1LoW/tbls/datasource/datasource.go:62 +0x29d
github.com/k1LoW/tbls/cmd.glob..func2(0x49ad220, 0xc000089c20, 0x0, 0x3)
        /Users/watarukura/src/github.com/k1LoW/tbls/cmd/doc.go:72 +0x110
github.com/spf13/cobra.(*Command).execute(0x49ad220, 0xc000089bf0, 0x3, 0x3, 0x49ad220, 0xc000089bf0)
        /Users/watarukura/src/github.com/spf13/cobra/command.go:766 +0x2cc
github.com/spf13/cobra.(*Command).ExecuteC(0x49ad940, 0xc0000f3f88, 0x4007b30, 0xc00007a058)
        /Users/watarukura/src/github.com/spf13/cobra/command.go:850 +0x2f8
github.com/spf13/cobra.(*Command).Execute(0x49ad940, 0x0, 0x0)
        /Users/watarukura/src/github.com/spf13/cobra/command.go:800 +0x2b
github.com/k1LoW/tbls/cmd.Execute()
        /Users/watarukura/src/github.com/k1LoW/tbls/cmd/root.go:59 +0x2d
main.main()
        /Users/watarukura/src/github.com/K1LoW/tbls/main.go:32 +0x20

/Users/watarukura/src/github.com/k1LoW/tbls/drivers/postgres/postgres.go:158

		// constraint
		constraintRows, err := db.Query(`
SELECT
  pc.conname AS name,
  (CASE WHEN contype='t' THEN pg_get_triggerdef((SELECT oid FROM pg_trigger WHERE tgconstraint = pc.oid LIMIT 1))
        ELSE pg_get_constraintdef(pc.oid)
   END) AS def,
  contype AS type
FROM pg_constraint AS pc
LEFT JOIN pg_stat_user_tables AS ps ON ps.relid = pc.conrelid
WHERE ps.relname = $1
AND ps.schemaname = $2
ORDER BY pc.conrelid, pc.conindid, pc.conname`, tableName, tableSchema)
		defer constraintRows.Close()
		if err != nil {
			return errors.WithStack(err)
		}

SELECT oid FROM pg_trigger WHERE tgconstraint = pc.oid LIMIT 1;

[42703][500310] [Amazon](500310) Invalid operation: column "tgconstraint" does not exist in pg_trigger; java.lang.RuntimeException: com.amazon.support.exceptions.ErrorException: [Amazon](500310) Invalid operation: column "tgconstraint" does not exist in pg_trigger;
@k1LoW
Copy link
Owner

k1LoW commented May 13, 2019

Thank you for you comment !! I'll fix it !!!

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

Successfully merging a pull request may close this issue.

2 participants