Browse Source

Add EnablePgSyntax flag (#8703)

Nikolay Shumkov 6 months ago
parent
commit
7f64b2da49

+ 2 - 1
ydb/core/kqp/compile_service/kqp_compile_actor.cpp

@@ -146,7 +146,8 @@ private:
             .SetIsEnableExternalDataSources(AppData(ctx)->FeatureFlags.GetEnableExternalDataSources())
             .SetIsEnableExternalDataSources(AppData(ctx)->FeatureFlags.GetEnableExternalDataSources())
             .SetIsEnablePgConstsToParams(Config->EnablePgConstsToParams)
             .SetIsEnablePgConstsToParams(Config->EnablePgConstsToParams)
             .SetApplicationName(ApplicationName)
             .SetApplicationName(ApplicationName)
-            .SetQueryParameters(QueryId.QueryParameterTypes);
+            .SetQueryParameters(QueryId.QueryParameterTypes)
+            .SetIsEnablePgSyntax(AppData(ctx)->FeatureFlags.GetEnablePgSyntax());
 
 
         return ParseStatements(QueryId.Text, QueryId.Settings.Syntax, QueryId.IsSql(), settingsBuilder, PerStatementResult);
         return ParseStatements(QueryId.Text, QueryId.Settings.Syntax, QueryId.IsSql(), settingsBuilder, PerStatementResult);
     }
     }

+ 2 - 1
ydb/core/kqp/host/kqp_host.cpp

@@ -1228,7 +1228,8 @@ private:
                 .SetIsEnableExternalDataSources(SessionCtx->Config().FeatureFlags.GetEnableExternalDataSources())
                 .SetIsEnableExternalDataSources(SessionCtx->Config().FeatureFlags.GetEnableExternalDataSources())
                 .SetIsEnablePgConstsToParams(SessionCtx->Config().EnablePgConstsToParams)
                 .SetIsEnablePgConstsToParams(SessionCtx->Config().EnablePgConstsToParams)
                 .SetQueryParameters(query.ParameterTypes)
                 .SetQueryParameters(query.ParameterTypes)
-                .SetApplicationName(ApplicationName);
+                .SetApplicationName(ApplicationName)
+                .SetIsEnablePgSyntax(SessionCtx->Config().FeatureFlags.GetEnablePgSyntax());
             auto astRes = ParseQuery(query.Text, isSql, sqlVersion, TypesCtx->DeprecatedSQL, ctx, settingsBuilder, result.KeepInCache, result.CommandTagName);
             auto astRes = ParseQuery(query.Text, isSql, sqlVersion, TypesCtx->DeprecatedSQL, ctx, settingsBuilder, result.KeepInCache, result.CommandTagName);
             if (astRes.ActualSyntaxType == NYql::ESyntaxType::Pg) {
             if (astRes.ActualSyntaxType == NYql::ESyntaxType::Pg) {
                 SessionCtx->Config().IndexAutoChooserMode = NKikimrConfig::TTableServiceConfig_EIndexAutoChooseMode::TTableServiceConfig_EIndexAutoChooseMode_MAX_USED_PREFIX;
                 SessionCtx->Config().IndexAutoChooserMode = NKikimrConfig::TTableServiceConfig_EIndexAutoChooseMode::TTableServiceConfig_EIndexAutoChooseMode_MAX_USED_PREFIX;

+ 1 - 0
ydb/core/kqp/host/kqp_translate.cpp

@@ -86,6 +86,7 @@ NSQLTranslation::TTranslationSettings TKqpTranslationSettingsBuilder::Build(NYql
         settings.SaveWorldDependencies = true;
         settings.SaveWorldDependencies = true;
     }
     }
 
 
+    settings.PGDisable = !IsEnablePgSyntax;
     settings.InferSyntaxVersion = true;
     settings.InferSyntaxVersion = true;
     settings.V0ForceDisable = false;
     settings.V0ForceDisable = false;
     settings.WarnOnV0 = false;
     settings.WarnOnV0 = false;

+ 6 - 0
ydb/core/kqp/host/kqp_translate.h

@@ -62,6 +62,11 @@ public:
         return *this;
         return *this;
     }
     }
 
 
+    TKqpTranslationSettingsBuilder& SetIsEnablePgSyntax(bool value) {
+        IsEnablePgSyntax = value;
+        return *this;
+    }
+
 private:
 private:
     const NYql::EKikimrQueryType QueryType;
     const NYql::EKikimrQueryType QueryType;
     const ui16 KqpYqlSyntaxVersion;
     const ui16 KqpYqlSyntaxVersion;
@@ -73,6 +78,7 @@ private:
     TString KqpTablePathPrefix = {};
     TString KqpTablePathPrefix = {};
     bool IsEnableExternalDataSources = false;
     bool IsEnableExternalDataSources = false;
     bool IsEnablePgConstsToParams = false;
     bool IsEnablePgConstsToParams = false;
