Deploying a MySQL application

2012-07-02 Thread Miguel Cardenas
Hello

After days of tests with different configurations for my VC++ project,
finally I was able to run it using both Release and Debug versions
with MySQL... now I have a few doubts on the application deployment...

1. The library was linked DINAMICALLY (DLL) since I want the MySQL
code independent from my binary (not linked statically), but my doubt
is if it would be a problem that the different target computers may
cause problems if the version of the installed MySQL is different...
In Linux I have no problem while the installed MySQL library is the
same version or newer, but would it cause a problem in windows if the
version is not the same that was used to build my app? or for example
if the MySQL is upgraded and the version changes for a new one?

2. It may be possible that the target machine is not a server, just a
client, so the MySQL may not be installed... is it allowed to include
the libmysql.* files into my installation package? After all, if I
link the static version the library is still included inside the
binary (executable) file, but don't know if it is okay to include the
DLL/LIB files when linked dynamically.

3. If it is allowed to include the library as external DLL, if the
target machine already has installed MySQL, would it interfer if I
install the DLL? The windows PATH has already appended
C:\...\MySQL\lib so I think that would not affect since the system
would find first the MySQL installation library (anything appended to
the path is appended at the end, so my installed files would be after
the MySQL in the PATH)... or I should make it optional at install time
depending if the user has or has not MySQL installed?

Thanks for your comments

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



Unhandled exception at 0x51716970 in MSQ.exe: 0xC0000005: Access violation reading location 0x00000000.

2012-06-30 Thread Miguel Cardenas
Hello

I have a simple application that uses MySQL C API that works fine in
release mode, but when run in debug mode it crashes:

Unhandled exception at 0x51716970 in MSQ.exe: 0xC005: Access
violation reading location 0x.

and don't know what can be the problem.

The application was built using VC++ 2010 Express and MySQL community
server 5.5, it consists of 2 parts

1. A DLL library with common functions to all my applications, it
contains the MySQL code (using the C API)

2. The application that connects to MySQL using my library that
invokes the MySQL C API

The library works fine under Linux and Windows but only in release
mode, if I use debug mode it simply crashes... never has worked in
debug mode, today with VC++ 2010 nor before when used VC++ 2008...

Fortunately the library works fine and has been exhaustively debugged,
so it runs perfectly under Linux and Wiindows... The problem is when I
try to debug an application that uses the library AND CALLS MYSQL
FUNCTIONS, it always crashes when executing any MySQL function by
access violation.

My applications always run in both Linux and Windows (that's why I use
my library that has been developed to compile in both systems, and Qt
for graphic apps) and are debugged under Linux since they're unable to
run in debug mode under Windows...

My configuration:

MY LIBRARY DLL
---
(RELEASE)
- Configuration: dynamic library (dll)
- Code generation: /MD (multithread dll)
- Input libs: libmysql.lib
- Ignore libs: LIBCMT.lib (otherwise fails link)
- Debug: No
(DEBUG)
- Configuration: dynamic library (dll)
- Code generation: /MDd (multithread dll debug)
- Input libs: libmysql.lib (also tested with mysqlclient.lib)
- Ignore libs: LIBCMT.lib (otherwise fails link)
- Debug: Yes

MY APPLICATION in debug mode
---
- Configuration: dynamic library (dll)
- Code generation: /MTd (multithread debug) --- (/MT for release)
- Input libs: libmysql.lib
- Ignore libs: -
- Debug: Yes

I have tried lots of configurations but simply does not run in debug
mode... I must say that all my library functions work in both
release.debug mode, just the mysql functions crash in debug mode...

What can I do or where can I find the right configuration to use it in
debug mode?


Thanks a lot!

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



Unresolved symbols with mysqlclient in DEBUG mode using VC++ 2010 Express

2012-06-19 Thread Miguel Cardenas
Hello friends

I'm back to MySQL programming using the C API... it works fine when I
compile using the RELEASE mode and C:\Program Files (x86)\MySQL\MySQL
Server 5.5\lib but if I choose the DEBUG mode and C:\Program Files
(x86)\MySQL\MySQL Server 5.5\lib\debug it fails at link time:

1mysqlclient.lib(dbug.obj) : error LNK2019: unresolved external
symbol __CrtSetReportFile referenced in function _DbugExit
1mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
symbol __CrtSetReportFile
1mysqlclient.lib(dbug.obj) : error LNK2019: unresolved external
symbol __CrtSetReportMode referenced in function _DbugExit
1mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
symbol __CrtSetReportMode
1mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external
symbol __CrtDumpMemoryLeaks referenced in function _my_end
1mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external
symbol __CrtCheckMemory referenced in function _my_end

I read some posts that found in google about this error and found that
it should be used the dynamic library libmysql instead of the static
mysqlclient when debugging, but the lib\debug directory contains just
the static library mysqlclient...

Do I have to include an aditional library so the symbols are resolved
correctly? The release mode works perfect and the application runs
fine in that way only...

Thanks,
Miguel

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



Re: Unresolved symbols with mysqlclient in DEBUG mode using VC++ 2010 Express

2012-06-19 Thread Miguel Cardenas
Hello Lars

After hours of testing different project configurations, finally I was
able to compile with debug mode... still pending the test of
debugging, but just created the DLL (it was a library that I'm
developing) without errors...

The configurations I used (VC++ 2010 Express) were:

RELEASE:
- Runtime: /MT (static threaded)
- Library: mysqlclient.lib (...\mysql\lib)
- Ignore library: LIBCMTD.lib (without this does not link the release)
- Debug: NO

RELEASE:
- Runtime: /MTd (static threaded debug)
- Library: mysqlclient.lib (...\mysql\lib\debug)
- Ignore library: empty (now allowed LIBCMTD.lib or does not link the debug)
- Debug: YES

If I try to use /MD or /MDd does not compile, if it works with /MT(d)
will leave it that way XD

I'm going to test the debug version (one thing is that compiled and
another one that works =) and if get stuck again will post it...

Thanks for your response

P.D. One last question, is it right to use ...\mysql\lib\debug
directory for debug version? or it should be set to ...\mysql\lib
in both cases and the linker chooses the right one? If compiling in
debug mode it works with both ...\mysql\lib and
...\mysql\lib\debug in DEBUG mode... maybe running the debugger will
not work with the lib, still have to test, but at least it compiles
with no errors... can you comment something about this?

On Tue, Jun 19, 2012 at 2:24 PM, Lars Nilsson chamael...@gmail.com wrote:
 On Tue, Jun 19, 2012 at 2:48 AM, Miguel Cardenas renit...@gmail.com wrote:
 Hello friends
 1mysqlclient.lib(dbug.obj) : error LNK2019: unresolved external
 symbol __CrtSetReportFile referenced in function _DbugExit
 1mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
 symbol __CrtSetReportFile
 1mysqlclient.lib(dbug.obj) : error LNK2019: unresolved external
 symbol __CrtSetReportMode referenced in function _DbugExit
 1mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
 symbol __CrtSetReportMode
 1mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external
 symbol __CrtDumpMemoryLeaks referenced in function _my_end
 1mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external
 symbol __CrtCheckMemory referenced in function _my_end

 Do I have to include an aditional library so the symbols are resolved
 correctly? The release mode works perfect and the application runs
 fine in that way only...

 The missing functions should be provided by the Visual Studio debug
 runtime library. Are all source files in your own code compiled and
 program linked with one, and only one, of the flags /MDd (dynamic
 linking) or /MTd (static linking)?

 Lars Nilsson

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



