{"action":"created","issue":{"url":"https://api.github.com/repos/mysql-d/mysql-native/issues/59","labels_url":"https://api.github.com/repos/mysql-d/mysql-native/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/mysql-d/mysql-native/issues/59/comments","events_url":"https://api.github.com/repos/mysql-d/mysql-native/issues/59/events","html_url":"https://github.com/mysql-d/mysql-native/issues/59","id":99267110,"number":59,"title":"getNextRow() returns superfluous empty row","user":{"login":"whitebyte","id":7704186,"avatar_url":"https://avatars.githubusercontent.com/u/7704186?v=3","gravatar_id":"","url":"https://api.github.com/users/whitebyte","html_url":"https://github.com/whitebyte","followers_url":"https://api.github.com/users/whitebyte/followers","following_url":"https://api.github.com/users/whitebyte/following{/other_user}","gists_url":"https://api.github.com/users/whitebyte/gists{/gist_id}","starred_url":"https://api.github.com/users/whitebyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitebyte/subscriptions","organizations_url":"https://api.github.com/users/whitebyte/orgs","repos_url":"https://api.github.com/users/whitebyte/repos","events_url":"https://api.github.com/users/whitebyte/events{/privacy}","received_events_url":"https://api.github.com/users/whitebyte/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-05T18:22:14Z","updated_at":"2015-08-05T21:15:48Z","closed_at":null,"body":"Consider this small example:\r\n```D\r\n        // ...\r\n        string query = \"SELECT * FROM `documents`\";\r\n        auto cmd = new Command(dbconnection, query);\r\n        ulong ra;\r\n        auto result = cmd.execSQL(ra);\r\n        \r\n        while (cmd.rowsPending) {\r\n            writeln(cmd.getNextRow());\r\n        }\r\n```\r\n\r\nLet's say we have a pretty simple SQL table \"documents\":\r\n```SQL\r\n+----+--------------+-----------------------------+\r\n| id | title        | content                     |\r\n+----+--------------+-----------------------------+\r\n|  1 | test1        | 1231232312312312            |\r\n|  2 | test2        | 123                         |\r\n|  3 | test3        | 123123123123123             |\r\n+----+--------------+-----------------------------+\r\n```\r\n\r\nAs we see, there are 3 rows, but this example program writelns 4, not 3, something like this:\r\n\r\n```\r\nRow([1, test1 , 1231232312312312 ], [false, false, false])\r\nRow([2, test2, 123], [false, false, false])\r\nRow([3, test3, 123123123123123], [false, false, false])\r\nRow([], [])  <-- ???\r\n```\r\nIs this a bug, or maybe I just missing some point ?"},"comment":{"url":"https://api.github.com/repos/mysql-d/mysql-native/issues/comments/128151509","html_url":"https://github.com/mysql-d/mysql-native/issues/59#issuecomment-128151509","issue_url":"https://api.github.com/repos/mysql-d/mysql-native/issues/59","id":128151509,"user":{"login":"Abscissa","id":714873,"avatar_url":"https://avatars.githubusercontent.com/u/714873?v=3","gravatar_id":"","url":"https://api.github.com/users/Abscissa","html_url":"https://github.com/Abscissa","followers_url":"https://api.github.com/users/Abscissa/followers","following_url":"https://api.github.com/users/Abscissa/following{/other_user}","gists_url":"https://api.github.com/users/Abscissa/gists{/gist_id}","starred_url":"https://api.github.com/users/Abscissa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Abscissa/subscriptions","organizations_url":"https://api.github.com/users/Abscissa/orgs","repos_url":"https://api.github.com/users/Abscissa/repos","events_url":"https://api.github.com/users/Abscissa/events{/privacy}","received_events_url":"https://api.github.com/users/Abscissa/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T21:15:48Z","updated_at":"2015-08-05T21:15:48Z","body":"If you're reading data returned from a query, you should use either ```execSQLResult``` (to grab all results at once and obtain array-like access via ```struct ResultSet```), or ```execSQLSequence``` (to grab the results lazily, row-by-row, via an input range interface ```struct ResultSequence```). The ```execSQL``` function is for queries like INSERT, UPDATE, CREATE, etc that don't return any data other than \"rows affected\".\r\n\r\nex:\r\n\r\n```d\r\n// Eager, random-access, array-like:\r\nauto rows = cmd.execSQLResult();\r\nwriteln(\"Num rows: \", rows.length);\r\n\r\nfor(row; rows) {\r\n    writeln(row);\r\n}\r\n```\r\n\r\nor:\r\n```d\r\n// Lazy, one-row-at-a-time, input range\r\nauto results = cmd.execSQLSequence();\r\n\r\nwhile(!results.empty) {\r\n    writeln(results.front);\r\n    results.popFront();\r\n}\r\n//or:\r\nfor(row; results) {\r\n    writeln(row);\r\n}\r\n```\r\n\r\nHowever, I am going to leave this ticket open, because your example code probably *should* either work as expected or trigger an error, it probably shouldn't just give a bad result (Unless that blank row is how mysql indicates there's no more results. I'll have to check into ```Command.rowsPending``` and ```Command.getNextRow```. Maybe those shouldn't even be public, not sure. Needs more digging.)\r\n"}}