Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-7840 fix null in indexed expressions, add fullDDL cases for this and... #2108

Merged
merged 2 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ public boolean isPrefixPatternString() {

@Override
public String explain(String unused) {
if (m_isNull) {
return "NULL";
}
if (m_valueType == VoltType.STRING) {
return "'" + m_value + "'";
}
Expand Down
44 changes: 44 additions & 0 deletions tests/frontend/org/voltdb/fullddlfeatures/fullDDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -876,3 +876,47 @@ T54
C2
);
ALTER TABLE T54 ALTER COLUMN C2 VARCHAR(2) CASCADE;

CREATE TABLE T55
(
STR VARCHAR(30)
, TS TIMESTAMP
, BIG BIGINT
);

-- These statements were added when use of some Volt-specific functions or ||
-- or NULL in indexed expressions was discovered to be mishandled (ENG-7792).
-- They showed that views and procs did NOT share these problems,
-- but let's make sure things stay that way.
CREATE PROCEDURE PROC_USES_CONCAT AS SELECT CONCAT(SUBSTRING(STR,4), SUBSTRING(STR,1,3)) FROM T55;
CREATE PROCEDURE PROC_USES_BARBARCONCAT AS SELECT SUBSTRING(STR,5) || SUBSTRING(STR,1,3) FROM T55;
CREATE PROCEDURE PROC_USES_NULL AS SELECT DECODE(STR, NULL, 'NULLISH', STR) FROM T55;
CREATE PROCEDURE PROC_USES_TO_TIMESTAMP AS SELECT TO_TIMESTAMP(SECOND, BIG) FROM T55;
CREATE VIEW V55_USES_NULL AS
SELECT DECODE(STR, NULL, 'NULLISH', STR), COUNT(*), SUM(BIG)
FROM T55
GROUP BY DECODE(STR, NULL, 'NULLISH', STR);
CREATE VIEW V55_USES_TO_TIMESTAMP AS
SELECT TO_TIMESTAMP(SECOND, BIG), COUNT(*), COUNT(STR)
FROM T55
GROUP BY TO_TIMESTAMP(SECOND, BIG);
CREATE VIEW V55_USES_CONCAT AS
SELECT CONCAT(SUBSTRING(STR,4), SUBSTRING(STR,1,3)), COUNT(*), COUNT(STR)
FROM T55
GROUP BY CONCAT(SUBSTRING(STR,4), SUBSTRING(STR,1,3));
CREATE VIEW V55_USES_BARBARCONCAT AS
SELECT SUBSTRING(STR,5) || SUBSTRING(STR,1,3), COUNT(*), COUNT(STR)
FROM T55
GROUP BY SUBSTRING(STR,5) || SUBSTRING(STR,1,3);

-- ENG-7792 Make sure that concat, ||, and volt-specific SQL functions survive DDL roundtripping.
-- This especially exercises FunctionForVoltDB.getSQL().
CREATE INDEX ENG7792_INDEX_USES_CONCAT ON T55 (CONCAT(SUBSTRING(STR,4), SUBSTRING(STR,1,3)));
CREATE INDEX ENG7792_INDEX_USES_BARBARCONCAT ON T55 (SUBSTRING(STR,5) || SUBSTRING(STR,1,3));
-- ENG-7840 Make sure that a NULL constant survives DDL roundtripping.
CREATE INDEX ENG7840_INDEX_USES_NULL ON T55 (DECODE(STR, NULL, 'NULLISH', STR));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to see these tests, looks good to me.

CREATE INDEX INDEX_USES_DECODE ON T55 (DECODE(STR, '', 'NULLISH', STR));
CREATE INDEX INDEX_USES_SINCE_EPOCH ON T55 (SINCE_EPOCH(SECOND, TS)/60);
CREATE INDEX INDEX_USES_TRUNCATE_AND_TO_TIMESTAMP ON T55 (TRUNCATE(DAY, TO_TIMESTAMP(SECOND, BIG)));
CREATE INDEX INDEX_USES_JSON_SET_FIELD_ON_FIELD ON T55 (SET_FIELD(FIELD(STR, 'A'), 'B', ''));
CREATE INDEX INDEX_USES_JSON_ARRAY_OPS ON T55 (ARRAY_ELEMENT(STR, ARRAY_LENGTH(STR)-1));