[API C] Little problem with MYSQL_ROW
Hi, After I've filled my MYSQL_ROW variable, I would like print it into the screen -- MYSQL_ROW lop; db.pgInfoSel(); lop = db.PreRow(); // return the reference to filled row for(int i = 0; i = 7; i++) cout lop[i] endl; but, if I would print from 0 to 7 don't print nothing, if I print from 1 to 1 I received the data but the first char of the first value is incorrect... anybody know why? select --- snprintf(c_query, DIMQUERY,SELECT pg_id, nome, cognome, altezza, peso, eta, sesso, pi.descr, pl.descr, cl.descr, ln.descr, ms.descr\ FROM pg\ JOIN pg_info AS pi ON pi.ex_pg_id = pg.pg_id\ JOIN popoli AS pl ON pi.ex_pl_id = pl.pl_id\ JOIN clan AS cl ON pi.ex_cl_id = cl.cl_id\ JOIN lingue AS ln ON pi.ex_ln_id = ln.ln_id\ JOIN mestieri AS ms ON pi.ex_ms_id = ms.ms_id\ WHERE pg.pg_id = %i;, mui_pgID); --- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
medida do tempo de consulta em API C
Olá pessoal, Estou fazendo um trabalho em API C na área de otimização de consulta. O meu problema esta em medir o tempo utilizado pela consulta. Estou usando difftime(end,start) para avaliar o tempo, só ele está fornecendo o temo em segundos, o que, na maioria das vezes, não é relevante. Como fazer para que o tempo seja fornecido em centésimos de segundo, por exemplo? Há como fazer isto? Um abraço, Volnei Galbino
Re: medida do tempo de consulta em API C
Volnei Galbino wrote: Olá pessoal, Estou fazendo um trabalho em API C na área de otimização de consulta. O meu problema esta em medir o tempo utilizado pela consulta. Estou usando difftime(end,start) para avaliar o tempo, só ele está fornecendo o temo em segundos, o que, na maioria das vezes, não é relevante. Como fazer para que o tempo seja fornecido em centésimos de segundo, por exemplo? Há como fazer isto? Um abraço, Volnei Galbino Please, this list is in english, try posting in english =) -- |...| | _ _|Victor Medina M | |\ \ \| | _ \ / \ |Linux - Java - MySQL | | \ \ \ _| | |_) / _ \ |Dpto. Sistemas - Ferreteria EPA | | / / / |___| __/ ___ \ |[EMAIL PROTECTED] | |/_/_/|_|_| /_/ \_\|Tel: +58-241-8507325 - ext. 325 | ||Cel: +58-412-8859934 | ||geek by nature - linux by choice | |...|
API C
Hello, I made a compilation test, to see how it works, and already the first beginner problems came. #include sys/time.h #include stdio.h #include mysql.h int main(int argc, char *argv[]){ MYSQL_RES *result; MYSQL_ROW row; MYSQL *connection, mysql; int state; /* Conectando com MySQL */ printf(Iniciando o MySQL!!!); mysql_init(mysql); connection = mysql_real_connect(mysql,localhost,root,mysql,banco,0,NULL,0); if (connection == NULL){ printf(Não conectado!!!); printf(mysql_error(mysql)); return 1; } /* Close connection */ mysql_close(connection); printf(\nSaindo! \n); } When I try to compile, with the command below, he says that cannot find the - lsocket. Is the command correct? Which the problem? [EMAIL PROTECTED] teste]# gcc -L/usr/local/mysql/lib/mysql -I/usr/local/mysql/include/mysql -o teste teste.c -lmysqlclient -lnsl -lsocket /usr/bin/ld: cannot find -lsocket collect2: ld returned 1 exit status [EMAIL PROTECTED] teste]# Removing the command - lsocket, the compilation is executed, however when I will execute, appears the message, as shown below. [EMAIL PROTECTED] teste]# gcc -L/usr/local/mysql/lib/mysql -I/usr/local/mysql/include/mysql -o teste teste.c -lmysqlclient -lnsl [EMAIL PROTECTED] teste]# [EMAIL PROTECTED] teste]# ./teste ./teste: error while loading shared libraries: libmysqlclient.so.14: cannot open shared object file: No such file or directory [EMAIL PROTECTED] teste]# what this happening? Volnei Galbino. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: API C
Hi Galbino is the MySQL-client and MySQL-devel package instaled Regards Luiz www.xharbour.com.br -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: API C
Hi Volnei, Under Linux you do not need the -lsocket. (If I recall correctly that is for SUN Solaris but I might be wrong) As for your run-time error, the DLL libmysqlclient.so is not in the library path. Either modify /etc/ld.so.conf to include where is that library (it seems to be /usr/local/mysql/lib/mysql from your gcc command line). In which case do not forget to run ldconfig -n OR Set the environment variable LD_LIBRARY_PATH to where the library is installed (again from your gcc command line it seems to be /usr/local/mysql/lib/mysql). Regards, Bernard On Wednesday 25 February 2004 09:37, Galbino wrote: Hello, I made a compilation test, to see how it works, and already the first beginner problems came. #include sys/time.h #include stdio.h #include mysql.h int main(int argc, char *argv[]){ MYSQL_RES *result; MYSQL_ROW row; MYSQL *connection, mysql; int state; /* Conectando com MySQL */ printf(Iniciando o MySQL!!!); mysql_init(mysql); connection = mysql_real_connect(mysql,localhost,root,mysql,banco,0,NULL,0); if (connection == NULL){ printf(Não conectado!!!); printf(mysql_error(mysql)); return 1; } /* Close connection */ mysql_close(connection); printf(\nSaindo! \n); } When I try to compile, with the command below, he says that cannot find the - lsocket. Is the command correct? Which the problem? [EMAIL PROTECTED] teste]# gcc -L/usr/local/mysql/lib/mysql -I/usr/local/mysql/include/mysql -o teste teste.c -lmysqlclient -lnsl -lsocket /usr/bin/ld: cannot find -lsocket collect2: ld returned 1 exit status [EMAIL PROTECTED] teste]# Removing the command - lsocket, the compilation is executed, however when I will execute, appears the message, as shown below. [EMAIL PROTECTED] teste]# gcc -L/usr/local/mysql/lib/mysql -I/usr/local/mysql/include/mysql -o teste teste.c -lmysqlclient -lnsl [EMAIL PROTECTED] teste]# [EMAIL PROTECTED] teste]# ./teste ./teste: error while loading shared libraries: libmysqlclient.so.14: cannot open shared object file: No such file or directory [EMAIL PROTECTED] teste]# what this happening? Volnei Galbino. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Update through API C
Hi, I've wrote this lines of code mysql_query(mp_cnn, UPDATE pg_info SET x=3, y=5 WHERE pg_id=0); but when I controll my db the record isn't change. Why? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Update through API C
Hi, I've wrote this lines of code mysql_query(mp_cnn, UPDATE pg_info SET x=3, y=5 WHERE pg_id=0); but when I controll my db the record isn't change. Why? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Update through API C
mmm I've deleted a select before the update function -- SELECT -- // usiamo mysql_real_query al posto di mysql_query xche' la prima e' piu' veloce if (mysql_real_query(mp_cnn, c_query, strlen(c_query)) != 0) return (-1); else { mp_res = mysql_use_result(mp_cnn); // resultset row = mysql_fetch_row(mp_res); // analizzo la riga e salvo i dati dentro row } -- -- UPDATE -- if (mysql_real_query(mp_cnn, c_query, strlen(c_query)) != 0) return (-1); else cout mysql_affected_rows(mp_cnn) endl; // mi ritorna quante righe ho modificato cout c_query endl; return (0); -- and now the update is right... o-: -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL API C leaks
gerald_clark wrote: Andreï V. FOMITCHEV wrote: Hello everyone, I use Valgrind to check my programs and this last found leaks in libmysqlclient.so. My code is simple: char * requete = SELECT * FROM NOM_TABLE_1; Looks like a misplaced '' . lol #define NOM_TABLE_1 files The problem is a function get_charset() used in libmysqlclient.so This function defined in mysql-4.0.14/include/my_sys.h:213:extern CHARSET_INFO *get_charset(uint cs_number, myf flags); mysql-4.0.14/mysys/charset.c:375:CHARSET_INFO *get_charset(uint cs_number, myf flags) If you use Vagrind (valgrind -v --leak-check=yes --show-reachable=yes) for checking your program, does it find errors or leaks? MYSQL * mysql = mysql_init((MYSQL *)NULL); MYSQL_RES * mysql_resultat; MYSQL_ROW mysql_ligne; if(mysql == NULL) { return(-1); } if (!mysql_real_connect(mysql, ADRESSE_BDD, LOGIN_BDD, PASSWORD_BDD, NOM_BDD, 0, NULL, 0)) { fprintf(stderr, Impossible de se connecter au serveur %s\n Error=%s\n, ADRESSE_BDD, mysql_error(mysql)); mysql_close(mysql); return(-1); } if(mysql_query(mysql, requete) != 0) { fprintf(stderr, Impossible d'executer la requête %s\nError=%s\n, requete, mysql_error(mysql)); } else { mysql_resultat = mysql_store_result(mysql); if(mysql_resultat != NULL) { for(i = 0; i mysql_resultat-row_count; i++) { mysql_ligne = mysql_fetch_row(mysql_resultat); // traitement } } mysql_free_result(mysql_resultat); } mysql_close(mysql); Result of Valgrind: ==3691== 64 bytes in 1 blocks are still reachable in loss record 1 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x40254A2D: my_malloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025A218: init_dynamic_array (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AE96: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) ==3691== ==3691== 4088 bytes in 1 blocks are still reachable in loss record 2 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x4025A64C: my_once_alloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025ACB0: read_charset_index (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AEAB: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) Is it a BUG or did I something? Best regards, -- Andreï V. FOMITCHEV [Quand faut-il arrêter l'informatique] Software RD Engineer [Lorsque, dans un kilo, on trouve 1024 grammes] Odixion SAS, FRANCE -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL API C leaks
Hello everyone, I use Valgrind to check my programs and this last found leaks in libmysqlclient.so. My code is simple: char * requete = SELECT * FROM NOM_TABLE_1; MYSQL * mysql = mysql_init((MYSQL *)NULL); MYSQL_RES * mysql_resultat; MYSQL_ROW mysql_ligne; if(mysql == NULL) { return(-1); } if (!mysql_real_connect(mysql, ADRESSE_BDD, LOGIN_BDD, PASSWORD_BDD, NOM_BDD, 0, NULL, 0)) { fprintf(stderr, Impossible de se connecter au serveur %s\n Error=%s\n, ADRESSE_BDD, mysql_error(mysql)); mysql_close(mysql); return(-1); } if(mysql_query(mysql, requete) != 0) { fprintf(stderr, Impossible d'executer la requête %s\nError=%s\n, requete, mysql_error(mysql)); } else { mysql_resultat = mysql_store_result(mysql); if(mysql_resultat != NULL) { for(i = 0; i mysql_resultat-row_count; i++) { mysql_ligne = mysql_fetch_row(mysql_resultat); // traitement } } mysql_free_result(mysql_resultat); } mysql_close(mysql); Result of Valgrind: ==3691== 64 bytes in 1 blocks are still reachable in loss record 1 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x40254A2D: my_malloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025A218: init_dynamic_array (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AE96: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) ==3691== ==3691== 4088 bytes in 1 blocks are still reachable in loss record 2 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x4025A64C: my_once_alloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025ACB0: read_charset_index (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AEAB: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) Is it a BUG or did I something? Best regards, -- Andreï V. FOMITCHEV [Quand faut-il arrêter l'informatique] Software RD Engineer [Lorsque, dans un kilo, on trouve 1024 grammes] Odixion SAS, FRANCE -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL API C leaks
Andreï V. FOMITCHEV wrote: Hello everyone, I use Valgrind to check my programs and this last found leaks in libmysqlclient.so. My code is simple: char * requete = SELECT * FROM NOM_TABLE_1; Looks like a misplaced '' . MYSQL * mysql = mysql_init((MYSQL *)NULL); MYSQL_RES * mysql_resultat; MYSQL_ROW mysql_ligne; if(mysql == NULL) { return(-1); } if (!mysql_real_connect(mysql, ADRESSE_BDD, LOGIN_BDD, PASSWORD_BDD, NOM_BDD, 0, NULL, 0)) { fprintf(stderr, Impossible de se connecter au serveur %s\n Error=%s\n, ADRESSE_BDD, mysql_error(mysql)); mysql_close(mysql); return(-1); } if(mysql_query(mysql, requete) != 0) { fprintf(stderr, Impossible d'executer la requête %s\nError=%s\n, requete, mysql_error(mysql)); } else { mysql_resultat = mysql_store_result(mysql); if(mysql_resultat != NULL) { for(i = 0; i mysql_resultat-row_count; i++) { mysql_ligne = mysql_fetch_row(mysql_resultat); // traitement } } mysql_free_result(mysql_resultat); } mysql_close(mysql); Result of Valgrind: ==3691== 64 bytes in 1 blocks are still reachable in loss record 1 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x40254A2D: my_malloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025A218: init_dynamic_array (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AE96: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) ==3691== ==3691== 4088 bytes in 1 blocks are still reachable in loss record 2 of 2 ==3691== at 0x4015E310: malloc (vg_clientfuncs.c:103) ==3691== by 0x4025A64C: my_once_alloc (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025ACB0: read_charset_index (in /usr/lib/mysql/libmysqlclient.so.10.0.0) ==3691== by 0x4025AEAB: init_available_charsets (in /usr/lib/mysql/ libmysqlclient.so.10.0.0) Is it a BUG or did I something? Best regards, -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Problems with the api c++
Tuomas Heroja wrote: I have red hat 8.0, gcc-3.2-7, gcc-c++-3.2-7 and mysql++-1.7.9-3.rh8x.i386.rpm. When I use the command g++ -I/usr/include/sqlplus myfirstdatabaseprogram.cpp, I get several basic errors concerning the include file sqlplus.hh Right now, MySQL++ isn't very well tuned for modern C++ environments like g++ 3.x. The best thing to do is to download the source code, apply the two GCC 3.x patches. You may also wish to search out my custom.pl patch on the MySQL++ mailing list or ask me to email it to you, because that kills a whole bunch of warnings when building custom-macros.hh with g++ 3.x. (I tried to post it to the list but the mailing list software rejects messages with attachments.) With these patches applied, build and install the library. You'll get some warnings, but don't worry about them. Next, when building code that uses the library, use the -Wno-deprecated flag to suppress warnings about uses of old pre-Standard header names and such. With all of this in place, you shouldn't be getting any warnings any more. If you do, send the compiler output to the list so that those interested in fixing the problem have enough information to do so. The deprecated C++ warnings will be fixed in 1.8.0, but that won't be out for a while yet. You should send such messages to the MySQL++ mailing list, by the way. It's a very low-volume list, so don't worry about subscribing to it. - 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
Problems with the api c++
Hello! I have problems in compiling my program which uses the mysql++-library. I have red hat 8.0, gcc-3.2-7, gcc-c++-3.2-7 and mysql++-1.7.9-3.rh8x.i386.rpm. When I use the command g++ -I/usr/include/sqlplus myfirstdatabaseprogram.cpp, I get several basic errors concerning the include file sqlplus.hh (for example, semicolon is missing from exceptions.hh 134 and so on). Could somebody tell me what would be the solution. I have istalled the mysql++- package with rpm -i -commmand. Tuomas Heroja [EMAIL PROTECTED] - 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: How to insert an Image in a table with libmysqlclient and API C ?
Hi. On Fri 2003-01-31 at 18:56:19 +0100, [EMAIL PROTECTED] wrote: Hi all, my problem is the following, it's possible to insert an image in a table with the libmysqlclient ? Yes. My language is C i'm working with GNU/Linux Bye, Benjamin. PS: In explanation: if you want a more specific answer, you have to provide more details... MySQL doesn't care whether you store text or binary data, so what is the problem? -- [EMAIL PROTECTED] - 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
How to insert an Image in a table with libmysqlclient and API C ?
Hi all, my problem is the following, it's possible to insert an image in a table with the libmysqlclient ? My language is C i'm working with GNU/Linux Best Regards, Stephane Wirtel - 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