Просмотр исходного кода

YQL-17038 [pg] ignore locking clause for now

vvvv 1 год назад
Родитель
Сommit
c05ebc290f

+ 3 - 0
ydb/library/yql/core/issue/protos/issue_id.proto

@@ -181,6 +181,9 @@ message TIssuesIds {
         DQ_GATEWAY_NEED_FALLBACK_ERROR = 6001;
         DQ_OPTIMIZE_ERROR = 6002;
 
+// pg
+        PG_NO_LOCKING_SUPPORT = 7000;
+
 // range [200000, 399999) reserved for KiKiMR issue codes, do not use!
 
     }

+ 4 - 0
ydb/library/yql/core/issue/yql_issue.txt

@@ -643,3 +643,7 @@ ids {
   code: YQL_HINT_INVALID_PARAMETERS
   severity: S_WARNING
 }
+ids {
+  code: PG_NO_LOCKING_SUPPORT
+  severity: S_WARNING
+}

+ 4 - 6
ydb/library/yql/sql/pg/pg_sql.cpp

@@ -946,11 +946,10 @@ public:
                     AddError(TStringBuilder() << "LimitOption unsupported value: " << (int)x->limitOption);
                     return nullptr;
                 }
-            }
 
-            if (ListLength(x->lockingClause) > 0) {
-                AddError("SelectStmt: not supported lockingClause");
-                return nullptr;
+                if (ListLength(x->lockingClause) > 0) {
+                    AddWarning(TIssuesIds::PG_NO_LOCKING_SUPPORT, "SelectStmt: lockingClause is ignored");
+                }
             }
 
             TVector<TAstNode*> res;
@@ -1054,8 +1053,7 @@ public:
         }
 
         if (ListLength(value->lockingClause) > 0) {
-            AddError("SelectStmt: not supported lockingClause");
-            return nullptr;
+            AddWarning(TIssuesIds::PG_NO_LOCKING_SUPPORT, "SelectStmt: lockingClause is ignored");
         }
 
         TAstNode* limit = nullptr;

+ 9 - 2
ydb/library/yql/sql/pg/pg_sql_ut.cpp

@@ -5,10 +5,18 @@
 using namespace NSQLTranslation;
 
 Y_UNIT_TEST_SUITE(PgSqlParsingOnly) {
+    Y_UNIT_TEST(Locking) {
+        auto res = PgSqlToYql("SELECT 1 FROM plato.Input FOR UPDATE");
+        UNIT_ASSERT(res.Root);
+        UNIT_ASSERT_EQUAL(res.Issues.Size(), 1);
+
+        auto issue = *(res.Issues.begin());
+        UNIT_ASSERT(issue.GetMessage().find("locking") != TString::npos);
+    }
+
     Y_UNIT_TEST(InsertStmt) {
         auto res = PgSqlToYql("INSERT INTO plato.Input VALUES (1, 1)");
         UNIT_ASSERT(res.Root);
-        res.Root->PrintTo(Cerr);
     }
 
     Y_UNIT_TEST(InsertStmt_DefaultValues) {
@@ -397,7 +405,6 @@ SELECT COUNT(*) FROM public.t;");
 
     Y_UNIT_TEST(UpdateStmt) {
         auto res = PgSqlToYql("UPDATE plato.Input SET kind = 'test' where kind = 'testtest'");
-        Cerr << res.Root->ToString();
         TString updateStmtProg = R"(
             (
                 (let world (Configure! world (DataSource 'config) 'OrderedColumns))