[MCOL-696] REVERSE may reverse all strings that are the same. Created: 2017-05-02  Updated: 2017-06-07  Resolved: 2017-06-07

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 1.1.0
Fix Version/s: 1.1.0

Type: Bug Priority: Major
Reporter: David Hall (Inactive) Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 Description   

The changes made for BLOB re-engineered the string dictionary. It exposed a problem where, with some compilers, std::string buffers are reused with a ref count behind the scenes. This meant that a simple query such as the following ended up reversing more than was intended:

MariaDB [tpch1]> select n_name, REVERSE(n_name) from nation;
-------------------------------+

n_name REVERSE(n_name)

-------------------------------+

AIREGLA AIREGLA
ANITNEGRA ANITNEGRA
LIZARB LIZARB
ADANAC ADANAC
TPYGE TPYGE
AIPOIHTE AIPOIHTE
ECNARF ECNARF
YNAMREG YNAMREG
AIDNI AIDNI
AISENODNI AISENODNI
NARI NARI
QARI QARI
NAPAJ NAPAJ
NADROJ NADROJ
AYNEK AYNEK
OCCOROM OCCOROM
EUQIBMAZOM EUQIBMAZOM
UREP UREP
ANIHC ANIHC
AINAMOR AINAMOR
AIBARA IDUAS AIBARA IDUAS
MANTEIV MANTEIV
AISSUR AISSUR
MODGNIK DETINU MODGNIK DETINU
SETATS DETINU SETATS DETINU

-------------------------------+
25 rows in set (15 min 53.39 sec)



 Comments   
Comment by David Hall (Inactive) [ 2017-05-02 ]

The fix is to make a copy of the string into a c-buffer before reversing.

Comment by Andrew Hutchings (Inactive) [ 2017-05-02 ]

Note for testing: I was only able to reproduce this on CentOS 7. Not on Ubuntu 16.04.

Comment by Daniel Lee (Inactive) [ 2017-06-07 ]

Build verified: Github source 1.1.0

[root@localhost mariadb-columnstore-server]# git show
commit a5f191d235596ca2ea6d0fabf628c2db95f61516
Author: david hill <david.hill@mariadb.com>
Date: Mon Jun 5 11:13:48 2017 -0500

[root@localhost mariadb-columnstore-engine]# git show
commit e79692ec3a6bdbbfb349851c8059f728ef2f2639
Merge: ba7825c 850d773
Author: David.Hall <david.hall@mariadb.com>
Date: Tue Jun 6 10:33:23 2017 -0500

Server version: 10.2.6-MariaDB-log Columnstore 1.1.0-1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [tpch1c]> select n_name, REVERSE(n_name) from nation;
-------------------------------+

n_name REVERSE(n_name)

-------------------------------+

ALGERIA AIREGLA
ARGENTINA ANITNEGRA
BRAZIL LIZARB
CANADA ADANAC
EGYPT TPYGE
ETHIOPIA AIPOIHTE
FRANCE ECNARF
GERMANY YNAMREG
INDIA AIDNI
INDONESIA AISENODNI
IRAN NARI
IRAQ QARI
JAPAN NAPAJ
JORDAN NADROJ
KENYA AYNEK
MOROCCO OCCOROM
MOZAMBIQUE EUQIBMAZOM
PERU UREP
CHINA ANIHC
ROMANIA AINAMOR
SAUDI ARABIA AIBARA IDUAS
VIETNAM MANTEIV
RUSSIA AISSUR
UNITED KINGDOM MODGNIK DETINU
UNITED STATES SETATS DETINU

-------------------------------+
25 rows in set (0.13 sec)

MariaDB [tpch1c]>

Generated at Thu Feb 08 02:23:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.