{"action":"created","issue":{"url":"https://api.github.com/repos/citusdata/pg_shard/issues/38","labels_url":"https://api.github.com/repos/citusdata/pg_shard/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/citusdata/pg_shard/issues/38/comments","events_url":"https://api.github.com/repos/citusdata/pg_shard/issues/38/events","html_url":"https://github.com/citusdata/pg_shard/pull/38","id":52495431,"number":38,"title":"Misleading error for incompletely created tables","user":{"login":"onderkalaci","id":7829470,"avatar_url":"https://avatars.githubusercontent.com/u/7829470?v=3","gravatar_id":"","url":"https://api.github.com/users/onderkalaci","html_url":"https://github.com/onderkalaci","followers_url":"https://api.github.com/users/onderkalaci/followers","following_url":"https://api.github.com/users/onderkalaci/following{/other_user}","gists_url":"https://api.github.com/users/onderkalaci/gists{/gist_id}","starred_url":"https://api.github.com/users/onderkalaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onderkalaci/subscriptions","organizations_url":"https://api.github.com/users/onderkalaci/orgs","repos_url":"https://api.github.com/users/onderkalaci/repos","events_url":"https://api.github.com/users/onderkalaci/events{/privacy}","received_events_url":"https://api.github.com/users/onderkalaci/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/citusdata/pg_shard/labels/waffle%3A+needs+review","name":"waffle: needs review","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-12-19T15:37:44Z","updated_at":"2015-01-08T07:06:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/citusdata/pg_shard/pulls/38","html_url":"https://github.com/citusdata/pg_shard/pull/38","diff_url":"https://github.com/citusdata/pg_shard/pull/38.diff","patch_url":"https://github.com/citusdata/pg_shard/pull/38.patch"},"body":"Before this fix, if you try to execute any query on tables which are distributed with `master_create_distributed_table` but no shards are created yet for the table (i.e. `master_create_worker_shards` not called), you get unclear error message. This fix catches that case implicitly and more meaningful message is shown.\r\n\r\nfixes #9 "},"comment":{"url":"https://api.github.com/repos/citusdata/pg_shard/issues/comments/69143721","html_url":"https://github.com/citusdata/pg_shard/pull/38#issuecomment-69143721","issue_url":"https://api.github.com/repos/citusdata/pg_shard/issues/38","id":69143721,"user":{"login":"jasonmp85","id":50673,"avatar_url":"https://avatars.githubusercontent.com/u/50673?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonmp85","html_url":"https://github.com/jasonmp85","followers_url":"https://api.github.com/users/jasonmp85/followers","following_url":"https://api.github.com/users/jasonmp85/following{/other_user}","gists_url":"https://api.github.com/users/jasonmp85/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonmp85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonmp85/subscriptions","organizations_url":"https://api.github.com/users/jasonmp85/orgs","repos_url":"https://api.github.com/users/jasonmp85/repos","events_url":"https://api.github.com/users/jasonmp85/events{/privacy}","received_events_url":"https://api.github.com/users/jasonmp85/received_events","type":"User","site_admin":false},"created_at":"2015-01-08T07:06:59Z","updated_at":"2015-01-08T07:06:59Z","body":"I was envisioning that the check would actually live in `DistributedQueryShardList` rather than after the call to it. Right now that method always returns a list, which can be the empty list (`NIL`). I'm proposing we change it to always return a non-empty list or error.\r\n\r\nGetting the relation name would also be easy because within that method the `distributedTableId` is in scope. It would just need a block like this:\r\n\r\n```c\r\nList *prunedShardList = PruneShardList(distributedTableId, restrictClauseList, shardIntervalList);\r\n\r\nif (prunedShardList == NIL)\r\n{\r\n    char *relname = get_rel_name(distributedTableId);\r\n\r\n    ereport(ERROR, (errmsg(\"... %s ...\", relname)));\r\n}\r\n\r\nreturn prunedShardList;\r\n```\r\n\r\nAs for the parts of the error message:\r\n\r\n  * `errcode` — we should use `ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE`\r\n  * `errmsg` — should read _could not find any shards for query_\r\n  * `errdetail` — should read _No shards exist for distributed table \"%s\"._\r\n  * `errhint` — Don't need the quotation marks around the method name: _Run master_create_worker_shards to create shards and try again._\r\n\r\nMy suggestions for the above are based on my reading of [the style guide](http://www.postgresql.org/docs/9.4/static/error-style-guide.html). I think we should avoid using quotes unless they contain dynamic strings that could contain space-separated words. If we know ahead of time that a function name looks like a function name, the quotes are \"unnecessary\" in the words of the style guide. Additionally, we should say _could not_ when the user can take an action to fix something and _cannot_ if it will remain impossible forever."}}