Re: C api mysql_store_result vs mysql_use_result
- Original Message - From: Alex Schaft al...@quicksoftware.co.za If I were to do a select count(*) from x where y prior to doing select * from x where y to get a number of records, how would this impact performance on the server itself? Would the first query be the one to do the most processing, with the second one being faster, or would both have to do the same amount of work? Heh. The amount of work put into parsing and executing would be the same, except if you can compose your count query to use only indexed fields. Easily checked with an explain of both queries, I'd say. Also, do consider if you really need a %complete progress indicator, or if a simple record counter with no indicated endpoint will do. That is, do your users need to know how long it's going to take, or do they just want assurance that the process didn't hang? -- Bier met grenadyn Is als mosterd by den wyn Sy die't drinkt, is eene kwezel Hy die't drinkt, is ras een ezel -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: C api mysql_store_result vs mysql_use_result
On 2012/02/09 01:40 PM, Johan De Meersman wrote: - Original Message - From: Alex Schaftal...@quicksoftware.co.za If I were to do a select count(*) from x where y prior to doing select * from x where y to get a number of records, how would this impact performance on the server itself? Would the first query be the one to do the most processing, with the second one being faster, or would both have to do the same amount of work? Heh. The amount of work put into parsing and executing would be the same, except if you can compose your count query to use only indexed fields. Easily checked with an explain of both queries, I'd say. Also, do consider if you really need a %complete progress indicator, or if a simple record counter with no indicated endpoint will do. That is, do your users need to know how long it's going to take, or do they just want assurance that the process didn't hang? From the user's perspective, they just need to know the process didn't hang. The count() query is more for getting memory requirements upfront. Can I handle it all, or do I need to break it down into pages? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: C api mysql_store_result vs mysql_use_result
- Original Message - From: Alex Schaft al...@quicksoftware.co.za From the user's perspective, they just need to know the process didn't hang. The count() query is more for getting memory requirements upfront. Can I handle it all, or do I need to break it down into pages? Then just use the cursor-based api (I guess that's mysql_use_result) all the time, and you won't have any memory problems at all. If you need to retrieve pages (as in, the third block of 10 results, for instance) LIMIT is your friend. Do read the documentation on limit, though - there's performance caveats when you use order by and similar. -- Bier met grenadyn Is als mosterd by den wyn Sy die't drinkt, is eene kwezel Hy die't drinkt, is ras een ezel -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: C API Function for count(*)
You might get closer to what you want if you put your command in a text file and run it from the command line. On a Mac OS X, I put a similar command: select count(*) from testTable; into a small text file: testCount.txt and ran this command from the Terminal: mysql -u username -ppassword /Users/myname/Documents/testCount.txt The result was: COUNT(*) 12 without the decorations. Bob On May 14, 2010, at 11:35 PM, Dan Nelson wrote: In the last episode (May 14), Tim Johnson said: I have MySQL version 5.0.84 on linux slackware 13.0 32-bit. I am working with a relatively new API written in a programming language with a small user base (newlisp). The newlisp API imports a number of C API functions from the system MySQL shared object. If I were to issue a count(*) query from my monitor interface: Example: mysql select count(*) from clients; +--+ | count(*) | +--+ | 16 | +--+ If select count(*) from clients is issued from the newlisp API, is there a a C API function that would return '16'? You can't do it with one function call, but you can do it, since the MySQL cli was able to print 16 in your example above, and it was written in C. Take a look at mysql_store_result(), mysql_num_fields(), mysql_field_count(), mysql_fetch_row(), and mysql_fetch_lengths(). There's a simple code fragment to print a resultset on this page: http://dev.mysql.com/doc/refman/5.1/en/mysql-fetch-row.html -- Dan Nelson dnel...@allantgroup.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=bobc...@earthlink.net -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: C API Function for count(*)
* Dan Nelson dnel...@allantgroup.com [100514 21:38]: You can't do it with one function call, but you can do it, since the MySQL cli was able to print 16 in your example above, and it was written in C. Take a look at mysql_store_result(), mysql_num_fields(), mysql_field_count(), mysql_fetch_row(), and mysql_fetch_lengths(). There's a simple code fragment to print a resultset on this page: http://dev.mysql.com/doc/refman/5.1/en/mysql-fetch-row.html Thanks Dan. I can use the C code there to model the code for the API. cheers -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: C API Function for count(*)
* Bob Cole bobc...@earthlink.net [100515 06:58]: You might get closer to what you want if you put your command in a text file and run it from the command line. On a Mac OS X, I put a similar command: select count(*) from testTable; into a small text file: testCount.txt and ran this command from the Terminal: mysql -u username -ppassword /Users/myname/Documents/testCount.txt The result was: COUNT(*) 12 Hi Bob: That's a good trick. It doesn't fit the API that I am trying to enhance, but it could be a good workaround by 'echo'ing to a tmpfile. Thanks. -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: C API Function for count(*)
In the last episode (May 14), Tim Johnson said: I have MySQL version 5.0.84 on linux slackware 13.0 32-bit. I am working with a relatively new API written in a programming language with a small user base (newlisp). The newlisp API imports a number of C API functions from the system MySQL shared object. If I were to issue a count(*) query from my monitor interface: Example: mysql select count(*) from clients; +--+ | count(*) | +--+ | 16 | +--+ If select count(*) from clients is issued from the newlisp API, is there a a C API function that would return '16'? You can't do it with one function call, but you can do it, since the MySQL cli was able to print 16 in your example above, and it was written in C. Take a look at mysql_store_result(), mysql_num_fields(), mysql_field_count(), mysql_fetch_row(), and mysql_fetch_lengths(). There's a simple code fragment to print a resultset on this page: http://dev.mysql.com/doc/refman/5.1/en/mysql-fetch-row.html -- Dan Nelson dnel...@allantgroup.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: C api - mysql_list_fields
Hi Mike, all, Mike Aubury wrote: I'm probably being a bit stupid - but I'm trying to determine (in code) the length of the string in the schema for a given table. So - for example : create table a ( blah char(20) ) I want to return '20', but I'm getting '60' when I use mysql_list_fields.. (Always seems to be 3x longer that I'm expecting)... Am I missing something ? (or should I just divide by 3!!) You are missing the distinction between character and byte, which is brought to you by the ISO character sets which go far beyond ASCII. The moment you allow international characters (US-ASCII + German Umlauts + French accented vowels + Spanish cedilla + ... + Chinese + Korean + ...) in your data, storing one character may need more than one byte. The current encoding (versions 5.0 and 5.1) uses up to 3 bytes per character, that is the factor 3 you notice. With 6.0, a different encoding may be used, which uses up to 4 bytes per character. If you know you won't need arbitrary characters, you can use the charset (or character set) option in your create statements. HTH, Jörg -- Joerg Bruehe, MySQL Build Team, [EMAIL PROTECTED] (+49 30) 417 01 487 Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
Basically - so I can display it in the same form as the orginal table.. Or - if you want the longer version I work with an Opensource project called 'Aubit4GL' (its a clone of Informix4GL - which allows you to write really nice screen based database oriented programs + reports), see http://sourceforge.net/projects/aubit4gl Anyway - part of that project is a tool called 'asql' (which is a replacement for the Informix 'isql' tool..), this tool is itself written using Aubit4GL. You can think of asql as an easy to use screen based (ncurses) equivilent of the mysql tool.. One of the options is a 'Table Info' - where you get a list of the columns and the datatypes etc. When you create a table with a char(20) - you dont want to see it appear as a char(60)! I have a workaround atm - but its really clunky - I do a separate select for each column in the form : SHOW COLUMNS FROM table LIKE 'column' for each column returned from mysql_list_fields BTW - I'll need some help with some of the other displays (indexes, status etc) - if anyone fancies lending a hand - we always welcome new volunteers! (The 'mysql' driver for Aubit4GL could probably do with some attention from someone who knows their way around) On Tuesday 07 October 2008 13:10:18 walter harms wrote: Mike Aubury schrieb: Excellent - this seems to be the issue - the show create table shows : mysql show create table a\g +---+ + | Table | Create Table | +---+ + | a | CREATE TABLE `a` ( `blah` char(20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +---+--- So - its utf8 (which I understand enough about to understand why its doing what its doing!) So - the next question is... Is there anyway in code I can find the 'fiddle' factor (1,3,or now possibly 4) that I need to use to divide by to get back to the character width specified in the CREATE TABLE ? why do you want to do that ? i would expect that mysql uses wchar_t for char() if utf8 is selected. re, wh -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
Mike, all, Mike Aubury wrote: [[...]] So - the next question is... Is there anyway in code I can find the 'fiddle' factor (1,3,or now possibly 4) that I need to use to divide by to get back to the character width specified in the CREATE TABLE ? In the information_schema database, which you can use to access schema information, MySQL differs between CHARACTER_MAXIMUM_LENGTH (the number of characters) and CHARACTER_OCTET_LENGTH (number of bytes). But this need not be the same factor for all columns: If you specify one with charset latin1, it is one octet (byte) per character. So I don't see any use in such a constant factor. And sorry, no, off-hand I don't know a way to programmatically ask the server for this factor. If you need to know the number of characters specified for some column, you should access the information_schema database and get all those details, including character set and collation. HTH, Jörg -- Joerg Bruehe, MySQL Build Team, [EMAIL PROTECTED] (+49 30) 417 01 487 Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
It works for me, I used your code: Field =mycol Type=254 Length=20 so at least your code is fine, and the problem must be somewhere else. I am using RH EL3. cheers, Doug On 6 Oct 2008, at 19:52, Mike Aubury wrote: I'm probably being a bit stupid - but I'm trying to determine (in code) the length of the string in the schema for a given table. So - for example : create table a ( blah char(20) ) I want to return '20', but I'm getting '60' when I use mysql_list_fields.. (Always seems to be 3x longer that I'm expecting)... Am I missing something ? (or should I just divide by 3!!) Heres an example : #include stdio.h #include stdlib.h #include mysql.h MYSQL conn; int main(int argc,char *argv[]) { // run with username port as arguments char *tabname=a; char *db=test1; char *u; char *p; MYSQL_RES *result; MYSQL_FIELD *field; if (argc!=3) { printf(usage : %s username password\n, argv[0]);exit(2); } u=argv[1]; p=argv[2]; mysql_init(conn); if (!mysql_real_connect(conn, NULL,u,p,db,0,NULL,0) ) { fprintf(stderr, Failed to connect to database: Error: %s\n, mysql_error(conn)); exit(2); } result = mysql_list_fields (conn, tabname, NULL); field = mysql_fetch_field (result); printf(Field =%s Type=%d Length=%d\n, field-name, field-type, field-length); } Thanks in advance... -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
Mike Aubury schrieb: Excellent - this seems to be the issue - the show create table shows : mysql show create table a\g +---++ | Table | Create Table | +---++ | a | CREATE TABLE `a` ( `blah` char(20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +---+--- So - its utf8 (which I understand enough about to understand why its doing what its doing!) So - the next question is... Is there anyway in code I can find the 'fiddle' factor (1,3,or now possibly 4) that I need to use to divide by to get back to the character width specified in the CREATE TABLE ? why do you want to do that ? i would expect that mysql uses wchar_t for char() if utf8 is selected. re, wh -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
Excellent - this seems to be the issue - the show create table shows : mysql show create table a\g +---++ | Table | Create Table | +---++ | a | CREATE TABLE `a` ( `blah` char(20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +---+--- So - its utf8 (which I understand enough about to understand why its doing what its doing!) So - the next question is... Is there anyway in code I can find the 'fiddle' factor (1,3,or now possibly 4) that I need to use to divide by to get back to the character width specified in the CREATE TABLE ? On Tuesday 07 October 2008 12:07:28 Joerg Bruehe wrote: Hi Mike, all, Mike Aubury wrote: I'm probably being a bit stupid - but I'm trying to determine (in code) the length of the string in the schema for a given table. So - for example : create table a ( blah char(20) ) I want to return '20', but I'm getting '60' when I use mysql_list_fields.. (Always seems to be 3x longer that I'm expecting)... Am I missing something ? (or should I just divide by 3!!) You are missing the distinction between character and byte, which is brought to you by the ISO character sets which go far beyond ASCII. The moment you allow international characters (US-ASCII + German Umlauts + French accented vowels + Spanish cedilla + ... + Chinese + Korean + ...) in your data, storing one character may need more than one byte. The current encoding (versions 5.0 and 5.1) uses up to 3 bytes per character, that is the factor 3 you notice. With 6.0, a different encoding may be used, which uses up to 4 bytes per character. If you know you won't need arbitrary characters, you can use the charset (or character set) option in your create statements. HTH, Jörg -- Joerg Bruehe, MySQL Build Team, [EMAIL PROTECTED] (+49 30) 417 01 487 Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api - mysql_list_fields
[EMAIL PROTECTED] (Mike Aubury) writes: I'm probably being a bit stupid - but I'm trying to determine (in code) the length of the string in the schema for a given table. So - for example : create table a ( blah char(20) ) I want to return '20', but I'm getting '60' when I use mysql_list_fields.. (Always seems to be 3x longer that I'm expecting)... Am I missing something ? (or should I just divide by 3!!) Is the table or database using UTF-8? I think that if it is MySQL will allocate space for each character and is forced to allocate 3x20 bytes as a UTF-8 character can be up to 3-bytes in length. SHOW CREATE TABLE a\G should show if this is the case. Simon -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API routines and cobol
Michael wrote: Has anyone successfully called the C API routines for MySQL from COBOL? Dude, April 1 was, like, a month ago now. You may have better luck finding an ODBC bridge for your COBOL environment, which let you access MySQL indirectly. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API - Mysql 5
Hello, Did you try to convert the .lib file to a GCC .a library ? See http://mingw.org/mingwfaq.shtml#faq-msvcdll If reimp doesn't work, you can try pexports and dlltool. I have an old batch file I used for older MySQL versions at http://athanatos.free.fr/EXE/implib.bat [EMAIL PROTECTED] a écrit : Hello, I'm trying to compile some C code with the simple following code (dev-c++): #include stdio.h #include stdlib.h #include windows.h #include mysql.h int main(int argc, char *argv[]) { MYSQL * mysql_con = NULL; mysql_con = mysql_init(mysql_con); return 0; } As the result, i obtain this : gcc.exe -D__DEBUG__ main.o -o my_try.exe -LC:/Dev-Cpp/lib C:/Program Files/MySQL/MySQL Server 5.0/lib/debug/mysqlclient.lib -g3 C:/Program Files/MySQL/MySQL Server 5.0/lib/debug/mysqlclient.lib(./debug/client.obj)(.debug$S+0x49cb):\build\mysql-5.0.2: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details. C:/Program Files/MySQL/MySQL Server 5.0/lib/debug/mysqlclient.lib(./debug/client.obj)(.text+0x192e): In function `mysql_read_default_options': e:\build\mysql-5.0:1026: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details. C:/Program Files/MySQL/MySQL Server 5.0/lib/debug/mysqlclient.lib(./debug/dbug.obj)(.debug$S+0x24c1):\build\mysql-5.0.2: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details. C:/Program Files/MySQL/MySQL Server 5.0/lib/debug/mysqlclient.lib(./debug/dbug.obj)(.text+0x15): In function `_db_push_': I've compiled C code with a previous version of mysql lib client without any trouble. I've tried with the --enable-auto-import as well as the disable one. Anyone have an idea? Thank's in advance Vincent Badier -- Cordialement Gabriel LINDER / JEUXVIDEO.COM --- http://www.jeuxvideo.com : Le site numéro 1 des jeux video en français http://boutique.jeuxvideo.com : Pour acheter tous ses jeux sur le net --- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API - Language Setup and MyISAM table setup
Fábio Emilio Costa wrote: I'm working in a project in C++ using MySQL C API (Win98/Dev-C++ 4.9.9.8/MySQL DevPak/MySQL 4.1.13) and I want to know if it's possible to setup the server environment language (--language) via mysql_options() function. It seems that you are actually asking whether the documentation for mysql_options() is wrong, since a glance at its documentation says that the answer is clearly no. Do you not trust the people maintaining the MySQL C API documentation? Also: http://dev.mysql.com/doc/mysql/en/languages.html Also, I want to know if it's possible to setup a table to MyISAM instead of InnoDB via C API. Again, the documentation answers your question. From the introductory material in chapter 14: To convert a table from one type to another, use an ALTER TABLE statement that indicates the new type: ALTER TABLE t ENGINE = MYISAM; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API : Problem using multi-statements
Answer is simple. Can't do that. - Original Message - From: [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Friday, May 06, 2005 5:40 AM Subject: C API : Problem using multi-statements Hello, I have some problems using multiple queries in a databased driven project, therefore I wrote a little testprogram which causes the same problems. I am using the C-API of MySQL 4.1.11 on a Gentoo Linux 3.3.2-r5, propolice-3.3-7 with 2.4.27 kernel. I connect to the server (on localhost) with mysql_real_connect and the flag CLIENT_MULTI_STATEMENTS, I submit multiple queries (two INSERTS seperated by ;) on the existing connection. Executing the multistatement with mysql_query in a loop (i.e. 10 times), I get a lot of lost connection during query errors, but sending a single INSERT query in a loop causes no errors !!! Thanks in advance for help regards Tinosch Ganjineh The following program operates on a simple table structure created with the following statement : CREATE TABLE BIGTABLE (myoid char(40), mykey char(40), myval char(40), myint bigint) TYPE = InnoDB; /** mysqltest.cpp */ #include iostream #include mysql.h #include sstream #include string using namespace std; string itos(long long i) { ostringstream sstream; sstream i; return sstream.str(); } int main(int argc, char** argv) { MYSQL* conn; if(conn = mysql_init(NULL)) { if(mysql_real_connect(conn, localhost, root, x, test, 0, NULL, CLIENT_MULTI_STATEMENTS )) { int loop=100; for(int i=0; iloop; ++i) { int e=0; string query; query = string(INSERT INTO BIGTABLE VALUES () + 'object- +itos(i)+', 'foo', 'bar', NULL);\ INSERT INTO BIGTABLE VALUES ( + 'object- +itos(i+1000)+', 'bar, 'foo', NULL); e = mysql_query(conn, query.c_str()); if(e) { cerr *Query failed*: e - mysql_error(conn) endl; } else { MYSQL_RES* result = mysql_store_result(conn); if(result) { // .. parse result set ... } else { //cerr Could not fetch Results from DB: mysql_error(conn); } mysql_free_result(result); } } } else { cerr Could not connect to MySQL database: mysql_error(conn) endl; } } else { cerr Could not initialize MySQL: mysql_error(conn) endl; } } /** mysqltest.cpp */ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API : Problem using multi-statements
Jeremiah I don't use the client library in my work but this should work from 4.1 on. -Reggie -Original Message- From: Jeremiah Gowdy [mailto:[EMAIL PROTECTED] Sent: Friday, May 06, 2005 11:19 AM To: [EMAIL PROTECTED]; mysql@lists.mysql.com Subject: Re: C API : Problem using multi-statements Answer is simple. Can't do that. - Original Message - From: [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Friday, May 06, 2005 5:40 AM Subject: C API : Problem using multi-statements Hello, I have some problems using multiple queries in a databased driven project, therefore I wrote a little testprogram which causes the same problems. I am using the C-API of MySQL 4.1.11 on a Gentoo Linux 3.3.2-r5, propolice-3.3-7 with 2.4.27 kernel. I connect to the server (on localhost) with mysql_real_connect and the flag CLIENT_MULTI_STATEMENTS, I submit multiple queries (two INSERTS seperated by ;) on the existing connection. Executing the multistatement with mysql_query in a loop (i.e. 10 times), I get a lot of lost connection during query errors, but sending a single INSERT query in a loop causes no errors !!! Thanks in advance for help regards Tinosch Ganjineh The following program operates on a simple table structure created with the following statement : CREATE TABLE BIGTABLE (myoid char(40), mykey char(40), myval char(40), myint bigint) TYPE = InnoDB; /** mysqltest.cpp */ #include iostream #include mysql.h #include sstream #include string using namespace std; string itos(long long i) { ostringstream sstream; sstream i; return sstream.str(); } int main(int argc, char** argv) { MYSQL* conn; if(conn = mysql_init(NULL)) { if(mysql_real_connect(conn, localhost, root, x, test, 0, NULL, CLIENT_MULTI_STATEMENTS )) { int loop=100; for(int i=0; iloop; ++i) { int e=0; string query; query = string(INSERT INTO BIGTABLE VALUES () + 'object- +itos(i)+', 'foo', 'bar', NULL);\ INSERT INTO BIGTABLE VALUES ( + 'object- +itos(i+1000)+', 'bar, 'foo', NULL); e = mysql_query(conn, query.c_str()); if(e) { cerr *Query failed*: e - mysql_error(conn) endl; } else { MYSQL_RES* result = mysql_store_result(conn); if(result) { // .. parse result set ... } else { //cerr Could not fetch Results from DB: mysql_error(conn); } mysql_free_result(result); } } } else { cerr Could not connect to MySQL database: mysql_error(conn) endl; } } else { cerr Could not initialize MySQL: mysql_error(conn) endl; } } /** mysqltest.cpp */ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API : Problem using multi-statements
Hi Instead of use two INSERT statements, try something like this: INSERT INTO Table table1 VALUES (list of values1), (list of values2) -Original Message- From: Jeremiah Gowdy [mailto:[EMAIL PROTECTED] Sent: 06 May 2005 17:19 To: [EMAIL PROTECTED]; mysql@lists.mysql.com Subject: Re: C API : Problem using multi-statements Answer is simple. Can't do that. - Original Message - From: [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Friday, May 06, 2005 5:40 AM Subject: C API : Problem using multi-statements Hello, I have some problems using multiple queries in a databased driven project, therefore I wrote a little testprogram which causes the same problems. I am using the C-API of MySQL 4.1.11 on a Gentoo Linux 3.3.2-r5, propolice-3.3-7 with 2.4.27 kernel. I connect to the server (on localhost) with mysql_real_connect and the flag CLIENT_MULTI_STATEMENTS, I submit multiple queries (two INSERTS seperated by ;) on the existing connection. Executing the multistatement with mysql_query in a loop (i.e. 10 times), I get a lot of lost connection during query errors, but sending a single INSERT query in a loop causes no errors !!! Thanks in advance for help regards Tinosch Ganjineh The following program operates on a simple table structure created with the following statement : CREATE TABLE BIGTABLE (myoid char(40), mykey char(40), myval char(40), myint bigint) TYPE = InnoDB; /** mysqltest.cpp */ #include iostream #include mysql.h #include sstream #include string using namespace std; string itos(long long i) { ostringstream sstream; sstream i; return sstream.str(); } int main(int argc, char** argv) { MYSQL* conn; if(conn = mysql_init(NULL)) { if(mysql_real_connect(conn, localhost, root, x, test, 0, NULL, CLIENT_MULTI_STATEMENTS )) { int loop=100; for(int i=0; iloop; ++i) { int e=0; string query; query = string(INSERT INTO BIGTABLE VALUES () + 'object- +itos(i)+', 'foo', 'bar', NULL);\ INSERT INTO BIGTABLE VALUES ( + 'object- +itos(i+1000)+', 'bar, 'foo', NULL); e = mysql_query(conn, query.c_str()); if(e) { cerr *Query failed*: e - mysql_error(conn) endl; } else { MYSQL_RES* result = mysql_store_result(conn); if(result) { // .. parse result set ... } else { //cerr Could not fetch Results from DB: mysql_error(conn); } mysql_free_result(result); } } } else { cerr Could not connect to MySQL database: mysql_error(conn) endl; } } else { cerr Could not initialize MySQL: mysql_error(conn) endl; } } /** mysqltest.cpp */ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API : Problem using multi-statements
doh! need another redbull. :) - Original Message - From: Reggie Burnett [EMAIL PROTECTED] To: 'Jeremiah Gowdy' [EMAIL PROTECTED]; [EMAIL PROTECTED]; mysql@lists.mysql.com Sent: Friday, May 06, 2005 9:31 AM Subject: RE: C API : Problem using multi-statements Jeremiah I don't use the client library in my work but this should work from 4.1 on. -Reggie -Original Message- From: Jeremiah Gowdy [mailto:[EMAIL PROTECTED] Sent: Friday, May 06, 2005 11:19 AM To: [EMAIL PROTECTED]; mysql@lists.mysql.com Subject: Re: C API : Problem using multi-statements Answer is simple. Can't do that. - Original Message - From: [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Friday, May 06, 2005 5:40 AM Subject: C API : Problem using multi-statements Hello, I have some problems using multiple queries in a databased driven project, therefore I wrote a little testprogram which causes the same problems. I am using the C-API of MySQL 4.1.11 on a Gentoo Linux 3.3.2-r5, propolice-3.3-7 with 2.4.27 kernel. I connect to the server (on localhost) with mysql_real_connect and the flag CLIENT_MULTI_STATEMENTS, I submit multiple queries (two INSERTS seperated by ;) on the existing connection. Executing the multistatement with mysql_query in a loop (i.e. 10 times), I get a lot of lost connection during query errors, but sending a single INSERT query in a loop causes no errors !!! Thanks in advance for help regards Tinosch Ganjineh The following program operates on a simple table structure created with the following statement : CREATE TABLE BIGTABLE (myoid char(40), mykey char(40), myval char(40), myint bigint) TYPE = InnoDB; /** mysqltest.cpp */ #include iostream #include mysql.h #include sstream #include string using namespace std; string itos(long long i) { ostringstream sstream; sstream i; return sstream.str(); } int main(int argc, char** argv) { MYSQL* conn; if(conn = mysql_init(NULL)) { if(mysql_real_connect(conn, localhost, root, x, test, 0, NULL, CLIENT_MULTI_STATEMENTS )) { int loop=100; for(int i=0; iloop; ++i) { int e=0; string query; query = string(INSERT INTO BIGTABLE VALUES () + 'object- +itos(i)+', 'foo', 'bar', NULL);\ INSERT INTO BIGTABLE VALUES ( + 'object- +itos(i+1000)+', 'bar, 'foo', NULL); e = mysql_query(conn, query.c_str()); if(e) { cerr *Query failed*: e - mysql_error(conn) endl; } else { MYSQL_RES* result = mysql_store_result(conn); if(result) { // .. parse result set ... } else { //cerr Could not fetch Results from DB: mysql_error(conn); } mysql_free_result(result); } } } else { cerr Could not connect to MySQL database: mysql_error(conn) endl; } } else { cerr Could not initialize MySQL: mysql_error(conn) endl; } } /** mysqltest.cpp */ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: Storing is easy; How do you retrieve?
Matthew Boehm wrote: Hey guys, (Why is there no C API specific list?) I want to write a C application that can take some audio file, store it in MySQL, then at a later date/time (upon request) pull from db and write to temporary file to be streamed. I've got the storing portion of the code down. The problem I have is, how do I SELECT out the audio and store it to a file on the local disk? 2 solutions for it. you can retrieve the data : mysql_query(mysql_conx, SELECT audio FROM ...); myres = mysql_store_result(mysql_conx); myrow = mysql_fetch_row(myres); audiodata = stripslashes(myrow[0]); (providing you escape characters); then the usual C function should do the trick (fopen, fwrite...) or SELECT INTO OUTFILE (check the manual, I don't know the details ;) to store the file on the server. -- Philippe Poelvoorde COS Trading Ltd. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: Storing is easy; How do you retrieve?
The docs should have it. Basically these API is what you require (in order): mysql_init(); mysql_real_connect(); mysql_real_query(); mysql_store_result() or mysql_use_result(); mysql_fetch_row(); mysql_free_result; mysql_close (); HTH --- Matthew Boehm [EMAIL PROTECTED] wrote: Hey guys, (Why is there no C API specific list?) I want to write a C application that can take some audio file, store it in MySQL, then at a later date/time (upon request) pull from db and write to temporary file to be streamed. I've got the storing portion of the code down. The problem I have is, how do I SELECT out the audio and store it to a file on the local disk? Any examples? Sample code? Specific API functions I should look at? I've seen how this is done using ODBC, but the ODBC code is really crappy and not at all as easy as MySQL API. Thanks, Matthew -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api incompatability from 3.x to 4.1
I provided the list below for our programmers, who also are dealing with a switch from 3.23 to 4.1. Perhaps it would be of some help for you. Cheers, --V - We've already hit a couple of API-related problems with the new version of MySQL. To try to make things a little easier, and because I love our programmers, I've sifted through the change history of MySQL 4.1 to pick out all the changes specifically related to the C API. Most won't apply to us. For a complete list of all MySQL changes, hit this link: http://dev.mysql.com/doc/mysql/en/News.html And now for the list: * Added new mysql_get_server_version() C API client function. * Added mysql_set_server_option() C API client function to allow multiple statement handling in the server to be enabled or disabled. * The mysql_next_result() C API function now returns -1 if there are no more result sets. * Warning: Incompatible change! Renamed the C API mysql_prepare_result() function to mysql_get_metadata() as the old name was confusing. * Added mysql_sqlstate() and mysql_stmt_sqlstate() C API client functions that return the SQLSTATE error code for the last error. * Warning: Incompatible change! Renamed prepared statements C API functions: Old Name New Name mysql_bind_param() mysql_stmt_bind_param() mysql_bind_result() mysql_stmt_bind_result() mysql_prepare() mysql_stmt_prepare() mysql_execute() mysql_stmt_execute() mysql_fetch() mysql_stmt_fetch() mysql_fetch_column() mysql_stmt_fetch_column() mysql_param_count() mysql_stmt_param_count() mysql_param_result() mysql_stmt_param_metadata() mysql_get_metadata() mysql_stmt_result_metadata() mysql_send_long_data() mysql_stmt_send_long_data() Now all functions that operate with a MYSQL_STMT structure begin with the prefix mysql_stmt_. * Warning: Incompatible change! The signature of the mysql_stmt_prepare() function was changed to int mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned long length). To create a MYSQL_STMT handle, you should use the mysql_stmt_init() function, not mysql_stmt_prepare(). * C API enhancement: SERVER_QUERY_NO_INDEX_USED and SERVER_QUERY_NO_GOOD_INDEX_USED flags are now set in the server_status field of the MYSQL structure. It is these flags that make the query to be logged as slow if mysqld was started with --log-slow-queries --log-queries-not-using-indexes. * Added support for unsigned integer types to prepared statement API (Bug #3035). * Warning: Incompatible change! C API change: mysql_shutdown() now requires a second argument. This is a source-level incompatibility that affects how you compile client programs; it does not affect the ability of compiled clients to communicate with older servers. See section 21.2.3.51 mysql_shutdown(). * Fixed a bug in client-side conversion of string column to MYSQL_TIME application buffer (prepared statements API). (Bug #4030) * Fixed a buffer overflow in prepared statements API (libmysqlclient) when a statement containing thousands of placeholders was executed. (Bug #5194) * The mysql_change_user() C API function now frees all prepared statements associated with the connection. (Bug #5315) * Fixed bug in libmysqlclient that fetched column defaults. * Fixed mysql_stmt_send_long_data() behavior on second execution of prepared statement and in case when long data had zero length. (Bug #1664) * You can now call mysql_stmt_attr_set(..., STMT_ATTR_UPDATE_MAX_LENGTH) to tell the client library to update MYSQL_FIELD-max_length when doing mysql_stmt_store_result(). (Bug #1647). * Fixed memory leak in the client library when statement handle was freed on closed connection (call to mysql_stmt_close after mysql_close). (Bug #3073) * Fixed mysql_stmt_affected_rows() call to always return number of rows affected by given statement. (Bug #2247) * Fix for a bug that caused client/server communication to be broken when mysql_set_server_option() or mysql_get_server_option() were invoked. (Bug #2207) * The MySQL server did not report any error if a statement (submitted through mysql_real_query() or mysql_stmt_prepare()) was terminated by garbage characters. This can happen if you pass a wrong length parameter to these functions. The result was that the garbage characters were written into the binary log. (Bug #2703) * Fixed bug in client library that caused mysql_stmt_fetch and mysql_stmt_store_result() to hang if they were called without prior call of mysql_stmt_execute(). Now they give an error instead. (Bug #2248) * Fixed a bug in mysql_stmt_close(), which hung up when attempting to close statement after failed mysql_stmt_fetch(). (Bug #4079) * Fixed potential memory overrun in mysql_real_connect() (which required a compromised DNS server and certain operating systems). (Bug #4017) * Fixed a bug that caused libmysql to crash when attempting to fetch a value of MEDIUMINT column. (Bug #5126) * Fixed that
Re: C api incompatability from 3.x to 4.1
In the last episode (Nov 10), Dave Dyer said: I have a family of applications which use the C api to access mysql. I found by doing a test upgrade to 4.1 that all of these applications crash, apparently because the structures passed between my applications and libmysql.dll are incompatible. Recompiling the applications fixes the problem, but I'm disturbed that these broken applications didn't fail gracefully, when stale applications presented unusable structures to the new libmysql. 1) Is there no automatic check for compatibility that I should be encountering, and somehow am not? On Unix, shared libraries bump their version number when the ABI changes to prevent this from happening. Maybe libmysql.dll should have the same protection? One workaround is to link that library statically. -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: c api and creating looped queries
I have arranged some MySQL C API examples at http://www.geocities.com/jahan.geo/mysql_c_by_example.html Larry Brown wrote: On Sat, 2004-08-28 at 00:48, I wrote: I know this is more along the lines of a c question; however, I am trying to write a loop to iterate insertions into a mysql database and was hoping someone would have a quick fix for this. I am used to using php with the luxury of the following syntax some loop giving values $column1 and $column2 usually from some array or parsing of a file $query = mysql_query( insert into my_table values ( null, '$column1', 'some description $column2' ); next iteration Can anyone just show a one liner of how to do this in c where the values are column1 and column2? I know there is a string concatenation function, it just seems so clumsey to write it out, get the string length of each of the two variables and create a new longer line. I won't be suprised if that is what I have to do though. ( being new to c and finding out how much more work it entails:-) ). Hope this make since at nearly 1 am. Been a long day... OK, hate to answer my own question but sprintf is what I was looking for. It is hard to switch languages! Especially in this direction. ;-) -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: c api and creating looped queries
On Sat, 2004-08-28 at 00:48, I wrote: I know this is more along the lines of a c question; however, I am trying to write a loop to iterate insertions into a mysql database and was hoping someone would have a quick fix for this. I am used to using php with the luxury of the following syntax some loop giving values $column1 and $column2 usually from some array or parsing of a file $query = mysql_query( insert into my_table values ( null, '$column1', 'some description $column2' ); next iteration Can anyone just show a one liner of how to do this in c where the values are column1 and column2? I know there is a string concatenation function, it just seems so clumsey to write it out, get the string length of each of the two variables and create a new longer line. I won't be suprised if that is what I have to do though. ( being new to c and finding out how much more work it entails:-) ). Hope this make since at nearly 1 am. Been a long day... OK, hate to answer my own question but sprintf is what I was looking for. It is hard to switch languages! Especially in this direction. ;-) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: mysql_options and mysql_real_connect
Paul DuBois wrote: At 13:03 -0700 8/11/04, V. M. Brasseur wrote: Assuming a my.cnf file which looks like this: [client] port=3306 socket=/path/to/mysql.sock [app] user=appuser password=apppwd host=my.host.com Ignore for now the insecurity of putting a password in the my.cnf file. This is mostly a hypothetical question at the moment. Calling mysql_options(MYSQL, MYSQL_READ_DEFAULT_FILE, /path/to/my.cnf); and mysql_options(MYSQL, MYSQL_READ_DEFAULT_GROUP, app); in the client will read the options in these two groups. How, if at all, would something like this be useful to mysql_real_connect? From my research it appears that you still need to specify the user, host, pwd and port (assuming TCP/IP connection) when calling mysql_real_connect(), so setting these parms in the my.cnf file does not really help for this scenario. Something (a non-API function, most likely) would still need to parse the file separately and grab the parms for passing to mysql_real_connect(). Is this an accurate assessment? No. If you pass NULL in the mysql_real_connect() params, the values from the option file(s) are used. Even for the password param? The mysql_real_connect() write-up in your MySQL book says that a NULL passed for password results in allowing connections only if there is no password in the mysql.user.password column for the current user. Perhaps having the password defined via a mysql_options() call trumps this NULL behavior? --V -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: mysql_options and mysql_real_connect
At 8:06 -0700 8/12/04, V. M. Brasseur wrote: Paul DuBois wrote: At 13:03 -0700 8/11/04, V. M. Brasseur wrote: Assuming a my.cnf file which looks like this: [client] port=3306 socket=/path/to/mysql.sock [app] user=appuser password=apppwd host=my.host.com Ignore for now the insecurity of putting a password in the my.cnf file. This is mostly a hypothetical question at the moment. Calling mysql_options(MYSQL, MYSQL_READ_DEFAULT_FILE, /path/to/my.cnf); and mysql_options(MYSQL, MYSQL_READ_DEFAULT_GROUP, app); in the client will read the options in these two groups. How, if at all, would something like this be useful to mysql_real_connect? From my research it appears that you still need to specify the user, host, pwd and port (assuming TCP/IP connection) when calling mysql_real_connect(), so setting these parms in the my.cnf file does not really help for this scenario. Something (a non-API function, most likely) would still need to parse the file separately and grab the parms for passing to mysql_real_connect(). Is this an accurate assessment? No. If you pass NULL in the mysql_real_connect() params, the values from the option file(s) are used. Even for the password param? The mysql_real_connect() write-up in your MySQL book says that a NULL passed for password results in allowing connections only if there is no password in the mysql.user.password column for the current user. Perhaps having the password defined via a mysql_options() call trumps this NULL behavior? Yes, that's correct. I take it that you're not finding this to be true? -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: mysql_options and mysql_real_connect
Paul DuBois wrote: At 8:06 -0700 8/12/04, V. M. Brasseur wrote: Paul DuBois wrote: At 13:03 -0700 8/11/04, V. M. Brasseur wrote: Assuming a my.cnf file which looks like this: [client] port=3306 socket=/path/to/mysql.sock [app] user=appuser password=apppwd host=my.host.com Ignore for now the insecurity of putting a password in the my.cnf file. This is mostly a hypothetical question at the moment. Calling mysql_options(MYSQL, MYSQL_READ_DEFAULT_FILE, /path/to/my.cnf); and mysql_options(MYSQL, MYSQL_READ_DEFAULT_GROUP, app); in the client will read the options in these two groups. How, if at all, would something like this be useful to mysql_real_connect? From my research it appears that you still need to specify the user, host, pwd and port (assuming TCP/IP connection) when calling mysql_real_connect(), so setting these parms in the my.cnf file does not really help for this scenario. Something (a non-API function, most likely) would still need to parse the file separately and grab the parms for passing to mysql_real_connect(). Is this an accurate assessment? No. If you pass NULL in the mysql_real_connect() params, the values from the option file(s) are used. Even for the password param? The mysql_real_connect() write-up in your MySQL book says that a NULL passed for password results in allowing connections only if there is no password in the mysql.user.password column for the current user. Perhaps having the password defined via a mysql_options() call trumps this NULL behavior? Yes, that's correct. I take it that you're not finding this to be true? I can't tell yet, as I haven't gotten the coding done. This was mostly a fact-finding excursion, setting up expectations for when I've finally finished with my changes. Many thanks for the assist. You've cleared up a lot for me. --V -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: mysql_options and mysql_real_connect
At 14:40 -0700 8/12/04, V. M. Brasseur wrote: Paul DuBois wrote: At 8:06 -0700 8/12/04, V. M. Brasseur wrote: Paul DuBois wrote: At 13:03 -0700 8/11/04, V. M. Brasseur wrote: Assuming a my.cnf file which looks like this: [client] port=3306 socket=/path/to/mysql.sock [app] user=appuser password=apppwd host=my.host.com Ignore for now the insecurity of putting a password in the my.cnf file. This is mostly a hypothetical question at the moment. Calling mysql_options(MYSQL, MYSQL_READ_DEFAULT_FILE, /path/to/my.cnf); and mysql_options(MYSQL, MYSQL_READ_DEFAULT_GROUP, app); in the client will read the options in these two groups. How, if at all, would something like this be useful to mysql_real_connect? From my research it appears that you still need to specify the user, host, pwd and port (assuming TCP/IP connection) when calling mysql_real_connect(), so setting these parms in the my.cnf file does not really help for this scenario. Something (a non-API function, most likely) would still need to parse the file separately and grab the parms for passing to mysql_real_connect(). Is this an accurate assessment? No. If you pass NULL in the mysql_real_connect() params, the values from the option file(s) are used. Even for the password param? The mysql_real_connect() write-up in your MySQL book says that a NULL passed for password results in allowing connections only if there is no password in the mysql.user.password column for the current user. Perhaps having the password defined via a mysql_options() call trumps this NULL behavior? Yes, that's correct. I take it that you're not finding this to be true? I can't tell yet, as I haven't gotten the coding done. This was mostly a fact-finding excursion, setting up expectations for when I've finally finished with my changes. Many thanks for the assist. You've cleared up a lot for me. Here's a short test program: #include my_global.h #include my_sys.h #include mysql.h static MYSQL *conn; /* pointer to connection handler */ void print_error (MYSQL *conn, char *message) { fprintf (stderr, %s\n, message); if (conn != NULL) { fprintf (stderr, Error %u (%s)\n, mysql_errno (conn), mysql_error (conn)); } } int main (int argc, char *argv[]) { my_init (); /* initialize connection handler */ conn = mysql_init (NULL); if (conn == NULL) { print_error (NULL, mysql_init() failed (probably out of memory)); exit (1); } /* set options */ mysql_options (conn, MYSQL_READ_DEFAULT_FILE, ./my-opts); mysql_options (conn, MYSQL_READ_DEFAULT_GROUP, my-option-group); /* connect to server */ if (mysql_real_connect (conn, NULL, NULL, NULL, NULL, 0, NULL, 0) == NULL) { print_error (conn, mysql_real_connect() failed); mysql_close (conn); exit (1); } /* disconnect from server */ mysql_close (conn); exit (0); } Compile the program and run it. It will likely fail to connect. Then create a file named my-opts in the same directory and put a [my-option-group] group in it: [my-option-group] user=your-user-name password=your-password Run the program again. This time it should work. Change the group name to be [mysql]. The program should still work. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: mysql_options and mysql_real_connect
At 13:03 -0700 8/11/04, V. M. Brasseur wrote: Assuming a my.cnf file which looks like this: [client] port=3306 socket=/path/to/mysql.sock [app] user=appuser password=apppwd host=my.host.com Ignore for now the insecurity of putting a password in the my.cnf file. This is mostly a hypothetical question at the moment. Calling mysql_options(MYSQL, MYSQL_READ_DEFAULT_FILE, /path/to/my.cnf); and mysql_options(MYSQL, MYSQL_READ_DEFAULT_GROUP, app); in the client will read the options in these two groups. How, if at all, would something like this be useful to mysql_real_connect? From my research it appears that you still need to specify the user, host, pwd and port (assuming TCP/IP connection) when calling mysql_real_connect(), so setting these parms in the my.cnf file does not really help for this scenario. Something (a non-API function, most likely) would still need to parse the file separately and grab the parms for passing to mysql_real_connect(). Is this an accurate assessment? No. If you pass NULL in the mysql_real_connect() params, the values from the option file(s) are used. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API 3.23 to 4.1
On Tue, Jul 06, 2004 at 03:40:02PM -0700, Ron Gilbert wrote: I am going to upgrade my MySQL server from 3.23 to 4.1, but I have a C program that needs to continue to connect to the new server, and it can't be recompiled. Is the old API 100% backwards compatible with a 4.1 server? I assume the performance is the same? You're confusing the API and the protocol. A 4.1 server can speak to a 3.23 client just fine if configured properly. See: http://dev.mysql.com/doc/mysql/en/Password_hashing.html Jeremy -- Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo! [EMAIL PROTECTED] | http://jeremy.zawodny.com/ [book] High Performance MySQL -- http://highperformancemysql.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API -- huge result sets slowin me down
Matt Eaton [EMAIL PROTECTED] wrote: Try to profile application from that point ... if (mysql_real_query(dbase,sqlBuff,strlen(sqlBuff))) { printf(Pool Attributes Select Failed... dumbass\n); fprintf(stderr, Error: %s\n, mysql_error(dbase)); exit(1); } result = mysql_store_result(dbase); numRows=mysql_num_rows(result); ... to that point and then from here to .. for (i=0;inumRows;i++) { row = mysql_fetch_row(result); tempq=atoi(row[1]); tempP=atoi(row[0]); genAttrib[tempP][tempq]=atoi(row[2]); } ..here. I suppose the cycle could be a slowdown/ -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API -- huge result sets slowin me down
Hi, The only thing that could slow you down is that the genAttrib array will take more and more memory as the result set grows. I would recommend you to create a function that uses the mysql row directly instead of creating this huge array. something like while ((row = mysql_num_rows(result))){ usedata(row); } Of course it depends on what do you need the mysql data for - but if you can make it to use one row at a time it should run a lot more faster. -- Dobromir Velev [EMAIL PROTECTED] http://www.websitepulse.com/ On Tuesday 29 June 2004 08:50, Matt Eaton wrote: Hi all, I was hoping this was the right place for a question about the C API. I've been grabbing result sets from tables in the C API for a few years now, but I'm starting to work with result sets that are big enough to bog me down. Of course, the result sets aren't insanely big, so I was wondering why it was taking so long for me to suck them in to C, especially when I can run the same query from the command line using the binaries and they can cache it to a file on the hard disk pretty much instantly. So, basically, I was just hoping that I've been doing something wrong, or at least that there was something I could do better, to make my database communication as fast as the mysql command line tools. I've checked out their source and nothing obvious jumps out at me. Here's a non-functional sample of my code: int main(int argc, char *argv[] ) { int uid; int sid; char sqlBuff[4000]; int err = 0; int i; // Setup the database communications space: MYSQL dbase; MYSQL_RES *result; MYSQL_ROW row; float **genAttrib; //... snip ... // Connect to the database: if (mysql_init(dbase) == NULL) err = 1; else { if(mysql_real_connect(dbase,localhost,login,pass,test,0,NULL,CL IENT_FOUND_ROWS) == NULL) { err = 1; fprintf(stderr, Failed to connect to database: Error: %s\n, mysql_error(dbase)); } } // If the connection couldn't be established: if(err) { printf(db connection failed!\n); exit(1); } //... snip ... // This query could have as many as a million rows returned, but the query itself runs quite fast. It seems to just be // sucking it into C that can take up to four seconds on our dual Xeon server. sprintf(sqlBuff,SELECT A.* FROM `attribs` as A, login AS L WHERE A.guid=L.guid AND L.isActive=1 AND L.sid=%d AND A.guid!=%d,sid,uid); if (mysql_real_query(dbase,sqlBuff,strlen(sqlBuff))) { printf(Pool Attributes Select Failed... dumbass\n); fprintf(stderr, Error: %s\n, mysql_error(dbase)); exit(1); } result = mysql_store_result(dbase); numRows=mysql_num_rows(result); for (i=0;inumRows;i++) { row = mysql_fetch_row(result); tempq=atoi(row[1]); tempP=atoi(row[0]); genAttrib[tempP][tempq]=atoi(row[2]); } return 0; } So, if someone sees something that I could change to speed things up, or I should direct this question elsewhere... thanks for your help and thanks for reading this far! Thanks again, Matt -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api: core dump on mysql_real_connect
On Wed, 25 Feb 2004, Sasha Pachev wrote: where dbh is a global MYSQL structure. This code works fine on the old system. If I pull it out into it's own little test program on the new server, it also works fine. But when I put it in with the analog source code, it compiles fine but the mysql_real_connect causes a core dump when run. The most common reason for the above error is mysql.h header/libmysqlsclient.so library incompatibility. Make sure they are in sync. Except that when I put the same code into it's own little program, it works fine. i.e. I build a C program whose main does nothing but call the connect function. Compiles/runs with no coredump. Cliff -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api: core dump on mysql_real_connect
Cliff Addy wrote: On Wed, 25 Feb 2004, Sasha Pachev wrote: where dbh is a global MYSQL structure. This code works fine on the old system. If I pull it out into it's own little test program on the new server, it also works fine. But when I put it in with the analog source code, it compiles fine but the mysql_real_connect causes a core dump when run. The most common reason for the above error is mysql.h header/libmysqlsclient.so library incompatibility. Make sure they are in sync. Except that when I put the same code into it's own little program, it works fine. i.e. I build a C program whose main does nothing but call the connect function. Compiles/runs with no coredump. Double-check the build process of the big program. Watch out for the include and library paths, and make sure to get rid of the stale .o files ( make clean) -- Sasha Pachev Create online surveys at http://www.surveyz.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C api: core dump on mysql_real_connect
Cliff Addy wrote: I've got on that really has me stumped ... I've modified tha analog web stats program before to use a mysql database before and I'm trying to do it again on a new system. I have this function: void db_connect(){ printf(start connect\n); mysql_init(dbh); if (!mysql_real_connect(dbh,localhost,usr,xxx,rdns,0,NULL,0)){ fprintf(stderr, Connection to rdns database failed\n); exit(1); } printf(finish connect\n); } where dbh is a global MYSQL structure. This code works fine on the old system. If I pull it out into it's own little test program on the new server, it also works fine. But when I put it in with the analog source code, it compiles fine but the mysql_real_connect causes a core dump when run. Running 4.0.17 on FreeBSD 4.9R Any ideas? The most common reason for the above error is mysql.h header/libmysqlsclient.so library incompatibility. Make sure they are in sync. -- Sasha Pachev Create online surveys at http://www.surveyz.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: undefined reference
Thanx so much! mysql_real_connect() certainly works. Best, hAj on 2003.11.11 17:55, Nick Gaugler at [EMAIL PROTECTED] wrote: http://www.mysql.com/doc/en/mysql_connect.html This function is deprecated. It is preferable to use mysql_real_connect() instead. #includestdio.h #includemysql.h int main(void) { MYSQL mysql; if(mysql_init(mysql) == NULL) { fprintf(stderr,Unable to initlize MySQL structure.\n); return(1); } if(mysql_real_connect(mysql,127.0.0.1,user,password, db, 0, NULL, 0) == NULL) { fprintf(stderr,Unable to connect to MySQL: %s\n, mysql_error(mysql)); return(1); } return(0); } mybox:/home/nickgsu gcc seeLog.c -o seeLog -I/usr/local/mysql/include -L/usr/local/mysql/lib -lmysqlclient -lz mybox:/home/nickgsu ./seeLog Unable to connect to MySQL: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) Good luck, nickg -Original Message- From: hAj [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 4:03 PM To: [EMAIL PROTECTED] Subject: C API: undefined reference Hello MySQL pros worldwide, ~/www -cat seeLog.c #define USE_OLD_FUNCTIONS #include stdio.h #include mysql/mysql.h int main() { MYSQL mysql; MYSQL *mysqldb = NULL; mysqldb = mysql_connect(mysql, geneofcube.net, USERID, PASSWORD); return 0; } ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient /tmp/ccEj3tmv.o: In function `main': /tmp/ccEj3tmv.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www - As shown above, I'm having a problem getting rid of a compilation error (undefined reference) coming out with a very simple c code (seeLog.c) which I wrote for a testing purpose. Got no I idea what I'm doing wrong or missing here. I'd appreciate any of your suggestions. Best, hAj -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API
There is a C++ package called OTL (http://otl.sourceforge.net/home.htm). It supports both MySQL through MyODBC, and Oracle. It works great with Oracle applications, but we have not used it with MySQL. Thanks, Brad Teale Universal Weather and Aviation, Inc. mailto:[EMAIL PROTECTED] 713-944-1440 ext. 3623 Arrange things so that a person needs to know nothing, and you'll end up with a person who is capable of nothing. -- K. Brown -Original Message- From: Priyanka Gupta [mailto:[EMAIL PROTECTED] Sent: Monday, October 20, 2003 7:14 PM To: [EMAIL PROTECTED] Subject: C API Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? priyanka _ Enjoy MSN 8 patented spam control and more with MSN 8 Dial-up Internet Service. Try it FREE for one month! http://join.msn.com/?page=dept/dialup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API: undefined reference
http://www.mysql.com/doc/en/mysql_connect.html This function is deprecated. It is preferable to use mysql_real_connect() instead. #includestdio.h #includemysql.h int main(void) { MYSQL mysql; if(mysql_init(mysql) == NULL) { fprintf(stderr,Unable to initlize MySQL structure.\n); return(1); } if(mysql_real_connect(mysql,127.0.0.1,user,password, db, 0, NULL, 0) == NULL) { fprintf(stderr,Unable to connect to MySQL: %s\n, mysql_error(mysql)); return(1); } return(0); } mybox:/home/nickgsu gcc seeLog.c -o seeLog -I/usr/local/mysql/include -L/usr/local/mysql/lib -lmysqlclient -lz mybox:/home/nickgsu ./seeLog Unable to connect to MySQL: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) Good luck, nickg -Original Message- From: hAj [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 4:03 PM To: [EMAIL PROTECTED] Subject: C API: undefined reference Hello MySQL pros worldwide, ~/www -cat seeLog.c #define USE_OLD_FUNCTIONS #include stdio.h #include mysql/mysql.h int main() { MYSQL mysql; MYSQL *mysqldb = NULL; mysqldb = mysql_connect(mysql, geneofcube.net, USERID, PASSWORD); return 0; } ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient /tmp/ccEj3tmv.o: In function `main': /tmp/ccEj3tmv.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www - As shown above, I'm having a problem getting rid of a compilation error (undefined reference) coming out with a very simple c code (seeLog.c) which I wrote for a testing purpose. Got no I idea what I'm doing wrong or missing here. I'd appreciate any of your suggestions. Best, hAj -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: undefined reference
alright. looking at your directory this should be ok. gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib/mysql -lmysqlclient ;) Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] http://www.DhakaStockExchangeGame.com/ hAj wrote: Hello Jahan, on 2003.11.11 07:43, Aftab Jahan Subedar at [EMAIL PROTECTED] wrote: use the following options to compile gcc seeLog.c -o seeLog -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient Strangely, your options and mine came out with the same error: The first is yours and 2nd is mine. ~/www -gcc seeLog.c -o seeLog -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient /tmp/ccuX7I5J.o: In function `main': /tmp/ccuX7I5J.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient /tmp/ccZxcaCR.o: In function `main': /tmp/ccZxcaCR.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status What does this undefined reference really imply, that the lib binary is broken ? Below is to show you where the .h and lib file I need are located on this particular system I'm trying to run the thing: ~/www -find / -name '*mysql.h*' 2- /home/temp/installd/buildapache/php-4.3.3/ext/dbx/dbx_mysql.h /home/temp/installd/buildapache/php-4.3.3/ext/mysql/libmysql/mysql.h /home/temp/installd/buildapache/php-4.3.3/ext/mysql/php_mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/dbx/dbx_mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/mysql/libmysql/mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/mysql/php_mysql.h /usr/include/mysql/mysql.h ~/www -find / -name '*mysqlclient*' 2- /usr/lib/mysql/libmysqlclient.a /usr/lib/mysql/libmysqlclient.la /usr/lib/mysql/libmysqlclient_r.a /usr/lib/mysql/libmysqlclient_r.la /usr/lib/libmysqlclient.so /usr/lib/libmysqlclient.so.12 /usr/lib/libmysqlclient.so.12.0.0 /usr/lib/libmysqlclient_r.so /usr/lib/libmysqlclient_r.so.12 /usr/lib/libmysqlclient_r.so.12.0.0 /usr/lib/libmysqlclient.so.10 /usr/lib/libmysqlclient.so.10.0.0 /usr/lib/libmysqlclient_r.so.10 /usr/lib/libmysqlclient_r.so.10.0.0 /usr/lib/libmysqlclient.so.9 /usr/lib/libmysqlclient.so.6 Best, hAj Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] http://www.DhakaStockExchangeGame.com/ hAj wrote: Hello MySQL pros worldwide, ~/www -cat seeLog.c #define USE_OLD_FUNCTIONS #include stdio.h #include mysql/mysql.h int main() { MYSQL mysql; MYSQL *mysqldb = NULL; mysqldb = mysql_connect(mysql, geneofcube.net, USERID, PASSWORD); return 0; } ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient use the following options to compile -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient jahan /tmp/ccEj3tmv.o: In function `main': /tmp/ccEj3tmv.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www - As shown above, I'm having a problem getting rid of a compilation error (undefined reference) coming out with a very simple c code (seeLog.c) which I wrote for a testing purpose. Got no I idea what I'm doing wrong or missing here. I'd appreciate any of your suggestions. Best, hAj -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API first row not being returned from a query
I use : numRows = mysql_num_rows( Result); numFields = mysql_num_fields( Result); for( j=0; j numRows; j++) { mysql_data_seek( Result, j); CurrentRow = mysql_fetch_row( Result); for( k = 0; k numFields; k++) printf( %s\t, CurrentRow[ k]); printf( \n); } and it works Try to add mysql_data_seek( Result, 0); before your loop. Santino At 14:06 -0800 26-10-2003, Carl B. Constantine wrote: I'm writing an application and have the following SQL Query written in C/GTK+ code: select customer_id, phone, last_name, first_name, company, account_code from customers; OK, I then issue the following C commands: results = mysql_store_result(conx); numRows = mysql_num_rows(results); g_print(There are %d rows returned\n, numRows); return(results); The print shows 7 rows returned, which is correct. I then have a while loop to step through each row like so: i = 0; while (db_row = mysql_fetch_row(results)) { g_print(getting data...\n); id = db_row[0]; phone = db_row[1]; last = db_row[2]; first = db_row[3]; company = db_row[4]; account = db_row[5]; row = g_strconcat(db_row[0],,,db_row[1],,,db_row[2],,,db_row[3],,,db_row[4], ,,db_row[5],0L); g_print(Row %d is: %s\n,i,row); i++; } OK, the problem is, I don't get the very first row, I only get the last 6 rows. Can anyone tell me WHY this is? It doesn't really make sense. This code supposedly prints rows 1-7 but really only prints 2-7. Your help is greatly appreciated. -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API first row not being returned from a query
* Santino ([EMAIL PROTECTED]) wrote: I use : numRows = mysql_num_rows( Result); numFields = mysql_num_fields( Result); for( j=0; j numRows; j++) { mysql_data_seek( Result, j); CurrentRow = mysql_fetch_row( Result); for( k = 0; k numFields; k++) printf( %s\t, CurrentRow[ k]); printf( \n); } and it works Try to add mysql_data_seek( Result, 0); I'll remember the mysql_data_seek call. However, I did find my problem. It seems I was calling mysql_fetch_row( Result) once BEFORE returning to my calling routing to fetch the rows out, thus I was only getting the last 6 rows. DOH! Thanks for the help. -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
Hi, You can not use native MYSQL C API to handle Oracle DataBase.Work very well (mixed with MYSQL C API) the ORACLE C API which is named OCI(Oracle Call Interface). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Priyanka Gupta [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 21, 2003 2:14 AM Subject: C API Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? priyanka _ Enjoy MSN 8 patented spam control and more with MSN 8 Dial-up Internet Service. Try it FREE for one month! http://join.msn.com/?page=dept/dialup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API
There is a C++ package called OTL (http://otl.sourceforge.net/home.htm). It supports both MySQL through MyODBC, and Oracle. It works great with Oracle applications, but we have not used it with MySQL. Thanks, Brad Teale Universal Weather and Aviation, Inc. mailto:[EMAIL PROTECTED] 713-944-1440 ext. 3623 Arrange things so that a person needs to know nothing, and you'll end up with a person who is capable of nothing. -- K. Brown -Original Message- From: Priyanka Gupta [mailto:[EMAIL PROTECTED] Sent: Monday, October 20, 2003 7:14 PM To: [EMAIL PROTECTED] Subject: C API Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? priyanka _ Enjoy MSN 8 patented spam control and more with MSN 8 Dial-up Internet Service. Try it FREE for one month! http://join.msn.com/?page=dept/dialup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
Priyanka Gupta wrote: Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? priyanka _ Enjoy MSN 8 patented spam control and more with MSN 8 Dial-up Internet Service. Try it FREE for one month! http://join.msn.com/?page=dept/dialup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] Priyanka, This might work for you - http://otl.sourceforge.net/home.htm walt -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
Hi Priyanka, BTW, which programming language you are using? In PHP there is a PEAR DB utitlity which acts as the database abstraction layer. Regards, Hardik Doshi walt [EMAIL PROTECTED] wrote: Priyanka Gupta wrote: Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? priyanka _ Enjoy MSN 8 patented spam control and more with MSN 8 Dial-up Internet Service. Try it FREE for one month! http://join.msn.com/?page=dept/dialup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] Priyanka, This might work for you - http://otl.sourceforge.net/home.htm walt -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] - Do you Yahoo!? The New Yahoo! Shopping - with improved product search
Re: C API
At 20:14 -0400 10/20/03, Priyanka Gupta wrote: Is there a way to have a common C API for MySQL and Oracle. I am writing some software that I would like to work with both MYSQL or Oracle as the backend server? The C API for MySQL is specific only to MySQL. You'd have to write your own abstraction that allows you to use the same API for MySQL or Oracle. -- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com Are you MySQL certified? http://www.mysql.com/certification/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API AND MYSQL
Dave, The documentation has several examples. Here's a function we use. Are you having a particular difficulty? Regards, Andy. snip MYSQL *aDb = NULL; int xConnect() { #define MYSQL_HOST 192.168.103.112 // or host name #define MYSQL_DBfoodb // database name #define MYSQL_USERIDmyuser// DB user name #define MYSQL_PASSWORD mypass// password aDb = mysql_init(NULL); if (!mysql_real_connect(aDb,MYSQL_HOST,MYSQL_USERID, MYSQL_PASSWORD,MYSQL_DB,0,NULL,0)) { die(701 Unable to connect\r\n); } return -1; } /snip dave wrote: anyone have a good sample script of connecting mysql from C API? thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- 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
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]
Re: C API - mysql_free_result
At 13:36 -0400 6/19/03, Adam Lawrence wrote: Stats: MySQL 4.0.13, under Windows98, using the C API with lcc-win32. Is there any way to determine if mysql_free_result() has been called on a result set pointer? There's no API function for that, no. Occasionally I recycle the pointer (use it, free it, use it again, free it again, etc.) and if my code calls mysql_free_result() on a result set pointer that was already freed, an exception is raised and my code gracefully crashes out. -- Adam Lawrence Sustaining Engineering Tectrol Inc. -- -- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com Are you MySQL certified? http://www.mysql.com/certification/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: C API - mysql_free_result
After I use mysql_free_result(), I immediately set the resultset to NULL. -Original Message- From: Adam Lawrence [mailto:[EMAIL PROTECTED] Sent: Thursday, June 19, 2003 11:36 AM To: [EMAIL PROTECTED] Subject: C API - mysql_free_result Stats: MySQL 4.0.13, under Windows98, using the C API with lcc-win32. Is there any way to determine if mysql_free_result() has been called on a result set pointer? Occasionally I recycle the pointer (use it, free it, use it again, free it again, etc.) and if my code calls mysql_free_result() on a result set pointer that was already freed, an exception is raised and my code gracefully crashes out. -- Adam Lawrence Sustaining Engineering Tectrol Inc. -- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
# [EMAIL PROTECTED] / 2003-06-03 18:45:31 +0200: Executing gcc.exe... gcc.exe U:\mep\Dev\abr.c -o U:\mep\Dev\abr.exe -IC:\Dev-Cpp\include -IC:\mysql\include -LC:\Dev-Cpp\lib C:\DOCUME~1\badier1\LOCALS~1\Temp/ccW8.o(.text+0x1d2):abr.c: undefined reference to [EMAIL PROTECTED]' shouldn't you have -LC:\mysql\lib there as well? -- If you cc me or remove the list(s) completely I'll most likely ignore your message.see http://www.eyrie.org./~eagle/faqs/questions.html -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
At 18:45 +0200 6/3/03, [EMAIL PROTECTED] wrote: Hello, I'm trying to code a small C client, under windows, with bloddshed Dev-C++, and i always get an error. /* Code */ #include conio.h #include stdarg.h #include winsock.h #include stdio.h #include stdlib.h #include string.h #include mysql.h int main(void) { MYSQL* toto; toto = mysql_init(toto); } /* this is the compler log */ Compiler: Default compiler Executing gcc.exe... gcc.exe U:\mep\Dev\abr.c -o U:\mep\Dev\abr.exe -IC:\Dev-Cpp\include -IC:\mysql\include -LC:\Dev-Cpp\lib C:\DOCUME~1\badier1\LOCALS~1\Temp/ccW8.o(.text+0x1d2):abr.c: undefined reference to [EMAIL PROTECTED]' Execution terminated I really don't know where this can come from. I downloaded the latest production mysql server (to get the client and libraries), but nothing i tried correct the problem. Any idea? Does that command list the directory where the MySQL client library is located, so that the compiler can find it? -LC:\mysql\lib\opt or -LC:\mysql\lib\debug perhaps? Thanks Vincent -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
From: [EMAIL PROTECTED] Date: 2003/06/03 Tue AM 11:45:31 CDT To: [EMAIL PROTECTED] Subject: C API Hello, I'm trying to code a small C client, under windows, with bloddshed Dev-C++, and i always get an error. /* Code */ #include conio.h #include stdarg.h #include winsock.h #include stdio.h #include stdlib.h #include string.h #include mysql.h My experience is that one should always include these files: #include my_global.h #include my_sys.h #include mysql.h This is just a stab in the dark, though. -S int main(void) { MYSQL* toto; toto = mysql_init(toto); } /* this is the compler log */ Compiler: Default compiler Executing gcc.exe... gcc.exe U:\mep\Dev\abr.c -o U:\mep\Dev\abr.exe -IC:\Dev-Cpp\include -IC:\mysql\include -LC:\Dev-Cpp\lib C:\DOCUME~1\badier1\LOCALS~1\Temp/ccW8.o(.text+0x1d2):abr.c: undefined reference to [EMAIL PROTECTED]' Execution terminated I really don't know where this can come from. I downloaded the latest production mysql server (to get the client and libraries), but nothing i tried correct the problem. Any idea? Thanks Vincent -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API
#include conio.h #include stdarg.h #include winsock.h #include stdio.h #include stdlib.h #include string.h #include mysql.h int main(void) { MYSQL* toto; toto = mysql_init(toto); } /* this is the compler log */ Compiler: Default compiler Executing gcc.exe... gcc.exe U:\mep\Dev\abr.c -o U:\mep\Dev\abr.exe -IC:\Dev-Cpp\include -IC:\mysql\include -LC:\Dev-Cpp\lib C:\DOCUME~1\badier1\LOCALS~1\Temp/ccW8.o(.text+0x1d2):abr.c: undefined reference to [EMAIL PROTECTED]' Execution terminated Does that command list the directory where the MySQL client library is located, so that the compiler can find it? -LC:\mysql\lib\opt or -LC:\mysql\lib\debug perhaps? I also include thoses directories, where dll's are located, and error remain the same : Compiler: Default compiler Executing gcc.exe... gcc.exe U:\mep\Dev\abr.c -o U:\mep\Dev\abr.exe -IC:\Dev-Cpp\include -IC:\mysql\include -LC:\Dev-Cpp\lib -Lc:\mysql\lib -LC:\mysql\lib\opt -Lc:\mysql\lib\debug C:\DOCUME~1\badier1\LOCALS~1\Temp/ccKI.o(.text+0x25):abr.c: undefined reference to [EMAIL PROTECTED]' Execution terminated -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API Question
At 10:57 -0600 2/19/03, William R. Mattil wrote: Hello, I am having some cockpit trouble with the following MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const char *wild); and it is like lack of understanding on my part. Syntax is: if (mysql_list_fields( mysql, some table name, some field name)) mysql_store_result and mysql_fetch_row follow but nothing is ever returned. If I replace the mysql_list_fields with: if (mysql_query(mysql,Describe some_table_name)) everything works. Where am I missing the boat here ? Nothing. It's just that the documentation for this function is unclear/ incorrect. I just came to realize this myself a few weeks ago. :-( The information that mysql_list_fields() returns about the columns is returned in the result set *metadata*. So what you should do is call mysql_fetch_field() to retrieve the metadata for each column of the result set. Note that the max_length value will always be zero. Thanks Bill -- William R. Mattil | Statisticians define a lottery as a tax Sr. System Aministrator | on not understanding mathematics (972) 399-4106 | - 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 Question
At 11:13 -0600 2/19/03, Paul DuBois wrote: At 10:57 -0600 2/19/03, William R. Mattil wrote: Hello, I am having some cockpit trouble with the following MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const char *wild); and it is like lack of understanding on my part. Syntax is: if (mysql_list_fields( mysql, some table name, some field name)) mysql_store_result and mysql_fetch_row follow but nothing is ever returned. If I replace the mysql_list_fields with: if (mysql_query(mysql,Describe some_table_name)) everything works. Where am I missing the boat here ? Nothing. It's just that the documentation for this function is unclear/ incorrect. I just came to realize this myself a few weeks ago. :-( The information that mysql_list_fields() returns about the columns is returned in the result set *metadata*. So what you should do is call mysql_fetch_field() to retrieve the metadata for each column of the result set. Note that the max_length value will always be zero. Thanks Bill -- William R. Mattil | Statisticians define a lottery as a tax Sr. System Aministrator | on not understanding mathematics (972) 399-4106 | To follow up on my own posting: Here's an example. It shows how to retrieve various bits of metadata, including the column metadata. It assumes tbl_name is a string containing the table name. MYSQL_ROW row; MYSQL_FIELD *field; unsigned long *length; unsigned inti; MYSQL_RES *res_set = mysql_list_fields (conn, tbl_name, NULL); if (res_set == NULL) fprintf (stderr, list_fields failed\n); else { printf (Number of columns: %d\n, mysql_num_fields (res_set)); printf (Number of rows: %d\n, mysql_num_rows (res_set)); printf ( %-12s %-12s, name, table); printf ( %-12s %3s %3s %4s %4s %s\n, default, len, max, type, dec, not null); for (i = 0; i mysql_num_fields (res_set); i++) { field = mysql_fetch_field (res_set); printf (%2u %-12s %-12s, i, field-name, field-table ? field-table : NULL); printf ( %-12s %3u %3u %3u %3u %0x %3d\n, field-def ? field-def : NULL, field-length, field-max_length, field-type, field-decimals, field-flags, IS_NOT_NULL(field-flags) ); } } mysql_free_result (res_set); - 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 Changes?
--- Amy Joseph Kormann [EMAIL PROTECTED] wrote: Are there any (significant) changes in the C API between MySQL 3.X and 4.X? If so, where are they located. Yes.Are some changes between ver 3.x and 4.x.If i understand well i think you try to find where this changes are declared/prototype?...on h files. Regards, Gelu mail-filter: sql,query,queries,smallint -- Amy and Joseph Kormann .- 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 Changes?
ggelu [EMAIL PROTECTED] wrote: --- Amy Joseph Kormann [EMAIL PROTECTED] wrote: Are there any (significant) changes in the C API between MySQL 3.X and 4.X? If so, where are they located. Yes. Are some changes between ver 3.x and 4.x.If i understand well i think you try to find where this changes are declared/prototype?...on h files. We should not need to read the source files to use the API. Are there any changes affecting the applications that use the API? Has the documentation changed? Stephen - 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 Changes?
Stephen Brownlow wrote: ggelu [EMAIL PROTECTED] wrote: --- Amy Joseph Kormann [EMAIL PROTECTED] wrote: Are there any (significant) changes in the C API between MySQL 3.X and 4.X? If so, where are they located. Yes. Are some changes between ver 3.x and 4.x.If i understand well i think you try to find where this changes are declared/prototype?...on h files. We should not need to read the source files to use the API. Are there any changes affecting the applications that use the API? Has the documentation changed? Stephen Precisely what I was after. Thanks Stephen. -- Amy and Joseph Kormann - 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 Changes?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Amy Joseph Kormann wrote: Stephen Brownlow wrote: ggelu [EMAIL PROTECTED] wrote: --- Amy Joseph Kormann [EMAIL PROTECTED] wrote: Are there any (significant) changes in the C API between MySQL 3.X and 4.X? If so, where are they located. Yes. Are some changes between ver 3.x and 4.x.If i understand well i think you try to find where this changes are declared/prototype?...on h files. We should not need to read the source files to use the API. Are there any changes affecting the applications that use the API? Has the documentation changed? Stephen Precisely what I was after. Thanks Stephen. Between 3.0 and 4.x, no, there are no significant changes other than bug fixes, and licensing. The client API for 3.x is LGPL, for 4.x and newer it is GPL. The documentation for the C-API is at http://www.mysql.com/doc/en/C.html Of course there are more features in 4.x compared to 3.x at the SQL and server config level, but that doesn't affect the C-API. You can usually always use an older version of any of the APIs to talk to a newer server, too. The changelog is at http://www.mysql.com/doc/en/News.html (pretty much where it always has been). -Mark - -- MySQL 2003 Users Conference - http://www.mysql.com/events/uc2003/ For technical support contracts, visit https://order.mysql.com/?ref=mmma __ ___ ___ __ / |/ /_ __/ __/ __ \/ / Mark Matthews [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java /_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA ___/ www.mysql.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.1.90 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE+UtoutvXNTca6JD8RArPyAJ45TDID3FyyqBIh6RlRu5w7UvAXywCgri+Q tot+R7HU1NpvKDId5k8dvfI= =5Uvr -END PGP SIGNATURE- - 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 for mysql
At 14:21 + 2/7/03, Qin Lu wrote: Hello, I'd like to practice my C application for using mysql. Do you know where can I find some examples? Look in the client directory of a MySQL source distribution. Many/most of the standard MySQL clients are written in C. You can also get examples at this site: http://www.kitebird.com/mysql-book/ Get the sampdb distribution and look in its capi directory for sample programs. These programs are discussed in the sample chapter available at the same site (PDF format). Which header files should I include in my code? And which lib.a should I link to? Many Thanks. Qin sql, query - 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 problems with InnoDB
Hello Mark, thanks for your answer. In fact the mysql shell where I update the row is using AUTOCOMMIT=1. Even after I issue a COMMIT manually the changes are not seen by the application. What I dont understand is that the program doing a SELECT has to issue an COMMIT to have all data available. Maybe I cannot see through the transaction model at all, but as far as I can see all other connections should have the data available after the session that changes data issues a COMMIT command. But in fact that doesnt happen here. For what reason ever. Any other ideas ? regards, Heri InnoDB takes a consistent 'snapshot' at the beginning of every transaction. This enables the 'I' in the infamous 'ACID' test...which is isolation...Transacations don't 'see' the effects of other transactions until after the others commit. InnoDB runs by default in an 'isolation level' of 'REPEATABLE_READ', which means that the isolation a particular transaction 'sees' remains in effect until that transaction itself has committed. InnoDB accomplishes this through the 'snapshotting' model mentioned above. See http://www.innodb.com/ibman.html#InnoDB_transaction_model for more detailed information, or consult any handy transaction processing or database textbook ;) -Mark - 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 problems with InnoDB
Hi Stefan, Does the second shell actually perform those changes? In this case, I assume it's got something to do with the isolation level / consistent read in InnoDB tables. shell1 sees all its changes immediately, shell2 (the application) has just a snapshot of the data at the time it performs the select. Well, in fact shell2 is just another mysql shell I opened. So the following is the situation : Application loops. shell1 changes data. shell2 (which is just another mysql shell i opened) can see the changes. The application still doesnt. So, how can that be caused by the isolation level ? Even after issuing a COMMIT in shell1 (the shell that changes data) theres nothing visible in the application. This should however only be true for the select the first time the application loops. But if it uses the same conn = mysql_init(NULL); (I am not a C programmer), it will keep the same isolation level, and thus, the same snapshot. Well, does that mean that I have to commit that dummy transaction in the application just to have the commited data of the other sessions available ? I call it dummy because this transaction doesnt change any data, just SELECTS it. Here I quote the innodb manual : If you are running with the default REPEATABLE READ isolation level, then all consistent reads within the same transaction read the snapshot established by the first such read in that transaction. You can get a fresher snapshot for your queries by committing the current transaction and after that issuing new queries This would explain the behaviour of the application but seems quite useless to me as I think the task of an atomic operation should be to have changes done or completely rolled back. Or do I get something wrong ? Thanks, Heri - 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 problems with InnoDB
Heri, H. Steuer schrieb: Hi Stefan, Does the second shell actually perform those changes? In this case, I assume it's got something to do with the isolation level / consistent read in InnoDB tables. shell1 sees all its changes immediately, shell2 (the application) has just a snapshot of the data at the time it performs the select. Well, in fact shell2 is just another mysql shell I opened. So the following is the situation : Application loops. shell1 changes data. shell2 (which is just another mysql shell i opened) can see the changes. The application still doesnt. So, how can that be caused by the isolation level ? Even after issuing a COMMIT in shell1 (the shell that changes data) theres nothing visible in the application. This should however only be true for the select the first time the application loops. But if it uses the same conn = mysql_init(NULL); (I am not a C programmer), it will keep the same isolation level, and thus, the same snapshot. Well, does that mean that I have to commit that dummy transaction in the application just to have the commited data of the other sessions available ? I call it dummy because this transaction That's the point! The repeatable read isolation level requires that the data must be presented as they were when your own transaction (not just your SELECT) started! Therefore you should commit regularly (in your case on every loop iteration) even if you issue nothing but SELECTs. The good news is that in future releases of InnoDB/MySQL the isolation level read committed will become available. doesnt change any data, just SELECTS it. Here I quote the innodb manual : If you are running with the default REPEATABLE READ isolation level, then all consistent reads within the same transaction read the snapshot established by the first such read in that transaction. You can get a fresher snapshot for your queries by committing the current transaction and after that issuing new queries This would explain the behaviour of the application but seems quite useless to me as I think the task of an atomic operation should be to have changes done or completely rolled back. should/should not: different isolation levels simply exist (dirty read, committed read, repeatable read)! Don't mix them up with what transactions do! Isolation levels deal more with __when__ I can see somebody else's permanent changes (committed transcations). Or do I get something wrong ? Thanks, Heri - 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 Regards, Frank. -- Dr. Frank Ullrich, Netzwerkadministration Heise Zeitschriften Verlag GmbH Co KG, Helstorfer Str. 7, D-30625 Hannover E-Mail: [EMAIL PROTECTED] Phone: +49 511 5352 587; FAX: +49 511 5352 538 - 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 problems with InnoDB
Heri, - Original Message - From: H. Steuer [EMAIL PROTECTED] Newsgroups: mailing.database.mysql Sent: Tuesday, December 03, 2002 11:49 AM Subject: Re: C API problems with InnoDB Hello Mark, thanks for your answer. In fact the mysql shell where I update the row is using AUTOCOMMIT=1. Even after I issue a COMMIT manually the changes are not seen by the application. What I dont understand is that the program doing a SELECT has to issue an COMMIT to have all data available. Maybe I cannot see through the transaction model at all, but as far as I can see all other connections should have the data available after the session that changes data issues a COMMIT command. But in fact that doesnt happen here. For what reason ever. under the default isolation level, which is REPEATABLE READ, it is logical that consistent reads within one transaction read the same snapshot. Consider, for example, a case where you have two bank accounts A1: 1000 euros and A2: 1000 euros. Suppose you move 100 euros from A1 to A2. If you in another transaction read first A1 and then read A2, the sum should be 2000 euros. This is guaranteed under REPEATABLE READ because both reads read the same snapshot. If they would read different snapshots, the sum could be 2100 euros. Any other ideas ? Upgrade to MySQL-4.0.5a and set the transaction isolation level READ COMMITTED: Consistent reads behave like in Oracle: each consistent read, even within the same transaction, sets and reads its own fresh snapshot. In terms of the SQL-1992 transaction isolation levels, the InnoDB default is REPEATABLE READ. Starting from version 4.0.5, InnoDB offers all 4 different transaction isolation levels described by the SQL-1992 standard. You can set the default isolation level for all connections in the [mysqld] section of my.cnf: transaction-isolation = {READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE} A user can change the isolation level of a single session or all new incoming connections with the SET [SESSION | GLOBAL] TRANSACTION ISOLATION LEVEL {READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE} READ COMMITTED Somewhat Oracle-like isolation level. All SELECT ... FOR UPDATE and SELECT ... LOCK IN SHARE MODE statements only lock the index records, NOT the gaps before them, and thus allow free inserting of new records next to locked records. UPDATE and DELETE which use a unique index with a unique search condition, only lock the index record found, not the gap before it. But still in range type UPDATE and DELETE InnoDB must set next-key or gap locks and block insertions by other users to the gaps covered by the range. This is necessary since 'phantom rows' have to be blocked for MySQL replication and recovery to work. Consistent reads behave like in Oracle: each consistent read, even within the same transaction, sets and reads its own fresh snapshot. regards, Heri Best regards, Heikki Tuuri Innobase Oy --- InnoDB - transactions, row level locking, and foreign key support for MySQL See http://www.innodb.com, download MySQL-Max from http://www.mysql.com sql query - 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 problems with InnoDB
Dear Heri, I tracked down the problem and saw that its only happening if I set autocommit=0. If I run a second mysql shell I can see all changes immediately. Just the application itself doesnt. Does the second shell actually perform those changes? In this case, I assume it's got something to do with the isolation level / consistent read in InnoDB tables. shell1 sees all its changes immediately, shell2 (the application) has just a snapshot of the data at the time it performs the select. This should however only be true for the select the first time the application loops. But if it uses the same conn = mysql_init(NULL); (I am not a C programmer), it will keep the same isolation level, and thus, the same snapshot. Hope it helps, -- Stefan Hinz [EMAIL PROTECTED] CEO / Geschäftsleitung iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Telefon: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: H. Steuer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 02, 2002 10:29 PM Subject: C API problems with InnoDB Hello MySQL users, I have a weired issue using the MySQL C API and InnoDB tables. An application polls a database every 30 seconds. When the application starts everything seems to be fine. During the running of the application i change some rows, but the application itself doesnt see the changes at all. I tracked down the problem and saw that its only happening if I set autocommit=0. If I run a second mysql shell I can see all changes immediately. Just the application itself doesnt. Here are the important parts of the code without any exception catching. Just wanted to show the steps I did for querying the database. conn = mysql_init(NULL); mysql_real_connect( conn, hostname, username, password, dbname, 0, NULL, 0) == NULL); mysql_query(conn,SET AUTOCOMMIT=0); ... so far for the preparing of the connection. now for the interresting part. the following query runs in an loop : mysql_query(conn,SELECT a.id,k.fix_SenderCompID,k.fix_TargetCompID,k.fix_version FROM aorder AS a,kontrahenten AS k WHERE status='active' AND fix_status='queued_send' AND k.id=a.kontrahent) result = mysql_store_result(conn); while ( ( row = mysql_fetch_row(result) ) != NULL ) { // do something with the data } mysql_free_result(result); sleep(30); okay, when running this application does not see the changes to the database - for what reason ever. If I drop the SET AUTOCOMMIT=0 it works fine. When inserting 'mysql_query(conn,COMMIT;) ' after the mysql_store_result everything seems to work fine, too. But theres only a select statement - nothing that changes data at all. why doesnt the application see the changes without the commit ? I wrote a small test application without any other code, just this simple query - the same result. Can anyone explain this thing to me ? Why is there a COMMIT needed after a select ? When stopping the application and restarting it immediately the changes are visible, too. I dont get any further - hope one of you guys can help. Thanks in advance, Heri - 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 problems with InnoDB
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 H. Steuer wrote: Hello MySQL users, I have a weired issue using the MySQL C API and InnoDB tables. An application polls a database every 30 seconds. When the application starts everything seems to be fine. During the running of the application i change some rows, but the application itself doesnt see the changes at all. I tracked down the problem and saw that its only happening if I set autocommit=0. If I run a second mysql shell I can see all changes immediately. Just the application itself doesnt. Here are the important parts of the code without any exception catching. Just wanted to show the steps I did for querying the database. [snip] okay, when running this application does not see the changes to the database - for what reason ever. If I drop the SET AUTOCOMMIT=0 it works fine. When inserting 'mysql_query(conn,COMMIT;) ' after the mysql_store_result everything seems to work fine, too. But theres only a select statement - nothing that changes data at all. why doesnt the application see the changes without the commit ? I wrote a small test application without any other code, just this simple query - the same result. Can anyone explain this thing to me ? Why is there a COMMIT needed after a select ? When stopping the application and restarting it immediately the changes are visible, too. I dont get any further - hope one of you guys can help. Thanks in advance, Heri InnoDB takes a consistent 'snapshot' at the beginning of every transaction. This enables the 'I' in the infamous 'ACID' test...which is isolation...Transacations don't 'see' the effects of other transactions until after the others commit. InnoDB runs by default in an 'isolation level' of 'REPEATABLE_READ', which means that the isolation a particular transaction 'sees' remains in effect until that transaction itself has committed. InnoDB accomplishes this through the 'snapshotting' model mentioned above. See http://www.innodb.com/ibman.html#InnoDB_transaction_model for more detailed information, or consult any handy transaction processing or database textbook ;) -Mark - -- For technical support contracts, visit https://order.mysql.com/?ref=mmma __ ___ ___ __ / |/ /_ __/ __/ __ \/ / Mark Matthews [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java /_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA ___/ www.mysql.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.1.90 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE96+iotvXNTca6JD8RAhcJAKC/u3ZjbJQYtI6ei94ddaY28jtZPwCguWJW MDbFde/rPHEy8BGawiVm8Y4= =1Xjv -END PGP SIGNATURE- - 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 and multiple resultsets
Greetings... Yes. If you want to traverse two result set in the same time then use the mysql_store_result(). If you don't have a big resultset coming then probably mysql_store_result() in the same connection is a better option. Otherwise you have to use two connections. Rgds Insane SQLyog - The Definitive Win32 GUI for MySQL http://www.sqlyog.com - Original Message - From: Stefan Fleiter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 29, 2002 1:16 AM Subject: C-API and multiple resultsets Hi! If I use mysql_use_reult() of the C-API, I must use two connections to traverse two different result sets at the same time. Is that right? Thanx, Stefan sql, query - 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 and multiple resultsets
Insanely Great wrote: Hi! If you want to traverse two result set in the same time then use the mysql_store_result(). If you don't have a big resultset coming then probably mysql_store_result() in the same connection is a better option. Otherwise you have to use two connections. Thanx, just wanted to be sure. Greetings, Stefan sql, query - 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
Most likely this will solve your problem. This comes right from the mysql website documentation. It is for the C API but I'm sure the same concepts go for C++ as well. If this doesn't work provide more info on the program you are using for coding and the errors you are getting. Thanks. http://www.mysql.com/doc/B/u/Building_clients.html 8.4.7 Building Client Programs If you compile MySQL clients that you've written yourself or that you obtain from a third-party, they must be linked using the -lmysqlclient -lz option on the link command. You may also need to specify a -L option to tell the linker where to find the library. For example, if the library is installed in `/usr/local/mysql/lib', use -L/usr/local/mysql/lib -lmysqlclient -lz on the link command. For clients that use MySQL header files, you may need to specify a -I option when you compile them (for example, -I/usr/local/mysql/include), so the compiler can find the header files. -- Original Message -- From: Marco Coletta -TV [EMAIL PROTECTED] Reply-To: Marco Coletta -TV [EMAIL PROTECTED] Date: Thu, 11 Jul 2002 15:41:02 +0200 I need to use the C++ API for mysql under a Linux system. I compiled the tarball downloaded from mysql.com/Downloads but I get several errors during compilation of C++ code. Can anyone supply some information. Thanks. - 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: mysql_data_seek
Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 9:29 PM Subject: C API: mysql_data_seek Hi, I'm using the MySQL built-in C function, mysql_data_seek, for accessing a particular row from the Result (MYSQL_RES) returned by mysql_store_result. int sql_result; MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery); mysql_data_seek(MResult, 1); row = mysql_fetch_row(MResult); However, row returns NULL. I wonder if I've made any mistake in the process. Can someone please help to check? In addition, is there any special considerations when using this function? Thanks in advance. wv - 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: mysql_data_seek
Hi, If i understand well you use twice mysql_data_seek.If you use mysql_data_seek() after mysql_fetch_row() the effect is NULL. Because mysql_data_seek() (in fact) set the cursor (if we can said like this...) in the MResult (MYSQL_RES) and not in the row (MYSQL_ROW). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 10:13 AM Subject: RE: C API: mysql_data_seek Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 9:29 PM Subject: C API: mysql_data_seek Hi, I'm using the MySQL built-in C function, mysql_data_seek, for accessing a particular row from the Result (MYSQL_RES) returned by mysql_store_result. int sql_result; MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery); mysql_data_seek(MResult, 1); row = mysql_fetch_row(MResult); However, row returns NULL. I wonder if I've made any mistake in the process. Can someone please help to check? In addition, is there any special considerations when using this function? Thanks in advance. wv - 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: mysql_data_seek
Hi Gelu, Thnx for the prompt reply. I called mysql_data_seek() once and I called it before mysql_fetch_row(). With this, mysql_fetch_row() returns NULL row. Then I decided to check if the connection (and query) is valid by commented out mysql_data_seek(). I called only mysql_fetch_row() and it returns non-NULL row. From the result, I know that the connection and the query are valid. The next thing I check is the number of rows in the MResult. I have 3 rows altogether. Hence, it should return me something if I set the cursor (using mysql_seek_data() ) to the 2nd row and then get the row with mysql_fetch_row(). However, this does not work. I've checked my concept on mysql_data_seek() against the description you have provided in the first reply, and I do not detect any different. Hence I presume the mistake was made due to some special considerations which I do not know. Please advice. Once again, thnx for replying. Regards, wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 09:38 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well you use twice mysql_data_seek.If you use mysql_data_seek() after mysql_fetch_row() the effect is NULL. Because mysql_data_seek() (in fact) set the cursor (if we can said like this...) in the MResult (MYSQL_RES) and not in the row (MYSQL_ROW). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 10:13 AM Subject: RE: C API: mysql_data_seek Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 9:29 PM Subject: C API: mysql_data_seek Hi, I'm using the MySQL built-in C function, mysql_data_seek, for accessing a particular row from the Result (MYSQL_RES) returned by mysql_store_result. int sql_result; MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery); mysql_data_seek(MResult, 1); row = mysql_fetch_row(MResult); However, row returns NULL. I wonder if I've made any mistake in the process. Can someone please help to check? In addition, is there any special considerations when using this function? Thanks in advance. wv - 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: mysql_data_seek
Hi, If i understand well, mysql_fetch_row() work fine but if you add mysql_data_seek() the row is NULL. ...you use pointers when declare variables ?In my pre-previuos e-mail i fill what (i considered) it's not was OK. MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; instead... MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 11:42 AM Subject: RE: C API: mysql_data_seek Hi Gelu, Thnx for the prompt reply. I called mysql_data_seek() once and I called it before mysql_fetch_row(). With this, mysql_fetch_row() returns NULL row. Then I decided to check if the connection (and query) is valid by commented out mysql_data_seek(). I called only mysql_fetch_row() and it returns non-NULL row. From the result, I know that the connection and the query are valid. The next thing I check is the number of rows in the MResult. I have 3 rows altogether. Hence, it should return me something if I set the cursor (using mysql_seek_data() ) to the 2nd row and then get the row with mysql_fetch_row(). However, this does not work. I've checked my concept on mysql_data_seek() against the description you have provided in the first reply, and I do not detect any different. Hence I presume the mistake was made due to some special considerations which I do not know. Please advice. Once again, thnx for replying. Regards, wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 09:38 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well you use twice mysql_data_seek.If you use mysql_data_seek() after mysql_fetch_row() the effect is NULL. Because mysql_data_seek() (in fact) set the cursor (if we can said like this...) in the MResult (MYSQL_RES) and not in the row (MYSQL_ROW). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 10:13 AM Subject: RE: C API: mysql_data_seek Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 9:29 PM Subject: C API: mysql_data_seek Hi, I'm using the MySQL built-in C function, mysql_data_seek, for accessing a particular row from the Result (MYSQL_RES) returned by mysql_store_result. int sql_result; MYSQL_RES *MResult; MYSQL_ROW row
RE: C API: mysql_data_seek
Hi Gelu, Yes, you are right in getting my problem. I tried using pointers when declaring the variables MYSQL_ROW *row; MYSQL *MQuery; However, I do not get the desired result too. Besides pointer, do you know any other possible mistakes? Really appreciate your response. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 11:02 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well, mysql_fetch_row() work fine but if you add mysql_data_seek() the row is NULL. ...you use pointers when declare variables ?In my pre-previuos e-mail i fill what (i considered) it's not was OK. MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; instead... MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 11:42 AM Subject: RE: C API: mysql_data_seek Hi Gelu, Thnx for the prompt reply. I called mysql_data_seek() once and I called it before mysql_fetch_row(). With this, mysql_fetch_row() returns NULL row. Then I decided to check if the connection (and query) is valid by commented out mysql_data_seek(). I called only mysql_fetch_row() and it returns non-NULL row. From the result, I know that the connection and the query are valid. The next thing I check is the number of rows in the MResult. I have 3 rows altogether. Hence, it should return me something if I set the cursor (using mysql_seek_data() ) to the 2nd row and then get the row with mysql_fetch_row(). However, this does not work. I've checked my concept on mysql_data_seek() against the description you have provided in the first reply, and I do not detect any different. Hence I presume the mistake was made due to some special considerations which I do not know. Please advice. Once again, thnx for replying. Regards, wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 09:38 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well you use twice mysql_data_seek.If you use mysql_data_seek() after mysql_fetch_row() the effect is NULL. Because mysql_data_seek() (in fact) set the cursor (if we can said like this...) in the MResult (MYSQL_RES) and not in the row (MYSQL_ROW). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 10:13 AM Subject: RE: C API: mysql_data_seek Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED
Re: C API: mysql_data_seek
Hi, Resume I understand that you use C API functions in the right order: mysql_init() mysql_option() mysql_real_connect() mysql_real_query() mysql_store_result() mysql_data_seek() mysql_fetch_field() mysql_fetch_row() mysql_free_result() mysql_close() Question : What version of libmysql.dll and what compilers you used ? I put this question because i wish to send to you an example with mysql_data_seek(); Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 3:03 PM Subject: RE: C API: mysql_data_seek Hi Gelu, Yes, you are right in getting my problem. I tried using pointers when declaring the variables MYSQL_ROW *row; MYSQL *MQuery; However, I do not get the desired result too. Besides pointer, do you know any other possible mistakes? Really appreciate your response. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 11:02 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well, mysql_fetch_row() work fine but if you add mysql_data_seek() the row is NULL. ...you use pointers when declare variables ?In my pre-previuos e-mail i fill what (i considered) it's not was OK. MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; instead... MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 11:42 AM Subject: RE: C API: mysql_data_seek Hi Gelu, Thnx for the prompt reply. I called mysql_data_seek() once and I called it before mysql_fetch_row(). With this, mysql_fetch_row() returns NULL row. Then I decided to check if the connection (and query) is valid by commented out mysql_data_seek(). I called only mysql_fetch_row() and it returns non-NULL row. From the result, I know that the connection and the query are valid. The next thing I check is the number of rows in the MResult. I have 3 rows altogether. Hence, it should return me something if I set the cursor (using mysql_seek_data() ) to the 2nd row and then get the row with mysql_fetch_row(). However, this does not work. I've checked my concept on mysql_data_seek() against the description you have provided in the first reply, and I do not detect any different. Hence I presume the mistake was made due to some special considerations which I do not know. Please advice. Once again, thnx for replying. Regards, wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 10 July 2002 09:38 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, If i understand well you use twice mysql_data_seek.If you use mysql_data_seek() after mysql_fetch_row() the effect is NULL. Because mysql_data_seek() (in fact) set the cursor (if we can said like this...) in the MResult (MYSQL_RES) and not in the row (MYSQL_ROW). Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: 'Gelu Gogancea' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 10:13 AM Subject: RE: C API: mysql_data_seek Hi, Thanks for ur reply. When i commented out the mysql_data_seek() function, mysql_fetch_row() returns me a non-NULL value (this should be the first row from the MResult). This results show that I've a valid connection and/or query. And when I call mysql_fetch_row() again (retrieving the 2nd row from the MResult, which is the desired row), it returns me a non-NULL value too. From this result, I know that I've not seek past the result set. However, with the addition of the mysql_data_seek(MResult, 1) function, a NULL value is returned. And that's where I don't know how the mistake was made. Please advice and thanks. wv -Original Message- From: Gelu Gogancea [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 23:03 To: Chan WieVia ICM N MC MI E3 Extern; [EMAIL PROTECTED] Subject: Re: C API: mysql_data_seek Hi, It's ok but you must retrieve
Re: C API: mysql_data_seek
Hi, It's ok but you must retrieve data from row. int sql_result;x,i; MYSQL_RES *MResult; MYSQL_ROW *row; MYSQL *MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery);//mysql_store_result return in MResult not in MQuery (here was :...mysql_store_result(MQuery)) mysql_data_seek(MResult, 1); //it's ok here...i suppose you whish to retrieve data from 2-nd row row = mysql_fetch_row( MResult) ;// if you have a valid connection(or query) mysql_fetch_row should return non NULL value. i = mysql_num_fields(MResult) ; for ( x = 0 ; x i ; x++ ) { printf(Data from MYSQL_ROW : %s \n,row[x]); } mysql_free_result( res ) ; I hope it's help. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Chan WieVia ICM N MC MI E3 Extern [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 9:29 PM Subject: C API: mysql_data_seek Hi, I'm using the MySQL built-in C function, mysql_data_seek, for accessing a particular row from the Result (MYSQL_RES) returned by mysql_store_result. int sql_result; MYSQL_RES *MResult; MYSQL_ROW row; MYSQL MQuery; char SQLQuery[]; sprintf( SQLQuery, SELECT * FROM Profile ); sql_result = mysql_query(SQLQuery); MResult = mysql_store_result(MQuery); mysql_data_seek(MResult, 1); row = mysql_fetch_row(MResult); However, row returns NULL. I wonder if I've made any mistake in the process. Can someone please help to check? In addition, is there any special considerations when using this function? Thanks in advance. wv - 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 row data not matching database data
At 19:54 +0200 6/14/02, Hihn Jason wrote: I'm using the C API to return a record which has a field that contains (somewhat) binary data. It's been properly mysql_escape_string()ed. I'm using a 3.23.4x server client. When I do a: select data into outfile 'out' from table where id='1'; from the mysql client, I get what I expect in the outfile. When I do a mysql_fetch_row() and a row[0] on the same query from within the C API, I get similar but completely different data. The former is ~1800 bytes long, and the latter ~6200 bytes long. Determined how? strlen(), or by calling mysql_fetch_lengths()? Incidentally the data in the outfile contains a good number of the two char sequence 0x91 0x11, but in the C program, it all comes out as 0xCD Anyway, at the end of the data is a plain text sequence that I am trying to extract. I can find it ok, IF the data were there. The CAPI doesn't show it, and that is my major problem. No 0x00s exist in the datastream. I'm really stuck, so I'd really appreciate any help! Thank you! PS. PHP returns the same thing as the C API. - 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 for Mysql
Hi Carsten, I've tried Mysql++ and SQLAPI. I am asking if someone out there know about other best tools in C++ for Mysql on linux. Thanks, Hisseine - Original Message - From: Carsten Gehling [EMAIL PROTECTED] To: Hisseine Dj. [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, May 06, 2002 11:31 AM Subject: SV: C++ API for Mysql You can download MySQL++ from www.mysql.com - Carsten -Oprindelig meddelelse- Fra: Hisseine Dj. [mailto:[EMAIL PROTECTED]] Sendt: 6. maj 2002 17:24 Til: [EMAIL PROTECTED] Emne: C++ API for Mysql Hello, Can someone tell me if there is an C++ API that works smooth with MYSQL on linux. So far I was trying msql++ and SQLAPI++. SQLAPI++ seems to be good by there are problems when runing the program. My system is Redhat 7.2 and Mysql 3.23.49 Thanks, Hisseine - 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 - 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
In fact, i'm trying to read data from a binary file and want to insert that into the database. I guess, it would be easier and more efficient if i use some data structure like we have vectors in C++ API. Thanks, Ritu Singla On Thu, 18 Apr 2002, Robert Cross wrote: you wrote: I want to know if there is any datatype in MySQL C API which is similar to a structure in C??? Why? The purpose of the API is to permit use of MySQL as a backend or datasource for user-written programs. That said, if your table consists of columns of differing types, then any the results of any query will be similar to a C struct. In which case the mysql_row type is probably the closest. The easiest answer is to refer to section 8.4.1 of the manual at http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#C_API_datatypes (amongst others) Hope this helps. Robert Cross. - 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 question
At 5:09 + 3/28/02, Federico Halperin wrote: In a table, I declared a column which is an integer unsigned. After calling mysql_fetch_row, I need to convert the value of the column (i.e. row[0]) to a string. According to the manual, *all* column values are returned as strings. I'd say you don't need to convert it. I tried to solve it doing this: char var[11]; sprintf (var, %u, row[0]); , but it doesn't work. Is *row[0] an unsigned int? Can anybody help me??? It's a good idea to take a good look at the descriptions of these functions (and the data types they use) in the manual to see how they work. No point in guessing. - 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 question
hi, I think u don't need to convert it in to string... all the column values comes out in string only... or even u need to use atoi() Function for getting the Int ot unsigned int... I have used it... Chetan Lavti -Original Message- From: Federico Halperin [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 10:40 AM Subject: C API question In a table, I declared a column which is an integer unsigned. After calling mysql_fetch_row, I need to convert the value of the column (i.e. row[0]) to a string. I tried to solve it doing this: char var[11]; sprintf (var, %u, row[0]); , but it doesn't work. Is *row[0] an unsigned int? Can anybody help me??? _ Con MSN Hotmail súmese al servicio de correo electrónico más grande del mundo. http://www.hotmail.com/ES - 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 question
hi, I think u don't need to convert it in to string... all the column values comes out in string only... I have used it... Chetan Lavti -Original Message- From: Federico Halperin [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 10:40 AM Subject: C API question In a table, I declared a column which is an integer unsigned. After calling mysql_fetch_row, I need to convert the value of the column (i.e. row[0]) to a string. I tried to solve it doing this: char var[11]; sprintf (var, %u, row[0]); , but it doesn't work. Is *row[0] an unsigned int? Can anybody help me??? _ Con MSN Hotmail súmese al servicio de correo electrónico más grande del mundo. http://www.hotmail.com/ES - 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 Question
multiple commands Not as far as I know, you need to open your file, read the commands and process them one at a time. The C API is not magic and has no more capability than you do setting down and typing in the commands yourself. What you can do is build one HUGE insert command from lots of individual row inserts, but you need to do that programatically, too. If you have loads of inserts to perform, it may be better to bulk load the data from a file made of the inserts' data than a record at a time if speed is an issue. I'd sure try the simple way first, though. Ken -Original Message- From: Javier [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 20, 2002 5:35 AM To: [EMAIL PROTECTED] Subject: C API Question Hi, I have a text file , with several MySQL instructions (CREATE TABLE, INSERT, SET @var, etc.). I want to execute all these instructions from a C program , using the API. It is possible to use the function mysql_query(), to execute all the instructions contained in the file in a single call to this function? , Can I execute several MySQL instructions in one only call to mysql_query() function? If it is possible, which is the best way to do this? Thanks in advance Javier Diaz IT Developer - Scanned for all known viruses by Messagelabs -- - 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 Question
At 11:35 + 3/20/02, Javier wrote: Hi, I have a text file , with several MySQL instructions (CREATE TABLE, INSERT, SET @var, etc.). I want to execute all these instructions from a C program , using the API. It is possible to use the function mysql_query(), to execute all the instructions contained in the file in a single call to this function? , Can I execute several MySQL instructions in one only call to mysql_query() function? No. Not for the C API, or for any API. The client-server protocol requires that you issue a single query at at time. But there's nothing to stop you from writing a utility function that takes all the statements and issues them. Then you just call *that* function once. And remember that you don't include a terminating semicolon on the statements when you use an API. If it is possible, which is the best way to do this? Thanks in advance Javier Diaz IT Developer - 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 BLOB type field lengths returned
At 16:48 -0600 3/7/02, Kenneth Hylton wrote: Howdy - I've posted this twice before - third time might be the charmer... Can anybody help me? I am using the C API and am returning a result set from a table with a BLOB type item in it. When I populate the BLOB fields initially (with all the same data) the length is returned properly when I issue SELECT * FROM table and decode the result set column metadata. Meaning, that if I put , This Blob's for you! in the column, the value of MYSQL_FIELDS.length = 65535 (max of BLOB type) and MYSQL_FIELDS.max_length = 21. When I update a few rows and put, That's OK man, but you still can't have my BLOB! in a few columns, the values for the length of the fields are returned funny, or at least, I don't understand why they are returning they way they are. Meaning the value of the new column length are all set to MYSQL_FIELDS.length = 65535 (again, max of BLOB type) and MYSQL_FIELDS.max_length = 49. Problem is, this is even on the unchaged rows! Yuk! A little experimentation showed that if I select on only unchanged rows, the length is returned as 21. But, if the result set has one of the changed rows in it, the length of all blob fields is returned as 49, when (at least to me) it should be 21 or 49. In other words, it returns as the BLOB max_length value the value of the longest blob in the result set, NOT the max_length of each row. I inserted Right. That's how it's supposed to work. length = length of the underlying column type, as defined in the CREATE TABLE statement. max_length = length of the longest value actually present in the result set. Neither of them indicate anything about particular values present in a given row. If you want that, use mysql_fetch_lengths() to get a pointer to an array of the lengths of the columns in the current row of the result set. (and updated) some records in the table with BLOB contents It's all about the BLOB and I see the same result. It returns not the length of the BLOB for the row, but the length of the longest BLOB field in the result set. We are running MySQL 3.23.46-Max on RedHat 7.2 Question: 1) How do I get the actual length of the BLOB column in the row, without storing a separate column to maintain BLOB length manually? 2) If this is not a problem because there is some other way to tell where the BLOB buffer ends, please let me know. - 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 BLOB type field lengths returned
Hi, Kenneth, On Fri, 2002-03-08 at 08:48, Kenneth Hylton wrote: I've posted this twice before - third time might be the charmer... Can anybody help me? I am using the C API and am returning a result set from a table with a BLOB type item in it. When I populate the BLOB fields initially (with all the same data) the length is returned properly when I issue SELECT * FROM table and decode the result set column metadata. Meaning, that if I put , This Blob's for you! in the column, the value of MYSQL_FIELDS.length = 65535 (max of BLOB type) and MYSQL_FIELDS.max_length = 21. When I update a few rows and put, That's OK man, but you still can't have my BLOB! in a few columns, the values for the length of the fields are returned funny, or at least, I don't understand why they are returning they way they are. Meaning the value of the new column length are all set to MYSQL_FIELDS.length = 65535 (again, max of BLOB type) and MYSQL_FIELDS.max_length = 49. Problem is, this is even on the unchaged rows! Yuk! A little experimentation showed that if I select on only unchanged rows, the length is returned as 21. But, if the result set has one of the changed rows in it, the length of all blob fields is returned as 49, when (at least to me) it should be 21 or 49. In other words, it returns as the BLOB max_length value the value of the longest blob in the result set, NOT the max_length of each row. I inserted (and updated) some records in the table with BLOB contents It's all about the BLOB and I see the same result. It returns not the length of the BLOB for the row, but the length of the longest BLOB field in the result set. This is correct behaviour. If you wanted to print out the result in a table layout, you'll want to know the max length of each column in the result set. That's why the field is called MYSQL_FIELDS.max_length. We are running MySQL 3.23.46-Max on RedHat 7.2 Question: 1)How do I get the actual length of the BLOB column in the row, without storing a separate column to maintain BLOB length manually? mysql_field_lengths(), which you can call after mysql_fetch_row(), and naturally the result will be unique for each row. 2)If this is not a problem because there is some other way to tell where the BLOB buffer ends, please let me know. See #1. Regards, Arjen. -- MySQL Training in Brisbane: 18-22 March, http://www.mysql.com/training/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Arjen G. Lentz [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Technical Writer, Trainer /_/ /_/\_, /___/\___\_\___/ Brisbane, QLD Australia ___/ www.mysql.com - 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 example code.
Thanks, I will have a look at the official site. Is anybody aware of a non-oficial site that contains an example with a real db as backend. (With real db I mean tables with a few thousand+ records per table and advanced queries with multiple joins) and then how one can optimise the c code to run optimaly with several clients connecting via the c client code to the server. Egor Egorov [EMAIL PROTECTED] 02/20 5:50 PM George, Wednesday, February 20, 2002, 4:51:32 PM, you wrote: GL Hi list, GL Where can I find an online tutorial / example on how to use the C API GL for mysql? Look in MySQL online documentation about C API: http://www.mysql.com/doc/C/C/C.html GL George GL (mysql, query, sql) -- For technical support contracts, goto https://order.mysql.com/ This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com - 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
Christopher Thompson writes: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 For various reasons, I need a C++ API to MySQL for use in Windows (and possibly Linux as well). I know I can find one or two in the downloads/contrib section but I'm looking for suggestions. I'm quite happy with the way the C API is set up. But I want something with nice C++ wrappers, ideally something that uses the C++ Standard Library correctly (i.e. #include iostream instead of #include iostream.h). Does anyone have any suggestions? I cannot even figure out which files to start looking at... Hi! Take a look at MySQL++... -- Regards, __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Sinisa Milivojevic [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus ___/ www.mysql.com - 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 on MacOS X 10.1.1
Chris Allum writes: Hi, I'm trying to use the mysql++ API on MacOS X with Project Builder, but I am not sure what to do to get started. Any suggestions? Thanks, - Chris -- Christopher Allum [EMAIL PROTECTED] Alluminity Solutions -- Hi! MySQL++ can easily be used on MacOS X with GNU 2.95.* and 3.0.* compilers. There is also a binary library for 2.95.2 on MySQL++ page for your OS. -- Regards, __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Sinisa Milivojevic [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus ___/ www.mysql.com - 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
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
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
Re: C API problem, CREATE TABLE SELECT SELECT
| query_len = sprintf(query, CREATE TEMPORARY TABLE temp SELECT ); try it out with asprintf(). but you have to define at compile time the following -D_GNU_SOURCE maybe you allocates not enough place for query. asprintf do it for you. char *query; int query_len; query_len=asprintf(query,select...); mysql_real_query(db_read, query, query_len); free(query); if (..){ ... cheers, ati - 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 mysql_query() malfunctioning (long)
So you mean to replace joining with combined condition? I think it is simply a terminological/syntactical difference. I simply never use LEFT JOIN commands. I always use '='. I think they do the same think, namely what is called a join in relational _theory_. I *understand* '=' better then JOIN. * * * It is good we found your bug now! There is still the question of your mysql monitor seemingly yelding the right results for the wrong query, but I'll leave that problem for you now ;-) -- , M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121 A M A D O Rua Campo Alegre, 823 fax 351+226003654 A L V E S P-4150 PORTO, Portugalmob 351+939354002 - 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 mysql_query() malfunctioning (long)
I know KR (section 4.9, 2nd ed.) says char s[] = ...; is equivalent to char s[] = { . . . , '\0'} but I always explicitely attach the \0 just to be sure i.e. char s[] = ...\0; /* mysql, database (cheating the filter, human reader ignore) */ -- , M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121 A M A D O Rua Campo Alegre, 823 fax 351+226003654 A L V E S P-4150 PORTO, Portugalmob 351+939354002 - 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 mysql_query() malfunctioning (long)
M. A. Alves wrote: My testing returns 16 rows in both ways (program using API vs. mysql monitor). I have copied verbatim the query string from your C code (it was the query constant right?) I think this contrasts with your results no? yes when I typed in the same query in mysql I get 4 rows - 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 mysql_query() malfunctioning (long)
M. A. Alves wrote: I think the problem is in your query expression. I have reformulated your original query using my style and that consistently results in 4 rows which I think is what you wanted. Original_Query : String := select distinct Exhibition.InternalNumber,Exhibition.Name, Exhibition.Openning,Exhibition.Closure,Exhibition.Schedule, Country.Name,City.Name,ExhibitionHall.Name,Exhibition.AdressPhones, Exhibition.ExhibitionURL,Exhibition.Organizer,Exhibition.OrganizerPhoneFax, Exhibition.OrganizerURL,Exhibition.Logo,Exhibition.Description from ExhibitionTopic left join Exhibition on ExhibitionTopic.Exhibition= Exhibition.InternalNumber left join ExhibitionHall on Exhibition.Hall= Exhibition.InternalNumber left join City on ExhibitionHall.City=City. InternalNumber left join Country on City.Country=Country.InternalNumber; My_Style : String := select distinct e.InternalNumber, e.Name, e.Openning, e.Closure, e.Schedule, co.Name, ci.Name, eh.Name, e.AdressPhones, e.ExhibitionURL, e.Organizer, e.OrganizerPhoneFax, e.OrganizerURL, e.Logo, e.Description from Exhibition e, ExhibitionHall eh, Country co, City ci where eh.InternalNumber = e.Hall and ci.InternalNumber = eh.City and co.InternalNumber = ci.Country; Also, your database scheme does not seem to be normalised. In your scheme an Exhibition has a City, a Hall and a Country, but the dependencies exist Hall - City City - Country no? that's an old reflex I prefer to hold straight links as well as canonical hierarchical - for sppeding up group selects But you forgot ExhibitionTopics table - they are involved in some case of filtering. So you mean to replace joining with combined condition? - 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