Recent

Author Topic: mysql55 problem with mysql_fetch_row  (Read 2160 times)

nadavvin

  • New Member
  • *
  • Posts: 28
mysql55 problem with mysql_fetch_row
« on: November 27, 2018, 08:13:05 pm »
Hello

I am porting HeidiSQl to Lazarus and my project is here: https://github.com/nadavvin/HeidiLazarusSQL

I got error on mysql_fetch_row: Error: Incompatible types: got "PPChar" expected "PMYSQL_ROW"

I did example project for this issue and it failed on the same problem.

It failed on compile and without the mysql_fetch_row it run and connected to the database.

row is PMYSQL_ROW defined in mysql.inc and it defined as:
Code: Pascal  [Select][+][-]
  1. PMYSQL_ROW = ^MYSQL_ROW;       // return data as array of strings
  2. MYSQL_ROW = ppchar;

The example code:

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   mysql55;
  7.  
  8. var
  9.   mysql: PMYSQL;
  10.   s: PMYSQL;
  11.   ClientFlags: qword;
  12.   sql: AnsiString;
  13.   status: Integer;
  14.   result: PMYSQL_RES;
  15.   row: PMYSQL_ROW;
  16. begin
  17.  
  18.   ClientFlags := CLIENT_LOCAL_FILES or CLIENT_INTERACTIVE or CLIENT_PROTOCOL_41 or CLIENT_MULTI_STATEMENTS or CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS;
  19.   WriteLn(ClientFlags);
  20.   mysql := mysql_init(nil);
  21.   s:=mysql_real_connect(mysql, 'localhost', 'root', 'root', nil, 3306,nil,ClientFlags);
  22.  
  23.   if s <> nil then begin
  24.     WriteLn('Success');
  25.   end else begin
  26.     WriteLn('Failed');
  27.   end;
  28.  
  29.   sql := 'show databases';
  30.   status := mysql_real_query(mysql,PAnsiChar(sql), Length(sql));
  31.   result := mysql_store_result(mysql);
  32.   row := mysql_fetch_row(result);
  33. end.
  34.  

Thanks for your help
« Last Edit: November 27, 2018, 08:23:11 pm by nadavvin »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: mysql55 problem with mysql_fetch_row
« Reply #1 on: November 27, 2018, 09:29:01 pm »
This is the signature of mysql_fetch_row:
Code: Pascal  [Select][+][-]
  1. function mysql_fetch_row(result:PMYSQL_RES):MYSQL_ROW;extdecl;external mysqllib name 'mysql_fetch_row';
  2.  
So now you should what row's type should be.

nadavvin

  • New Member
  • *
  • Posts: 28
Re: mysql55 problem with mysql_fetch_row
« Reply #2 on: November 28, 2018, 05:43:37 am »
Thanks, I confused because in the heidisql project the signature is in with PMYSQL_ROW:
mysql_fetch_row: function(Result: PMYSQL_RES): PMYSQL_ROW; stdcall;

 

TinyPortal © 2005-2018