Very Strange and Interesting Problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Very Strange and Interesting Problem

Jim Wang
hi, every one.
     Here is a very strange and interesting problem.
     I used the following SQL to create the table teacher.
     CREATE TABLE techer(poiId INTEGER NOT NULL PRIMARY KEY,
                                            versionId INTEGER NOT NULL,
                                            regionId INTEGER ,
                                            postalCode TEXT ,
                                            phone TEXT ,
                                            attrBitMask INTEGER ,
                                            attributeBlob BLOB)
 
     and  then I used the following SQL,
     select rowid,*  from teacher.    So the strange and interesting problem happen.
     the name of the rowid column change to poiId, and the name of the poiId become poiId_1. But the two columns have the same values.
         
     Why the rowid change is column name?
     Is the problem reasonable ?  How do you think about this problem? why?
     I  am looking forward to hearing from you.
   
     Best regards.
         WQG

 





 
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Very Strange and Interesting Problem

Stephan Beal-3
On Mon, Dec 14, 2015 at 11:21 AM, 王庆刚 <[hidden email]> wrote:

> hi, every one.
>      Here is a very strange and interesting problem.
>      I used the following SQL to create the table teacher.
>      CREATE TABLE techer(poiId INTEGER NOT NULL PRIMARY KEY,
>                                             versionId INTEGER NOT NULL,
>                                             regionId INTEGER ,
>                                             postalCode TEXT ,
>                                             phone TEXT ,
>                                             attrBitMask INTEGER ,
>                                             attributeBlob BLOB)
>
>      and  then I used the following SQL,
>      select rowid,*  from teacher.    So the strange and interesting
> problem happen.
>      the name of the rowid column change to poiId, and the name of the
> poiId become poiId_1. But the two columns have the same values.
>
>      Why the rowid change is column name?
>      Is the problem reasonable ?  How do you think about this problem? why?
>      I  am looking forward to hearing from you.
>

Two answers come to mind:

1) if you do not alias column names using "AS" then the name you get from
the db driver is UNDEFINED. It might call all of them "foo" and still be
legal. The ONLY way to guaranty the names is to use "AS" to give them an
explicit name.

2) i'm guessing that you are using an abstraction layer which is changing
the returned name of your rowid.


--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Very Strange and Interesting Problem

Simon Slavin-3
In reply to this post by Jim Wang

On 14 Dec 2015, at 10:21am, 王庆刚 <[hidden email]> wrote:

>     Here is a very strange and interesting problem.

Your problem with renaming is not caused by SQLite.

How are you talking to SQLite ?  Have you written a C program which calls the SQLite API ?  Are you using the command line program supplied by the SQLite team ?

<https://www.sqlite.org/cli.html>

Are you programming in some other language ?  Are you using a program someone else wrote ?

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Very Strange and Interesting Problem

Stephan Beal-3
In reply to this post by Stephan Beal-3
On Mon, Dec 14, 2015 at 11:47 AM, Stephan Beal <[hidden email]>
wrote:

> On Mon, Dec 14, 2015 at 11:21 AM, 王庆刚 <[hidden email]> wrote:
>
>> hi, every one.
>>      Here is a very strange and interesting problem.
>>      I used the following SQL to create the table teacher.
>>      CREATE TABLE techer(poiId INTEGER NOT NULL PRIMARY KEY,...
>
>

> 1) if you do not alias column names using "AS" then the name you get from
>> the db driver is UNDEFINED. It might call all of them "foo" and still be
>> legal. The ONLY way to guaranty the names is to use "AS" to give them an
>> explicit name.
>>
>
>

> 2) i'm guessing that you are using an abstraction layer which is changing
> the returned name of your rowid.
>

i overlooked that you explicitly declared a rowid replacement. That is the
reason for what you are seeing. The link from Quan explains it in more
detail.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users