Closed onderkalaci closed 9 years ago
@jasonmp85 After our chat, I understand the bug. Yes, as you suggest, we already find all check constraints(column and table) in the table and convert them to table constraints. The following quote from the PostgreSQL documentation also reinforces our approach:
We say that the first two constraints are column constraints, whereas the third one is a table constraint because it is written separately from any one column definition. Column constraints can also be written as table constraints, while the reverse is not necessarily possible, since a column constraint is supposed to refer to only the column it is attached to. (PostgreSQL doesn't enforce that rule, but you should follow it if you want your table definitions to work with other database systems.)
This commit fixes DeparseCreateStmt function, in which we fail to add a comma for the first table constraint that is deparsed. Since we forget the first comma after column definitions, the first table constraint was considered as column constraint.
Basically, I tried to use the same approach in pg_shard_get_tableschemadef_string, which works as expected.
Looks good. Merging this!
:shipit:
Fixes #94