MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / start_execution

Function start_execution

web/pgadmin/tools/debugger/__init__.py:1366–1439  ·  view source on GitHub ↗

start_execution(trans_id, port_num) This method is responsible for creating an asynchronous connection for execution thread. Also store the session id into session return with attach port query for the direct debugging. Parameters: trans_id - Transaction ID

(trans_id, port_num)

Source from the content-addressed store, hash-verified

1364)
1365@pga_login_required
1366def start_execution(trans_id, port_num):
1367 """
1368 start_execution(trans_id, port_num)
1369
1370 This method is responsible for creating an asynchronous connection for
1371 execution thread. Also store the session id into session return with
1372 attach port query for the direct debugging.
1373
1374 Parameters:
1375 trans_id
1376 - Transaction ID
1377 port_num
1378 - Port number to attach
1379 """
1380
1381 de_inst = DebuggerInstance(trans_id)
1382 if de_inst.debugger_data is None:
1383 return make_json_response(
1384 data={
1385 'status': 'NotConnected',
1386 'result': SERVER_CONNECTION_CLOSED
1387 }
1388 )
1389
1390 # Create asynchronous connection using random connection id.
1391 exe_conn_id = str(secrets.choice(range(1, 9999999)))
1392 try:
1393 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
1394 de_inst.debugger_data['server_id'])
1395 conn = manager.connection(
1396 did=de_inst.debugger_data['database_id'],
1397 conn_id=exe_conn_id)
1398 except Exception as e:
1399 return internal_server_error(errormsg=str(e))
1400
1401 # Connect the Server
1402 status, msg = conn.connect()
1403 if not status:
1404 return internal_server_error(errormsg=str(msg))
1405
1406 # find the debugger version and execute the query accordingly
1407 dbg_version = de_inst.debugger_data['debugger_version']
1408 if dbg_version <= 2:
1409 template_path = DEBUGGER_SQL_V1_PATH
1410 else:
1411 template_path = DEBUGGER_SQL_V3_PATH
1412
1413 # connect to port and store the session ID in the session variables
1414 sql = render_template(
1415 "/".join([template_path, 'attach_to_port.sql']), port=port_num)
1416 status_port, res_port = execute_dict_search_path(
1417 conn, sql, de_inst.debugger_data['search_path'])
1418 if not status_port:
1419 return internal_server_error(errormsg=res_port)
1420
1421 if res_port == BUSY:
1422 return make_json_response(
1423 data={'status': 'Busy', 'result': []}

Callers

nothing calls this directly

Calls 10

update_sessionMethod · 0.95
DebuggerInstanceClass · 0.90
make_json_responseFunction · 0.90
get_driverFunction · 0.90
internal_server_errorFunction · 0.90
execute_dict_search_pathFunction · 0.85
connection_managerMethod · 0.80
connectionMethod · 0.80
joinMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected