Skip to content

Commit

Permalink
Adding support for sp_reset_connection stored procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharath BP committed Jul 19, 2024
1 parent 245d7ce commit dffe0b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/babelfishpg_tds/src/backend/tds/tds_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ pe_tds_init(void)
pltsql_plugin_handler_ptr->set_context_info = &set_tds_context_info;
pltsql_plugin_handler_ptr->get_datum_from_byte_ptr = &TdsBytePtrToDatum;
pltsql_plugin_handler_ptr->get_datum_from_date_time_struct = &TdsDateTimeTypeToDatum;
pltsql_plugin_handler_ptr->reset_tds_connection = &ResetTDSConnection;

invalidate_stat_table_hook = invalidate_stat_table;
guc_newval_hook = TdsSetGucStatVariable;
Expand Down
4 changes: 4 additions & 0 deletions contrib/babelfishpg_tsql/sql/sys_procedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,7 @@ GRANT EXECUTE ON PROCEDURE sys.sp_dropextendedproperty TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_enum_oledb_providers()
AS 'babelfishpg_tsql', 'sp_enum_oledb_providers_internal' LANGUAGE C;
GRANT EXECUTE on PROCEDURE sys.sp_enum_oledb_providers() TO PUBLIC;

CREATE OR REPLACE PROCEDURE sys.sp_reset_connection()
AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC;
1 change: 1 addition & 0 deletions contrib/babelfishpg_tsql/src/pltsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@ typedef struct PLtsql_protocol_plugin
Datum (*sp_unprepare_callback) (PG_FUNCTION_ARGS);

void (*reset_session_properties) (void);
void (*reset_tds_connection) (void);

void (*sqlvariant_set_metadata) (bytea *result, int pgBaseType, int scale, int precision, int maxLen);
void (*sqlvariant_get_metadata) (bytea *result, int pgBaseType, int *scale,
Expand Down
14 changes: 14 additions & 0 deletions contrib/babelfishpg_tsql/src/procedures.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ PG_FUNCTION_INFO_V1(sp_babelfish_volatility);
PG_FUNCTION_INFO_V1(sp_rename_internal);
PG_FUNCTION_INFO_V1(sp_execute_postgresql);
PG_FUNCTION_INFO_V1(sp_enum_oledb_providers_internal);
PG_FUNCTION_INFO_V1(sp_reset_connection_internal);
PG_FUNCTION_INFO_V1(sp_renamedb_internal);

extern void delete_cached_batch(int handle);
Expand Down Expand Up @@ -4177,3 +4178,16 @@ sp_enum_oledb_providers_internal(PG_FUNCTION_ARGS)

PG_RETURN_VOID();
}

Datum
sp_reset_connection_internal(PG_FUNCTION_ARGS)
{
elog(DEBUG2, "Test sp_reset_connection_internal");

if ((*pltsql_protocol_plugin_ptr)->reset_tds_connection)
{
(*pltsql_protocol_plugin_ptr)->reset_tds_connection();
}

PG_RETURN_VOID();
}

0 comments on commit dffe0b3

Please sign in to comment.