fix: ensure Create Or Replace and If Not Exist cannot coexist in create view (#5003)

ensure Create Or Replace and If Not Exist cannot coexist in create view statement
This commit is contained in:
Lanqing Yang
2024-11-16 23:08:30 -08:00
committed by GitHub
parent 4b263ef1cc
commit 485782af51
2 changed files with 21 additions and 18 deletions

View File

@@ -97,26 +97,23 @@ SELECT * FROM v1;
--- if not exists with replace, so it changes ---
CREATE OR REPLACE VIEW IF NOT EXISTS v1 AS SELECT c FROM t1;
Affected Rows: 0
Error: 1004(InvalidArguments), Invalid SQL, error: syntax error Create Or Replace and If Not Exist cannot be used together
SHOW CREATE VIEW v1;
+------+-------------------------------------------------------------+
| View | Create View |
+------+-------------------------------------------------------------+
| v1 | CREATE OR REPLACE VIEW IF NOT EXISTS v1 AS SELECT c FROM t1 |
+------+-------------------------------------------------------------+
+------+------------------------------------------------------------------+
| View | Create View |
+------+------------------------------------------------------------------+
| v1 | CREATE OR REPLACE VIEW v1 AS SELECT a, b, c FROM t1 WHERE a > 43 |
+------+------------------------------------------------------------------+
SELECT * FROM v1;
+-------------------------+
| c |
+-------------------------+
| 1970-01-01T00:00:00.001 |
| 1970-01-01T00:00:00.002 |
| 1970-01-01T00:00:00.003 |
| 1970-01-01T00:00:00.004 |
+-------------------------+
+----+------------+-------------------------+
| a | b | c |
+----+------------+-------------------------+
| 44 | greptimedb | 1970-01-01T00:00:00.004 |
+----+------------+-------------------------+
DROP VIEW v1;