List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:September 7 2010 5:04pm
Subject:Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)
Bug#47485
View as plain text  
On 9/7/10 2:01 PM, Dmitry Shulga wrote:
> Hi Davi!
>
>> On 9/7/10 1:34 AM, Dmitry Shulga wrote:
>>>>> +  MYSQL_RES    *res;
>>>>>>> +  MYSQL_BIND    bind[2]; +  int           rc; +  const
>>>>>>> char* sql_select = "SELECT 1, 'a'";
>>>>>
>>>>> const char sql_select[]= "SELECT 1, 'a'";
>>> Left as is since const char* is better type for a character
>>> literal.
>>
>> sql_select in your patch is just a pointer, whereas what I
>> suggested is a array. A array is certainly a "better" type to hold
>> a array of characters. Also, the pointer is useless as nothing is
>> being assigned to it afterward, yet its a full blown variable.
> Lets consider statement const char* sql_select = "SELECT 1, 'a'";
> "SELECT 1, 'a'" is a string literal. In accordance with C++ language
> standard (ISO/IEC 14882) an ordinary string literal has type “array
> of n const char” and static storage duration, where n is the size of
> the string as defined below, and is initialized with the given
> characters. (clause 2.13.4) sql_select is just name for this string

It's not just a name, it's a pointer.

> literal. I can make this variable declaration more strong and declare
> sql_select as
>
> const char* const sql_select = "SELECT 1, 'a'"; In any case
> sql_select is just label name for this string literal value.

No. The array case is the one that is just a "label".

> On the other hand If we declare sql_select as const char sql_select[]
> = "SELECT 1, 'a'"; we have array with name sql_select and this array
> filled by byte values from array corresponding to string literal
> value "SELECT 1, 'a'".
>
> I think this is not best approach.

Whatever, this is not a important.

Regards,

Davi
Thread
bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456) Bug#47485Dmitry Shulga29 Jul
  • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Davi Arnaut6 Sep
    • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Dmitry Shulga7 Sep
      • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Davi Arnaut7 Sep
        • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Dmitry Shulga7 Sep
          • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Davi Arnaut7 Sep
          • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Bjorn Munch8 Sep
            • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3456)Bug#47485Dmitry Shulga9 Sep