Emergency backup from *.frm *.MYD *.MYI files

2012-06-08 Thread Miguel Cardenas
Hello

My linux system died due a bad system driver and it does not boot
ANYMORE, I am backing up my data files to restore a previous worlking
backup of the whole system that DOES NOT INCLUDE THE DATABASES...

I'm still backing up and will take some time before restore the
system, in the mean time I want to know if I can restore the databases
from the *.frm *.MYD and *.MYI files, maybe creating the databases
again and replace them with the old data files?

Or please tell me what procedure should I follow to backup my
databases FROM THE FILESYSTEM since I have not access to the mysql, I
am using a live CD to access the files...

Thanks for your help!

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



Uninstalling MySQL 6.x from Windows

2010-06-29 Thread Miguel Cardenas
Hello

I have an old windows installation with MySQL 6.x and want to remove it so I
can install latest version 5.1.48 but I tried once before with another
computer and newer installation never worked, had to reinstall whole windows
to make a new clean installation.

How can I remove completely version 6.x so it does not affect the new
installation? The problem with uninstall and new installation was that the
MySQL SERVICE was unable to be installed/activated for some reason, and if I
tried to run it manually the same error was produced, unable to start
service...

Thanks for your help


MySQL application development LIBS

2010-02-13 Thread Miguel Cardenas
Hello

I have a small Windows application linked to the MySQL development libraries
and have to run in on another computer, do I have to copy the DLL/LIB files
or are they already static linked to the application? The other computer has
no MySQL installed, and the application will run only as client to access my
web server to perform some simple tasks.

I have the Win32 binary .ZIP (not compiled)... so it has the already built
libraries as they came in the package...


And a second question... currently I have MySQL 6.0 on my laptop, since it
is deprecated, how can I uninstall version 6 and then install latest 5.x?
Some day in the past I tried simply to uninstall and reinstall another
version, but the previous files didn't get removed and was unable to make it
work again since the new installation failed due the older remaining
files... what is the correct way to completely remove MySQL to install a
different and clean version? Note that in the past when I tried the new
installation it aborted, or it succeeded but never could install it as
service again and had to reinstall the wole system to make a brand new
installation...


Thanks for your help!!!


LIMIT/OFFSET to paginate results

2009-11-23 Thread Miguel Cardenas
Hello list :)

I am developing an application that will show records in paginated
documents, i.e. 10 records per page

Lets supose this row structure

MyTable
ID(autoincrement)   SectionID   Name   Description

The ID is automatic autoincrement for unique records, the SectionID is to
separate items into different sections.

If I query a particular SectionID rows it should return all those rows.

If I use LIMIT x,10 it should return 10 rows beginning at record #x, but
my doubt is:

Does the OFFSET x assumes its value to be #x number of consecutive rows, or
it is relative to the query results?

For example

ID   SID  name   description
--
01   01   nameA   descriptionA
02   02   nameB   descriptionB
03   01   nameC   descriptionC
04   02   nameD   descriptionD
05   02   nameE   descriptionE
06   01   nameF   descriptionF
07   02   nameG   descriptionG
08   01   nameH   descriptionH
09   02   nameI   descriptionI
10   02   nameJ   descriptionJ
--

If I do
   SELECT name from MyTable SID where SID='02' LIMIT 1,2 (offset 1, 2
elements)
it should return: nameB, nameD

theni f I do
   SELECT name from MyTable SID where SID='02' LIMIT 3,2 (offset 3, 2
elements)
it should return: nameE, nameG

and if I do
   SELECT name from MyTable SID where SID='02' LIMIT 3,2 (offset 5, 2
elements)
it should return: nameI, nameJ

Is it correct? My doubt is if the OFFSET is relative to the SELECT results
(to ignore the # first result rows) that match the condition SID='02' only,
to show 2 by 2 records (or N by N)...

Thanks for your help


Removing MySQL to install new version

2009-11-12 Thread Miguel Cardenas
Hello

I noticed that mysql 6 alpha is no longer available so I want to
remove it from my laptop and install the latest 5.x version. I have
just restored my Linux system image so my database is clean and empty
and is a good moment to do it.

My question is, how can I remove it completely from my disk to make a
new clean installation? The current installation is from source code
in /usr/local/mysql and as far as I know everything is under this
directory except /etc/my.cnf

Is it enough to delete that directory and file?

Thanks

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



Linking mysqlclient to a windows program

2009-03-11 Thread Miguel Cardenas
Hello

I have configured my VC++ to link my programs with mysqlclient, but now am
trying a program with Qt that is compiled using make from the command
line, is it enough to add mysqlclient.lib to my makefile library
configuration? I mean, is it enough to add the path to the header files and
mysqlclient? in *nix I use mysql_config with --libs and --include and the
output is inserted during the make process, but in windows I see only the
header files and the lib files...

Thanks!


Re: VC++ 2008 / MySQL debug / Unhandled exception

2009-01-14 Thread Miguel Cardenas
Hi

I tested with both release and debug versions and the problem is the same,
it fails when calling

mysql_real_connect()
   shared memory request function
  strcpy() asm code access violation to 0x

Regards,
Miguel

On Sun, Jan 11, 2009 at 9:57 AM, Patrick Sherrill patr...@coconet.comwrote:

 I seem to recall the issue with the debug library, but don't recall the
 fix. Do you get the same permissions (access) error with the release
 library?
 Pat...

 - Original Message - From: Miguel Cardenas renit...@gmail.com
 To: mysql@lists.mysql.com
 Sent: Saturday, January 10, 2009 10:22 AM
 Subject: VC++ 2008 / MySQL debug / Unhandled exception



  Hello list

 I have a problem debugging a program that uses MySQL. The program itself
 does not have problems, it runs perfectly when run in the console (command
 prompt), but if it is executed inside the Visual C++ 2008 debugger it
 causes
 an error:

 Unhandled exception at 0x004b1560 in MyProgram.exe: 0xC005: Access
 violation reading location 0x

 when it reaches mysql_real_connect() I'm using mysql-6.0.8-alpha-win32
 binary with setup.exe installer.

 Note that I don't try to enter inside mysql functions, even if no
 breakpoints are setup and I let the program to run freely it aborts there
 with the unhandled exception.

 My VC++ 2008 configuration is this:

 
 Includes:
 C:\Program Files\MySQL\MySQL Server 6.0\include

 Libraries:
 C:\Program Files\MySQL\MySQL Server 6.0\lib\debug

 Code generation:
 Multi-threaded /MT

 Precompiled headers: NO

 Aditional dependencies:
 wsock32.lib mysqlclient.lib libmysql.lib mysys.lib

 Ignore specific library: (as found in a forum post)
 LIBCMTD.lib

 Debugging: YES /DEBUG
 

 I based my configuration on this post for VC++ 6.0
 http://forums.mysql.com/read.php?45,49606,49606#msg-49606

 I guess it may be due to the ignored LIBCMTD.lib (debug version of MT?),
 but
 if don't ignore it the compilation fails at link time with lots of
 redefined
 symbols.

 My concrete question: is there something wrong with the configuration
 shown
 in that post that I adapted to VC++ 2008? are VC++ programs with MySQL
 unable to run inside VC++ debugger? I don't want to debut my MySQL code it
 is working already for *NIX, but there are other parts of the program that
 may require debug and it aborts when calling a mysql function.

 Thanks for any comment or help





Re: VC++ 2008 / MySQL debug / Unhandled exception

2009-01-14 Thread Miguel Cardenas
Hi

I'm using /MT (LIBCMT.lib?) and it is multi-threaded since all my
multi-thread code is working. LIBCMTD.lib is ignored because it is indicated
in a post at MySQL forums 
http://forums.mysql.com/read.php?45,49606,49606#msg-49606; and anyway
applications do not compile if not ignored because lots of duplicated
symbols at link time.

The issue is like this (as accurate as I remember) according the debugger
call stack:

1) Call mysql_real_connect()

