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

Value too long varchar(275) error with src/AdminViews/v_generate_tbl_ddl.sql #38

Closed
mattmc3 opened this issue Aug 26, 2015 · 5 comments
Closed
Assignees

Comments

@mattmc3
Copy link

mattmc3 commented Aug 26, 2015

When running v_generate_tbl_ddl.sql on certain databases, the script errors with the message:

ERROR: value too long for type character varying(275)

When hacking at the script, I discovered that changing line 77 from this:
,'\t,' + pg_get_constraintdef(con.oid) AS ddl
to this:
,'\t,' + pg_get_constraintdef(con.oid)::VARCHAR(8000) AS ddl
addresses the problem for my use case. Unfortunately, I cannot speak to whether this would be the optimal way to solve this for all conditions due to the script's close ties with the deep inner workings of Redshift.

@IanMeyers IanMeyers assigned IanMeyers and ericfe and unassigned IanMeyers Aug 26, 2015
@ericfe
Copy link
Contributor

ericfe commented Oct 31, 2015

Have you tried with other values ( like 1024 instead of 8000 ) ?

@mattmc3
Copy link
Author

mattmc3 commented Nov 2, 2015

8000 is semi-arbitrary. The size just has to be large enough to hold the text of a long FOREIGN KEY object name. 1024 would work until you had a DDL generation for a line needing 1025 characters.

On Oct 31, 2015, at 6:46 PM, ericfe notifications@github.com wrote:

Have you tried with other values ( like 1024 instead of 8000 ) ?


Reply to this email directly or view it on GitHub #38 (comment).

@ericfe
Copy link
Contributor

ericfe commented Nov 2, 2015

Correct. Given the max size of objects( tables and columns ) 1024 should be enough.
8000 has performance implications. If 1024 works for you, I will go with that for now.

@ericfe
Copy link
Contributor

ericfe commented Feb 9, 2016

Pushed fix

@ericfe ericfe closed this as completed Feb 9, 2016
@ghost
Copy link

ghost commented Jul 12, 2016

Looks like the problem isn't fixed. The fix should go on line 89 in the --CONSTRAINT LIST section of the query. This can be reproduced by adding a UNIQUE constraint on a table using enough columns to blow past 275 characters, and then querying v_generate_tbl_ddl. The fix is still the same as I described - change line 89 to:
,'\t,' + pg_get_constraintdef(con.oid)::VARCHAR(1024) AS ddl

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