[Groonga-commit] groonga/groonga [master] Fix a bug that int64 literal is truncated to uint32

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Feb 4 15:28:30 JST 2013


Kouhei Sutou	2013-02-04 15:28:30 +0900 (Mon, 04 Feb 2013)

  New Revision: 4f0516b4fda2b8cfd1b300f8543f75f1da201214
  https://github.com/groonga/groonga/commit/4f0516b4fda2b8cfd1b300f8543f75f1da201214

  Log:
    Fix a bug that int64 literal is truncated to uint32
    
    Workaround for the bug: Use string literal such as
    
      "20130204150"
    
    instead of
    
      20130204150
    
    The string literal is casted when it is used. It doesn't face the
    bug.

  Added files:
    test/command/suite/select/filter/literal/int64.expected
    test/command/suite/select/filter/literal/int64.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+2 -1)
===================================================================
--- lib/expr.c    2013-02-04 14:10:16 +0900 (f6fffe6)
+++ lib/expr.c    2013-02-04 15:28:30 +0900 (04f1931)
@@ -5905,7 +5905,8 @@ parse_script(grn_ctx *ctx, efs_info *q)
           const char *rest64 = rest;
           unsigned int uint32 = grn_atoui(q->cur, q->str_end, &rest);
           // checks to see grn_atoi failed (see above NOTE)
-          if (q->str_end != rest && *rest >= '0' && *rest <= '9') {
+          if ((int64 > UINT32_MAX) ||
+              (q->str_end != rest && *rest >= '0' && *rest <= '9')) {
             grn_obj int64buf;
             GRN_INT64_INIT(&int64buf, 0);
             GRN_INT64_SET(ctx, &int64buf, int64);

  Added: test/command/suite/select/filter/literal/int64.expected (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/literal/int64.expected    2013-02-04 15:28:30 +0900 (c7a4196)
@@ -0,0 +1,11 @@
+table_create Output TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Output int64 COLUMN_SCALAR Int64
+[[0,0.0,0.0],true]
+load --table Output
+[
+{"_key": "output"}
+]
+[[0,0.0,0.0],1]
+select Output   --filter "true"   --scorer "int64 = 20130204150"   --output_columns int64
+[[0,0.0,0.0],[[[1],[["int64","Int64"]],[20130204150]]]]

  Added: test/command/suite/select/filter/literal/int64.test (+12 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/literal/int64.test    2013-02-04 15:28:30 +0900 (346ffe0)
@@ -0,0 +1,12 @@
+table_create Output TABLE_HASH_KEY ShortText
+column_create Output int64 COLUMN_SCALAR Int64
+
+load --table Output
+[
+{"_key": "output"}
+]
+
+select Output \
+  --filter "true" \
+  --scorer "int64 = 20130204150" \
+  --output_columns int64
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index