2) mysql_real_connect() calls a shared memory request function

3) the shared memory request fails in a internal strcpy() (asm, not source
available) because a memory violation trying to acces 0x

Note these conditions:
- The program fails inside VC++ 2008 express debug session
- The program runs perfect without debug session or called directly by user
- I'm programming inside VirtualBox/WinXP

Now I don't know if this problem is related to the VC++ debugger that fails
with certain condition of the MySQL client library or the VirtualBox manages
shared memory in a different way than a real computer.

I emphasize that my program works perfect with Linux, FreeBSD and Solaris,
even Windows if not run in a debug session, and the problem arises inside
the MySQL library, not in the MySQL code but inside the shared memory
function it calls.

I hope this could help to get an idea

Regards,
Miguel


VC++ 2008 / MySQL debug / Unhandled exception

2009-01-10 Thread Miguel Cardenas
Hello list

I have a problem debugging a program that uses MySQL. The program itself
does not have problems, it runs perfectly when run in the console (command
prompt), but if it is executed inside the Visual C++ 2008 debugger it causes
an error:

Unhandled exception at 0x004b1560 in MyProgram.exe: 0xC005: Access
violation reading location 0x

when it reaches mysql_real_connect() I'm using mysql-6.0.8-alpha-win32
binary with setup.exe installer.

Note that I don't try to enter inside mysql functions, even if no
breakpoints are setup and I let the program to run freely it aborts there
with the unhandled exception.

My VC++ 2008 configuration is this:


Includes:
C:\Program Files\MySQL\MySQL Server 6.0\include

Libraries:
C:\Program Files\MySQL\MySQL Server 6.0\lib\debug

Code generation:
Multi-threaded /MT

Precompiled headers: NO

Aditional dependencies:
wsock32.lib mysqlclient.lib libmysql.lib mysys.lib

Ignore specific library: (as found in a forum post)
LIBCMTD.lib

Debugging: YES /DEBUG


I based my configuration on this post for VC++ 6.0
http://forums.mysql.com/read.php?45,49606,49606#msg-49606

I guess it may be due to the ignored LIBCMTD.lib (debug version of MT?), but
if don't ignore it the compilation fails at link time with lots of redefined
symbols.

My concrete question: is there something wrong with the configuration shown
in that post that I adapted to VC++ 2008? are VC++ programs with MySQL
unable to run inside VC++ debugger? I don't want to debut my MySQL code it
is working already for *NIX, but there are other parts of the program that
may require debug and it aborts when calling a mysql function.

Thanks for any comment or help


MySQL programming from *NIX to Windows

2008-12-14 Thread Miguel Cardenas
Hi list

I am porting a *NIX MySQL application from Linux to Windows, it uses the C
API (header files and libraries) that comes with the distribution package.
My program is already working on Windows and just have to add the last part
that is the MySQL support but have two doubts:

The Windows zip/Setup.exe package should be fine (or not?) since it has the
header files and libraries, found a reference in the MySQL forums about
making it work with Visual C++ 6, have just download Visual C++ 2008 express
and I guess it should be fine to follow the same configuration process to
setup the include header/libraries paths.

My doubt is because never have used it on windows and have these questions:

1. In Linux (and *NIX in general) I use 'mysql_config' to setup options and
directories so the application links dinamically to mysql*.so libraries, in
the case of windows just have to include the mysqlclient.lib libmysql.lib
etc. BUT... will the program be linked dinamically or statically to MySQL
client libraries? What if I need them to be linked statically to the
program?

2. If it is a simple MySQL client and if it is possible to statically link
the client libraries, do MySQL need  to be installed to allow the program to
work? or it is enough if everything is statically linked inside the program
and it is not required to install MySQL on every machine where the program
runs?

3. If it is really a must to have installed MySQL on every windows computer,
is it enough having it installed or should I compile the program in every
station?

4. In the case of question 3, if MySQL is upgraded in the future, do the
program requires to be recompiled with the new version?

I still don't make the installation, just download MySQL and asked you
before doing anything...

Thanks for any help,
Miguel


MySQL 6.0.4: 'RESTORE TABLE' *nor* 'RESTORE DATABASE' available

2008-06-26 Thread Miguel Cardenas
Hi

I've just reinstalled my system and used the oportunity to get the latest
MySQL, so I got 6.0.4 version and installed it.

The problem is that want to restore some tables but 'RESTORE TABLE' nor
'RESTORE DATABASE' (as specified in the manual online) are not available,
'BACKUP xxx' are neither available...

What can I do? the console terminal throws an error that should verify the
syntax for my version :S

Thanks for any help


BACKUP DATABASE * TO '/tmp/all.backup'; - DOES NOT WORK (6.0.4-alpha)

2008-06-26 Thread Miguel Cardenas
Hello

Hello

I have troubles with 'BACKUP DATABASE', I thought it was problem of syntax,
but have tried even the samples in
http://dev.mysql.com/doc/refman/6.0/en/backup-database.html and the command
is not recognized

$ mysql --version
mysql Ver 14.14 Distrib 6.0.4-alpha, for pc-linux-gnu (i686) using EditLine
wrapper

mysql BACKUP DATABASE * TO '/tmp/all.backup';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'BACKUP DATABASE * TO '/tmp/all.backup'' at line 1

Have tried 'BACKUP TABLE' but does not work either and documentation tells
it has been removed...

Any idea of what is going on? I've used and installed from sources MySQL
since version 3.xx so it is not an installation problem, tried the
'./configure --help' to see if there are options related to the 'BACKUP...'
command but found nothing, the most related option was one to enable the
'LOAD DATA LOCAL...', or, does

--enable-local-infile Enable LOAD DATA LOCAL INFILE (default: disabled)

require to be activated? I never activate it and 'BACKUP TABLE' used to work
fine, so 'BACKUP DATABASE' should too, isn't it? or should I recompile with
that option enabled? anyway I've read all the installation and backup
documentation and does not mention it is requiered to make BACKUP DATABASE
work...

Regards


Selecting rows by DATE ranges

2007-06-23 Thread Miguel Cardenas
Hello list

I found a little problem with an application am developing, in particular 
creating reports by DATE ranges.

Examples:

select ... where date2007-01-01;
returns all records where date is greater (and equal inclusive) to 2007-01-01

select ... where date=2007-01-01;
returns all records where date is greater/equal to 2007-01-01

