crossdb-org / crossdb

Ultra High-performance Lightweight Embedded and Server OLTP RDBMS✨
https://crossdb.org
Mozilla Public License 2.0
184 stars 12 forks source link

Selecting expressions does not work #12

Closed mripley closed 2 months ago

mripley commented 2 months ago

There appears to be no ability to project expressions in queries. Example

XDB> create table t1 (c1 int); 
Query OK, 0 row affected (2.217 ms)

XDB> insert into t1 values (0),(1); 
Query OK, 2 rows affected (0.254 ms)

XDB> select c1 + 10 from t1; 
ERROR 3: Except FROM
mripley commented 2 months ago

Yea ... I'm not downloading some random media fire link. If you have a fix please push a branch here and i'll consider reviewing it.

jcwangxp commented 2 months ago

Will support in next release, but only simple expression. Complex expression will be supported later.

mripley commented 2 months ago

You may want to update your documentation to reflect these limitations otherwise folks may find themselves disappointed once they start to use it.

jcwangxp commented 2 months ago

It's noted here. I've delivered this feature just now.

https://crossdb.org/sql/operators/

mripley commented 2 months ago

There seems to be a bug in predicate evaluation. Example:

XDB> select * from t2 where c2 < 3; 
+----+
| c2 |
+----+
| 0  |
| 1  |
| 2  |
+----+
3 rows in set (0.025 ms)

XDB> select * from t2 where 3 < c1; 
+----+
| c2 |
+----+
| 0  |
| 1  |
| 2  |
| 3  |
| 4  |
+----+
5 rows in set (0.033 ms)
jcwangxp commented 2 months ago

'3 < c1' can be changed to 'c1 > 3', and I'll support later.

mripley commented 2 months ago

Sure. I also noted any constant false predicates returned wrong results as well. E g 'where 1 = 2'

On Wed, Aug 28, 2024, 08:38 JC Wang @.***> wrote:

'3 < c1' can be changed to 'c1 > 3', and I'll support later.

— Reply to this email directly, view it on GitHub https://github.com/crossdb-org/CrossDB/issues/12#issuecomment-2315697690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFOY3VKPU4OCBFM7HOO3KLZTXVI3AVCNFSM6AAAAABNFFXJO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJVGY4TONRZGA . You are receiving this because you authored the thread.Message ID: @.***>

jcwangxp commented 2 months ago

For constant predicates like '1 = 1', this may cause SQL injection attacks. I plan not to support this feature. What's your opinion? Are there any real use cases that need this feature?

jcwangxp commented 2 months ago

Support in 0.8.0