MindsDB 25.9.2.0a1__py3-none-any.whl → 25.10.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of MindsDB might be problematic. Click here for more details.

Files changed (163) hide show
  1. mindsdb/__about__.py +1 -1
  2. mindsdb/__main__.py +40 -29
  3. mindsdb/api/a2a/__init__.py +1 -1
  4. mindsdb/api/a2a/agent.py +16 -10
  5. mindsdb/api/a2a/common/server/server.py +7 -3
  6. mindsdb/api/a2a/common/server/task_manager.py +12 -5
  7. mindsdb/api/a2a/common/types.py +66 -0
  8. mindsdb/api/a2a/task_manager.py +65 -17
  9. mindsdb/api/common/middleware.py +10 -12
  10. mindsdb/api/executor/command_executor.py +51 -40
  11. mindsdb/api/executor/datahub/datanodes/datanode.py +2 -2
  12. mindsdb/api/executor/datahub/datanodes/information_schema_datanode.py +7 -13
  13. mindsdb/api/executor/datahub/datanodes/integration_datanode.py +101 -49
  14. mindsdb/api/executor/datahub/datanodes/project_datanode.py +8 -4
  15. mindsdb/api/executor/datahub/datanodes/system_tables.py +3 -2
  16. mindsdb/api/executor/exceptions.py +29 -10
  17. mindsdb/api/executor/planner/plan_join.py +17 -3
  18. mindsdb/api/executor/planner/query_prepare.py +2 -20
  19. mindsdb/api/executor/sql_query/sql_query.py +74 -74
  20. mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +1 -2
  21. mindsdb/api/executor/sql_query/steps/subselect_step.py +0 -1
  22. mindsdb/api/executor/utilities/functions.py +6 -6
  23. mindsdb/api/executor/utilities/sql.py +37 -20
  24. mindsdb/api/http/gui.py +5 -11
  25. mindsdb/api/http/initialize.py +75 -61
  26. mindsdb/api/http/namespaces/agents.py +10 -15
  27. mindsdb/api/http/namespaces/analysis.py +13 -20
  28. mindsdb/api/http/namespaces/auth.py +1 -1
  29. mindsdb/api/http/namespaces/chatbots.py +0 -5
  30. mindsdb/api/http/namespaces/config.py +15 -11
  31. mindsdb/api/http/namespaces/databases.py +140 -201
  32. mindsdb/api/http/namespaces/file.py +17 -4
  33. mindsdb/api/http/namespaces/handlers.py +17 -7
  34. mindsdb/api/http/namespaces/knowledge_bases.py +28 -7
  35. mindsdb/api/http/namespaces/models.py +94 -126
  36. mindsdb/api/http/namespaces/projects.py +13 -22
  37. mindsdb/api/http/namespaces/sql.py +33 -25
  38. mindsdb/api/http/namespaces/tab.py +27 -37
  39. mindsdb/api/http/namespaces/views.py +1 -1
  40. mindsdb/api/http/start.py +16 -10
  41. mindsdb/api/mcp/__init__.py +2 -1
  42. mindsdb/api/mysql/mysql_proxy/executor/mysql_executor.py +15 -20
  43. mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +26 -50
  44. mindsdb/api/mysql/mysql_proxy/utilities/__init__.py +0 -1
  45. mindsdb/api/mysql/mysql_proxy/utilities/dump.py +8 -2
  46. mindsdb/integrations/handlers/byom_handler/byom_handler.py +165 -190
  47. mindsdb/integrations/handlers/databricks_handler/databricks_handler.py +98 -46
  48. mindsdb/integrations/handlers/druid_handler/druid_handler.py +32 -40
  49. mindsdb/integrations/handlers/file_handler/file_handler.py +7 -0
  50. mindsdb/integrations/handlers/gitlab_handler/gitlab_handler.py +5 -2
  51. mindsdb/integrations/handlers/lightwood_handler/functions.py +45 -79
  52. mindsdb/integrations/handlers/mssql_handler/mssql_handler.py +438 -100
  53. mindsdb/integrations/handlers/mssql_handler/requirements_odbc.txt +3 -0
  54. mindsdb/integrations/handlers/mysql_handler/mysql_handler.py +235 -3
  55. mindsdb/integrations/handlers/oracle_handler/__init__.py +2 -0
  56. mindsdb/integrations/handlers/oracle_handler/connection_args.py +7 -1
  57. mindsdb/integrations/handlers/oracle_handler/oracle_handler.py +321 -16
  58. mindsdb/integrations/handlers/oracle_handler/requirements.txt +1 -1
  59. mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +14 -2
  60. mindsdb/integrations/handlers/shopify_handler/shopify_handler.py +25 -12
  61. mindsdb/integrations/handlers/snowflake_handler/snowflake_handler.py +2 -1
  62. mindsdb/integrations/handlers/statsforecast_handler/requirements.txt +1 -0
  63. mindsdb/integrations/handlers/statsforecast_handler/requirements_extra.txt +1 -0
  64. mindsdb/integrations/handlers/web_handler/urlcrawl_helpers.py +4 -4
  65. mindsdb/integrations/handlers/zendesk_handler/zendesk_tables.py +144 -111
  66. mindsdb/integrations/libs/api_handler.py +10 -10
  67. mindsdb/integrations/libs/base.py +4 -4
  68. mindsdb/integrations/libs/llm/utils.py +2 -2
  69. mindsdb/integrations/libs/ml_handler_process/create_engine_process.py +4 -7
  70. mindsdb/integrations/libs/ml_handler_process/func_call_process.py +2 -7
  71. mindsdb/integrations/libs/ml_handler_process/learn_process.py +37 -47
  72. mindsdb/integrations/libs/ml_handler_process/update_engine_process.py +4 -7
  73. mindsdb/integrations/libs/ml_handler_process/update_process.py +2 -7
  74. mindsdb/integrations/libs/process_cache.py +132 -140
  75. mindsdb/integrations/libs/response.py +18 -12
  76. mindsdb/integrations/libs/vectordatabase_handler.py +26 -0
  77. mindsdb/integrations/utilities/files/file_reader.py +6 -7
  78. mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/__init__.py +1 -0
  79. mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/snowflake_jwt_gen.py +151 -0
  80. mindsdb/integrations/utilities/rag/config_loader.py +37 -26
  81. mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +83 -30
  82. mindsdb/integrations/utilities/rag/rerankers/reranker_compressor.py +4 -4
  83. mindsdb/integrations/utilities/rag/retrievers/sql_retriever.py +55 -133
  84. mindsdb/integrations/utilities/rag/settings.py +58 -133
  85. mindsdb/integrations/utilities/rag/splitters/file_splitter.py +5 -15
  86. mindsdb/interfaces/agents/agents_controller.py +2 -3
  87. mindsdb/interfaces/agents/constants.py +0 -2
  88. mindsdb/interfaces/agents/litellm_server.py +34 -58
  89. mindsdb/interfaces/agents/mcp_client_agent.py +10 -10
  90. mindsdb/interfaces/agents/mindsdb_database_agent.py +5 -5
  91. mindsdb/interfaces/agents/run_mcp_agent.py +12 -21
  92. mindsdb/interfaces/chatbot/chatbot_task.py +20 -23
  93. mindsdb/interfaces/chatbot/polling.py +30 -18
  94. mindsdb/interfaces/data_catalog/data_catalog_loader.py +16 -17
  95. mindsdb/interfaces/data_catalog/data_catalog_reader.py +15 -4
  96. mindsdb/interfaces/database/data_handlers_cache.py +190 -0
  97. mindsdb/interfaces/database/database.py +3 -3
  98. mindsdb/interfaces/database/integrations.py +7 -110
  99. mindsdb/interfaces/database/projects.py +2 -6
  100. mindsdb/interfaces/database/views.py +1 -4
  101. mindsdb/interfaces/file/file_controller.py +6 -6
  102. mindsdb/interfaces/functions/controller.py +1 -1
  103. mindsdb/interfaces/functions/to_markdown.py +2 -2
  104. mindsdb/interfaces/jobs/jobs_controller.py +5 -9
  105. mindsdb/interfaces/jobs/scheduler.py +3 -9
  106. mindsdb/interfaces/knowledge_base/controller.py +244 -128
  107. mindsdb/interfaces/knowledge_base/evaluate.py +36 -41
  108. mindsdb/interfaces/knowledge_base/executor.py +11 -0
  109. mindsdb/interfaces/knowledge_base/llm_client.py +51 -17
  110. mindsdb/interfaces/knowledge_base/preprocessing/json_chunker.py +40 -61
  111. mindsdb/interfaces/model/model_controller.py +172 -168
  112. mindsdb/interfaces/query_context/context_controller.py +14 -2
  113. mindsdb/interfaces/skills/custom/text2sql/mindsdb_sql_toolkit.py +10 -14
  114. mindsdb/interfaces/skills/retrieval_tool.py +43 -50
  115. mindsdb/interfaces/skills/skill_tool.py +2 -2
  116. mindsdb/interfaces/skills/skills_controller.py +1 -4
  117. mindsdb/interfaces/skills/sql_agent.py +25 -19
  118. mindsdb/interfaces/storage/db.py +16 -6
  119. mindsdb/interfaces/storage/fs.py +114 -169
  120. mindsdb/interfaces/storage/json.py +19 -18
  121. mindsdb/interfaces/tabs/tabs_controller.py +49 -72
  122. mindsdb/interfaces/tasks/task_monitor.py +3 -9
  123. mindsdb/interfaces/tasks/task_thread.py +7 -9
  124. mindsdb/interfaces/triggers/trigger_task.py +7 -13
  125. mindsdb/interfaces/triggers/triggers_controller.py +47 -52
  126. mindsdb/migrations/migrate.py +16 -16
  127. mindsdb/utilities/api_status.py +58 -0
  128. mindsdb/utilities/config.py +68 -2
  129. mindsdb/utilities/exception.py +40 -1
  130. mindsdb/utilities/fs.py +0 -1
  131. mindsdb/utilities/hooks/profiling.py +17 -14
  132. mindsdb/utilities/json_encoder.py +24 -10
  133. mindsdb/utilities/langfuse.py +40 -45
  134. mindsdb/utilities/log.py +272 -0
  135. mindsdb/utilities/ml_task_queue/consumer.py +52 -58
  136. mindsdb/utilities/ml_task_queue/producer.py +26 -30
  137. mindsdb/utilities/render/sqlalchemy_render.py +22 -20
  138. mindsdb/utilities/starters.py +0 -10
  139. mindsdb/utilities/utils.py +2 -2
  140. {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0rc1.dist-info}/METADATA +293 -276
  141. {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0rc1.dist-info}/RECORD +144 -158
  142. mindsdb/api/mysql/mysql_proxy/utilities/exceptions.py +0 -14
  143. mindsdb/api/postgres/__init__.py +0 -0
  144. mindsdb/api/postgres/postgres_proxy/__init__.py +0 -0
  145. mindsdb/api/postgres/postgres_proxy/executor/__init__.py +0 -1
  146. mindsdb/api/postgres/postgres_proxy/executor/executor.py +0 -189
  147. mindsdb/api/postgres/postgres_proxy/postgres_packets/__init__.py +0 -0
  148. mindsdb/api/postgres/postgres_proxy/postgres_packets/errors.py +0 -322
  149. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_fields.py +0 -34
  150. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message.py +0 -31
  151. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_formats.py +0 -1265
  152. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_identifiers.py +0 -31
  153. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_packets.py +0 -253
  154. mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +0 -477
  155. mindsdb/api/postgres/postgres_proxy/utilities/__init__.py +0 -10
  156. mindsdb/api/postgres/start.py +0 -11
  157. mindsdb/integrations/handlers/mssql_handler/tests/__init__.py +0 -0
  158. mindsdb/integrations/handlers/mssql_handler/tests/test_mssql_handler.py +0 -169
  159. mindsdb/integrations/handlers/oracle_handler/tests/__init__.py +0 -0
  160. mindsdb/integrations/handlers/oracle_handler/tests/test_oracle_handler.py +0 -32
  161. {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0rc1.dist-info}/WHEEL +0 -0
  162. {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0rc1.dist-info}/licenses/LICENSE +0 -0
  163. {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,14 +0,0 @@
1
- from mindsdb.api.mysql.mysql_proxy.libs.constants.mysql import ERR
2
-
3
-
4
- # base exception for known error
5
- class SqlApiException(Exception):
6
- err_code = ERR.ER_SYNTAX_ERROR
7
-
8
-
9
- class ErSqlSyntaxError(SqlApiException):
10
- err_code = ERR.ER_SYNTAX_ERROR
11
-
12
-
13
- class ErWrongCharset(SqlApiException):
14
- err_code = ERR.ER_UNKNOWN_CHARACTER_SET
File without changes
File without changes
@@ -1 +0,0 @@
1
- from mindsdb.api.postgres.postgres_proxy.executor.executor import *
@@ -1,189 +0,0 @@
1
- from typing import Union
2
-
3
- from mindsdb_sql_parser import parse_sql
4
- from mindsdb.api.executor.planner import utils as planner_utils
5
-
6
- from numpy import dtype as np_dtype
7
- from pandas.api import types as pd_types
8
-
9
- from mindsdb.api.executor.sql_query import SQLQuery
10
- from mindsdb.api.executor.sql_query.result_set import Column
11
- from mindsdb.api.mysql.mysql_proxy.utilities.lightwood_dtype import dtype
12
- from mindsdb.api.executor.command_executor import ExecuteCommands
13
- from mindsdb.api.mysql.mysql_proxy.utilities import SqlApiException
14
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_fields import POSTGRES_TYPES
15
- from mindsdb.utilities import log
16
-
17
-
18
- class Executor:
19
- def __init__(self, session, proxy_server, charset=None):
20
- self.session = session
21
- self.server = proxy_server
22
-
23
- self.logger = log.getLogger(__name__)
24
- self.charset = charset or "utf8"
25
- self.query = None
26
- self.columns = []
27
- self.params = []
28
- self.data = None
29
- self.server_status = None
30
- self.state_track = None
31
- self.is_executed = False
32
-
33
- self.sql = ""
34
- self.sql_lower = ""
35
-
36
- self.command_executor = ExecuteCommands(self.session)
37
-
38
- def parse(self, sql: Union[str, bytes]):
39
- self.logger.info("%s.parse: sql - %s", self.__class__.__name__, sql)
40
- if type(sql) == bytes:
41
- sql = sql.decode(encoding=self.charset)
42
- self.sql = sql
43
- sql_lower = self.sql.lower()
44
- self.sql_lower = sql_lower.replace("`", "")
45
-
46
- try:
47
- self.query = parse_sql(sql)
48
- except Exception as mdb_error:
49
- # not all statements are parsed by parse_sql
50
- self.logger.warning('Failed to parse SQL query')
51
- self.logger.debug(f'Query that cannot be parsed: {sql}')
52
-
53
- raise SqlApiException(
54
- f"The SQL statement cannot be parsed - {sql}: {mdb_error}"
55
- ) from mdb_error
56
-
57
- def stmt_execute(self, param_values):
58
- if self.is_executed:
59
- return
60
-
61
- # fill params
62
- self.query = planner_utils.fill_query_params(self.query, param_values)
63
-
64
- # execute query
65
- self.do_execute()
66
-
67
- def execute_external(self, sql):
68
- return None
69
-
70
- def query_execute(self, sql):
71
- self.logger.info("%s.query_execute: sql - %s", self.__class__.__name__, sql)
72
- resp = self.execute_external(sql)
73
- if resp is not None:
74
- # is already executed
75
- self.is_executed = True
76
- return
77
-
78
- self.parse(sql)
79
- self.do_execute()
80
-
81
- def do_execute(self):
82
- self.logger.info("%s.do_execute", self.__class__.__name__)
83
- # it can be already run at prepare state
84
- if self.is_executed:
85
- return
86
-
87
- ret = self.command_executor.execute_command(self.query)
88
-
89
- self.is_executed = True
90
-
91
- if ret.data is not None:
92
- self.data = ret.data.to_lists()
93
- self.columns = ret.data.columns
94
-
95
- self.state_track = ret.state_track
96
-
97
- def _to_json(self):
98
- params = {
99
- "columns": self.to_postgres_columns(self.columns),
100
- "params": self.to_postgres_columns(self.params),
101
- "data": self.data,
102
- "state_track": self.state_track,
103
- "server_status": self.server_status,
104
- "is_executed": self.is_executed,
105
- "session": self.session.to_json()
106
-
107
- }
108
- return params
109
-
110
- def to_postgres_columns(self, columns):
111
-
112
- result = []
113
-
114
- database = (
115
- None if self.session.database == "" else self.session.database.lower()
116
- )
117
- for column_record in columns:
118
-
119
- field_type = column_record.type
120
-
121
- column_type = POSTGRES_TYPES.VARCHAR
122
- # is already in mysql protocol type?
123
- if isinstance(field_type, int):
124
- column_type = POSTGRES_TYPES.INT
125
- # pandas checks
126
- elif isinstance(field_type, np_dtype):
127
- if pd_types.is_integer_dtype(field_type):
128
- column_type = POSTGRES_TYPES.LONG
129
- elif pd_types.is_numeric_dtype(field_type):
130
- column_type = POSTGRES_TYPES.DOUBLE
131
- elif pd_types.is_datetime64_any_dtype(field_type):
132
- column_type = POSTGRES_TYPES.DATETIME
133
- # lightwood checks
134
- elif field_type == dtype.date:
135
- column_type = POSTGRES_TYPES.DATE
136
- elif field_type == dtype.datetime:
137
- column_type = POSTGRES_TYPES.DATETIME
138
- elif field_type == dtype.float:
139
- column_type = POSTGRES_TYPES.DOUBLE
140
- elif field_type == dtype.integer:
141
- column_type = POSTGRES_TYPES.LONG
142
-
143
- if "()" in column_record.alias:
144
- column_record.alias = column_record.alias.strip("()")
145
- if "()" in column_record.name:
146
- column_record.name = column_record.name.strip("()")
147
-
148
- result.append(
149
- {
150
- "database": column_record.database or database,
151
- # TODO add 'original_table'
152
- "table_name": column_record.table_name,
153
- "name": column_record.name,
154
- "alias": column_record.alias or column_record.name,
155
- # NOTE all work with text-type, but if/when wanted change types to real,
156
- # it will need to check all types casts in BinaryResultsetRowPacket
157
- "type": column_type,
158
- }
159
- )
160
- return result
161
-
162
- def change_default_db(self, new_db):
163
- self.command_executor.change_default_db(new_db)
164
-
165
- def stmt_prepare(self, sql):
166
- # Returns True if ready for query afterwards.
167
- # Check if execute external here
168
- self.parse(sql)
169
- params = planner_utils.get_query_params(self.query)
170
- if len(params) == 0:
171
- pass
172
- # self.do_execute()
173
- # return True
174
- else:
175
- # plan query
176
-
177
- sqlquery = SQLQuery(self.query, session=self.session, execute=False)
178
-
179
- sqlquery.prepare_query()
180
-
181
- self.params = [
182
- Column(
183
- name=p.value,
184
- alias=p.value,
185
- type="str",
186
- )
187
- for p in params
188
- ]
189
- self.columns = sqlquery.columns_list
@@ -1,322 +0,0 @@
1
- POSTGRES_ERROR_CODES = {
2
- "CLASS_00": {
3
- "successful_completion": "00000"},
4
- "CLASS_01": {
5
- "warning": "01000",
6
- "dynamic_result_sets_returned": "0100C",
7
- "implicit_zero_bit_padding": "01008",
8
- "null_value_eliminated_in_set_function": "01003",
9
- "privilege_not_granted": "01007",
10
- "privilege_not_revoked": "01006",
11
- "string_data_right_truncation": "01004",
12
- "deprecated_feature": "01P01"},
13
- "CLASS_02": {
14
- "no_data": "02000",
15
- "no_additional_dynamic_result_sets_returned": "02001"
16
- },
17
- "CLASS_03": {
18
- "sql_statement_not_yet_complete": "03000",
19
- },
20
- "CLASS_08": {
21
- "connection_exception": "08000",
22
- "connection_does_not_exist": "08003",
23
- "connection_failure": "08006",
24
- "sqlclient_unable_to_establish_sqlconnection": "08001",
25
- "sqlserver_rejected_establishment_of_sqlconnection": "08004",
26
- "transaction_resolution_unknown": "08007",
27
- "protocol_violation": "08P01"},
28
- "CLASS_09": {
29
-
30
- "triggered_action_exception": "09000",
31
- },
32
- "CLASS_0A": {
33
- "feature_not_supported": "0A000"},
34
- "CLASS_0B": {
35
- "invalid_transaction_initiation": "0B000"},
36
- "CLASS_0F": {
37
- "locator_exception": "0F000",
38
- "invalid_locator_specification": "0F001",
39
- },
40
- "CLASS_0L": {
41
- "invalid_grantor": "0L000",
42
- "invalid_grant_operation": "0LP01",
43
- },
44
- "CLASS_0P": {
45
- "invalid_role_specification": "0P000",
46
- },
47
- "CLASS_0Z": {
48
- "diagnostics_exception": "0Z000",
49
- "stacked_diagnostics_accessed_without_active_handler": "0Z002"},
50
- "CLASS_20": {
51
- "case_not_found": "20000"},
52
-
53
- "CLASS_21": {
54
- "cardinality_violation": "21000"},
55
- "CLASS_22": {
56
- "data_exception": "22000",
57
- "array_subscript_error": "2202E",
58
- "character_not_in_repertoire": "22021",
59
- "datetime_field_overflow": "22008",
60
- "division_by_zero": "22012",
61
- "error_in_assignment": "22005",
62
- "escape_character_conflict": "2200B",
63
- "indicator_overflow": "22022",
64
- "interval_field_overflow": "22015",
65
- "invalid_argument_for_logarithm": "2201E",
66
- "invalid_argument_for_ntile_function": "22014",
67
- "invalid_argument_for_nth_value_function": "22016",
68
- "invalid_argument_for_power_function": "2201F",
69
- "invalid_argument_for_width_bucket_function": "2201G",
70
- "invalid_character_value_for_cast": "22018",
71
- "invalid_datetime_format": "22007",
72
- "invalid_escape_character": "22019",
73
- "invalid_escape_octet": "2200D",
74
- "invalid_escape_sequence": "22025",
75
- "nonstandard_use_of_escape_character": "22P06",
76
- "invalid_indicator_parameter_value": "22010",
77
- "invalid_parameter_value": "22023",
78
- "invalid_preceding_or_following_size": "22013",
79
- "invalid_regular_expression": "2201B",
80
- "invalid_row_count_in_limit_clause": "2201W",
81
- "invalid_row_count_in_result_offset_clause": "2201X",
82
- "invalid_tablesample_argument": "2202H",
83
- "invalid_tablesample_repeat": "2202G",
84
- "invalid_time_zone_displacement_value": "22009",
85
- "invalid_use_of_escape_character": "2200C",
86
- "most_specific_type_mismatch": "2200G",
87
- "null_value_not_allowed": "22004",
88
- "null_value_no_indicator_parameter": "22002",
89
- "numeric_value_out_of_range": "22003",
90
- "sequence_generator_limit_exceeded": "2200H",
91
- "string_data_length_mismatch": "22026",
92
- "string_data_right_truncation": "22001",
93
- "substring_error": "22011",
94
- "trim_error": "22027",
95
- "unterminated_c_string": "22024",
96
- "zero_length_character_string": "2200F",
97
- "floating_point_exception": "22P01",
98
- "invalid_text_representation": "22P02",
99
- "invalid_binary_representation": "22P03",
100
- "bad_copy_file_format": "22P04",
101
- "untranslatable_character": "22P05",
102
- "not_an_xml_document": "2200L",
103
- "invalid_xml_document": "2200M",
104
- "invalid_xml_content": "2200N",
105
- "invalid_xml_comment": "2200S",
106
- "invalid_xml_processing_instruction": "2200T",
107
- "duplicate_json_object_key_value": "22030",
108
- "invalid_argument_for_sql_json_datetime_function": "22031",
109
- "invalid_json_text": "22032",
110
- "invalid_sql_json_subscript": "22033",
111
- "more_than_one_sql_json_item": "22034",
112
- "no_sql_json_item": "22035",
113
- "non_numeric_sql_json_item": "22036",
114
- "non_unique_keys_in_a_json_object": "22037",
115
- "singleton_sql_json_item_required": "22038",
116
- "sql_json_array_not_found": "22039",
117
- "sql_json_member_not_found": "2203A",
118
- "sql_json_number_not_found": "2203B",
119
- "sql_json_object_not_found": "2203C",
120
- "too_many_json_array_elements": "2203D",
121
- "too_many_json_object_members": "2203E",
122
- "sql_json_scalar_required": "2203F",
123
- "sql_json_item_cannot_be_cast_to_target_type": "2203G"
124
- },
125
- "CLASS_23": {
126
- "integrity_constraint_violation": "23000",
127
- "restrict_violation": "23001",
128
- "not_null_violation": "23502",
129
- "foreign_key_violation": "23503",
130
- "unique_violation": "23505",
131
- "check_violation": "23514",
132
- "exclusion_violation": "23P01"},
133
- "CLASS_24": {
134
- "invalid_cursor_state": "24000"},
135
- "CLASS_25": {
136
- "invalid_transaction_state": "25000",
137
- "active_sql_transaction": "25001",
138
- "branch_transaction_already_active": "25002",
139
- "held_cursor_requires_same_isolation_level": "25008",
140
- "inappropriate_access_mode_for_branch_transaction": "25003",
141
- "inappropriate_isolation_level_for_branch_transaction": "25004",
142
- "no_active_sql_transaction_for_branch_transaction": "25005",
143
- "read_only_sql_transaction": "25006",
144
- "schema_and_data_statement_mixing_not_supported": "25007",
145
- "no_active_sql_transaction": "25P01",
146
- "in_failed_sql_transaction": "25P02",
147
- "idle_in_transaction_session_timeout": "25P03"},
148
- "CLASS_26": {
149
- "invalid_sql_statement_name": "26000"},
150
- "CLASS_27": {
151
- "triggered_data_change_violation": "27000"},
152
- "CLASS_28": {
153
- "invalid_authorization_specification": "28000",
154
- "invalid_password": "28P01",
155
- "dependent_privilege_descriptors_still_exist": "2B000",
156
- "dependent_objects_still_exist": "2BP01"},
157
- "CLASS_2D": {
158
-
159
- "invalid_transaction_termination": "2D000"},
160
- "CLASS_2F": {
161
-
162
- "sql_routine_exception": "2F000",
163
- "function_executed_no_return_statement": "2F005",
164
- "modifying_sql_data_not_permitted": "2F002",
165
- "prohibited_sql_statement_attempted": "2F003",
166
- "reading_sql_data_not_permitted": "2F004"},
167
- "CLASS_34": {
168
- "invalid_cursor_name": "34000"},
169
- "CLASS_38": {
170
- "external_routine_exception": "38000",
171
- "containing_sql_not_permitted": "38001",
172
- "modifying_sql_data_not_permitted": "38002",
173
- "prohibited_sql_statement_attempted": "38003",
174
- "reading_sql_data_not_permitted": "38004"},
175
- "CLASS_39": {
176
- "external_routine_invocation_exception": "39000",
177
- "invalid_sqlstate_returned": "39001",
178
- "null_value_not_allowed": "39004",
179
- "trigger_protocol_violated": "39P01",
180
- "srf_protocol_violated": "39P02",
181
- "event_trigger_protocol_violated": "39P03"},
182
- "CLASS_3B": {
183
- "savepoint_exception": "3B000",
184
- "invalid_savepoint_specification": "3B001"
185
- },
186
- "CLASS_3D": {
187
- "invalid_catalog_name": "3D000"},
188
- "CLASS_3F": {
189
- "invalid_schema_name": "3F000"},
190
- "CLASS_40": {
191
- "transaction_rollback": "40000",
192
- "transaction_integrity_constraint_violation": "40002",
193
- "serialization_failure": "40001",
194
- "statement_completion_unknown": "40003",
195
- "deadlock_detected": "40P01"},
196
- "CLASS_42": { # Syntax Errors
197
- "syntax_error_or_access_rule_violation": "42000",
198
- # DEFAULTS to here:
199
- "syntax_error": "42601",
200
- "insufficient_privilege": "42501",
201
- "cannot_coerce": "42846",
202
- "grouping_error": "42803",
203
- "windowing_error": "42P20",
204
- "invalid_recursion": "42P19",
205
- "invalid_foreign_key": "42830",
206
- "invalid_name": "42602",
207
- "name_too_long": "42622",
208
- "reserved_name": "42939",
209
- "datatype_mismatch": "42804",
210
- "indeterminate_datatype": "42P18",
211
- "collation_mismatch": "42P21",
212
- "indeterminate_collation": "42P22",
213
- "wrong_object_type": "42809",
214
- "generated_always": "428C9",
215
- "undefined_column": "42703",
216
- "undefined_function": "42883",
217
- "undefined_table": "42P01",
218
- "undefined_parameter": "42P02",
219
- "undefined_object": "42704",
220
- "duplicate_column": "42701",
221
- "duplicate_cursor": "42P03",
222
- "duplicate_database": "42P04",
223
- "duplicate_function": "42723",
224
- "duplicate_prepared_statement": "42P05",
225
- "duplicate_schema": "42P06",
226
- "duplicate_table": "42P07",
227
- "duplicate_alias": "42712",
228
- "duplicate_object": "42710",
229
- "ambiguous_column": "42702",
230
- "ambiguous_function": "42725",
231
- "ambiguous_parameter": "42P08",
232
- "ambiguous_alias": "42P09",
233
- "invalid_column_reference": "42P10",
234
- "invalid_column_definition": "42611",
235
- "invalid_cursor_definition": "42P11",
236
- "invalid_database_definition": "42P12",
237
- "invalid_function_definition": "42P13",
238
- "invalid_prepared_statement_definition": "42P14",
239
- "invalid_schema_definition": "42P15",
240
- "invalid_table_definition": "42P16",
241
- "invalid_object_definition": "42P17"},
242
-
243
- "CLASS_44": {
244
- "with_check_option_violation": "44000"},
245
-
246
- "CLASS_53": {
247
- "insufficient_resources": "53000",
248
- "disk_full": "53100",
249
- "out_of_memory": "53200",
250
- "too_many_connections": "53300",
251
- "configuration_limit_exceeded": "53400", },
252
-
253
- "CLASS_54": {
254
- "program_limit_exceeded": "54000",
255
- "statement_too_complex": "54001",
256
- "too_many_columns": "54011",
257
- "too_many_arguments": "54023"},
258
- "CLASS_55": {
259
- "object_not_in_prerequisite_state": "55000",
260
- "object_in_use": "55006",
261
- "cant_change_runtime_param": "55P02",
262
- "lock_not_available": "55P03",
263
- "unsafe_new_enum_value_usage": "55P04"},
264
- "CLASS_57": {
265
- "operator_intervention": "57000",
266
- "query_canceled": "57014",
267
- "admin_shutdown": "57P01",
268
- "crash_shutdown": "57P02",
269
- "cannot_connect_now": "57P03",
270
- "database_dropped": "57P04",
271
- "idle_session_timeout": "57P05"},
272
- "CLASS_58": {
273
- "system_error": "58000",
274
- "io_error": "58030",
275
- "undefined_file": "58P01",
276
- "duplicate_file": "58P02"},
277
- "CLASS_72": {
278
- "snapshot_too_old": "72000"},
279
- "CLASS_F0": {
280
- "config_file_error": "F0000",
281
- "lock_file_exists": "F0001"},
282
- "CLASS_HV": {
283
- "fdw_error": "HV000",
284
- "fdw_column_name_not_found": "HV005",
285
- "fdw_dynamic_parameter_value_needed": "HV002",
286
- "fdw_function_sequence_error": "HV010",
287
- "fdw_inconsistent_descriptor_information": "HV021",
288
- "fdw_invalid_attribute_value": "HV024",
289
- "fdw_invalid_column_name": "HV007",
290
- "fdw_invalid_column_number": "HV008",
291
- "fdw_invalid_data_type": "HV004",
292
- "fdw_invalid_data_type_descriptors": "HV006",
293
- "fdw_invalid_descriptor_field_identifier": "HV091",
294
- "fdw_invalid_handle": "HV00B",
295
- "fdw_invalid_option_index": "HV00C",
296
- "fdw_invalid_option_name": "HV00D",
297
- "fdw_invalid_string_length_or_buffer_length": "HV090",
298
- "fdw_invalid_string_format": "HV00A",
299
- "fdw_invalid_use_of_null_pointer": "HV009",
300
- "fdw_too_many_handles": "HV014",
301
- "fdw_out_of_memory": "HV001",
302
- "fdw_no_schemas": "HV00P",
303
- "fdw_option_name_not_found": "HV00J",
304
- "fdw_reply_handle": "HV00K",
305
- "fdw_schema_not_found": "HV00Q",
306
- "fdw_table_not_found": "HV00R",
307
- "fdw_unable_to_create_execution": "HV00L",
308
- "fdw_unable_to_create_reply": "HV00M",
309
- "fdw_unable_to_establish_connection": "HV00N"},
310
- "CLASS_P0": {
311
- "plpgsql_error": "P0000",
312
- "raise_exception": "P0001",
313
- "no_data_found": "P0002",
314
- "too_many_rows": "P0003",
315
- "assert_failure": "P0004"},
316
- "CLASS_XX": {
317
- "internal_error": "XX000",
318
- "data_corrupted": "XX001",
319
- "index_corrupted": "XX002"
320
- }
321
- }
322
- POSTGRES_SYNTAX_ERROR_CODE = POSTGRES_ERROR_CODES["CLASS_42"]["syntax_error"]
@@ -1,34 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class PostgresField:
5
- def __init__(self, name: str, object_id: int, dt_size: int, type_modifier: int, format_code: int, table_id: int = 0,
6
- column_id: int = 0):
7
- self.name = name
8
- self.object_id = object_id
9
- self.dt_size = dt_size
10
- self.type_modifier = type_modifier
11
- self.format_code = format_code
12
- self.table_id = table_id
13
- self.column_id = column_id
14
-
15
-
16
- class GenericField(PostgresField):
17
- def __init__(self, name: str, object_id: int, table_id: int = 0, column_id: int = 0):
18
- super().__init__(name=name, object_id=object_id, dt_size=-1, type_modifier=-1, format_code=0, table_id=table_id,
19
- column_id=column_id)
20
-
21
-
22
- class IntField(PostgresField):
23
- def __init__(self, name: str, table_id: int = 0, column_id: int = 0):
24
- super().__init__(name=name, object_id=23, dt_size=4, type_modifier=-1, format_code=0, table_id=table_id,
25
- column_id=column_id)
26
-
27
-
28
- class POSTGRES_TYPES(Enum):
29
- VARCHAR = 0
30
- INT = 1
31
- LONG = 2
32
- DOUBLE = 3
33
- DATETIME = 4
34
- DATE = 5
@@ -1,31 +0,0 @@
1
- from typing import Union, BinaryIO
2
-
3
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_message_identifiers import \
4
- PostgresBackendMessageIdentifier, PostgresFrontendMessageIdentifier
5
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_packets import PostgresPacketReader, \
6
- PostgresPacketBuilder
7
-
8
-
9
- class PostgresMessage:
10
- identifier: Union[PostgresBackendMessageIdentifier, PostgresFrontendMessageIdentifier]
11
- backend_capable: bool
12
- frontend_capable: bool
13
-
14
- def __init__(self):
15
- pass
16
-
17
- def send(self, write_file: BinaryIO):
18
- # with open("test_write.txt", "a") as f:
19
- # f.write(str(type(self)))
20
- return self.send_internal(write_file=write_file)
21
-
22
- def send_internal(self, write_file: BinaryIO):
23
- raise NotImplementedError("Must implement send_internal in sub-class")
24
-
25
- def read(self, packet_reader: PostgresPacketReader):
26
- pass
27
-
28
- def get_packet_builder(self) -> PostgresPacketBuilder:
29
- ppb = PostgresPacketBuilder()
30
- ppb.set_identifier(self.identifier)
31
- return ppb