the  and = have the same effect

select ... where date2007-01-01 and date2007-01-20;
returns all records where date is greater/equal to 2007-01-01 and less 
than 2007-01-20
*** DOES NOT RETURN RECORDS FROM DAY *20*

select ... where date2007-01-01 and date=2007-01-20;
returns all records where date is greater/equal to 2007-01-01 and less 
than 2007-01-20 although I'm using =
*** DOES NOT RETURN RECORDS FROM DAY *20*

My doubts are:

1. how can I retrieve rows with a date... NOT INCLUDING the day of the 
specified date, I mean apply a strict GREATHER THAN

2. how can I retrieve rows with date=... INCLUDING the day of the specified 
date. currently I have to do a date=date1 and date=date2+1day

I need to retrieve rows in this way

dateX
date=X
dateX
date=X
dateX and dateY
date=X and dateY
date=X and date=Y
dateX and date=Y

and so... didn't find a function to specify ranges of dates and the LESS 
THAN/EQUAL operator does not include the last day, so my reports with = 
are done by adding one day but don't like to use it this way since it could 
be confusing and generate errors on reports.

Thanks for any comment,
Miguel

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



Avoiding TIMESTAMP

2007-05-26 Thread Miguel Cardenas
Hello list

I need to solve a little problem but don't mind how, maybe you could suggest 
something.

I have a database which registers payments, records have a AUTO_INCREMENT 
field to assign a unique consecutive number associated to every payment, some 
other fields that store the amount, type of payment, etc. and another 
TIMESTAMP field that stores the date and time.

One of the fields contains the username for who received the payment and it is 
stored automatically by the software, so I can know who processed the 
payment, when, and all related information...

In the first stage of the system it worked only for 'localhost' and a unique 
test user, so all my current payments have registered that user. Now the 
system is able to select a host and a user, so I want to update the test user 
username for a real user, the database has already some records and would not 
like to reenter them by hand logging in as a real user.

My problem is this... if I update the username field, the TIMESTAMP updates 
the date and time of the payment to the current values and the payment 
date/time does not coincide then...

Is there a way to update only that one field avoiding the TIMESTAMP update? 
One way is to update both fields, specifying the user and the same date/time 
by hand, but comes a new problem, payments have different date and time, so I 
would need to create a small routine to update records one by one with its 
particular date/time, but maybe there is another way to do it with a single 
command...

Thanks for any comment


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



Re: Problem with GRANT ... 'user'@'%'

2007-05-21 Thread Miguel Cardenas
 If you don't specify a hostname in SHOW GRANTS, '%' is assumed.  My mistake
 for not telling you this before.  If you enable networking, and connect
 with

   mysql -h 127.0.0.1

 instead of

   mysql -h localhost

Well, in fact 127.0.0.1 and localhost produce the same effect but by using the 
ip address of the server works fine :D

Somebody has just sent a comment saying that localhost and a normal ip address 
work different, and in fact was right, now am able to connect to the ip 
instead of localhost...

Thanks for all your comments

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



Re: Problem with GRANT ... 'user'@'%'

2007-05-21 Thread Miguel Cardenas
 Localhost is indeed a special value that isn't include in '%'. It's a
 feature not a bug ;)

 Regards,

Bingo! That was the point! If i connect to the server ip or server name it 
works perfectly, but if I try to connect to localhost it fails unless I add a 
new user specific to localhost :D

Thanks for your comments

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



Re: Problem with GRANT ... 'user'@'%'

2007-05-21 Thread Miguel Cardenas
 Hm, I didn't know that!  I thought it was only a special value to the
 client tools, which I know will try to connect via socket on UNIX machines
 when they see 'localhost' but will try to connect via TCP/IP when they see
 '127.0.0.1'. Thanks for pointing this out!

 Baron

In fact that was the problem, connecting to localhost didn't work unless I add 
specifically localhost... If tried with the host ip or name worked perfectly, 
so your comment had sense and solved it all...

Just one comment, 127.0.0.1 had the same effect as localhost, I should connect 
to the specific host ip or name.

Thanks for all your comments

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



Re: Problem with GRANT ... 'user'@'%'

2007-05-20 Thread Miguel Cardenas
 Remember to quote the user and host carefully.  So,

The quoting is okay, I tested again

 If you have doubts about what you actually granted, do this:
 SHOW GRANTS FOR 'user'

I've sent this command:
grant all on mydatabase.* to 'myuser'@'%' identified by 'mypass';

Then tested the show grants:
show grants for 'myuser';
---
Grants for [EMAIL PROTECTED] :
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY PASSWORD '...'
GRANT ALL PRIVILEGES ON `mydatabase`.* TO 'myuser'@'%'

so it appears that user is added correctly, but when I try to connect get this 
error again:

ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using 
password: YES)

 Oh, one more place to look is at the server configuration in /etc/my.cnf or
 equivalent, to be sure networking is configured right.  You want to check
 the bind-address and skip-networking settings.  You don't want
 skip-networking, and you want bind-address set to the machine's IP address.
  Now that I think of it, this is more likely to be the problem for you.

- skip-networking is disabled
- bind-address option is not present in /etc/my.cnf

should I try to add a:

bind-address = x.y.z.a

to the configuration file :-?


Thanks for any comment

**
P.S.
I've added the same user but using 'myuser'@'localhost' whithout deleting the 
first one created, and the new show grants outputs the *same* two lines of 
information

Grants for [EMAIL PROTECTED] :
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY PASSWORD '...'
GRANT ALL PRIVILEGES ON `mydatabase`.* TO 'myuser'@'%'

but this time am able to connect. What can be wrong? or do I need to add 
both '%' and 'localhost' hosts?
**

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



Problem with GRANT ... 'user'@'%'

2007-05-19 Thread Miguel Cardenas
Hello list

I have a problem adding a user with host '%' ...

*** If I add a user with host '%' when trying to connect get this error:
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using 
password: YES)

*** If I add the same user with localhost it connects and works fine...

My specific doubt is:

1) do I need to add a same user with both '%' and 'localhost' to connect 
locally and from another location???, or...

2) for some reason a host '%' is not working or need to do something so it 
allows connections from any host?

Thanks for your help


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



Compiling mysql-5.0.18 under solaris 10

2006-02-07 Thread Miguel Cardenas
Hello

Am trying to compile mysql-5.0.18 under solaris 10 but get the following
error

Making all in zlib
make[2]: Entering directory `/tmp/mysql-5.0.18/zlib'
/bin/bash ../libtool --preserve-dup-deps --mode=link gcc  -O3 -DDBUG_OFF
-DHAVE_RWLOCK_T   -o libz.la -rpath /usr/local/mysql/lib/mysql -version-info
3:3:2 adler32.lo compress.lo crc32.lo deflate.lo gzio.lo infback.lo
inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo  -lpthread
-lthread -lposix4 -lcrypt -lgen -lsocket -lnsl -lm  -lpthread -lthread
rm -fr  .libs/libz.so .libs/libz.so.1 .libs/libz.so.1.2.3
gcc -shared -Wl,-h -Wl,libz.so.1 -o .libs/libz.so.1.2.3  .libs/adler32.o
.libs/compress.o .libs/crc32.o .libs/deflate.o .libs/gzio.o .libs/infback.o
.libs/inffast.o .libs/inflate.o .libs/inftrees.o .libs/trees.o
.libs/uncompr.o .libs/zutil.o  -lpthread -lthread -lposix4 -lcrypt -lgen
-lsocket -lnsl -lm -lpthread -lthread -lc
(cd .libs  rm -f libz.so.1  ln -s libz.so.1.2.3 libz.so.1)
(cd .libs  rm -f libz.so  ln -s libz.so.1.2.3 libz.so)
false cru .libs/libz.a  adler32.o compress.o crc32.o deflate.o gzio.o
infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
make[2]: *** [libz.la] Error 1
make[2]: Leaving directory `/tmp/mysql-5.0.18/zlib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/mysql-5.0.18'
make: *** [all] Error 2

