Kouhei Sutou
null+****@clear*****
Wed Oct 26 13:48:36 JST 2016
Kouhei Sutou 2016-10-26 13:48:36 +0900 (Wed, 26 Oct 2016) New Revision: 88931a041c5455de8a556878ed09d329e00cc01b https://github.com/groonga/groonga/commit/88931a041c5455de8a556878ed09d329e00cc01b Message: select: ignore wrong column name that starts with number in output_columns The behavior change was unexpected. So we should revert the behavior change. Added files: test/command/suite/select/output_columns/nonexistent/invalid_identifier.expected test/command/suite/select/output_columns/nonexistent/invalid_identifier.test Modified files: lib/output.c Modified: lib/output.c (+13 -1) =================================================================== --- lib/output.c 2016-10-25 22:48:27 +0900 (131342f) +++ lib/output.c 2016-10-26 13:48:36 +0900 (d894280) @@ -2809,6 +2809,7 @@ is_output_columns_format_v1(grn_ctx *ctx, { const char *current; const char *end; + grn_bool in_identifier = GRN_FALSE; current = output_columns; end = current + output_columns_len; @@ -2822,18 +2823,29 @@ is_output_columns_format_v1(grn_ctx *ctx, switch (current[0]) { case ' ' : - case '.' : + case ',' : + in_identifier = GRN_FALSE; + break; case '_' : + in_identifier = GRN_TRUE; + break; + case '.' : case '-' : case '#' : case '@' : + if (!in_identifier) { + return GRN_FALSE; + } break; default : if ('a' <= current[0] && current[0] <= 'z') { + in_identifier = GRN_TRUE; break; } else if ('A' <= current[0] && current[0] <= 'Z') { + in_identifier = GRN_TRUE; break; } else if ('0' <= current[0] && current[0] <= '9') { + in_identifier = GRN_TRUE; break; } else { return GRN_FALSE; Added: test/command/suite/select/output_columns/nonexistent/invalid_identifier.expected (+50 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/output_columns/nonexistent/invalid_identifier.expected 2016-10-26 13:48:36 +0900 (057ee1e) @@ -0,0 +1,50 @@ +table_create Sites TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Sites uri COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +load --table Sites +[ +["_key","uri"], +["groonga","http://groonga.org/"], +["razil","http://razil.jp/"] +] +[[0,0.0,0.0],2] +select Sites --output_columns '_id, _key, 0nonexistent, uri' +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "uri", + "ShortText" + ] + ], + [ + 1, + "groonga", + "http://groonga.org/" + ], + [ + 2, + "razil", + "http://razil.jp/" + ] + ] + ] +] Added: test/command/suite/select/output_columns/nonexistent/invalid_identifier.test (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/output_columns/nonexistent/invalid_identifier.test 2016-10-26 13:48:36 +0900 (6bad9ce) @@ -0,0 +1,11 @@ +table_create Sites TABLE_HASH_KEY ShortText +column_create Sites uri COLUMN_SCALAR ShortText + +load --table Sites +[ +["_key","uri"], +["groonga","http://groonga.org/"], +["razil","http://razil.jp/"] +] + +select Sites --output_columns '_id, _key, 0nonexistent, uri' -------------- next part -------------- HTML����������������������������... Download