C api query vs. real_query vs. send_query

2010-08-15 Thread Surendra Singhi
Hi,

I am doing some work on a nodejs/v8 bindings for libmysqlclient and
ran into some questions while working on the asynchronous part of the
interface.
http://github.com/kreetitech/node-mysql-libmysqlclient

The documentation says that:

mysql_query() cannot be used for statements that contain binary data;
you must use mysql_real_query() instead.
In addition, mysql_real_query() is faster than mysql_query() because
it does not call strlen() on the statement string.

Besides these, I found another important difference, it is possible to
call mysql_query followed by mysql_store_result multiple times and
have separate MYSQL_RES objects which work.

Meaning:

mysql_query(conn. 'some select query');
res1 = mysql_store_result(conn)

mysql_query(conn. 'some other select query');
res2 = mysql_store_result(conn)

   mysql_fetch_row(res1)
   mysql_fetch_row(res2)


But the above doesn't work with mysql_real_query, if returns error
code CR_COMMANDS_OUT_OF_SYNC.
mysql_real_query expects that all the results have been fetched,
before it can be called again.

Is the behavior of mysql_query, as expected, and something which can
be relied upon? Can res1 and res2 be assumed to be independent?
Why does mysql_real_query behaves differently?

mysql_send_query is not  a documented function, is there any reason for that?

Your help will be appreciated.

Thanks!
-- 
Surendra Singhi

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



C API Query Semantics

2003-06-19 Thread Sean Macmillan
Using the C API I have written a program that calls mysql_query() on a 
table with values I know to be in the table.  It returns fine and I 
then call mysql_store_result.  The problem I am having is figuring out 
how to dump the contents of that query to the screen (printf for 
example).  I have tried mysql_fetch_rows and a few others.  What am 
trying to do is see the data on the terminal once the c program 
executes.  Any suggestions?

Sean Mac Millan

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: C API Query Semantics

2003-06-19 Thread gerald_clark
Look at the source for the mysql client.
It is a perfect example.
Sean Macmillan wrote:

Using the C API I have written a program that calls mysql_query() on a 
table with values I know to be in the table.  It returns fine and I 
then call mysql_store_result.  The problem I am having is figuring out 
how to dump the contents of that query to the screen (printf for 
example).  I have tried mysql_fetch_rows and a few others.  What am 
trying to do is see the data on the terminal once the c program 
executes.  Any suggestions?

Sean Mac Millan




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


C-API Query

2002-01-07 Thread udayashankarl_n

Hi,
I have written the following code using C-API and would like to retrieve
the info from MYSQL.
But it gives me error messages. Please let me know where iam going
wrong.
the code and error messages are :
#include stdio.h
#include mysql/mysql.h

main()
{
int sel;
MYSQL *mysql=NULL;
mysql_init(mysql);
if(mysql == NULL)
{ 
printf(\n MySQL unable to intialise\n);
exit(-1);
}

mysql_real_connect(mysql,23.22.2.2,user,pwd,db_name,0,NULL,0);
sel = mysql_query(mysql, select e-no,ename from employee);
printf(sel %d\n,sel);
}

produces the following error messages.

/tmp/ccPhnnJk.o: In function `main':
/tmp/ccPhnnJk.o(.text+0x14): undefined reference to `mysql_init'
/tmp/ccPhnnJk.o(.text+0x5a): undefined reference to `mysql_real_connect'
/tmp/ccPhnnJk.o(.text+0x6d): undefined reference to `mysql_query'
collect2: ld returned 1 exit status

Regards
Uday

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: C-API Query

2002-01-07 Thread John Lodge

Hello,

I have corrected the code as I would have written it. Also are you sure the
file mysql.h
is where you think it is?

#include stdio.h
#include mysql/mysql.h

main()
{
   int sel;
   MYSQL mysql=NULL;
   MYSQL *connection;
 MYSQL_RES *result;
 mysql_init(mysql);
   if(mysql == NULL)
   { 
printf(\n MySQL unable to intialise\n);
exit(-1);
}

connection=mysql_real_connect(mysql,23.22.2.2,user,pwd,db_name,0,NU
LL,0);
sel = mysql_query(connection, select e-no,ename from employee);
printf(sel %d\n,sel);
}

John Lodge

-Original Message-
From: udayashankarl_n [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 07, 2002 11:51 AM
To: [EMAIL PROTECTED]
Subject: C-API Query


Hi,
I have written the following code using C-API and would like to retrieve
the info from MYSQL.
But it gives me error messages. Please let me know where iam going
wrong.
the code and error messages are :
#include stdio.h
#include mysql/mysql.h

main()
{
int sel;
MYSQL *mysql=NULL;
mysql_init(mysql);
if(mysql == NULL)
{ 
printf(\n MySQL unable to intialise\n);
exit(-1);
}

mysql_real_connect(mysql,23.22.2.2,user,pwd,db_name,0,NULL,0);
sel = mysql_query(mysql, select e-no,ename from employee);
printf(sel %d\n,sel);
}

produces the following error messages.

/tmp/ccPhnnJk.o: In function `main':
/tmp/ccPhnnJk.o(.text+0x14): undefined reference to `mysql_init'
/tmp/ccPhnnJk.o(.text+0x5a): undefined reference to `mysql_real_connect'
/tmp/ccPhnnJk.o(.text+0x6d): undefined reference to `mysql_query'
collect2: ld returned 1 exit status

Regards
Uday

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: C-API Query

2002-01-07 Thread Aigars Grins

Hi,

[..]
 produces the following error messages.

 /tmp/ccPhnnJk.o: In function `main':
 /tmp/ccPhnnJk.o(.text+0x14): undefined reference to `mysql_init'
 /tmp/ccPhnnJk.o(.text+0x5a): undefined reference to `mysql_real_connect'
 /tmp/ccPhnnJk.o(.text+0x6d): undefined reference to `mysql_query'
 collect2: ld returned 1 exit status
[..]

I would think that the error message is from ld (the linker). So, it's not a
fault in your code per se, but rather the arguments to the linker. Have you
stated to include the mysql library? Using gcc it could be something like:
-L/usr/local/lib/mysql -lmysqlclient.

--
Aigars

DISCLAIMER:

Internet communications are not secure and therefore Defcom does not accept
legal responsibility for the contents or accuracy of this message. The views
and opinions contained in the message are solely those of the author and do
not necessarily represent those of Defcom unless otherwise specifically
stated.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php