I checked for libz and found /opt/csw/lib/libz.so.1.2.3 in the system...
probably the problem is that mysql looks for libz.la and the system has
libz.so... what can I do? am thinking on remove the libz shipped with
solaris and install it from sources, but probably could break system
dependences. Any suggestion before I try anything?

Regards


User/Password for every host?

2005-10-01 Thread Miguel Cardenas
Hello list

I have a doubt... Do I need to set a password to a user for each host the user 
has permission to connect from?

Let's supose

// add user 'somebody'
GRANT ALL PRIVILEGES ON *.* TO somebody@192.168.0.% IDENTIFIED BY 'onepass';

if I want 'somebody' to have access from dsl-A.B.C.D-provider.com with 
dynamic address, maybe I should try something like

// add new host
GRANT ALL PRIVILEGES ON *.* TO somebody@dsl-%-provider.com IDENTIFIED BY 
'onepass';
   or the right way should be
GRANT ALL PRIVILEGES ON *.* TO somebody@dsl-%-provider.com;

When adding a new host, should I provide again the same 'onepass' or the 
password may/must be different so it changes depending where the user 
connects from? if I don't use 'IDENTIFIED BY...' what happens? does mysql 
accept the connection with no password (the user already exists on the 
system)?

I'm not sure, but I guess that in table mysql/user it is possible to have 
different Host/User/Password entries with a same user and all valid.

Thanks for any comment


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



ADDING ALLOWED HOSTS

2005-09-25 Thread Miguel Cardenas
Hello

I've just read the users management, it is pretty clear but have a technical 
doubt...

I have a server at the office and want to work on it from home sometimes. It 
has not a fixed ip, is ADSL and address changes from time to time. Am able to 
access the server via ssh by using a domain over dynamic address (it gets 
updated constantly so there's no problem to reach the server).

My doubt is...

The providers domain is always dsl-IPADDRESS.provider.com and have a domain 
over dynamic IP configured as MYDOMAIN.subdomain.com which points to the 
current IPADDRESS.

Would it be possible to add an entry to the 'Host' table using 
MYDOMAIN.subdomain.com ??? I was thinking that it depends on how the 
validation process works... if the domain is converted to IP and then 
compared with the incoming IP then it should work, but, if the incoming IP is 
converted to domain name and then compared to the database will not work 
since that returns the name of the provider and not MYDOMAIN...

Server does not work on weekend so I can't test right now, but I wanted to 
ask, anybody knows how is the validation process of the IP?

1. does MySQL convert domain name in database into IP and then compares with 
the incoming connection IP?

or

2. the incoming connection IP is converted to domain and then compared to the 
domain names and IPs in the hosts table?

It would be great to work from home, but don't want to set the permission to 
the provider's subnet domain name, but to the customized domain set to the 
dynamic ip (MYDOMAIN) instead.

Any suggestion?

Thanks


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



myhostname-bin.000nn @ /usr/local/mysql/var

2005-09-24 Thread Miguel Cardenas
Hello list

I wanted to know how much space was using the database am working on, but 
found some big files I don't know what they do... these files are located in

   /usr/local/mysql/var

and are named 'myhostname-bin.000nn' (nn is 1 to 29 at this moment)... I don't 
know that are those files, so I did a 'less' on them and it appears to be 
binary data with mixed full insert commands for part of my existing database.

My question is... why are those files there? are they really needed or can be 
removed? they are really big and contain old insert commands that will not be 
used never more... can I simple delete all of them?

Thanks for any information!!!


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



Creating HUGE reports

2005-09-24 Thread Miguel Cardenas
Hello...

After solving some problems with the code, now am working with the real one 
database. On my tests was playing with 20,000 records and worked pretty fine 
sorting by X or Y field and setting some 'where ...' conditions.

At this moment the database has 250,000+ records, new insertions are pretty 
fast, searchs are pretty fast too, but generating reports is almost 
impossible, the computer may hang one hour and still be working with any 
output.

My tables are something like this:

CONTACTS - about 250,000 records
--
|   id (INT)   |   contact(CHAR)   |   active(BOOL)   |   ...   |
--

LISTS - about 60,000 records
(category for some contacts)

|   id (INT)   |   category(CHAR)   |


Contacts may have a category, although not all of them have one, and some of 
them may be in more than one, so it is not option to use a 'category' field 
inside the CONTACTS table... perhaps, intuitively could have a 'SET' type 
field with categories, but there are not fixed categories and may (will) grow 
with usage...

There are two conditions that should be both acomplished:


Cond 1. CONTACTS.active = 1
Select all active contacts

Cond 2. LISTS.category = (or ) mycagegory
Add/remove contacts from the report that are listed in mycategory

If I try a select on both tables by conditioning CONTACTS.id=LISTS.ID and 
LISTS.category=something the whole system becomes slow and unusable, and 
still do not wait enough to see how long it will take.

This task will be performed once or twice a week, so it must be optimized, and 
don't know what should be better...

1st option: let the complex select finish (have no idea of how long will take)

2nd option: generate a temporal table with results matching Cond1, and then 
apply Cond2 to the temporal table.

Commonly, the 'category' applies to discard contacts, more than choosing them, 
so I would simply remove LIST.id records from TEMPORAL table where 
LIST.id=TEMPORAL.id and then would have the final report.

But... what should be better? a single select with complex conditions or a 
temporal table with multiple parses to append/discard records for every 
category used (one or various)?

Thanks for any comment.


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



Re: mysql_free_result() 2 different connections

2005-09-21 Thread Miguel Cardenas
 4.1.4 is beta version, isn't it ? I'll suggest you try the latest
 binary for 4.1 available for your setup.

Oops, sorry, type mismatch error... I mean 4.1.14, the most recent

  I suspect that the current version of MySQL frees the resources
  automatically,
 no, it does not :-)

I thought that, 'cos my doubt on it I have insisted to findout more

 again, showing _real_ code would help, or a strip-down code that
 crashes. The MySQL api does not free ressources automatically, so if
 you have the crash on two different system, I would think the bug
 comes from your code.

Well, in fact you are right... I took a look again to the mysql_store_result() 
and mysql_use_result() and that lighted my brain!

It was a logic error... inside the while I was making a free_result() every 
loop that made a fetch_row(), and not once per query, that was the first 
thing... as you said in the last message, I did not check for NULL return to 
perform the free() and because of that was the random crash (sometimes NULL, 
sometimes not)...

The problem was not mysql nor what I was thinking, but your last mail made me 
to discover the real problem :D

 nop, you MYSQL_RES, and it's value. did you set to NULL after freeing
 it ? that would help.

