Closed onderkalaci closed 9 years ago
I added in some minor comments. More importantly, could you check to see why get_attnum
doesn't catch this problem when I pass in an index name instead of a table name?
@sumedhpathak for get_attnum
called with index as table name, there are two possible scenarios:
if index is created on the partition column provided to master_create_distributed_table
, we get no errors.
CREATE INDEX index_1 ON customer_reviews(customer_id);
SELECT master_create_distributed_table('index_1', 'customer_id');
if index is NOT created on the partition column provided to master_create_distributed_table, we get an error
CREATE INDEX index_1 ON customer_reviews(customer_id);
SELECT master_create_distributed_table('index_1', 'product_id');
# ERROR: could not find column: product_id
So, with this fix we are on the safe side, we do not allow master_create_distributed_table
called with indexes. Also, error message and code become more informative.
@sumedhpathak is there any interest in moving this error-handling logic into ResolveRelationId
? I consider ResolveRelationId
analogous to regclassin
, which follows its logic exactly (i.e. it will gladly return an Oid
for an index, not just tables), so I don't think we want to do this, but just wanted to bring it up.
From what @onderkalaci is saying, it appears get_attnum
is designed to return attribute numbers both for columns within a table and to return columns used within a (possibly multi-column) index. So when we call it, we want to make sure we're passing an Oid
for a table and not an index.
When I talked to @sumedhpathak on Tuesday he said he had no blockers for shipping this. I have a couple of style things, but as I've got time to kill and this PR is getting a bit old, I'm going to make them myself and merge this (i.e. :shipit: from @sumedhpathak and me and I'm going to merge it for us to get it into develop and close the issue).
This fix handles when
master_create_distributed_table
is called with a an index as the first argument. More generally, it is called with a relation that is not ordinary table or foreign table.closes #13