Bug 20929

Summary: substr broken
Product: Sisyphus Reporter: viy <viy>
Component: sqlite3Assignee: Vladimir D. Seleznev <vseleznv>
Status: CLOSED NOTABUG QA Contact: qa-sisyphus
Severity: major    
Priority: P3 CC: nbr, sem, shrek, vseleznv
Version: unstable   
Hardware: all   
OS: Linux   
URL: http://www.sqlite.org/cvstrac/tktview?tn=3877,39

Description viy 2009-08-01 20:18:17 MSD
перестали работать встроенные функции работы со строками.
sqlite> select substr('teststring',0,1);
 
sqlite> 

должно быть substr('teststring',0,1) == 't'
a оно ''.
Comment 1 viy 2009-08-01 20:19:50 MSD
3.6.16-alt1
Comment 2 viy 2009-08-01 20:20:38 MSD
как понимаю, Валерий взялся сопровождать, перевешиваю.
Comment 3 Valery Inozemtsev 2009-08-01 20:31:52 MSD
как воспроизвести?
Comment 4 viy 2009-08-01 20:46:15 MSD
с консоли:
[repocop@repocop ~]$ sqlite3 
SQLite version 3.6.16
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select substr('test',0,1);

sqlite> [repocop@repocop ~]$ 
[repocop@repocop ~]$
Comment 5 Valery Inozemtsev 2009-08-01 20:57:07 MSD
ты ничего не попутал?
sqlite> select substr('test',1,1);
t
sqlite>
Comment 6 viy 2009-08-01 21:05:23 MSD
нет, все верно.
песочница repocop.altlinux.org,
сегодня с утра dist-upgrade -ился,
и вот такое вылезло :(
присылай ключик, выдам ssh доступ.
Comment 7 Valery Inozemtsev 2009-08-01 21:11:24 MSD
sqlite> select substr('test',1,2);
te

нулевого символа там быть не может
Comment 8 Valery Inozemtsev 2009-08-01 21:14:29 MSD
sqlite> select substr('test',0,3);
te
Comment 9 Sir Raorn 2009-08-01 21:18:53 MSD
http://www.sqlite.org/lang_corefunc.html

substr(X,Y,Z), substr(X,Y)

Return a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then all character through the end of the string are returned.
!!!!
> The left-most character of X is number 1.
!!!!
If Y is negative the the first character of the substring is found by counting from the right rather than the left. If X is string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.
Comment 10 viy 2009-08-01 21:22:18 MSD
О. спасибо!
значит, работает.
Сорри за беспокойство.