Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-10

The Interface to MySQL has changed on version by version

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andi Purwito

Hi all. This is my test program to track interface changes in mysql lib.

program MySQLku;
uses
  mysql50; //Before is mysql4
const
   DataBase : Pchar = 'dbtes';
   Query    : Pchar = 'select * from tbl';
   InsertSQL : PChar = 'insert into tbl (a, b) values (''value a'',"value b")';
var
  count,num : longint;
  code : integer;
  sock : PMYSQL;
  qmysql : TMYSQL;
  qbuf : string [160];
  rowbuf : TMYSQL_ROW;
  dummy : string;
  recbuf : PMYSQL_RES;
begin
  if paramcount=1 then
    begin
    Dummy:=Paramstr(1)+#0;
    ;
    end;
  Write ('Connecting to MySQL...');
  mysql_init(PMySQL(@qmysql));
  sock :=  mysql_real_connect(PMysql(@qmysql),nil,'root','',nil,0,nil,0);
  if sock=Nil  then
    begin
    Writeln (stderr,'Couldn''t connect to MySQL.');
    Writeln (stderr,mysql_error(@qmysql));
    halt(1);
    end;
  Writeln ('Done.');
  Writeln ('Connection data:');
{$ifdef Unix}
  writeln ('Mysql_port      : ',mysql_port);
  writeln ('Mysql_unix_port : ',mysql_unix_port);
{$endif}
  writeln ('Host info       : ',mysql_get_host_info(sock));
  writeln ('Server info     : ',mysql_stat(sock));
  writeln ('Client info     : ',mysql_get_client_info);
  Writeln ('Selecting Database ',DataBase,'...');
 if mysql_select_db(sock,DataBase) < 0 then
    begin
    Writeln (stderr,'Couldn''t select database ',Database);
    Writeln  (stderr,mysql_error(sock));
    halt (1);
    end;
  writeln ('Executing query : ',InsertSQL,'...');
    if (mysql_query(sock,InsertSQL) < 0) then
      begin
      Writeln (stderr,'Query failed ');
      writeln (stderr,mysql_error(sock));
      Halt(1);
      end;
  recbuf := mysql_store_result(sock);
  if RecBuf=Nil then
    begin
    Writeln ('Query returned nil result.');
    mysql_close(sock);
    halt (1);
    end;
  Writeln ('Number of records returned  : ',mysql_num_rows (recbuf));
  Writeln ('Number of fields per record : ',mysql_num_fields(recbuf));
  rowbuf := mysql_fetch_row(recbuf);
  while (rowbuf  nil) do
       begin
       Write  ('(Id: ', rowbuf[0]);
       Write  (', Name: ', rowbuf[1]);
       Writeln(', Email : ', rowbuf[2],')');
rowbuf := mysql_fetch_row(recbuf);
       end;
  Writeln ('Freeing memory occupied by result set...');
  mysql_free_result (recbuf);
  Writeln ('Closing connection with MySQL.');
  mysql_close(sock);
  halt(0);
end.

--------------------------------------------------------------------- Compiling MySQLku.pas

mysqlku.pas(16,18) Error: Identifier not found "TMYSQL"
mysqlku.pas(16,18) Error: Error in type definition
mysqlku.pas(18,22) Error: Identifier not found "TMYSQL_ROW"
mysqlku.pas(18,22) Error: Error in type definition
mysqlku.pas(74,17) Error: Operator is not  overloaded
mysqlku.pas(76,32) Error: Illegal qualifier
mysqlku.pas(76,35) Error: Illegal expression
mysqlku.pas(77,35) Error: Illegal qualifier
mysqlku.pas(77,38) Error: Illegal expression
mysqlku.pas(78,37) Error: Illegal qualifier
mysqlku.pas(78,44) Error: Illegal expression

It's look that the interface has changed. But where can we get and follow its change? Thanks

---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.

Michael Van Canneyt
to Andi Purwito
Andi Purwito wrote 18 lines
Hi all. This is my test program to track interface changes in mysql lib. --------------------------------------------------------------------- Compiling MySQLku.pas mysqlku.pas(16,18) Error: Identifier not found "TMYSQL" mysqlku.pas(16,18) Error: Error in type definition mysqlku.pas(18,22) Error: Identifier not found "TMYSQL_ROW" mysqlku.pas(18,22) Error: Error in type definition mysqlku.pas(74,17) Error: Operator is not overloaded mysqlku.pas(76,32) Error: Illegal qualifier mysqlku.pas(76,35) Error: Illegal expression mysqlku.pas(77,35) Error: Illegal qualifier mysqlku.pas(77,38) Error: Illegal expression mysqlku.pas(78,37) Error: Illegal qualifier mysqlku.pas(78,44) Error: Illegal expression It's look that the interface has changed. But where can we get and follow its change?

You cannot. Mysql is a pain to maintain. They break interface compatibility almost every release.

Michael.

Chris Kirkpatrick
to Andi Purwito: Hi all. This is my test program to track interface changes in mysql lib. program MySQLku;…

I am trying to create documentation for Lazarus lcl, by providing XML files suitable for input to FPDoc

I have looked at some of the HTML output of Controls and Forms (following the changes to links made by Vincent Snijders), and find that they are not pointing to the page I expected.

For example, a link from 'Controls.TCustomControl.Canvas' to 'Graphics.TCanvas' causes the Index page of 'Graphics' to be loaded, rather than the description of TCanvas. On the other hand, the hyperlink from the type-specification 'TCanvas' in the property definition points correctly to the page where TCanvas is described

I believe that links to any identifier within the LCL need only contain the name of the identifier, without the path to the unit where they are defined; it is only when the link points to something in the RTL or FCL that we should have to specify a more extended path (such as #rtl.sysutils. etc).

I may of course be wrong, and the FPDoc manual suggests that the Unit name must be inserted, but this seems to produce the undesired effect I mentioned above - ie the hyperink takes us to the Index page for the Unit. I would welcome any advice about how best to achieve the links that I desire.

Vincent reports that when I omit the Unit prefix from the link, he gets reports from FPDoc such as:

Show quoted text 5 lines
Warning: Target ID of <link> is unknown: "TFormStyle" Warning: Target ID of <link> is unknown: "TMainMenu" Warning: Target ID of <link> is unknown: "TCustomControl" Warning: Target ID of <link> is unknown: "TWinControl" Warning: Target ID of <link> is unknown: "TControl"

Regards - Chris