diff --git a/.github/composite-actions/install-extensions/action.yml b/.github/composite-actions/install-extensions/action.yml index 367606c0fc..51c0ccb363 100644 --- a/.github/composite-actions/install-extensions/action.yml +++ b/.github/composite-actions/install-extensions/action.yml @@ -65,9 +65,9 @@ runs: if [[ ${{ inputs.server_collation_name }} != "default" ]]; then sudo echo "babelfishpg_tsql.server_collation_name = '${{ inputs.server_collation_name }}'" >> postgresql.conf fi - ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l logfile start + ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l ~/${{inputs.install_dir}}/$DATADIR/logfile start cd ~/work/babelfish_extensions/babelfish_extensions/ sudo ~/${{inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -p ${{inputs.psql_port}} -v user="jdbc_user" -v db="babelfish_db" -v migration_mode=${{inputs.migration_mode}} -v tsql_port=${{inputs.tsql_port}} -v parallel_query_mode=${{inputs.parallel_query_mode}} -f .github/scripts/create_extension.sql - ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l logfile restart + ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l ~/${{inputs.install_dir}}/$DATADIR/logfile restart sqlcmd -S localhost,${{inputs.tsql_port}} -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" shell: bash diff --git a/.github/workflows/jdbc-tests.yml b/.github/workflows/jdbc-tests.yml index 26b5b1b3c4..df7d1cc639 100644 --- a/.github/workflows/jdbc-tests.yml +++ b/.github/workflows/jdbc-tests.yml @@ -100,6 +100,16 @@ jobs: ~/psql/data/logfile ~/psql/data_5433/logfile + - name: Check for cache reference leak + if: always() + run: | + if grep -q "cache reference leak" ~/psql/data/logfile ~/psql/data_5433/logfile; then + echo "Cache reference leak detected in logs!" + exit 1 + else + echo "No cache reference leak found in logs." + fi + # The test summary files contain paths with ':' characters, which is not allowed with the upload-artifact actions - name: Rename Test Summary Files id: test-file-rename diff --git a/contrib/babelfishpg_tsql/src/pl_handler.c b/contrib/babelfishpg_tsql/src/pl_handler.c index 00d64b2301..6fb0c2a036 100644 --- a/contrib/babelfishpg_tsql/src/pl_handler.c +++ b/contrib/babelfishpg_tsql/src/pl_handler.c @@ -2519,6 +2519,7 @@ bbf_ProcessUtility(PlannedStmt *pstmt, bool with_recompile = false; Node *tbltypStmt = NULL; ListCell *parameter; + HeapTuple proctup; cfs = makeNode(CreateFunctionStmt); cfs->returnType = NULL; @@ -2600,13 +2601,23 @@ bbf_ProcessUtility(PlannedStmt *pstmt, originalFunc.objectId = oldoid; originalFunc.classId = ProcedureRelationId; originalFunc.objectSubId = 0; - if(get_bbf_function_tuple_from_proctuple(SearchSysCache1(PROCOID, ObjectIdGetDatum(oldoid))) == NULL) + proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(oldoid)); + + if (!HeapTupleIsValid(proctup)) { - /* Detect PSQL functions and throw error */ - ereport(ERROR, - (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("No existing TSQL procedure found with the name for ALTER PROCEDURE"))); + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("cache lookup failed for procedure %u", oldoid))); } + if (get_bbf_function_tuple_from_proctuple(proctup) == NULL) + { + /* Detect PSQL functions and throw error */ + ereport(ERROR, + (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), + errmsg("No existing TSQL procedure found with the name for ALTER PROCEDURE"))); + } + ReleaseSysCache(proctup); + if(!cfs->is_procedure) { /*