sql: add pg_catalog.pg_get_viewdef#18618
Conversation
|
Thanks for the contribution! A few comments enclosed. The difference between the true and false argument is pretty minor I think and I only discovered it by looking at the Postgres source code. It controls whether the output is formatted using disambiguating parentheses. For example: I'm fine with us ignoring this difference entirely. Review status: 0 of 2 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. pkg/sql/logictest/testdata/logic_test/builtin_function, line 1605 at r1 (raw file):
There's a shortcut for this, so you don't have to do this subselect: pkg/sql/parser/pg_builtins.go, line 231 at r1 (raw file):
This should return pkg/sql/parser/pg_builtins.go, line 237 at r1 (raw file):
It's fine that we have no special behavior in this overload, but it seems unnecessary to me to repeat the code in both overloads. Could you DRY this definition? Comments from Reviewable |
|
Reviewed 2 of 2 files at r1. Comments from Reviewable |
|
sounds good! Comments from Reviewable |
|
pkg/sql/logictest/testdata/logic_test/builtin_function, line 1605 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
I will update with this, thanks for the pointer. Comments from Reviewable |
|
pkg/sql/parser/pg_builtins.go, line 231 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Agreed. Comments from Reviewable |
|
pkg/sql/parser/pg_builtins.go, line 237 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Sounds good, I will refactor it. Comments from Reviewable |
b9d2ed9 to
2c619d7
Compare
|
pkg/sql/logictest/testdata/logic_test/builtin_function, line 1605 at r1 (raw file): Previously, bsnyder788 (Brett Snyder) wrote…
Done. Comments from Reviewable |
|
pkg/sql/parser/pg_builtins.go, line 231 at r1 (raw file): Previously, bsnyder788 (Brett Snyder) wrote…
Done. Comments from Reviewable |
|
pkg/sql/parser/pg_builtins.go, line 237 at r1 (raw file): Previously, bsnyder788 (Brett Snyder) wrote…
Done. Comments from Reviewable |
|
Reviewed 2 of 2 files at r1, 2 of 2 files at r2. Comments from Reviewable |
@jordanlewis I wasn't able to re-use the SHOW CREATE VIEW code as it actually returns a different format than PostgreSQL pg_get_viewdef. Thus, I had to extract it from the pg_catalog.pg_views table. Let me know if the SHOW CREATE VIEW format is indeed okay for this purpose in Cockroach and I can easily modify it to leverage that. Also I couldn't tell the difference on the overloaded function with the boolean when setting up some fake data in PostgreSQL 9.6. If you have a good example where true and false would yield different outputs I can update that portion of the PR as well. Thanks!