From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: converting pointer to value Date: Fri, 5 Mar 2021 15:00:41 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <02709d96-50fe-4e87-bdb5-4f430fa2717an@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 X-Mozilla-News-Host: news://news.aioe.org Xref: reader02.eternal-september.org comp.lang.ada:61488 List-Id: On 2021-03-05 12:57, Björn Lundin wrote: > Den 2021-03-05 kl. 12:02, skrev Björn Lundin: > >> >> SQLParamData1.2:  4790608 >> >> >> I'm thinking that I may be dealing with a pointer to a pointer here? >> hmm, needs more testing. I changed the expected value from 5 to 7. >> Still a bit off... >> > > The way I put the value 5 or 7 into the API is > > procedure Bind_Parameter(Statement    : in out Statement_Type; >                            Column_Index : in Positive; >                            Value        : in CLOB; >                            Null_Value   : in Boolean := False) is >     A : Bind_Parameter_Type; >     L : Sqlulen := Sqlulen(Length(Value)); >     Rc : Sqlreturn := 0; >     Local_Length : Sqllen ; >   begin > >     Local_Length := Sqllen(Sqllen(-100) -Sqllen(L)); > --Sqllen'(SQL_LEN_DATA_AT_EXEC_OFFSET  - L); > >     A.String_Pointer := new String'(To_String(Value) & Ascii.Nul); > >     if Null_Value then >       A.Length_Pointer := new Sqllen'(Sql_Null_Data); >     else >       A.Length_Pointer := new Sqllen'(Local_Length); >     end if; > >      Rc := gnu.Db.Sqlcli.Sqlbindparameter >          (Statementhandle  => Statement.Get_Handle, >           Parameternumber  => Sql_Parameter_Number (Column_Index), >           Inputoutputtype  => Sql_Param_Input, >           Valuetype        => Sql_C_Char, >           Parametertype    => Sql_Char, >           Columnsize       => L, >           Decimaldigits    => 0, >           Value            => 7,         --<-- here >           Bufferlength     => 0, >           Strlen_Or_Indptr => A.Length_Pointer); > >   exception >     when  Gnu.Db.Sqlcli.Table_Not_Found => raise Sql.No_Such_Object; >   end Bind_Parameter; > > >   where Bind_parameter_Type contains >     Length_Pointer : aliased PTR_SQLLEN := null; >     String_Pointer : aliased PTR_STRING := null; > > > and PTR_types defined as > type PTR_STRING is access all String; > Type PTR_SQLLEN is access all SQLLEN; > > and SQLLEN is a signed 64-bit integer > > and SQLBindParameter looks like > > > function SQLBindParameter (StatementHandle  : in SQLHSTMT; >                               ParameterNumber  : in SQL_Parameter_Number; >                               InputOutputType  : in SQL_Parameter_Type; >                               ValueType        : in SQL_C_DATA_TYPE; >                               ParameterType    : in SQL_DATA_TYPE; >                               ColumnSize       : in SQLULEN; >                               DecimalDigits    : in SQLSMALLINT; >                               Value            : in SQLINTEGER; This looks wrong because SQLINTEGER is 32-bit. Why do not you use Package System.Storage_Elements.Integer_Address instead, in order to place an integer there? It must be SQL_DATA_AT_EXEC which is -1, not 7. Alternatively you could use ptrdiff_t from Interfaces.C, because ARM is kind of ambiguous whether Integer_Address is signed. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de