well, I had a member function

void MYCLASS::FreeResult (void) {
   mysql_free_result(sql_result);
}

and now modified it this way

void MYCLASS::FreeResult (void) {
   if (sql_result) {
  mysql_free_result(sql_result);
  sql_result = NULL;
   }
}

 again, I doubt it's a bug in the api, I use various 4.0.x, 4.1.x daily

Well, as I said, it was a double logic error, I should not anymore copy/paste 
from other programs trusting that they do what I remember they do, it will be 
better to start always from zero the code, even for test only purposes...

Thanks for your patience and help during this time... your ideas were very 
useful...

Regards


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



Re: mysql_free_result() 2 different connections

2005-09-20 Thread Miguel Cardenas
  I have 2 different result sets, since are two different connections to
  the server, simultaneous but independent (two handles, two connections,
  two different queries)

 what is the code you're using ?

in a very small representation the program is this

*** dbmail and dbmail2 open 2 different connections, one accesses 
DBM_ADDRESSES table and the other accesses DBM_NAMES table. The first one 
retrieves addresses from the table DBM_ADDRESSES, the second one a relationed 
names to the addresses from DBM_NAMES. Not all addresses have name set, so 
for questions of space I separated into tables, just 10% of addresses have a 
name and it would be waste of space having that column in the same table 
(90%+ of over 50,000 rows), so I created a new table for the names and linked 
them to a corresponding address via an 'id'

DBM_ADDRESSES
id, address, ...

DBM_NAMES
id,name

1. connect dbmail and dbmail2 to server
2. dbmail.query:   SELECT id,address from DBM_ADDRESSES WHERE ...
sp_id = atoll(record[0]); // stores the id in 'sp_id'
3. while ( dbmail retrieves rows from query at step 2 ) {
   dbmail2.query:
   3.1 SELECT name FROM DBM_NAMES WHERE id=sp_id(from step 2)
   3.2 if ( name exists for id=sp_id )
   do something with DBM_ADDRESSES.address,DBM_NAMES.name
else
   do something with DBM_ADDRESSES.address
   3.3 free results from dbmail2.query (inside while)
   }
4. free results from dbmail.query (1st query before while) ***CRASH***
5. disconnect dbmail and dbmail2 connections

The crash is in step #4 after  all data is retrieved successfully, but why? 
every loop in the while is performed a query/free without problems, but the 
most external unique query does not accept mysql_free_result(), even when 
they are two different connections to the server.

I've just tested with a single query program (one connection with one query) 
and it crashed too when I mysql_free_result() ***called only once*** after 
retrieving all rows:

1. query: SELECT ...
2. while ( fetch rows ) { use the results }
3. mysql_free_result()

it crashes too, this model is very (really very simple) and does not leave 
space for errors in code and still fails on the free function...

I've asked on a linux list and somebody told me just to avoid using 
mysql_free_result() if the program works that way ('cos the results maybe are 
being already free by the library), but I don't think it is a solution, I 
want to know what happens, if really the set is free automatically by the C 
API functions after reading it or not, and if so, why the documentation tells 
that it is a *must* call the free function after the whole set of rows is 
retrieved...

Thanks for your comments


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



Re: mysql_free_result() 2 different connections

2005-09-20 Thread Miguel Cardenas
 Are your two tables in the same database ?
 If yes only one connection if enough, and you could use a join query
 to do it, thus having a speed improvement of several magnitudes.

I've just downloaded another 2 mysql manuals and have been sit on my chair all 
day reading them, but still do not reach the join usage, I hope tomorrow...

 Have you checked that you free the correct result ? set it to NULL
 after used, and add a test for nullity, it may help.
 What version of the API are you using ? which OS ?
 Have you check bugs.mysql.com ?

It is Linux Slackware 10.1 with MySQL 4.1.4 installed from source... I have 
tested it too (same program and same version of MySQL) with FreeBSD and the 
result is almost the same, the difference is that Linux craches with glib 
message and in FreeBSD just sends a warning that the results have been 
already free...

I suspect that the current version of MySQL frees the resources automatically, 
in FreeBSD the warning was more explicit, it said something like trying to 
free again a result chunk... this one performed a single query and a single 
result_free() so there was no place for a mistake...

 That would leave a nice memory leak indeed...
 eventually, recompile and set a break-point before calling mysql_free,
 and look at all variables.

MySQL internal variables? to see the status before? that's a good idea, I will 
do it, thanks for your comments and will post it as soon as I get results :-)

Regards

P.S.
I already posted it to bugs.mysql.com but still do not get response

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



Re: mysql_free_result() WITHOUT mysql_fetch_row()

2005-09-19 Thread Miguel Cardenas
Hello

 Have you try :
 select count(*) from mytable where id=x and list=something
 if count ==0, it's like fetchrow==NULL from your solution, but without
 all the fuss about use_result();

No, but looks fine, I didn't know this usage of count(*) combined with 
conditions, but now will use it :)

 Second solution :
 ALTER TABLE mytable ADD UNIQUE(id,list)
 which make a unique index on two field. inserting a duplicate value
 would give you back an error and let the table untouched.

Is it possible to do this during the creation of the table? my database is not 
large, it has just some records (by now is being tested only), so I can 
backup all data and build the table again.

Is there a MySQL manual I can download, apart of the one manual-split.tar.gz 
found in mysql.com? so I would be able to find a more generic or advanced 
usage?

Thanks for your patience :-)


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



Re: mysql_free_result() 2 different connections

2005-09-19 Thread Miguel Cardenas
Hello

I was re-reading last mails, analized it carefull again and...

  while ( my1.fetch ) {
     my2.query + my2.store
     if ( my2.fetch ) {
        report = my1 + my2 results
     } else {
        report = my1
     }
     my2.FreeResult --- free for every my2.query inside loop
  }
  my1.FreeResult --- free for unique my1.query

 One My2.store == One My2.free.
 you're doing it more thant once, it can't work.
 from the fine manual :
 http://dev.mysql.com/doc/mysql/en/mysql-store-result.html
 You must call mysql_free_result() once you are done with the result set. 
 but in you're code you're still using the result set ! --- ***

I have 2 different result sets, since are two different connections to the 
server, simultaneous but independent (two handles, two connections, two 
different queries)