+    bool IsEnablePgSyntax = false;
     TMaybe<bool> SqlAutoCommit = {};
     TMaybe<bool> SqlAutoCommit = {};
     TGUCSettings::TPtr GUCSettings;
     TGUCSettings::TPtr GUCSettings;
     TMaybe<TString> ApplicationName = {};
     TMaybe<TString> ApplicationName = {};

+ 1 - 0
ydb/core/kqp/ut/common/kqp_ut_common.cpp

@@ -132,6 +132,7 @@ TKikimrRunner::TKikimrRunner(const TKikimrSettings& settings) {
     ServerSettings->SetEnableMoveIndex(true);
     ServerSettings->SetEnableMoveIndex(true);
     ServerSettings->SetUseRealThreads(settings.UseRealThreads);
     ServerSettings->SetUseRealThreads(settings.UseRealThreads);
     ServerSettings->SetEnableTablePgTypes(true);
     ServerSettings->SetEnableTablePgTypes(true);
+    ServerSettings->SetEnablePgSyntax(true);
     ServerSettings->S3ActorsFactory = settings.S3ActorsFactory;
     ServerSettings->S3ActorsFactory = settings.S3ActorsFactory;
 
 
     if (settings.Storage) {
     if (settings.Storage) {

+ 2 - 1
ydb/core/kqp/ut/pg/kqp_pg_ut.cpp

@@ -4801,7 +4801,8 @@ Y_UNIT_TEST_SUITE(KqpPg) {
         ui16 mbusport = tp.GetPort(2134);
         ui16 mbusport = tp.GetPort(2134);
         auto settings = Tests::TServerSettings(mbusport)
         auto settings = Tests::TServerSettings(mbusport)
             .SetDomainName("Root")
             .SetDomainName("Root")
-            .SetUseRealThreads(false);
+            .SetUseRealThreads(false)
+            .SetEnablePgSyntax(true);
 
 
         Tests::TServer::TPtr server = new Tests::TServer(settings);
         Tests::TServer::TPtr server = new Tests::TServer(settings);
 
 

+ 1 - 0
ydb/core/protos/feature_flags.proto

@@ -155,4 +155,5 @@ message TFeatureFlags {
     optional bool EnableOptionalColumnsInColumnShard = 136 [default = false];
     optional bool EnableOptionalColumnsInColumnShard = 136 [default = false];
     optional bool EnableGranularTimecast = 137 [default = true];
     optional bool EnableGranularTimecast = 137 [default = true];
     optional bool EnableAlterShardingInColumnShard = 138 [default = false];
     optional bool EnableAlterShardingInColumnShard = 138 [default = false];
+    optional bool EnablePgSyntax = 139 [default = true];
 }
 }

+ 1 - 0
ydb/core/testlib/basics/feature_flags.h

@@ -64,6 +64,7 @@ public:
     FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables)
     FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables)
     FEATURE_FLAG_SETTER(EnableBackupService)
     FEATURE_FLAG_SETTER(EnableBackupService)
     FEATURE_FLAG_SETTER(EnableGranularTimecast)
     FEATURE_FLAG_SETTER(EnableGranularTimecast)
+    FEATURE_FLAG_SETTER(EnablePgSyntax)
 
 
     #undef FEATURE_FLAG_SETTER
     #undef FEATURE_FLAG_SETTER
 };
 };

+ 1 - 0
ydb/library/yql/sql/settings/translation_settings.cpp

@@ -58,6 +58,7 @@ namespace NSQLTranslation {
         , InferSyntaxVersion(false)
         , InferSyntaxVersion(false)
         , V0Behavior(EV0Behavior::Disable)
         , V0Behavior(EV0Behavior::Disable)
         , V0ForceDisable(InTestEnvironment())
         , V0ForceDisable(InTestEnvironment())
+        , PGDisable(false)
         , WarnOnV0(true)
         , WarnOnV0(true)
         , V0WarnAsError(ISqlFeaturePolicy::MakeAlwaysDisallow())
         , V0WarnAsError(ISqlFeaturePolicy::MakeAlwaysDisallow())
         , DqDefaultAuto(ISqlFeaturePolicy::MakeAlwaysDisallow())
         , DqDefaultAuto(ISqlFeaturePolicy::MakeAlwaysDisallow())

+ 1 - 0
ydb/library/yql/sql/settings/translation_settings.h

@@ -106,6 +106,7 @@ namespace NSQLTranslation {
         bool InferSyntaxVersion;
         bool InferSyntaxVersion;
         EV0Behavior V0Behavior;
         EV0Behavior V0Behavior;
         bool V0ForceDisable;
         bool V0ForceDisable;
+        bool PGDisable;
         bool WarnOnV0;
         bool WarnOnV0;
         ISqlFeaturePolicy::TPtr V0WarnAsError;
         ISqlFeaturePolicy::TPtr V0WarnAsError;
         ISqlFeaturePolicy::TPtr DqDefaultAuto;
         ISqlFeaturePolicy::TPtr DqDefaultAuto;

Some files were not shown because too many files changed in this diff