~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
826
826
%token  ULONGLONG_NUM
827
827
%token  UNCOMMITTED_SYM               /* SQL-2003-N */
828
828
%token  UNDEFINED_SYM
829
 
%token  UNDERSCORE_CHARSET
830
829
%token  UNDOFILE_SYM
831
830
%token  UNDO_SYM                      /* FUTURE-USE */
832
831
%token  UNION_SYM                     /* SQL-2003-R */
995
994
%type <charset>
996
995
        collation_name
997
996
        collation_name_or_default
998
 
        UNDERSCORE_CHARSET
999
997
 
1000
998
%type <variable> internal_variable_name
1001
999
 
5301
5299
            uint32_t repertoire= session->lex->text_string_is_7bit &&
5302
5300
                             my_charset_is_ascii_based(cs_cli) ?
5303
5301
                             MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5304
 
            if (session->charset_is_collation_connection ||
5305
 
                (repertoire == MY_REPERTOIRE_ASCII &&
5306
 
                 my_charset_is_ascii_based(cs_con)))
5307
 
              tmp= $1;
5308
 
            else
5309
 
              session->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli);
5310
 
            $$= new Item_string(tmp.str, tmp.length, cs_con,
5311
 
                                DERIVATION_COERCIBLE, repertoire);
5312
 
          }
5313
 
        | UNDERSCORE_CHARSET TEXT_STRING
5314
 
          {
5315
 
            Item_string *str= new Item_string($2.str, $2.length, $1);
5316
 
            str->set_repertoire_from_value();
5317
 
            str->set_cs_specified(true);
5318
 
 
5319
 
            $$= str;
 
5302
            tmp= $1;
 
5303
            $$= new Item_string(tmp.str, tmp.length, cs_con, DERIVATION_COERCIBLE, repertoire);
5320
5304
          }
5321
5305
        | text_literal TEXT_STRING_literal
5322
5306
          {
5388
5372
        | TRUE_SYM { $$= new Item_int((char*) "TRUE",1,1); }
5389
5373
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
5390
5374
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
5391
 
        | UNDERSCORE_CHARSET HEX_NUM
5392
 
          {
5393
 
            Item *tmp= new Item_hex_string($2.str, $2.length);
5394
 
            /*
5395
 
              it is OK only emulate fix_fieds, because we need only
5396
 
              value of constant
5397
 
            */
5398
 
            String *str= tmp ?
5399
 
              tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5400
 
              (String*) 0;
5401
 
 
5402
 
            Item_string *item_str=
5403
 
              new Item_string(NULL, /* name will be set in select_item */
5404
 
                              str ? str->ptr() : "",
5405
 
                              str ? str->length() : 0,
5406
 
                              $1);
5407
 
            if (!item_str ||
5408
 
                !item_str->check_well_formed_result(&item_str->str_value, true))
5409
 
            {
5410
 
              DRIZZLE_YYABORT;
5411
 
            }
5412
 
 
5413
 
            item_str->set_repertoire_from_value();
5414
 
            item_str->set_cs_specified(true);
5415
 
 
5416
 
            $$= item_str;
5417
 
          }
5418
 
        | UNDERSCORE_CHARSET BIN_NUM
5419
 
          {
5420
 
            Item *tmp= new Item_bin_string($2.str, $2.length);
5421
 
            /*
5422
 
              it is OK only emulate fix_fieds, because we need only
5423
 
              value of constant
5424
 
            */
5425
 
            String *str= tmp ?
5426
 
              tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5427
 
              (String*) 0;
5428
 
 
5429
 
            Item_string *item_str=
5430
 
              new Item_string(NULL, /* name will be set in select_item */
5431
 
                              str ? str->ptr() : "",
5432
 
                              str ? str->length() : 0,
5433
 
                              $1);
5434
 
            if (!item_str ||
5435
 
                !item_str->check_well_formed_result(&item_str->str_value, true))
5436
 
            {
5437
 
              DRIZZLE_YYABORT;
5438
 
            }
5439
 
 
5440
 
            item_str->set_cs_specified(true);
5441
 
 
5442
 
            $$= item_str;
5443
 
          }
5444
5375
        | DATE_SYM text_literal { $$ = $2; }
5445
5376
        | TIMESTAMP text_literal { $$ = $2; }
5446
5377
        ;
5637
5568
          IDENT { $$= $1; }
5638
5569
        | IDENT_QUOTED
5639
5570
          {
5640
 
            Session *session= YYSession;
5641
 
 
5642
 
            if (session->charset_is_system_charset)
 
5571
            const CHARSET_INFO * const cs= system_charset_info;
 
5572
            int dummy_error;
 
5573
            uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
 
5574
                                                 $1.str+$1.length,
 
5575
                                                 $1.length, &dummy_error);
 
5576
            if (wlen < $1.length)
5643
5577
            {
5644
 
              const CHARSET_INFO * const cs= system_charset_info;
5645
 
              int dummy_error;
5646
 
              uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
5647
 
                                                   $1.str+$1.length,
5648
 
                                                   $1.length, &dummy_error);
5649
 
              if (wlen < $1.length)
5650
 
              {
5651
 
                my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
5652
 
                         cs->csname, $1.str + wlen);
5653
 
                DRIZZLE_YYABORT;
5654
 
              }
5655
 
              $$= $1;
 
5578
              my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
 
5579
                       cs->csname, $1.str + wlen);
 
5580
              DRIZZLE_YYABORT;
5656
5581
            }
5657
 
            else
5658
 
              session->convert_string(&$$, system_charset_info,
5659
 
                                  $1.str, $1.length, session->charset());
 
5582
            $$= $1;
5660
5583
          }
5661
5584
        ;
5662
5585
 
5663
5586
TEXT_STRING_sys:
5664
5587
          TEXT_STRING
5665
5588
          {
5666
 
            Session *session= YYSession;
5667
 
 
5668
 
            if (session->charset_is_system_charset)
5669
 
              $$= $1;
5670
 
            else
5671
 
              session->convert_string(&$$, system_charset_info,
5672
 
                                  $1.str, $1.length, session->charset());
 
5589
            $$= $1;
5673
5590
          }
5674
5591
        ;
5675
5592
 
5676
5593
TEXT_STRING_literal:
5677
5594
          TEXT_STRING
5678
5595
          {
5679
 
            Session *session= YYSession;
5680
 
 
5681
 
            if (session->charset_is_collation_connection)
5682
 
              $$= $1;
5683
 
            else
5684
 
              session->convert_string(&$$, session->variables.getCollation(),
5685
 
                                  $1.str, $1.length, session->charset());
 
5596
            $$= $1;
5686
5597
          }
5687
5598
        ;
5688
5599
 
5689
5600
TEXT_STRING_filesystem:
5690
5601
          TEXT_STRING
5691
5602
          {
5692
 
            Session *session= YYSession;
5693
 
 
5694
 
            if (session->charset_is_character_set_filesystem)
5695
 
              $$= $1;
5696
 
            else
5697
 
              session->convert_string(&$$, session->variables.character_set_filesystem,
5698
 
                                  $1.str, $1.length, session->charset());
 
5603
            $$= $1;
5699
5604
          }
5700
5605
        ;
5701
5606