Today was probing one of my programs with just one single connection and 
mysql_free_result() still crashes even with just one set of results, no 
matter how I use it, it always crashes :-(

Any idea?


Regards

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



Re: mysql_free_result() WITHOUT mysql_fetch_row()

2005-09-18 Thread Miguel Cardenas
 http://dev.mysql.com/doc/mysql/en/mysql-free-result.html
 it does not says : you have to retrieve all rows before freing it. So
 you should be able to free the result. Otherwise it's a bug or
 undocumented behaviour.
 But why don't you use the Count(*) solution ?? that's exactly what you
 need IMHO.

No, I don't need to know if exists *any* record, I need to know if it exist 
one specific record or set of records, but not to retrieve them, just need to 
know if it/they exist to take a decition on how to insert the following 
ones... if I need only to know if there is data on the table the COUNT(*) 
would be enough...

Thanks for the link, I'm gonna see it...

Regards

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



mysql_free_result() CRASHES

2005-09-18 Thread Miguel Cardenas
Hello

I've just experienced troubles with mysql_free_result() but don't know what is 
wrong... one of my programs has 2 simultaneous connections to MySQL and 
crashed when doing the mysql_free_result(), I thought it was 'cos the way I 
was making the program, but now I have the problem with single connection and 
still crashes randomly.

This is the part of of the source code, not to understand what does every 
function, just to illustrate, it is almost self-explanatory


MYCLASS dbmail;

   // CONNECT TO MYSQL
   if ( !dbmail.RealConnect(host,user,password) ) {
  printf(Unable to connect to %s...\n%s,host,dbmail.Error());
  return 0;
   }

   // SELECT DATABASE
   if ( dbmail.SelectDatabase((char*)DBM_DATABASE)!=0 ) {
  printf(Unable to open database: %s...\n,DBM_DATABASE);
  dbmail.Close();
  return 0;
   }

   // QUERY DATABASE
   // 'condition' is suplied by user (where x=y, etc)
   sprintf(query_search,SELECT address FROM DBM_ADDRESS %s,condition);
   if ( dbmail.RealQuery(query_search,strlen(query_search))!= 0 ||
!dbmail.UseResult() ) { // leaves MYSQL_RES* stored inside the class
  printf(*** %s\n,dbmail.Error()); fflush(stdout);
  dbmail.Close();
  return 0;
   }

   MYSQL_ROW record;
   while ( (record=dbmail.FetchRow())!=NULL ) {
  printf(%s\n,record[0]);
   }
   //dbmail.FreeResult();

   dbmail.Close();


When it reaches dbmail.FreeResult() it crashes... why? I don't know, by 
commenting that line everything works (although possibly resources are not 
free). The important member functions and internals involved in the code 
above are these: (handler, result arrays etc are inside the class)


   class MYCLASS {
  ...
  private:
  MYSQL   sql_handle;
  MYSQL_RES  *sql_result;
  MYSQL_ROW  sql_rows;
  ...
   }

MYSQL_RES* MYCLASS::UseResult (void) {
   return (sql_result=mysql_use_result(sql_handle));
}
MYSQL_RES* MYCLASS::StoreResult (void) {
   return (sql_result=mysql_store_result(sql_handle));
}

MYSQL_ROW MYCLASS::FetchRow (void) {
   return mysql_fetch_row(sql_result);
}

void MYCLASS::FreeResult (MYSQL_RES* result) {
   if (result) {
  mysql_free_result(result);
   } else {
  mysql_free_result(sql_result);
   }
}


In very short words, after the UseResult()/StoreResult()+FetchRows() when I 
call FreeResult() it crashes aleatory... MYCLASS members are very simple as 
you can see, it does not improve nothing new, just encapsulates a standalone 
connection with isolated pointers, arrays, etc.

What may be wrong that when mysql_free_result(sql_result); is called the 
program crashes? NOTE THAT ALL DATA IS RETRIEVED SUCCESSFULLY AND COMPLETE, 
THE PROBLEM COMES WHEN I FREE THE RESOURCES...

*** glibc detected *** double free or corruption (!prev): 0x08051d58 ***
Aborted

mysql_free_result(sql_result) is called ONLY ONE TIME, so why the hell the 
error says double free? that reduces options to corruption but why?

I will try to move to an older MySQL (currently have the latest) to see if the 
error continues, but if it persists, what may produce the error? the way 
I ./configure'd it maybe?

Thanks for your patience...


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



mysql_free_result() WITHOUT mysql_fetch_row()

2005-09-17 Thread Miguel Cardenas
Hello list

I have a technical doubt, very simple but not mentioned in the manual...

What happens if I call mysql_free_result() after performing a query but 
without doing mysql_fetch_row() ???

It may sound strange, but just need to know if a data row exists more than the 
data itself...

The right algorithm should be:

   1. send a query: select something from table1
   2. get the results: mysql_use_result() or mysql_store_result()
   3. if results available mysql_fetch_row()
   4. free the resources: mysql_free__result()

but in fact I don't require step 3, only need something like this:

   1. send a query: select something from table1
   2. get the results: mysql_use_result() or mysql_store_result()
   3. if results available CONDITION=TRUE else CONDITION=FALSE
   4. free the resources: mysql_free__result()

   5. if CONDITION=TRUE then ...

so... is there any problem if I free the resources before reading all of them?

Thanks!!!


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



mysql_free_result() 2 different connections

2005-09-17 Thread Miguel Cardenas
Hello list

There is another doubt... I have programmed a C++ object that connects to 
MySQL, it has encapsulated its own

MYSQL *mysql
MYSQL_RES *result
...
etc etc

data, so it it possible to have several simultaneous connections to MySQL 
performing different jobs, but I have experienced a strange error... Let's 
supose (pseudocode) y have the class MY and have 2 instances my1 and my2

   MY my1, my2;

both are already connected to the server and both retrieve independently data 
by 'real_query' and 'use_result'... but the problem comes when I call 
'free_results' for both connections, the program crashes with this message:

   *** glibc detected *** double free or corruption (!prev): 0x08053e68 ***
   Aborted

The pseudocode I have is this:

---
my1.query + my1.store --- UNIQUE QUERY (* where ...)

while ( my1.fetch ) {
   my2.query + my2.store
   if ( my2.fetch ) {
  report = my1 + my2 results
   } else {
  report = my1
   }
   my2.FreeResult --- free for every my2.query inside loop
}
my1.FreeResult --- free for unique my1.query
---

NOTE AGAIN: my1 and my2 are independent connections, have independent 
encapsulated handles and variables...

What would happen if I don't free the resources inside the loop, would it 
leave unfreed memory resources?

My tables are like this:

TABLE1
--
|   ID   |   FIELDX   |   ...   | 
--
|   0|   x1   |   ...   | 
|   1|   x2   |   ...   | 
|   2|   x3   |   ...   | 
|   3|   x4   |   ...   | 

TABLE2
-
|   ID   |   FIELDY   |
-
|   0|   y1   |
|   3|   y4   |


if I try a SELECT using condition WHERE TABLE1.ID=TABLE2.ID the results will 
return only x1-y1 and x4-y4 pairs, and in fact what I need is this the full 
pair of data when available, and the data from TABLE1 when there is no pair 
in TABLE2

x1-y1
x2
x3
x4-y4

I send a query to connection1---TABLE1 that retrieves all 'x#', and for every 
row returned, send a query to connection2---TABLE2 looking for a possible 
pair and build a report with both values, and if TABLE2 does not return 
nothing then use only value from TABLE1

SO... how should I manage 'mysql_free_results()' when I have multiple 
independent connections that make independent queries and free its own 
resources allocated? it appears that it affects globally calling this 
function, even if it is called in separate connections...

Sorry, I extended too much, maybe is not very clear, but just concentrate on 
the question above...

Thanks very much...


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



Re: mysql_free_result() WITHOUT mysql_fetch_row()

2005-09-17 Thread Miguel Cardenas
 In the last episode (Sep 17), Miguel Cardenas said:
  I have a technical doubt, very simple but not mentioned in the manual...
 
  What happens if I call mysql_free_result() after performing a query
  but without doing mysql_fetch_row() ???
 
  It may sound strange, but just need to know if a data row exists more
  than the data itself...

 A faster way would be to run a SELECT count(*) WHERE ... query, and
 check the result.  Since you are not selecting any data, mysql is more
 likely to be able to use index lookups to speed the query up.

Well, in fact don't want to check if there is data already inserted on the 
table to make condition TRUE, what I want is to do this:

SELECT id,data FROM table WHERE id=XXX

but, just want to check if it the search found something and then free the 
resources, not to retrieve the data... in short words:

1. search rows which id=XXX
2. if mysql_num_rows()  0 then CONDITION=TRUE else CONDITION=FALSE
3. mysql_free_result()

WHY? well, this operation will be repeated over 100,000 times and only need to 
know if the specified data exists, the difference between just know and 
retrieve 1 time and 100,000 times surely would be significative if I try

1. search rows which id=XXX
2. if mysql_fetch_row() then CONDITION=TRUE else CONDITION=FALSE
3. mysql_free_result()

Specifically, my doubt is, what happen if I call mysql_free_result() if I 
don't call mysql_fetch_row() before, or if not all rows are read before 
calling it...

Regards


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



mysql_free_result() --- PART II

2005-09-17 Thread Miguel Cardenas
Hello again

Sorry, this is the third mail but found something strange... In the past mail 
commented about the following error:

*** glibc detected *** double free or corruption (!prev): 0x08051d58 ***
Aborted

but found that mysql_free_result() produces this error only when ALL data has 
been retrieved with mysql_fetch_row(), when there is still pending data 
there's no problem, only when all of it has been retrieved and there is no 
more data waiting...

Anybody has an idea of what is wrong?

Thanks!!

P.S. I have MySQL 4.1.14


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



MySQL 4.0.14 mysql_create_db(), mysql_drop_db()

2003-08-14 Thread Miguel Cardenas
Hello list...

Am developing an application with mysql support and it works fine, but today 
changed from 3.23 (deinstalled completely) to 4.0.14 and when recompiling my 
program get the following errors:

---
/usr/include/voodoo2/mysql/mysql.cpp: In member function `int
   MYSQL_V::CreateDatabase(char*)':
/usr/include/voodoo2/mysql/mysql.cpp:54: `mysql_create_db' undeclared (first
   use this function)
