MindsDB 25.9.3rc1__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 (88) hide show
  1. mindsdb/__about__.py +1 -1
  2. mindsdb/__main__.py +1 -9
  3. mindsdb/api/a2a/__init__.py +1 -1
  4. mindsdb/api/a2a/agent.py +9 -1
  5. mindsdb/api/a2a/common/server/server.py +4 -0
  6. mindsdb/api/a2a/common/server/task_manager.py +8 -1
  7. mindsdb/api/a2a/common/types.py +66 -0
  8. mindsdb/api/a2a/task_manager.py +50 -0
  9. mindsdb/api/common/middleware.py +1 -1
  10. mindsdb/api/executor/command_executor.py +49 -36
  11. mindsdb/api/executor/datahub/datanodes/information_schema_datanode.py +7 -13
  12. mindsdb/api/executor/datahub/datanodes/integration_datanode.py +2 -2
  13. mindsdb/api/executor/datahub/datanodes/system_tables.py +2 -1
  14. mindsdb/api/executor/planner/query_prepare.py +2 -20
  15. mindsdb/api/executor/utilities/sql.py +5 -4
  16. mindsdb/api/http/initialize.py +76 -60
  17. mindsdb/api/http/namespaces/agents.py +0 -3
  18. mindsdb/api/http/namespaces/chatbots.py +0 -5
  19. mindsdb/api/http/namespaces/file.py +2 -0
  20. mindsdb/api/http/namespaces/handlers.py +10 -5
  21. mindsdb/api/http/namespaces/knowledge_bases.py +20 -0
  22. mindsdb/api/http/namespaces/sql.py +2 -2
  23. mindsdb/api/http/start.py +2 -2
  24. mindsdb/api/mysql/mysql_proxy/utilities/dump.py +8 -2
  25. mindsdb/integrations/handlers/byom_handler/byom_handler.py +2 -10
  26. mindsdb/integrations/handlers/databricks_handler/databricks_handler.py +98 -46
  27. mindsdb/integrations/handlers/druid_handler/druid_handler.py +32 -40
  28. mindsdb/integrations/handlers/gitlab_handler/gitlab_handler.py +5 -2
  29. mindsdb/integrations/handlers/mssql_handler/mssql_handler.py +438 -100
  30. mindsdb/integrations/handlers/mssql_handler/requirements_odbc.txt +3 -0
  31. mindsdb/integrations/handlers/mysql_handler/mysql_handler.py +235 -3
  32. mindsdb/integrations/handlers/oracle_handler/__init__.py +2 -0
  33. mindsdb/integrations/handlers/oracle_handler/connection_args.py +7 -1
  34. mindsdb/integrations/handlers/oracle_handler/oracle_handler.py +321 -16
  35. mindsdb/integrations/handlers/oracle_handler/requirements.txt +1 -1
  36. mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +2 -2
  37. mindsdb/integrations/handlers/zendesk_handler/zendesk_tables.py +144 -111
  38. mindsdb/integrations/libs/response.py +2 -2
  39. mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/__init__.py +1 -0
  40. mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/snowflake_jwt_gen.py +151 -0
  41. mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +24 -21
  42. mindsdb/interfaces/agents/agents_controller.py +0 -2
  43. mindsdb/interfaces/data_catalog/data_catalog_loader.py +6 -7
  44. mindsdb/interfaces/data_catalog/data_catalog_reader.py +15 -4
  45. mindsdb/interfaces/database/data_handlers_cache.py +190 -0
  46. mindsdb/interfaces/database/database.py +3 -3
  47. mindsdb/interfaces/database/integrations.py +1 -121
  48. mindsdb/interfaces/database/projects.py +2 -6
  49. mindsdb/interfaces/database/views.py +1 -4
  50. mindsdb/interfaces/jobs/jobs_controller.py +0 -4
  51. mindsdb/interfaces/jobs/scheduler.py +0 -1
  52. mindsdb/interfaces/knowledge_base/controller.py +197 -108
  53. mindsdb/interfaces/knowledge_base/evaluate.py +36 -41
  54. mindsdb/interfaces/knowledge_base/executor.py +11 -0
  55. mindsdb/interfaces/knowledge_base/llm_client.py +51 -17
  56. mindsdb/interfaces/model/model_controller.py +4 -4
  57. mindsdb/interfaces/skills/custom/text2sql/mindsdb_sql_toolkit.py +4 -10
  58. mindsdb/interfaces/skills/skills_controller.py +1 -4
  59. mindsdb/interfaces/storage/db.py +16 -6
  60. mindsdb/interfaces/triggers/triggers_controller.py +1 -3
  61. mindsdb/utilities/config.py +19 -2
  62. mindsdb/utilities/exception.py +2 -2
  63. mindsdb/utilities/json_encoder.py +24 -10
  64. mindsdb/utilities/render/sqlalchemy_render.py +15 -14
  65. mindsdb/utilities/starters.py +0 -10
  66. {mindsdb-25.9.3rc1.dist-info → mindsdb-25.10.0rc1.dist-info}/METADATA +276 -264
  67. {mindsdb-25.9.3rc1.dist-info → mindsdb-25.10.0rc1.dist-info}/RECORD +70 -84
  68. mindsdb/api/postgres/__init__.py +0 -0
  69. mindsdb/api/postgres/postgres_proxy/__init__.py +0 -0
  70. mindsdb/api/postgres/postgres_proxy/executor/__init__.py +0 -1
  71. mindsdb/api/postgres/postgres_proxy/executor/executor.py +0 -182
  72. mindsdb/api/postgres/postgres_proxy/postgres_packets/__init__.py +0 -0
  73. mindsdb/api/postgres/postgres_proxy/postgres_packets/errors.py +0 -322
  74. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_fields.py +0 -34
  75. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message.py +0 -31
  76. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_formats.py +0 -1265
  77. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_identifiers.py +0 -31
  78. mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_packets.py +0 -265
  79. mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +0 -477
  80. mindsdb/api/postgres/postgres_proxy/utilities/__init__.py +0 -10
  81. mindsdb/api/postgres/start.py +0 -11
  82. mindsdb/integrations/handlers/mssql_handler/tests/__init__.py +0 -0
  83. mindsdb/integrations/handlers/mssql_handler/tests/test_mssql_handler.py +0 -169
  84. mindsdb/integrations/handlers/oracle_handler/tests/__init__.py +0 -0
  85. mindsdb/integrations/handlers/oracle_handler/tests/test_oracle_handler.py +0 -32
  86. {mindsdb-25.9.3rc1.dist-info → mindsdb-25.10.0rc1.dist-info}/WHEEL +0 -0
  87. {mindsdb-25.9.3rc1.dist-info → mindsdb-25.10.0rc1.dist-info}/licenses/LICENSE +0 -0
  88. {mindsdb-25.9.3rc1.dist-info → mindsdb-25.10.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,1265 +0,0 @@
1
- from typing import BinaryIO, Sequence, Dict, Type
2
-
3
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_fields import PostgresField
4
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_message import PostgresMessage
5
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_message_identifiers import \
6
- PostgresBackendMessageIdentifier, PostgresFrontendMessageIdentifier, PostgresAuthType
7
-
8
- from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_packets import PostgresPacketReader
9
- from mindsdb.api.postgres.postgres_proxy.utilities import strip_null_byte
10
- from mindsdb.utilities.sql import clear_sql
11
-
12
-
13
- # All docstrings for Messages are taken from
14
- # https://www.postgresql.org/docs/current/protocol-message-formats.html as of 2023-2-8 for Postgresql 15
15
-
16
-
17
- class NoticeResponse(PostgresMessage):
18
- """
19
- NoticeResponse (B)
20
- Byte1('N')
21
- Identifies the message as a notice.
22
-
23
- Int32
24
- Length of message contents in bytes, including self.
25
-
26
- The message body consists of one or more identified fields, followed by a zero byte as a terminator. Fields can
27
- appear in any order. For each field there is the following:
28
-
29
- Byte1
30
- A code identifying the field type; if zero, this is the message terminator and no string follows. The
31
- presently defined field types are listed in Section 55.8. Since more field types might be added in future,
32
- frontends should silently ignore fields of unrecognized type.
33
-
34
- String
35
- The field value. """ # noqa
36
-
37
- def __init__(self):
38
- self.identifier = PostgresBackendMessageIdentifier.NOTICE_RESPONSE
39
- self.backend_capable = True
40
- self.frontend_capable = False
41
- super().__init__()
42
-
43
- def send_internal(self, write_file: BinaryIO):
44
- self.get_packet_builder().write(write_file=write_file)
45
-
46
-
47
- class AuthenticationOk(PostgresMessage):
48
- """
49
- AuthenticationOk (B)
50
- Byte1('R')
51
- Identifies the message as an authentication request.
52
-
53
- Int32(8)
54
- Length of message contents in bytes, including self.
55
-
56
- Int32(0)
57
- Specifies that the authentication was successful. """ # noqa
58
-
59
- def __init__(self):
60
- self.identifier = PostgresBackendMessageIdentifier.AUTHENTICATION_REQUEST
61
- self.backend_capable = True
62
- self.frontend_capable = False
63
- super().__init__()
64
-
65
- def send_internal(self, write_file: BinaryIO):
66
- self.get_packet_builder() \
67
- .add_int32(0) \
68
- .write(write_file=write_file)
69
-
70
-
71
- class AuthenticationClearTextPassword(PostgresMessage):
72
- """
73
- AuthenticationCleartextPassword (B)
74
- Byte1('R')
75
- Identifies the message as an authentication request.
76
-
77
- Int32(8)
78
- Length of message contents in bytes, including self.
79
-
80
- Int32(3)
81
- Specifies that a clear-text password is required. """ # noqa
82
-
83
- def __init__(self):
84
- self.identifier = PostgresBackendMessageIdentifier.AUTHENTICATION_REQUEST
85
- self.backend_capable = True
86
- self.frontend_capable = False
87
- super().__init__()
88
-
89
- def send_internal(self, write_file: BinaryIO):
90
- self.get_packet_builder() \
91
- .add_int32(3) \
92
- .write(write_file=write_file)
93
-
94
-
95
- class ReadyForQuery(PostgresMessage):
96
- """
97
- ReadyForQuery (B)
98
- Byte1('Z')
99
- Identifies the message type. ReadyForQuery is sent whenever the backend is ready for a new query cycle.
100
-
101
- Int32(5)
102
- Length of message contents in bytes, including self.
103
-
104
- Byte1
105
- Current backend transaction status indicator. Possible values are 'I' if idle (not in a transaction block);
106
- 'T' if in a transaction block; or 'E' if in a failed transaction block (queries will be rejected until block is
107
- ended).""" # noqa
108
-
109
- transaction_status: bytes
110
-
111
- def __init__(self, transaction_status=None):
112
- self.identifier = PostgresBackendMessageIdentifier.READY_FOR_QUERY
113
- self.backend_capable = True
114
- self.frontend_capable = False
115
- self.transaction_status = transaction_status or b'I'
116
- super().__init__()
117
-
118
- def send_internal(self, write_file: BinaryIO):
119
- self.get_packet_builder() \
120
- .add_char(self.transaction_status) \
121
- .write(write_file=write_file)
122
-
123
-
124
- class CommandComplete(PostgresMessage):
125
- """
126
- CommandComplete (B)
127
- Byte1('C')
128
- Identifies the message as a command-completed response.
129
-
130
- Int32
131
- Length of message contents in bytes, including self.
132
-
133
- String
134
- The command tag. This is usually a single word that identifies which SQL command was completed.
135
-
136
- For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid used to be the object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; therefore oid is always 0.
137
-
138
- For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.
139
-
140
- For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.
141
-
142
- For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.
143
-
144
- For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.
145
-
146
- For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.
147
-
148
- For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.) """ # noqa
149
-
150
- tag: bytes
151
-
152
- def __init__(self, tag: bytes):
153
- self.identifier = PostgresBackendMessageIdentifier.COMPLETE
154
- self.tag = tag
155
- self.backend_capable = True
156
- self.frontend_capable = False
157
- super().__init__()
158
-
159
- def send_internal(self, write_file: BinaryIO):
160
- self.get_packet_builder() \
161
- .add_string(self.tag) \
162
- .write(write_file=write_file)
163
-
164
-
165
- class BindComplete(PostgresMessage):
166
- """
167
- BindComplete (B)
168
- Byte1('2')
169
- Identifies the message as a Bind-complete indicator.
170
-
171
- Int32(4)
172
- Length of message contents in bytes, including self. """
173
-
174
- def __init__(self):
175
- self.identifier = PostgresBackendMessageIdentifier.BIND_COMPLETE
176
- self.backend_capable = True
177
- self.frontend_capable = False
178
- super().__init__()
179
-
180
- def send_internal(self, write_file: BinaryIO):
181
- self.get_packet_builder() \
182
- .write(write_file=write_file)
183
-
184
-
185
- class Error(PostgresMessage):
186
- """
187
- ErrorResponse (B)
188
- Byte1('E')
189
- Identifies the message as an error.
190
-
191
- Int32
192
- Length of message contents in bytes, including self.
193
-
194
- The message body consists of one or more identified fields, followed by a zero byte as a terminator. Fields can
195
- appear in any order. For each field there is the following:
196
-
197
- Byte1 A code identifying the field type; if zero, this is the message terminator and no string follows. The
198
- presently defined field types are listed in Section 55.8. Since more field types might be added in future,
199
- frontends should silently ignore fields of unrecognized type.
200
-
201
- String
202
- The field value. """ # noqa
203
- severity: bytes
204
- code: bytes
205
- message: bytes
206
-
207
- def __init__(self, severity: bytes, code: bytes, message: bytes):
208
- self.identifier = PostgresBackendMessageIdentifier.ERROR
209
- self.backend_capable = True
210
- self.frontend_capable = False
211
- self.severity = severity
212
- self.code = code
213
- self.message = message
214
- super().__init__()
215
-
216
- def send_internal(self, write_file: BinaryIO):
217
- self.get_packet_builder() \
218
- .add_char(b'S') \
219
- .add_string(self.severity) \
220
- .add_char(b'C') \
221
- .add_string(self.code) \
222
- .add_char(b'M') \
223
- .add_string(self.message) \
224
- .add_char(b'\x00') \
225
- .write(write_file=write_file)
226
-
227
- @staticmethod
228
- def from_answer(error_code: bytes, error_message: bytes):
229
- return Error(severity=b"ERROR", code=error_code, message=error_message)
230
-
231
-
232
- class ConnectionFailure(Error):
233
- def __init__(self, message: str = None, charset: str = "UTF-8"):
234
- if message is None:
235
- message = "Connection Failure occurred."
236
- super().__init__(severity="FATAL".encode(encoding=charset), code="08006".encode(encoding=charset),
237
- message=message.encode(encoding=charset))
238
-
239
-
240
- class InvalidSQLStatementName(Error):
241
- def __init__(self, message: str = None, charset: str = "UTF-8"):
242
- if message is None:
243
- message = "Invalid SQL Statement Name"
244
- super().__init__(severity="FATAL".encode(encoding=charset), code="26000".encode(encoding=charset),
245
- message=message.encode(encoding=charset))
246
-
247
-
248
- class DataException(Error):
249
- def __init__(self, message: str = None, charset: str = "UTF-8", code: str = "22000"):
250
- if message is None:
251
- message = "Data Exception"
252
- super().__init__(severity="FATAL".encode(encoding=charset), code=code.encode(encoding=charset),
253
- message=message.encode(encoding=charset))
254
-
255
-
256
- class ParameterStatus(PostgresMessage):
257
- """
258
- ParameterStatus (B)
259
- Byte1('S')
260
- Identifies the message as a run-time parameter status report.
261
-
262
- Int32
263
- Length of message contents in bytes, including self.
264
-
265
- String
266
- The name of the run-time parameter being reported.
267
-
268
- String
269
- The current value of the parameter. """
270
-
271
- def __init__(self, name: bytes, value: bytes):
272
- self.identifier = PostgresBackendMessageIdentifier.PARAMETER
273
- self.backend_capable = True
274
- self.frontend_capable = False
275
- self.name = name
276
- self.value = value
277
- super().__init__()
278
-
279
- def send_internal(self, write_file: BinaryIO):
280
- self.get_packet_builder() \
281
- .add_string(self.name) \
282
- .add_string(self.value) \
283
- .write(write_file=write_file)
284
-
285
-
286
- class RowDescriptions(PostgresMessage):
287
- """
288
- RowDescription (B)
289
- Byte1('T')
290
- Identifies the message as a row description.
291
-
292
- Int32
293
- Length of message contents in bytes, including self.
294
-
295
- Int16
296
- Specifies the number of fields in a row (can be zero).
297
-
298
- Then, for each field, there is the following:
299
-
300
- String
301
- The field name.
302
-
303
- Int32
304
- If the field can be identified as a column of a specific table, the object ID of the table; otherwise zero.
305
-
306
- Int16
307
- If the field can be identified as a column of a specific table, the attribute number of the column; otherwise zero.
308
-
309
- Int32
310
- The object ID of the field's data type.
311
-
312
- Int16
313
- The data type size (see pg_type.typlen). Note that negative values denote variable-width types.
314
-
315
- Int32
316
- The type modifier (see pg_attribute.atttypmod). The meaning of the modifier is type-specific.
317
-
318
- Int16
319
- The format code being used for the field. Currently will be zero (text) or one (binary). In a
320
- RowDescription returned from the statement variant of Describe, the format code is not yet known and will always
321
- be zero.""" # noqa
322
-
323
- fields: Sequence[PostgresField]
324
-
325
- def __init__(self, fields: Sequence[PostgresField]):
326
- self.identifier = PostgresBackendMessageIdentifier.ROW_DESCRIPTION
327
- self.backend_capable = True
328
- self.frontend_capable = False
329
- self.fields = fields
330
- super().__init__()
331
-
332
- def send_internal(self, write_file: BinaryIO):
333
- self.get_packet_builder() \
334
- .add_int16(len(self.fields)) \
335
- .add_fields(self.fields) \
336
- .write(write_file=write_file)
337
-
338
-
339
- class ParameterDescription(PostgresMessage):
340
- """
341
- ParameterDescription (B)
342
- Byte1('t')
343
- Identifies the message as a parameter description.
344
-
345
- Int32
346
- Length of message contents in bytes, including self.
347
-
348
- Int16
349
- The number of parameters used by the statement (can be zero).
350
-
351
- Then, for each parameter, there is the following:
352
-
353
- Int32
354
- Specifies the object ID of the parameter data type. """
355
-
356
- def __init__(self, parameters: Sequence):
357
- self.identifier = PostgresBackendMessageIdentifier.PARAMETER_DESCRIPTION
358
- self.backend_capable = True
359
- self.frontend_capable = False
360
- self.num_params = len(parameters)
361
- self.parameters = parameters
362
- super().__init__()
363
-
364
- def send_internal(self, write_file: BinaryIO):
365
- packet = self.get_packet_builder().add_int16(self.num_params)
366
- for param in self.parameters:
367
- packet = packet.add_int32(param)
368
- packet.write(write_file=write_file)
369
-
370
-
371
- class DataRow(PostgresMessage):
372
- """
373
- DataRow (B)
374
- Byte1('D')
375
- Identifies the message as a data row.
376
-
377
- Int32
378
- Length of message contents in bytes, including self.
379
-
380
- Int16
381
- The number of column values that follow (possibly zero).
382
-
383
- Next, the following pair of fields appear for each column:
384
-
385
- Int32
386
- The length of the column value, in bytes (this count does not include itself). Can be zero. As a special
387
- case, -1 indicates a NULL column value. No value bytes follow in the NULL case.
388
-
389
- Byten
390
- The value of the column, in the format indicated by the associated format code. n is the above length. """ # noqa
391
-
392
- rows: Sequence[Sequence[bytes]]
393
- num_cols: int
394
-
395
- def __init__(self, rows: Sequence[Sequence[bytes]]):
396
- self.identifier = PostgresBackendMessageIdentifier.DATA_ROW
397
- self.backend_capable = True
398
- self.frontend_capable = False
399
- if len(rows) != 0:
400
- self.num_cols = len(rows[0])
401
- else:
402
- self.num_cols = 0
403
- self.rows = rows
404
- super().__init__()
405
-
406
- def send_internal(self, write_file: BinaryIO):
407
- for row in self.rows:
408
- self.get_packet_builder() \
409
- .add_int16(self.num_cols) \
410
- .add_row(row) \
411
- .write(write_file=write_file)
412
-
413
-
414
- class NegotiateProtocolVersion(PostgresMessage):
415
- """
416
- NegotiateProtocolVersion (B)
417
- Byte1('v')
418
- Identifies the message as a protocol version negotiation message.
419
-
420
- Int32
421
- Length of message contents in bytes, including self.
422
-
423
- Int32
424
- Newest minor protocol version supported by the server for the major protocol version requested by the client.
425
-
426
- Int32
427
- Number of protocol options not recognized by the server.
428
-
429
- Then, for protocol option not recognized by the server, there is the following:
430
-
431
- String
432
- The option name. """
433
-
434
- def __init__(self, major_version, minor_version, option_not_recognized=None):
435
- self.identifier = PostgresBackendMessageIdentifier.NEGOTIATE_VERSION
436
- self.backend_capable = True
437
- self.frontend_capable = False
438
- self.major_version = major_version
439
- self.minor_version = minor_version
440
- self.option_not_recognized = option_not_recognized
441
- super().__init__()
442
-
443
- def send_internal(self, write_file: BinaryIO):
444
- packet_builder = self.get_packet_builder() \
445
- .add_int32(self.major_version) \
446
- .add_int32(self.minor_version)
447
- if self.option_not_recognized:
448
- packet_builder = packet_builder.add_string(self.option_not_recognized)
449
-
450
- packet_builder.write(write_file=write_file)
451
-
452
-
453
- class ParseComplete(PostgresMessage):
454
- """
455
- ParseComplete (B)
456
- Byte1('1')
457
- Identifies the message as a Parse-complete indicator.
458
-
459
- Int32(4)
460
- Length of message contents in bytes, including self. """
461
-
462
- def __init__(self):
463
- self.identifier = PostgresBackendMessageIdentifier.PARSE_COMPLETE
464
- self.backend_capable = True
465
- self.frontend_capable = False
466
- super().__init__()
467
-
468
- def send_internal(self, write_file: BinaryIO):
469
- self.get_packet_builder() \
470
- .write(write_file=write_file)
471
-
472
-
473
- class Query(PostgresMessage):
474
- """
475
- Query (F)
476
- Byte1('Q')
477
- Identifies the message as a simple query.
478
-
479
- Int32
480
- Length of message contents in bytes, including self.
481
-
482
- String
483
- The query string itself. """
484
-
485
- sql: bytes
486
- length: int
487
-
488
- def __init__(self):
489
- self.sql = b''
490
- self.length = 0
491
- self.identifier = PostgresFrontendMessageIdentifier.QUERY
492
- self.backend_capable = False
493
- self.frontend_capable = True
494
- super().__init__()
495
-
496
- def read(self, packet_reader: PostgresPacketReader):
497
- self.length = packet_reader.read_int32()
498
- self.sql = packet_reader.read_bytes(self.length - 4)
499
- return self
500
-
501
- def get_parsed_sql(self, encoding=None):
502
- if not encoding:
503
- encoding = 'utf-8'
504
- try:
505
- sql = self.sql.decode('utf-8')
506
- except Exception:
507
- raise Exception(f'SQL contains non {encoding} values: {self.sql}')
508
- # Remove null bytes from end of sql statement. This is important.
509
- sql = strip_null_byte(sql)
510
- sql = clear_sql(sql)
511
- return sql
512
-
513
-
514
- class Terminate(PostgresMessage):
515
- """
516
- Terminate (F)
517
- Byte1('X')
518
- Identifies the message as a termination.
519
-
520
- Int32(4)
521
- Length of message contents in bytes, including self. """
522
-
523
- def __init__(self):
524
- self.identifier = PostgresFrontendMessageIdentifier.TERMINATE
525
- self.backend_capable = False
526
- self.frontend_capable = True
527
- super().__init__()
528
-
529
- def read(self, packet_reader: PostgresPacketReader):
530
- return self
531
-
532
-
533
- class BaseFrontendMessage(PostgresMessage):
534
- def __init__(self):
535
- self.backend_capable = False
536
- self.frontend_capable = True
537
- super().__init__()
538
-
539
- def read(self, packet_reader: PostgresPacketReader):
540
- self.length = packet_reader.read_int32()
541
- if (self.length - 4) > 0:
542
- self.response = packet_reader.read_bytes(self.length - 4)
543
- return self
544
-
545
-
546
- class Parse(BaseFrontendMessage):
547
- """
548
- Parse (F)
549
- Byte1('P')
550
- Identifies the message as a Parse command.
551
-
552
- Int32
553
- Length of message contents in bytes, including self.
554
-
555
- String
556
- The name of the destination prepared statement (an empty string selects the unnamed prepared statement).
557
-
558
- String
559
- The query string to be parsed.
560
-
561
- Int16 The number of parameter data types specified (can be zero). Note that this is not an indication of the
562
- number of parameters that might appear in the query string, only the number that the frontend wants to pre-specify
563
- types for.
564
-
565
- Then, for each parameter, there is the following:
566
-
567
- Int32 Specifies the object ID of the parameter data type. Placing a zero here is equivalent to leaving the type
568
- unspecified."""
569
-
570
- def __init__(self):
571
- self.identifier = PostgresFrontendMessageIdentifier.PARSE
572
- self.name = None
573
- self.query = None
574
- self.num_params = None
575
- self.parameters = []
576
- super().__init__()
577
-
578
- def read(self, packet_reader: PostgresPacketReader):
579
- self.length = packet_reader.read_int32()
580
- self.name = packet_reader.read_string()
581
- self.query = packet_reader.read_string()
582
- self.num_params = packet_reader.read_int16()
583
- for i in range(self.num_params):
584
- self.parameters.append(packet_reader.read_int32())
585
- return self
586
-
587
-
588
- class Bind(BaseFrontendMessage):
589
- """
590
- Bind (F)
591
- Byte1('B')
592
- Identifies the message as a Bind command.
593
-
594
- Int32
595
- Length of message contents in bytes, including self.
596
-
597
- String
598
- The name of the destination portal (an empty string selects the unnamed portal).
599
-
600
- String
601
- The name of the source prepared statement (an empty string selects the unnamed prepared statement).
602
-
603
- Int16 The number of parameter format codes that follow (denoted C below). This can be zero to indicate that there
604
- are no parameters or that the parameters all use the default format (text); or one, in which case the specified
605
- format code is applied to all parameters; or it can equal the actual number of parameters.
606
-
607
- Int16[C]
608
- The parameter format codes. Each must presently be zero (text) or one (binary).
609
-
610
- Int16 The number of parameter values that follow (possibly zero). This must match the number of parameters needed
611
- by the query.
612
-
613
- Next, the following pair of fields appear for each parameter:
614
-
615
- Int32 The length of the parameter value, in bytes (this count does not include itself). Can be zero. As a special
616
- case, -1 indicates a NULL parameter value. No value bytes follow in the NULL case.
617
-
618
- Byten
619
- The value of the parameter, in the format indicated by the associated format code. n is the above length.
620
-
621
- After the last parameter, the following fields appear:
622
-
623
- Int16 The number of result-column format codes that follow (denoted R below). This can be zero to indicate that
624
- there are no result columns or that the result columns should all use the default format (text); or one,
625
- in which case the specified format code is applied to all result columns (if any); or it can equal the actual
626
- number of result columns of the query.
627
-
628
- Int16[R]
629
- The result-column format codes. Each must presently be zero (text) or one (binary). """
630
-
631
- def __init__(self):
632
- self.identifier = PostgresFrontendMessageIdentifier.BIND
633
- self.length = None
634
- self.name = None
635
- self.statement_name = None
636
- self.format_codes = [] # 0=text 1=binary
637
- self.parameters = []
638
- self.result_format_codes = []
639
-
640
- super().__init__()
641
-
642
- def read(self, packet_reader: PostgresPacketReader):
643
- self.length = packet_reader.read_int32()
644
- self.name = packet_reader.read_string()
645
- self.statement_name = packet_reader.read_string()
646
- num_format_codes = packet_reader.read_int16()
647
- for _ in range(num_format_codes):
648
- self.format_codes.append(packet_reader.read_int16())
649
- num_parameters = packet_reader.read_int16()
650
- for _ in range(num_parameters):
651
- param_length = packet_reader.read_int32()
652
- if param_length == -1:
653
- self.parameters.append(None)
654
- else:
655
- self.parameters.append(packet_reader.read_bytes(param_length))
656
- num_result_format_codes = packet_reader.read_int16()
657
- for _ in range(num_result_format_codes):
658
- self.result_format_codes.append(packet_reader.read_int16())
659
- return self
660
-
661
-
662
- class Execute(BaseFrontendMessage):
663
- """
664
- Execute (F)
665
- Byte1('E')
666
- Identifies the message as an Execute command.
667
-
668
- Int32
669
- Length of message contents in bytes, including self.
670
-
671
- String
672
- The name of the portal to execute (an empty string selects the unnamed portal).
673
-
674
- Int32 Maximum number of rows to return, if portal contains a query that returns rows (ignored otherwise). Zero
675
- denotes “no limit”."""
676
-
677
- def __init__(self):
678
- self.identifier = PostgresFrontendMessageIdentifier.EXECUTE
679
- self.length = None
680
- self.name = None
681
- self.max_rows_ret = None
682
- super().__init__()
683
-
684
- def read(self, packet_reader: PostgresPacketReader):
685
- self.length = packet_reader.read_int32()
686
- self.name = packet_reader.read_string()
687
- self.max_rows_ret = packet_reader.read_int32()
688
- return self
689
-
690
-
691
- class Sync(BaseFrontendMessage):
692
- """
693
- Sync (F)
694
- Byte1('S')
695
- Identifies the message as a Sync command.
696
-
697
- Int32(4)
698
- Length of message contents in bytes, including self. """
699
-
700
- def __init__(self):
701
- self.identifier = PostgresFrontendMessageIdentifier.SYNC
702
- super().__init__()
703
-
704
-
705
- class Describe(BaseFrontendMessage):
706
- """
707
- Describe (F)
708
- Byte1('D')
709
- Identifies the message as a Describe command.
710
-
711
- Int32
712
- Length of message contents in bytes, including self.
713
-
714
- Byte1
715
- 'S' to describe a prepared statement; or 'P' to describe a portal.
716
-
717
- String The name of the prepared statement or portal to describe (an empty string selects the unnamed prepared
718
- statement or portal)."""
719
-
720
- def __init__(self):
721
- self.identifier = PostgresFrontendMessageIdentifier.DESCRIBE
722
- self.length = None
723
- self.describe_type = None
724
- self.name = None
725
- super().__init__()
726
-
727
- def read(self, packet_reader: PostgresPacketReader):
728
- self.length = packet_reader.read_int32()
729
- self.describe_type = packet_reader.read_byte()
730
- self.name = packet_reader.read_string()
731
- return self
732
-
733
-
734
- IMPLEMENTED_BACKEND_POSTGRES_MESSAGE_CLASSES = [
735
- NoticeResponse, AuthenticationOk, AuthenticationClearTextPassword, ReadyForQuery, CommandComplete, Error,
736
- RowDescriptions, DataRow, NegotiateProtocolVersion, ParameterStatus, ParseComplete, BindComplete,
737
- ParameterDescription
738
- ]
739
- IMPLEMENTED_FRONTEND_POSTGRES_MESSAGE_CLASSES = [
740
- Query, Terminate, Parse, Bind, Execute, Sync, Describe
741
- ]
742
- FE_MESSAGE_MAP: Dict[PostgresFrontendMessageIdentifier, Type[PostgresMessage]] = {
743
- PostgresFrontendMessageIdentifier.QUERY: Query,
744
- PostgresFrontendMessageIdentifier.TERMINATE: Terminate,
745
- PostgresFrontendMessageIdentifier.PARSE: Parse,
746
- PostgresFrontendMessageIdentifier.BIND: Bind,
747
- PostgresFrontendMessageIdentifier.EXECUTE: Execute,
748
- PostgresFrontendMessageIdentifier.SYNC: Sync,
749
- PostgresFrontendMessageIdentifier.DESCRIBE: Describe
750
- }
751
- SUPPORTED_AUTH_TYPES = [PostgresAuthType.PASSWORD]
752
-
753
- # Below Lies Unimplemented Messages
754
-
755
- """
756
- '''
757
- AuthenticationKerberosV5 (B)
758
- Byte1('R')
759
- Identifies the message as an authentication request.
760
-
761
- Int32(8)
762
- Length of message contents in bytes, including self.
763
-
764
- Int32(2)
765
- Specifies that Kerberos V5 authentication is required. '''
766
-
767
- '''
768
- AuthenticationMD5Password (B)
769
- Byte1('R')
770
- Identifies the message as an authentication request.
771
-
772
- Int32(12)
773
- Length of message contents in bytes, including self.
774
-
775
- Int32(5)
776
- Specifies that an MD5-encrypted password is required.
777
-
778
- Byte4
779
- The salt to use when encrypting the password. '''
780
-
781
- '''
782
- AuthenticationSCMCredential (B)
783
- Byte1('R')
784
- Identifies the message as an authentication request.
785
-
786
- Int32(8)
787
- Length of message contents in bytes, including self.
788
-
789
- Int32(6)
790
- Specifies that an SCM credentials message is required. '''
791
-
792
- '''
793
- AuthenticationGSS (B)
794
- Byte1('R')
795
- Identifies the message as an authentication request.
796
-
797
- Int32(8)
798
- Length of message contents in bytes, including self.
799
-
800
- Int32(7)
801
- Specifies that GSSAPI authentication is required. '''
802
-
803
- '''
804
- AuthenticationGSSContinue (B)
805
- Byte1('R')
806
- Identifies the message as an authentication request.
807
-
808
- Int32
809
- Length of message contents in bytes, including self.
810
-
811
- Int32(8)
812
- Specifies that this message contains GSSAPI or SSPI data.
813
-
814
- Byten
815
- GSSAPI or SSPI authentication data. '''
816
-
817
- '''
818
- AuthenticationSSPI (B)
819
- Byte1('R')
820
- Identifies the message as an authentication request.
821
-
822
- Int32(8)
823
- Length of message contents in bytes, including self.
824
-
825
- Int32(9)
826
- Specifies that SSPI authentication is required. '''
827
-
828
- '''
829
- AuthenticationSASL (B)
830
- Byte1('R')
831
- Identifies the message as an authentication request.
832
-
833
- Int32
834
- Length of message contents in bytes, including self.
835
-
836
- Int32(10)
837
- Specifies that SASL authentication is required.
838
-
839
- The message body is a list of SASL authentication mechanisms, in the server's order of preference. A zero byte is
840
- required as terminator after the last authentication mechanism name. For each mechanism, there is the following:
841
-
842
- String
843
- Name of a SASL authentication mechanism. '''
844
-
845
- '''
846
- AuthenticationSASLContinue (B)
847
- Byte1('R')
848
- Identifies the message as an authentication request.
849
-
850
- Int32
851
- Length of message contents in bytes, including self.
852
-
853
- Int32(11)
854
- Specifies that this message contains a SASL challenge.
855
-
856
- Byten
857
- SASL data, specific to the SASL mechanism being used. '''
858
-
859
- '''
860
- AuthenticationSASLFinal (B)
861
- Byte1('R')
862
- Identifies the message as an authentication request.
863
-
864
- Int32
865
- Length of message contents in bytes, including self.
866
-
867
- Int32(12)
868
- Specifies that SASL authentication has completed.
869
-
870
- Byten
871
- SASL outcome "additional data", specific to the SASL mechanism being used. '''
872
-
873
- '''BackendKeyData (B) Byte1('K') Identifies the message as cancellation key data. The frontend must save these values
874
- if it wishes to be able to issue CancelRequest messages later.
875
-
876
- Int32(12)
877
- Length of message contents in bytes, including self.
878
-
879
- Int32
880
- The process ID of this backend.
881
-
882
- Int32
883
- The secret key of this backend. '''
884
-
885
- '''
886
- CancelRequest (F)
887
- Int32(16)
888
- Length of message contents in bytes, including self.
889
-
890
- Int32(80877102) The cancel request code. The value is chosen to contain 1234 in the most significant 16 bits,
891
- and 5678 in the least significant 16 bits. (To avoid confusion, this code must not be the same as any protocol
892
- version number.)
893
-
894
- Int32
895
- The process ID of the target backend.
896
-
897
- Int32
898
- The secret key for the target backend. '''
899
-
900
- '''
901
- Close (F)
902
- Byte1('C')
903
- Identifies the message as a Close command.
904
-
905
- Int32
906
- Length of message contents in bytes, including self.
907
-
908
- Byte1
909
- 'S' to close a prepared statement; or 'P' to close a portal.
910
-
911
- String The name of the prepared statement or portal to close (an empty string selects the unnamed prepared statement
912
- or portal).'''
913
-
914
- '''
915
- CloseComplete (B)
916
- Byte1('3')
917
- Identifies the message as a Close-complete indicator.
918
-
919
- Int32(4)
920
- Length of message contents in bytes, including self. '''
921
-
922
- '''
923
- CommandComplete (B)
924
- Byte1('C')
925
- Identifies the message as a command-completed response.
926
-
927
- Int32
928
- Length of message contents in bytes, including self.
929
-
930
- String
931
- The command tag. This is usually a single word that identifies which SQL command was completed.
932
-
933
- For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid used to be the
934
- object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported
935
- anymore; therefore oid is always 0.
936
-
937
- For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.
938
-
939
- For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.
940
-
941
- For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.
942
-
943
- For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.
944
-
945
- For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.
946
-
947
- For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only
948
- in PostgreSQL 8.2 and later.)'''
949
-
950
- '''
951
- CopyData (F & B)
952
- Byte1('d')
953
- Identifies the message as COPY data.
954
-
955
- Int32
956
- Length of message contents in bytes, including self.
957
-
958
- Byten Data that forms part of a COPY data stream. Messages sent from the backend will always correspond to single
959
- data rows, but messages sent by frontends might divide the data stream arbitrarily.'''
960
-
961
- '''
962
- CopyDone (F & B)
963
- Byte1('c')
964
- Identifies the message as a COPY-complete indicator.
965
-
966
- Int32(4)
967
- Length of message contents in bytes, including self. '''
968
-
969
- '''
970
- CopyFail (F)
971
- Byte1('f')
972
- Identifies the message as a COPY-failure indicator.
973
-
974
- Int32
975
- Length of message contents in bytes, including self.
976
-
977
- String
978
- An error message to report as the cause of failure. '''
979
-
980
- '''CopyInResponse (B) Byte1('G') Identifies the message as a Start Copy In response. The frontend must now send
981
- copy-in data (if not prepared to do so, send a CopyFail message).
982
-
983
- Int32
984
- Length of message contents in bytes, including self.
985
-
986
- Int8 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator
987
- characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more
988
- information.
989
-
990
- Int16
991
- The number of columns in the data to be copied (denoted N below).
992
-
993
- Int16[N] The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be
994
- zero if the overall copy format is textual.'''
995
-
996
- '''
997
- CopyOutResponse (B)
998
- Byte1('H')
999
- Identifies the message as a Start Copy Out response. This message will be followed by copy-out data.
1000
-
1001
- Int32
1002
- Length of message contents in bytes, including self.
1003
-
1004
- Int8 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator
1005
- characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more
1006
- information.
1007
-
1008
- Int16
1009
- The number of columns in the data to be copied (denoted N below).
1010
-
1011
- Int16[N] The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be
1012
- zero if the overall copy format is textual.'''
1013
-
1014
- '''
1015
- CopyBothResponse (B)
1016
- Byte1('W')
1017
- Identifies the message as a Start Copy Both response. This message is used only for Streaming Replication.
1018
-
1019
- Int32
1020
- Length of message contents in bytes, including self.
1021
-
1022
- Int8 0 indicates the overall COPY format is textual (rows separated by newlines, columns separated by separator
1023
- characters, etc.). 1 indicates the overall copy format is binary (similar to DataRow format). See COPY for more
1024
- information.
1025
-
1026
- Int16
1027
- The number of columns in the data to be copied (denoted N below).
1028
-
1029
- Int16[N] The format codes to be used for each column. Each must presently be zero (text) or one (binary). All must be
1030
- zero if the overall copy format is textual.'''
1031
-
1032
- '''
1033
- Describe (F)
1034
- Byte1('D')
1035
- Identifies the message as a Describe command.
1036
-
1037
- Int32
1038
- Length of message contents in bytes, including self.
1039
-
1040
- Byte1
1041
- 'S' to describe a prepared statement; or 'P' to describe a portal.
1042
-
1043
- String The name of the prepared statement or portal to describe (an empty string selects the unnamed prepared
1044
- statement or portal).'''
1045
-
1046
- '''
1047
- EmptyQueryResponse (B)
1048
- Byte1('I')
1049
- Identifies the message as a response to an empty query string. (This substitutes for CommandComplete.)
1050
-
1051
- Int32(4)
1052
- Length of message contents in bytes, including self. '''
1053
-
1054
- '''
1055
- Execute (F)
1056
- Byte1('E')
1057
- Identifies the message as an Execute command.
1058
-
1059
- Int32
1060
- Length of message contents in bytes, including self.
1061
-
1062
- String
1063
- The name of the portal to execute (an empty string selects the unnamed portal).
1064
-
1065
- Int32 Maximum number of rows to return, if portal contains a query that returns rows (ignored otherwise). Zero
1066
- denotes “no limit”.'''
1067
-
1068
- '''
1069
- Flush (F)
1070
- Byte1('H')
1071
- Identifies the message as a Flush command.
1072
-
1073
- Int32(4)
1074
- Length of message contents in bytes, including self. '''
1075
-
1076
- '''
1077
- FunctionCall (F)
1078
- Byte1('F')
1079
- Identifies the message as a function call.
1080
-
1081
- Int32
1082
- Length of message contents in bytes, including self.
1083
-
1084
- Int32
1085
- Specifies the object ID of the function to call.
1086
-
1087
- Int16 The number of argument format codes that follow (denoted C below). This can be zero to indicate that there are
1088
- no arguments or that the arguments all use the default format (text); or one, in which case the specified format code
1089
- is applied to all arguments; or it can equal the actual number of arguments.
1090
-
1091
- Int16[C]
1092
- The argument format codes. Each must presently be zero (text) or one (binary).
1093
-
1094
- Int16
1095
- Specifies the number of arguments being supplied to the function.
1096
-
1097
- Next, the following pair of fields appear for each argument:
1098
-
1099
- Int32 The length of the argument value, in bytes (this count does not include itself). Can be zero. As a special
1100
- case, -1 indicates a NULL argument value. No value bytes follow in the NULL case.
1101
-
1102
- Byten
1103
- The value of the argument, in the format indicated by the associated format code. n is the above length.
1104
-
1105
- After the last argument, the following field appears:
1106
-
1107
- Int16
1108
- The format code for the function result. Must presently be zero (text) or one (binary). '''
1109
-
1110
- '''
1111
- FunctionCallResponse (B)
1112
- Byte1('V')
1113
- Identifies the message as a function call result.
1114
-
1115
- Int32
1116
- Length of message contents in bytes, including self.
1117
-
1118
- Int32 The length of the function result value, in bytes (this count does not include itself). Can be zero. As a
1119
- special case, -1 indicates a NULL function result. No value bytes follow in the NULL case.
1120
-
1121
- Byten
1122
- The value of the function result, in the format indicated by the associated format code. n is the above length. '''
1123
-
1124
- '''
1125
- GSSENCRequest (F)
1126
- Int32(8)
1127
- Length of message contents in bytes, including self.
1128
-
1129
- Int32(80877104) The GSSAPI Encryption request code. The value is chosen to contain 1234 in the most significant 16
1130
- bits, and 5680 in the least significant 16 bits. (To avoid confusion, this code must not be the same as any protocol
1131
- version number.)'''
1132
-
1133
- '''GSSResponse (F) Byte1('p') Identifies the message as a GSSAPI or SSPI response. Note that this is also used for
1134
- SASL and password response messages. The exact message type can be deduced from the context.
1135
-
1136
- Int32
1137
- Length of message contents in bytes, including self.
1138
-
1139
- Byten
1140
- GSSAPI/SSPI specific message data. '''
1141
-
1142
- '''
1143
- NoData (B)
1144
- Byte1('n')
1145
- Identifies the message as a no-data indicator.
1146
-
1147
- Int32(4)
1148
- Length of message contents in bytes, including self. '''
1149
-
1150
- '''
1151
- NotificationResponse (B)
1152
- Byte1('A')
1153
- Identifies the message as a notification response.
1154
-
1155
- Int32
1156
- Length of message contents in bytes, including self.
1157
-
1158
- Int32
1159
- The process ID of the notifying backend process.
1160
-
1161
- String
1162
- The name of the channel that the notify has been raised on.
1163
-
1164
- String
1165
- The “payload” string passed from the notifying process. '''
1166
-
1167
- '''
1168
- Parse (F)
1169
- Byte1('P')
1170
- Identifies the message as a Parse command.
1171
-
1172
- Int32
1173
- Length of message contents in bytes, including self.
1174
-
1175
- String
1176
- The name of the destination prepared statement (an empty string selects the unnamed prepared statement).
1177
-
1178
- String
1179
- The query string to be parsed.
1180
-
1181
- Int16 The number of parameter data types specified (can be zero). Note that this is not an indication of the number
1182
- of parameters that might appear in the query string, only the number that the frontend wants to prespecify types for.
1183
-
1184
- Then, for each parameter, there is the following:
1185
-
1186
- Int32 Specifies the object ID of the parameter data type. Placing a zero here is equivalent to leaving the type
1187
- unspecified.'''
1188
-
1189
- '''PasswordMessage (F) Byte1('p') Identifies the message as a password response. Note that this is also used for
1190
- GSSAPI, SSPI and SASL response messages. The exact message type can be deduced from the context.
1191
-
1192
- Int32
1193
- Length of message contents in bytes, including self.
1194
-
1195
- String
1196
- The password (encrypted, if requested). '''
1197
-
1198
- '''PortalSuspended (B) Byte1('s') Identifies the message as a portal-suspended indicator. Note this only appears if
1199
- an Execute message's row-count limit was reached.
1200
-
1201
- Int32(4)
1202
- Length of message contents in bytes, including self. '''
1203
-
1204
- '''SASLInitialResponse (F) Byte1('p') Identifies the message as an initial SASL response. Note that this is also used
1205
- for GSSAPI, SSPI and password response messages. The exact message type is deduced from the context.
1206
-
1207
- Int32
1208
- Length of message contents in bytes, including self.
1209
-
1210
- String
1211
- Name of the SASL authentication mechanism that the client selected.
1212
-
1213
- Int32
1214
- Length of SASL mechanism specific "Initial Client Response" that follows, or -1 if there is no Initial Response.
1215
-
1216
- Byten
1217
- SASL mechanism specific "Initial Response". '''
1218
-
1219
- '''SASLResponse (F) Byte1('p') Identifies the message as a SASL response. Note that this is also used for GSSAPI,
1220
- SSPI and password response messages. The exact message type can be deduced from the context.
1221
-
1222
- Int32
1223
- Length of message contents in bytes, including self.
1224
-
1225
- Byten
1226
- SASL mechanism specific message data. '''
1227
-
1228
- '''
1229
- StartupMessage (F)
1230
- Int32
1231
- Length of message contents in bytes, including self.
1232
-
1233
- Int32(196608) The protocol version number. The most significant 16 bits are the major version number (3 for the
1234
- protocol described here). The least significant 16 bits are the minor version number (0 for the protocol described
1235
- here).
1236
-
1237
- The protocol version number is followed by one or more pairs of parameter name and value strings. A zero byte is
1238
- required as a terminator after the last name/value pair. Parameters can appear in any order. user is required,
1239
- others are optional. Each parameter is specified as:
1240
-
1241
- String
1242
- The parameter name. Currently recognized names are:
1243
-
1244
- user
1245
- The database user name to connect as. Required; there is no default.
1246
-
1247
- database
1248
- The database to connect to. Defaults to the user name.
1249
-
1250
- options Command-line arguments for the backend. (This is deprecated in favor of setting individual run-time
1251
- parameters.) Spaces within this string are considered to separate arguments, unless escaped with a backslash
1252
- write to represent a literal backslash.
1253
-
1254
- replication Used to connect in streaming replication mode, where a small set of replication commands can be issued
1255
- instead of SQL statements. Value can be true, false, or database, and the default is false. See Section 55.4 for
1256
- details.
1257
-
1258
- In addition to the above, other parameters may be listed. Parameter names beginning with _pq_. are reserved for use
1259
- as protocol extensions, while others are treated as run-time parameters to be set at backend start time. Such
1260
- settings will be applied during backend start (after parsing the command-line arguments if any) and will act as
1261
- session defaults.
1262
-
1263
- String
1264
- The parameter value. '''
1265
- """