Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nV9xj-0008D1-Et for pgsql-odbc@arkaria.postgresql.org; Fri, 18 Mar 2022 10:36:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nV9xi-0007Dz-E1 for pgsql-odbc@arkaria.postgresql.org; Fri, 18 Mar 2022 10:36:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUudk-0007hs-8j for pgsql-odbc@lists.postgresql.org; Thu, 17 Mar 2022 18:14:24 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nUudd-0003nL-SY for pgsql-odbc@postgresql.org; Thu, 17 Mar 2022 18:14:23 +0000 Received: by mail-ot1-x32e.google.com with SMTP id v25-20020a05683024b900b005b2463a41faso4009165ots.10 for ; Thu, 17 Mar 2022 11:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=UBj9uJ9zYJPGjkeOm0gE1qQCO0llJHDrbr2SCGXEM00=; b=UKAecIrxUennQC+54aS+ssvdVynqN6tYKbnfblQNNxvLC+/qWjqYhAnWq/OnlsVj9l OqKWDs/omltMwWUxC9e21XN/6jpT2Ogy5r0YyH4B3c4hfWKOU+2ozLqWRh2dPUS8+qg5 xyOaNI2zUnZ78RtslDVTot7nr/gZTYKOU1daIj7mQUCUsWwxBMLTMXoWUlQsBa6uSrvs e9vOK/SJoQm1uXt6GoGOWt9r4eZHnnWVy4c+nMdpZFG1bZABNsxLAVCvIGOBpffwQOCV YiBMWe3J8UyZRXuESuBXhemX1W0AHAe/GIBiZzYfF1nEsGT9aWb4msiTeh8xozR5WDMg XEOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=UBj9uJ9zYJPGjkeOm0gE1qQCO0llJHDrbr2SCGXEM00=; b=5/cwoBapJt94GuxH2kJcHoEiTMHK6kHwoN0wsje9wE462EBuuPQ0Cwj1r0zCi1Gz5/ 5UI1aIupqFn4Z9w+jgOUh9WqG5obojf9iv2ADHy8Fuyl/IuWVGymmeWTlQqFAdZdj7zP s1aS9wvmNDtA9ouRemwMrEtwIl9RsuDad8U4QLDsQ/aWdaY2zkTc0uKNRVvX1KfMa0L4 0ljXnBxumPl5EIMem/PPH8aE3TuNDHsO9s/B7c3K8AnuFJuikylbOB8TboEgqCZMVvKT Sxh0qAWWbIrGB9HEDnBydt+d8j2944L+Sr0H43x01mCGk1njIV5LYkehoYXP57sMaTz5 wpnQ== X-Gm-Message-State: AOAM531Vmoq8g9rDVWjrxB3c9M3fPegt/++WE1GC8Hmgv0Yb/qUTHP8X rgFBIgLB6oo20VQ96qJYE82iRUcTDoQ9DgHvq6TClxK8S6NK X-Google-Smtp-Source: ABdhPJwdTWM+Kzfg4rVeSsu81TaFvnjBAXS6nKIsQAbepjj8W3T0VsmlnGhQu7Jmbz+rmT7kccKjBQU5Gost2N6Fckk= X-Received: by 2002:a05:6830:438e:b0:5c9:37f4:1ed9 with SMTP id s14-20020a056830438e00b005c937f41ed9mr2129169otv.62.1647540855793; Thu, 17 Mar 2022 11:14:15 -0700 (PDT) MIME-Version: 1.0 From: Daniel Kempenich Date: Thu, 17 Mar 2022 13:14:05 -0500 Message-ID: Subject: psqlodbc copy_and_convert_field "Unrecognized return value" To: pgsql-odbc@postgresql.org Content-Type: multipart/alternative; boundary="000000000000766ba405da6dffc6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000766ba405da6dffc6 Content-Type: text/plain; charset="UTF-8" In my client code I was seeing the message through the odbc driver: native=<8> sqlerror= sqlstate= during a fetch. There are only a few places where copy_and_convert_field return SQL_ERROR instead of a COPY specific or COPY_GENERAL_ERROR with a message. I believe it comes from psqlodbc's results.c when the convert returns SQL_ERROR instead of COPY_* Would it be possible to update the convert.c to something like the following to print a more specific message to aid in debugging? Thanks, Dan. (From the git branch: REL-13_02_0000) diff --git a/convert.c b/convert.c index d94fdb6..e525bd1 100644 --- a/convert.c +++ b/convert.c @@ -1277,7 +1277,8 @@ copy_and_convert_field(StatementClass *stmt, { if (stmt->current_col >= opts->allocated) { - return SQL_ERROR; + SC_set_error(stmt, STMT_INTERNAL_ERROR, "current column is greater than amount allocated", func); + return COPY_GENERAL_ERROR; } if (gdata->allocated != opts->allocated) extend_getdata_info(gdata, opts->allocated, TRUE); @@ -1389,7 +1390,7 @@ MYLOG(0, "null_cvt_date_string=%d\n", conn->connInfo.cvt_null_date_string); else { SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT_INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was retrieved", func); - return SQL_ERROR; + return COPY_GENERAL_ERROR; } --000000000000766ba405da6dffc6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In my client code I was seeing the message through the odb= c driver: native=3D<8> sqlerror=3D<Unrecognized return value from = copy_and_convert_field.> sqlstate=3D<HY000> during a fetch.=C2=A0 = There are only a few places where copy_and_convert_field return SQL_ERROR i= nstead of a COPY specific or COPY_GENERAL_ERROR with a message.=C2=A0 I bel= ieve it comes from psqlodbc's=C2=A0results.c when the convert returns S= QL_ERROR instead of COPY_*

Would it be possible to updat= e the convert.c to something like the following to print a more=C2=A0specif= ic=C2=A0message to aid in debugging?

Thanks,
=
Dan.

(From the git branch:=C2=A0REL-13_02_000= 0)

diff --git a/convert.c b/convert.c
index d94= fdb6..e525bd1 100644
--- a/convert.c
+++ b/convert.c
@@ -1277,7 +1= 277,8 @@ copy_and_convert_field(StatementClass *stmt,
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if = (stmt->current_col >=3D opts->allocated)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return SQL_ERROR;
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SC_s= et_error(stmt, STMT_INTERNAL_ERROR, "current column is greater than am= ount allocated", func);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return =C2=A0COPY_GENERAL_ERROR;
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (gdata->allocated !=3D opts-&g= t;allocated)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 extend_getdata_info(gdata, opts->allocated, TRU= E);
@@ -1389,7 +1390,7 @@ MYLOG(0, "null_cvt_date_string=3D%d\n&quo= t;, conn->connInfo.cvt_null_date_string);
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT= _INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was ret= rieved", func);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 return =C2=A0SQL_ERROR;
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return =C2=A0CO= PY_GENERAL_ERROR;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 }
--000000000000766ba405da6dffc6--