/usr/include/voodoo2/mysql/mysql.cpp:54: (Each undeclared identifier is
   reported only once for each function it appears in.)
/usr/include/voodoo2/mysql/mysql.cpp: In member function `int
   MYSQL_V::DropDatabase(char*)':
/usr/include/voodoo2/mysql/mysql.cpp:62: `mysql_drop_db' undeclared (first use
   this function)
---

I performed a 'grep mysql_create_db' /usr/local/mysql/include' thinking that 
the api could change, but it is exactly the same as in 3.23 so I don't 
understand why that error...

the source code is the following:

---
/* mysql_v.cpp */
#include mysql_v.h
...
int MYSQL_V::CreateDatabase (char* database) {
   return mysql_create_db(sql_handle,database);
}
int MYSQL_V::DropDatabase (char* database) {
   return mysql_drop_db(sql_handle,database);
}
...
---

Note that my code contains mysql.h from the MySQL distribution include's 
directory. All other C API functions are fine compiled except 
mysql_create_db() and mysql_drop_db()...

Anybody has idea of what can be wrong? the same code compiles and works fine 
on MySQL 3.23 but when trying on 4.0 results on that error...

Am using mysql-standard-4.0.14-pc-linux-i686.tar.gz

Thanx a lot!!!


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



`mysql_config --...` does not work

2003-08-14 Thread Miguel Cardenas
Hello list

For some strange reason `mysql_config --...` does not work. If try something 
like

gcc -o progname `mysql_config --cflags` progname.c `mysql_config --libs`

(NOTE: /usr/local/mysql/bin is in the PATH var, mysql_config works when 
invoked)

the compiler does not find the header files and the libraries... if I execute 
the command by hand and paste the output to the gcc/g++ command line it 
works, but not with the quotes `mysql...`

I can't run by hand mysql_config and paste the output to the gcc statement 
since it will be invoked from a Makefile, and don't want to paste the output 
directly into the Makefile since linked libs could vary from one version of 
mysql to another... what can I do? generated Makefile should work with any 
linux system without changes

I need to have a distribution Makefile working for ANY possible version of 
mysql and mysql_config `quoted` does not give the compiler the right 
parameters (don't know why).

Is there some way to let the system (linux x86) find the libraries (.a) 
*without moving* them to a standard lib path? /etc/ld.so.conf does not work 
since libraries are static, not shared...

Am using qmake (Qt) to generate the Makefile and need to make something like

-
TEMPLATE = app
TARGET = myapp

SOURCES = app.cpp
HEADERS = app.h

INCLUDEPATH += `mysql_config --cflags`

CONFIG += qt thread warn_on release
LIBS += `mysql_config --libs` lpthread -ldl -lvoodoo2
-

I've created a library that manages all mysql stuff I need, so can't use mysql 
stuff included with Qt 'cos should change all my sources from my applications 
already working... necesarily have to use my lib and generate the right 
makefiles with qmake...

HELP!!!


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



Re: MySQL 4.0.14 mysql_create_db(), mysql_drop_db()

2003-08-14 Thread Miguel Cardenas
Hello

 #ifdef USE_OLD_FUNCTIONS
 MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char
 *passwd); int STDCALL mysql_create_db(MYSQL *mysql, const char
 *DB); int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
 #define  mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
 #endif

Tried last night but did not work... it compiles fine, but at the link time 
mysql_create_db and mysql_drop_db symbols are undefined :(

I re-read the API documentation (the latest) and found the functions are 
deprecated, so replaced them by mysql_real_query'es.

All is working now, but found a little problem with the original mysql 
mysql.com distribution, includes and libraries are placed in non-standard 
directories. Reading the documentation found that I had to use -L and -I but 
the problem is that am working with qmake (Qt) and...

- if there's a mysql modified distribution (for example redhat or slackware) 
that changes the default directories for libs/includes qmake works fine 
without -L and -I 'cos they are placed in standard system directories

- if the original unmodified distribution installed it is a need to use -L and 
-I to generate the makefile but need to include the parameters by hand since 
mysql_config can't be run by qmake while generating the Makefile. It works 
fine by now, but don't know with different (older/future) versions of mysql 
that may require more or different libs

the question is: is there some way to use .../mysql/lib without moving the 
libs to /usr/local/lib or something similar? tried to add the path to 
/etc/ld.so.conf (tried although they are .a) and LD_LIBRARY_PATH environment 
variable, but library is not found. Am going to try to symlink .../mysql/lib 
to /usr/local/lib/mysql hoping that it could work, since I don't want to have 
different makefiles depending on standard/non-standard mysql distribution...

Regards.


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



MySQL 4.0.14 mysql_create_db()... II

2003-08-14 Thread Miguel Cardenas
Hello again...

I opened mysql.h and found this...

---
#ifdef USE_OLD_FUNCTIONS
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
  const char *user, const char *passwd);
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
#define  mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#endif
---

why old functions? should I use new ones instead? I #define'd 
USE_OLD_FUNCTIONS before #include'ing mysql.h and now compiles fine, but I 
think it is not the best way...

any comments or suggestions?

thnx!


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