Subject: [PATCH] Automatic fetching of refcursors

From: Adrian Grucza <[email-masked]>
Date: Mon, 17 May 2021 12:20:54 +1000

Hi all,

I've created a patch that enables automatic fetching of refcursors from a
function/procedure. Functions/procedures can return one or more refcursors,
and the client application can then consume them the way multiple result
sets are normally consumed via ODBC.

Below is a summary of the attached patches:

0001 (`regress.ps1` changes unrelated to refcursors)
  * Allow installation and testing of a debug build of the driver (useful
for debugging)
  * Fixed a bug in `regress.ps1` where accepting the default password of
`postgres` did not work

0002
  * Added a FetchRefcursors setting
  * When FetchRefcursors is enabled, executes some refcursor code in
`statement.c` that already existed but was not compiled in due to
REFCUR_SUPPORT not being #defined

0003
  * Enhanced refcursor code to support multiple refcursors
  * Fixed an issue where output parameter bindings were not processed when
using refcursors
  * Added a `fetch-refcursors` regression test

Notes:
  * Client application must execute the statement in a transaction to avoid
cursors being closed prematurely (i.e. turn auto-commit off)
  * Works with both ODBC CALL and PostgreSQL CALL syntaxes
  * A search through the mailing list archive shows that refcursor support
is a feature that multiple people have wanted

Regards,

Adrian Grucza  
Technical Lead
Tel: +61390185800
[email-masked]
www.iress.com
Level 16, 385 Bourke Street,
 Melbourne, Victoria, 3000
The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities. ​If you have received this email in error please notify the sender immediately and delete this email. 
nosig

---

From: "Inoue,Hiroshi" <[email-masked]>
Date: Mon, 17 May 2021 15:35:47 +0900

Hi Adrian,

I would take care of your patches.

Thanks.
Hiroshi Inoue

2021年5月17日(月) 11:21 Adrian Grucza <[email-masked]>:

>   * Client application must execute the statement in a transaction to
> avoid cursors being closed prematurely (i.e. turn auto-commit off)
>  <https://www.iress.com/>
> Adrian Grucza​
> [email-masked]* <[email-masked]>
> *www.iress.com* <https://www.iress.com/>
> Level 16, 385 Bourke Street,  Melbourne,  Victoria,  3000
> The contents of this email originated from Iress. For this purpose Iress
> includes Iress Limited and/or any of its subsidiaries, holding companies
> and trading entities. ​If you have received this email in error please
> notify the sender immediately and delete this email.
> nosig
>

---

From: "Inoue,Hiroshi" <[email-masked]>
Date: Wed, 19 May 2021 21:54:44 +0900

Hi Adrian,

As for the patch 0001, is DriverConfiguration necessary?
For example, how about the following patch?

diff --git a/winbuild/regress.ps1 b/winbuild/regress.ps1
index b5e1f85..f83a411 100644
--- a/winbuild/regress.ps1
+++ b/winbuild/regress.ps1
@@ -27,7 +27,7 @@
     automatically unless this option is specified.  Currently "4.0",
     "12.0" or "14.0" is available.
 .PARAMETER Configuration
-    Specify "Release"(default) or "Debug".
+    Specify the configuration used for the regression tests.
"Release"(default) or "Debug".
 .PARAMETER BuildConfigPath
     Specify the configuration xml file name if you want to use
     the configuration file other than standard one.
@@ -263,7 +263,7 @@ function SpecialDsn($testdsn, $testdriver)
                        $uid = $in
                }
                $in = read-host -assecurestring "Password [$passwd]"
-               if ("$in" -ne "") {
+               if ($in.Length -ne 0) {
                        $ptr =
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($in)
                        $passwd =
[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ptr)
                }
@@ -394,12 +394,12 @@ foreach ($pl in $pary) {
         "Win32" {
                        $targetdir="test_x86"
                        $bit="32-bit"
-                       $dlldir="$objbase\x86_${ansi_dir_part}_Release"
+
$dlldir="$objbase\x86_${ansi_dir_part}_$Configuration"
                }
         default {
                        $targetdir="test_x64"
                        $bit="64-bit"
-                       $dlldir="$objbase\x64_${ansi_dir_part}_Release"
+
$dlldir="$objbase\x64_${ansi_dir_part}_$Configuration"
                }
        }
        pushd $pushdir\$targetdir

regards,
Hiroshi Inoue

2021年5月17日(月) 15:35 Inoue,Hiroshi <[email-masked]>:

>>   * Fixed an issue where output parameter bindings were not processed
>> when using refcursors
>>   * A search through the mailing list archive shows that refcursor
>> support is a feature that multiple people have wanted
>>
>> Regards,
>>  <https://www.iress.com/>
>> Adrian Grucza​
>> Technical Lead
>> Tel:  +61390185800