mysql_install_db and error 22

2003-12-27 Thread A. Tucovic
This is a new 4.0.17 source install on Panther, and this is as far as I 
got.

 sudo /usr/local/mysql/bin/mysql_install_db

Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
Got error 22 when trying to lock mutex at log.cc, line 1689
/usr/local/mysql/bin/mysql_install_db: line 1: 11940 Abort trap 
 /usr/local/mysql/libexec/mysqld --bootstrap --skip-grant-tables 
--basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --skip-innodb 
--skip-bdb
Installation of grant tables failed!



I followed the articles:

http://developer.apple.com/internet/macosx/osdb.html

and cross-referenced with:

http://www.mysql.com/doc/en/Quick_install.html

I am a newbie so if there are any answers please spell it out for me : )

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


newbie question about calculations

2003-12-27 Thread daryl hansen
Please excuse me if I do not use the correct terminology for what I am 
trying to descibe. I am new to mySQL and am using FileMaker and Lass to 
export Filemaker data for use with mySQL. How do you make a field that 
is the sum of two other fields in the same record? I have riffled 
through the mySQL manual, but I still have no clue on how to make 
calculation fields. Right now I have FileMaker talking to mySQL 4.0.15 
using the JDBC driver and a SQL plug-in for Filemaker.  And it is 
working very well, for static data, But  Anyway, this is a sample 
of my current code to create my Table called, cart:

CREATE TABLE Cart (
ID bigint(20) NOT NULL auto_increment ,
Field1 varchar (5) ,
Field2 varchar (5) ,
Field3 varchar (5) ,
KEY `ID` (`ID`)
)
And code to input data into the table:

INSERT INTO cart (
Field1,
Field2,
Field3  )
VALUES ( '1', '1', '2')
How do I make Field3 a calculation, which equals 2 if fields 1  2 
where values set to 1? Any pointers in the right direction would be 
sincerely appreciated.

Aloha,

Daryl Hansen

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


Re: newbie question about calculations

2003-12-27 Thread Steve Folly
On 27 Dec 2003, at 08:59, daryl hansen wrote:

How do I make Field3 a calculation, which equals 2 if fields 1  2 
where values set to 1? Any pointers in the right direction would be 
sincerely appreciated.


Take a look at 6.3.1.3 and 6.3.1.4 in the MySQL documentation for 
logical operators and control flow functions.

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


Re: foreign keys plz?

2003-12-27 Thread Martijn Tonies
Hi,

 Hi there. I heave heared that mysql doesnot support
 foreign keys?

It does, but only with the InnoDB table type.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL  MS SQL
Server.
Upscene Productions
http://www.upscene.com


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



Re: How to use API to write blobs

2003-12-27 Thread Fred van Engen
On Fri, Dec 26, 2003 at 09:35:42PM -0500, Angus March wrote:
  Angus,
 
  On Fri, Dec 26, 2003 at 08:26:38PM -0500, Angus March wrote:
   I'm trying to use the API to write to a MEDIUMBLOB, but I'm getting a
 very
   vague error: something about a problem near '' on line 1. I'm
 forumating
   the query string w/
  
   sprintf(query, INSERT INTO support_files
 (session_id,file_type,file_body)
   VALUES (%ld,%ld,, sessionID,fileType);
  
   Then w/calls to things like memcpy, and unformatted reads from a stream,
 I
   append the blob to the end of that, and finalize it w/a ')'. I'm very
 
  Well, your blob data may contain a NUL character, which will end your
  query string. It may contain quotes, a comma, ')' and other nasty stuff.
  You can't expect the MySQL parser to understand when these characters
  are part of your blob data and when they are meant to end your query or
  separate your query parameters. It is all just one single (long) query
  string that the parser needs to work with.
 
  So you will need to escape at least the following in your blob data:
 
  NUL because it is a C string terminator
  '   because it would terminate your blob 'string'
 
 [snip]
 
 Are you sure this is how it works? If you need to escape stuff, you aren't
 dealing with binary data, you are dealing with a character string. The first

Correct. Queries are character strings, so you'll need to encode your
binary data as such.

 part starts off as a character string (with the INSERT and everything) but
 the manual explicitly calls blob data in a query binary. Furthermore, it
 acknowledges the presence of string-unfriendly characters; specifically, the
 '\0'. Check out:
 http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_real_query
 The quote I'm thinking of is:
  You must use mysql_real_query() rather than mysql_query() for queries that
 contain binary data, because binary data may contain the `\0' character
 

That's a confusing statement IMHO. It may not be necessary to escape the
NUL character, but you still need to create a valid query. There is no
way to do that other than putting your binary data into a quoted string
in your query. Again, how would the MySQL parser see where your binary
data ends? How would the parser distinguish two binary values from one
binary value? Binary is a property of the column. It has nothing to do
with queries per se.

Values in CHAR and VARCHAR columns are sorted and compared in case-
insensitive fashion, unless the BINARY attribute was specified when the
table was created. The BINARY attribute means that column values are
sorted and compared in case-sensitive fashion according to the ASCII
order of the machine where the MySQL server is running. BINARY doesn't
affect how the column is stored or retrieved.
(http://www.mysql.com/documentation/mysql/bychapter/index.html#CHAR)

You might want to look at the example at this URL:

http://www.mysql.com/documentation/mysql/bychapter/index.html#mysql_real_escape_string


Regards,

Fred.

-- 
Fred van Engen  XB Networks B.V.
email: [EMAIL PROTECTED]Televisieweg 2
tel: +31 36 5462400 1322 AC  Almere
fax: +31 36 5462424 The Netherlands

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



RE: sending array data using php mail

2003-12-27 Thread Abs
 --- Mike Johnson [EMAIL PROTECTED] wrote: 
 For the record, there's a syntax error in there --
 the closing curly brace is missing.
 
 echo {$row[Password]}\n;
^
 
 Also, I've never tried this syntax with
 double-quotes. Do the curly braces keep the PHP
 parser from thinking that the opening  for Password
 is a close of the string? I use single quotes in
 that kind of situation, FWIW.

yeah, my bad, the ending curly braces were missing.
when using double quotes, the curly braces are there
so that it can identify the whole variable as an array
type. yeah, it would probably mix up the meaning of
the double quotes in the array key name. even i use
single quotes for array keys, was just showing how the
syntax should be in that situation.

the manual uses  and ' quotes in just about all
contexts anyway. if the whole thing is in double
quotes then it needs curly braces anyway, regardless
of which quotes i use for the key. i haven't come
across anything specific regarding this in the
documentation. for the array stuff in strings and
filehandling, it's shown with single quotes. whereas,
in the array function examples, they use double
quotes. not using any quotes... END_OF_EXAMPLE
// Works but note that this works differently outside
string-quotes
echo A banana is $fruits[banana].;
END_OF_EXAMPLE;

so for safety, i use curly braces and single quotes.
maybe double quotes can be used when u want to use a
weird key name like: $a[all$myvars_start_with_all]
though $a['all'.$myvars_start_with_all.'EVERYWHERE']
would be clearer in that case. (uself if u're
importing variables and prefixing them with something
so that u don't need to re-write code u've written
and/or can adapt code written for register globals on
while using it when off.

just mho.

abs


Yahoo! Messenger - Communicate instantly...Ping 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

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



num rows / pages

2003-12-27 Thread Abs
hi
i was trying to group my results 10 per page ($p per
per page). if i use limit, then there's no way of
knowing how many there are left so i can't give page
numbers as:
 first 2 3 4 last . perhaps running the query
twice, first time wihtout limit to see how many there
were and the 2nd just for a particular bunch with
limit. wouldn't that load the mysql db? and what if
i've got 10,000 rows or so? the query will take time.
any solutions?

thanks
abs


Yahoo! Messenger - Communicate instantly...Ping 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

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



Re: num rows / pages

2003-12-27 Thread Chris Elsworth
On Sat, Dec 27, 2003 at 02:08:08PM +, Abs wrote:
 hi
 i was trying to group my results 10 per page ($p per
 per page). if i use limit, then there's no way of
 knowing how many there are left so i can't give page
 numbers as:
  first 2 3 4 last . perhaps running the query
 twice, first time wihtout limit to see how many there
 were and the 2nd just for a particular bunch with
 limit. wouldn't that load the mysql db? and what if
 i've got 10,000 rows or so? the query will take time.
 any solutions?

Use SQL_CALC_FOUND_ROWS.
Documented in http://www.mysql.com/doc/en/SELECT.html

You run your first query with SQL_CALC_FOUND_ROWS, then once you're
done with it, you run another (SELECT FOUND_ROWS()) and you get the
total resultcount you would have got, had you not LIMIT'ed it.

-- 
Chris

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



Re: foreign keys plz?

2003-12-27 Thread Alaios
with myIsam? Does not check about integrity? Mysql
3.2? 
What u will use for your application Innodb or MyISAM?
--- Martijn Tonies [EMAIL PROTECTED] wrote:
 Hi,
 
  Hi there. I heave heared that mysql doesnot
 support
  foreign keys?
 
 It does, but only with the InnoDB table type.
 
 With regards,
 
 Martijn Tonies
 Database Workbench - developer tool for InterBase,
 Firebird, MySQL  MS SQL
 Server.
 Upscene Productions
 http://www.upscene.com
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:   
 http://lists.mysql.com/[EMAIL PROTECTED]
 

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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



Re: How to use API to write blobs

2003-12-27 Thread Angus March
 On Fri, Dec 26, 2003 at 09:35:42PM -0500, Angus March wrote:
   Angus,
  
   On Fri, Dec 26, 2003 at 08:26:38PM -0500, Angus March wrote:
I'm trying to use the API to write to a MEDIUMBLOB, but I'm getting
a
  very
vague error: something about a problem near '' on line 1. I'm
  forumating
the query string w/
   
sprintf(query, INSERT INTO support_files
  (session_id,file_type,file_body)
VALUES (%ld,%ld,, sessionID,fileType);
   
Then w/calls to things like memcpy, and unformatted reads from a
stream,
  I
append the blob to the end of that, and finalize it w/a ')'. I'm
very
  
   Well, your blob data may contain a NUL character, which will end your
   query string. It may contain quotes, a comma, ')' and other nasty
stuff.
   You can't expect the MySQL parser to understand when these characters
   are part of your blob data and when they are meant to end your query
or
   separate your query parameters. It is all just one single (long) query
   string that the parser needs to work with.
  
   So you will need to escape at least the following in your blob data:
  
   NUL because it is a C string terminator
   '   because it would terminate your blob 'string'
  
  [snip]
 
  Are you sure this is how it works? If you need to escape stuff, you
aren't
  dealing with binary data, you are dealing with a character string. The
first

 Correct. Queries are character strings, so you'll need to encode your
 binary data as such.

  part starts off as a character string (with the INSERT and everything)
but
  the manual explicitly calls blob data in a query binary. Furthermore,
it
  acknowledges the presence of string-unfriendly characters; specifically,
the
  '\0'. Check out:
 
http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_real_query
  The quote I'm thinking of is:
   You must use mysql_real_query() rather than mysql_query() for queries
that
  contain binary data, because binary data may contain the `\0' character
 

 That's a confusing statement IMHO. It may not be necessary to escape the
 NUL character, but you still need to create a valid query. There is no
 way to do that other than putting your binary data into a quoted string
 in your query. Again, how would the MySQL parser see where your binary
 data ends? How would the parser distinguish two binary values from one

By using the length parameter in the mysql_real_query() header.

 binary value? Binary is a property of the column. It has nothing to do
 with queries per se.

 Values in CHAR and VARCHAR columns are sorted and compared in case-
 insensitive fashion, unless the BINARY attribute was specified when the
 table was created. The BINARY attribute means that column values are
 sorted and compared in case-sensitive fashion according to the ASCII
 order of the machine where the MySQL server is running. BINARY doesn't
 affect how the column is stored or retrieved.
 (http://www.mysql.com/documentation/mysql/bychapter/index.html#CHAR)

 You might want to look at the example at this URL:


http://www.mysql.com/documentation/mysql/bychapter/index.html#mysql_real_escape_string

I didn't notice this function before. That and mysql_real_query() don't
seem to be written with each other in mind. It even encodes the '\0', which
mysql_real_query() is said to be able to deal w/. In fact, why should I need
to use mysql_real_query() over mysql_query() if I use
mysql_real_escape_string()?
Well, whatever the reason, I guess this is what API guys are expected to
use. I'll try that and see how it goes.



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



Re: Quering user privileges

2003-12-27 Thread Plinio Conti
Yes, a cron job will make the solution more robust.

I'm new to *classic* client-server DB apps and I'm still amazed for a so standard 
issue I have to find tricks.

Particularly I wonder at this:
standard SQL commands exist to assign (GRANT) and remove (REVOKE) privileges,
but there is not a SQL command to query current privileges.



On Wed, 24 Dec 2003 14:17:45 -0500
Michael Stassen [EMAIL PROTECTED] wrote:

 
 Plinio Conti wrote:
  Yes, I think I will do it with an additional table on the db server,
  for the moment (I have no time to implement parsing etc...)
  
  The problem is, like you stated, to mantain that table up to date
  with changes in system tables. The best solution would be a trigger
  for this, but we haven't them at the moment in MySQL.
  
  Since any other solution will expose the client app to the
  possibility it has invalid information, I will have to handle access
  denied etc... but this is the less.
  
  I will have to pray system administrators to do user management
  exclusivly through a special application provided by me, which will
  keep the *table* updated.
  
  If administrators will use MySQL to store other databases than mine,
  my solution will be quite poor.
  
 
 There's a middle road.  Since you're writing a program to maintain your 
 additional table anyway, you could (should?) write a cron job to make 
 sure it stays in sync.  That way, instead of relying on humans (the 
 system administrators) to do the right thing, you automatically fix it 
 for them when they don't.  Have it run once a day, every hour, every 10 
 minutes, ... whatever frequency seems the best balance for your app.  In 
 fact, if you're willing to live with the lag, and don't trust your SAs, 
 you could skip the user management app and stick with just the cron job.
 
 Michael
 
 
 -- 
 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: How to use API to write blobs

2003-12-27 Thread Fred van Engen
Angus,

On Sat, Dec 27, 2003 at 11:09:54AM -0500, Angus March wrote:
  On Fri, Dec 26, 2003 at 09:35:42PM -0500, Angus March wrote:
 http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_real_query
   The quote I'm thinking of is:
You must use mysql_real_query() rather than mysql_query() for queries
 that
   contain binary data, because binary data may contain the `\0' character
  
 
  That's a confusing statement IMHO. It may not be necessary to escape the
  NUL character, but you still need to create a valid query. There is no
  way to do that other than putting your binary data into a quoted string
  in your query. Again, how would the MySQL parser see where your binary
  data ends? How would the parser distinguish two binary values from one
 
 By using the length parameter in the mysql_real_query() header.
 

The single length parameter would pass the total length of the query
string, not the length of each (or any) of its binary values.


  You might want to look at the example at this URL:
 
 
 http://www.mysql.com/documentation/mysql/bychapter/index.html#mysql_real_escape_string
 
 I didn't notice this function before. That and mysql_real_query() don't
 seem to be written with each other in mind. It even encodes the '\0', which
 mysql_real_query() is said to be able to deal w/. In fact, why should I need
 to use mysql_real_query() over mysql_query() if I use
 mysql_real_escape_string()?

Right. I guess you would only need mysql_real_query if you do your own
escaping without escaping NUL characters or if you want to save a few
CPU cycles and already know the length. Look at the implementation of
mysql_query:

int STDCALL
mysql_query(MYSQL *mysql, const char *query)
{
  return mysql_real_query(mysql,query, (uint) strlen(query));
}


 Well, whatever the reason, I guess this is what API guys are expected to
 use. I'll try that and see how it goes.
 

Regards,

Fred.

-- 
Fred van Engen  XB Networks B.V.
email: [EMAIL PROTECTED]Televisieweg 2
tel: +31 36 5462400 1322 AC  Almere
fax: +31 36 5462424 The Netherlands

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



Re: foreign keys plz?

2003-12-27 Thread Roger Baklund
* Alaios
 with myIsam? Does not check about integrity?

That is correct, the myisam table handler does not support foreign key
constraints. It does of course support foreign keys, but not foreign key
constraints, consequently the foreign key itegrity is not checked for myisam
tables.

 Mysql 3.2?

(I suppose you meant 3.23)

 What u will use for your application Innodb or MyISAM?

Both? It would depend on your needs. Foreign key constraints is neat, and in
some projects it might be a requirement, but the myisam table handler is
lighter because it does not do these checks, and it is also not
transactional, thus it is faster than InnoDB in many cases. myisam also
requires less disk space.

Read more about the different table handlers in the manual, and note that
you can combine different table types in the same database and in the same
statement:

URL: http://www.mysql.com/doc/en/Table_types.html 

--
Roger


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



backup

2003-12-27 Thread Rick
i guys!! im newbie, how can i backup a mysql database? what do you recommend
me?


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



Re: num rows / pages

2003-12-27 Thread Abs
 --- Chris Elsworth [EMAIL PROTECTED] wrote:
 Use SQL_CALC_FOUND_ROWS.
 Documented in
 http://www.mysql.com/doc/en/SELECT.html
 
 You run your first query with SQL_CALC_FOUND_ROWS,
 then once you're
 done with it, you run another (SELECT
 FOUND_ROWS()) and you get the
 total resultcount you would have got, had you not
 LIMIT'ed it.

thanks. i didn't know there was such a function. nice.
now all i've to do is get the site hosting ppl to
upgrade to 4.x :P

fortunately, in this case, the table to browse will
always be scanned entirely so my big set is the number
of rows of the table (there's no where clause). so the
SHOW TABLE STATUS FROM db LIKE tbl will do. 'Rows' has
what i need. just in case anyone else was in a similar
situation.

abs


Yahoo! Messenger - Communicate instantly...Ping 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

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



Re: How to do case sensitive replace with wild card matching?

2003-12-27 Thread mos
At 12:44 AM 12/27/2003, Michael Stassen wrote:
You're welcome.  I did suggest some (not very elegant) SQL in my first 
note.  I take it that didn't turn out to be useful.  It's possible that if 
you were to describe why not, someone could make a better suggestion.  Of 
course, I suppose you may have already solved this in Delphi.

mos wrote:

Chris  Michael,
Thanks for the feedback.  I was hoping it could be done in SQL 
without using Perl since I don't have any experience with it.  But I can 
use some of the ideas you gave me to create a Delphi program quick 
enough. Thanks again. :)
Mike



Mike,
Thanks again for your insight. Re: your SQL solution:
Perhaps we can take advantage of what we know about your data.  I will 
pretend your table is named table1 and your column with the letters is 
named code.  If I understand you correctly, the code column has some 
number of capital letters followed by 2 or 3 lower case letters.  If that's 
true, I think we could do this in 2 updates, like this:

Unfortunately there could be more than 2 or 3 lowercase letters.  (That's 
my fault for not explaining the scope of the problem more thoroughly).
Example: Ab or Abcdfg or ABCDEFg or ABCDEFghijk etc.

Instead of writing a Perl script which I don't know or have (but I have 
used PHP though), I would find it easier to roll my own Delphi program to 
do it. I'm a bit lazy and was hoping the MySQL functions could do it in SQL 
only, but it looks like that's not possible. Thanks again for the effort. :-)

Mike 



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


VC++ and mysql and openssl

2003-12-27 Thread Aaron Hagan
Hello there,
I am having a bit of trouble to get a ssl enabled client working on windows. For 
testing purposes i was trying to compile mysqldump useing ssl. it compiles and loads 
okay but right after i enter the password i get a debug assertion failed in file 
dbgheap.c on line 1044. (the server its talking to is a mysqlsql version 4.0.13 on 
unix)

i am using openssl version openssl-0.9.7a and mysql-4.0.17.  Has anyone else seen this 
type of error before?

thanks for the help!

Aaron 

 
__ __ __ __



 
   

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



Re: How to use API to write blobs

2003-12-27 Thread Angus March
 On Sat, Dec 27, 2003 at 11:09:54AM -0500, Angus March wrote:
   On Fri, Dec 26, 2003 at 09:35:42PM -0500, Angus March wrote:
 
http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql_real_query
The quote I'm thinking of is:
 You must use mysql_real_query() rather than mysql_query() for
queries
  that
contain binary data, because binary data may contain the `\0'
character
   

[snip]

 
http://www.mysql.com/documentation/mysql/bychapter/index.html#mysql_real_escape_string
 
  I didn't notice this function before. That and mysql_real_query()
don't
  seem to be written with each other in mind. It even encodes the '\0',
which
  mysql_real_query() is said to be able to deal w/. In fact, why should I
need
  to use mysql_real_query() over mysql_query() if I use
  mysql_real_escape_string()?

[snip]

It seems there's a little more to it than this. Also like a character
string, a character string-encoded blob has to be enclosed in single quotes.
Early on I tried double quotes, then when that didn't work, I went through a
very long process of trying long strings of decimal numbers, with varied
result, many of which didn't generate an error even. When I finally hit on
single quotes, it came together. I remember fighting for rather a long time
w/SQL a few years ago over the single quote problem w/character strings, but
that was different from blobs. I really wish the documentation I read was
clearer about handling blobs.
Well, thanks for putting me on the right track.


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



Re: How to use API to write blobs

2003-12-27 Thread Andy Bakun
On Fri, 2003-12-26 at 19:26, Angus March wrote:
 I'm trying to use the API to write to a MEDIUMBLOB, but I'm getting a very
 vague error: something about a problem near '' on line 1. I'm forumating
 the query string w/
 
 sprintf(query, INSERT INTO support_files (session_id,file_type,file_body)
 VALUES (%ld,%ld,, sessionID,fileType);
 
 Then w/calls to things like memcpy, and unformatted reads from a stream, I
 append the blob to the end of that, and finalize it w/a ')'. I'm very
 careful about what I do w/my pointers, and not to use string-handling
 functions on the blob data. I also use mysql_real_query(), which is where
 the error is returned. From what I can tell from the on-line documentation,
 this is the right way to handle blobs. I also tried:
 
 sprintf(query, INSERT INTO support_files (session_id,file_type,file_body)
 VALUES (%ld,%ld,0), sessionID,fileType); //exact same as before, but the
 blob is a mere '0'
 
 Is this right? I can use a char * to point to binary data, can't I?
 I'm running Linux RH9, if that makes a difference.

If you are using MySQL 4.1, it would be a lot easier to use Prepared
SQL statements as outlined in section 11.1.4 of the manual, which
allows you to pass variable parts of queries in a length-specified
binary format, rather than requiring that all the data in the query be
escaped for MySQL.  

Short of using 4.1, you could do something like you've done above with
sprintf but, but with the whole query.  I find it a little easier to be
sure that the whole query is valid by having the entire query in a
single string rather than trying to build the query by appending
successive parts.  In this case, you can also test that the query works
with data that doesn't need to be escaped without butchering your code
(you can just change the format string in the snprintf to some literal
data to verify that it works.

 --8-pseudo-code--8
char *blob_data = some big buffer of blob data;
unsigned long blob_data_length = you-should-know-this-value;
blob_data_escaped = (char *) malloc(blob_data_length * 2+1);
escaped_length = mysql_real_escape_string(
   (MYSQL *) mysql, 
   (char *) blob_data_escaped, 
   (const char *) blob_data, 
   (unsigned long) blob_data_length);
/*
  blob_data_escaped[escaped_length] should be the only null byte
  in blob_data_escaped now, so the snprintf below should work just
  fine
 */

query_length = some-huge-amount-that-can-hold-
   escaped_length-plus-the-rest-of-the-query;
query = (char *)malloc(query_length);

snprintf(query, 
query_length, 
insert into s (i,f,b) values (%d, %f, '%s'),
some_integer,
some_float,
blob_data);
 --8-pseudo-code--8

See the query string?  Other than the fact it contains the printf escape
sequences, it's a syntacticly correct query, closing parens and all. 
You could change that to:

snprintf(query, 
query_length, 
insert into s (i,f,b) values (%d, %f, '%s'),
1,
2.0,
blob\\'test\\0has embedded null byte);

to make sure the query is syntacticly correct.  If you print out the
query (so you know what it is), then try pasting it into the mysql
client, you should be able to run it without problems (as a way to test
where there are problems with it).  The C library functions that print
stuff out are bound by the same string-interpretation limits that the
MySQL library is, so if your query comes up short, or syntacticly
incorrect due to those limitations, you'll see it.

You could also abstract this out the pseudo-code I've provided above to
a function that formats a query for you if you give it all the data
values and the lengths of the input buffers and whatnot (thereby making
it work somewhat more like the prepared statement support in 4.1).

(BTW, you should get in the habit of using snprintf rather than sprintf,
if your platform supports it, in order to avoid buffer overruns).

-- 
Andy Bakun [EMAIL PROTECTED]


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



Core Certification

2003-12-27 Thread arjun
Hello everybody ! I have question regarding the MySQL core certification. Does 
anybody have any general insights on taking the exam ? I am studying from the 
manual, but I am pretty nervous about the exam as I don't know how much in 
depth the questions will be or even if studying from the manual alone will be 
sufficient.

I would appreciate any thoughts or comments from anyone about the exam.Thanks !

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



Re: Quering user privileges

2003-12-27 Thread Jim Richardson
On Sat, Dec 27, 2003 at 05:40:46PM +0100, Plinio Conti wrote:
Yes, a cron job will make the solution more robust.

I'm new to *classic* client-server DB apps and I'm still amazed for a
so standard issue I have to find tricks.
Particularly I wonder at this: standard SQL commands exist to assign
(GRANT) and remove (REVOKE) privileges, but there is not a SQL command
to query current privileges.




At least on MySQL 4.0.16, SHOW GRANTS FOR [EMAIL PROTECTED]; shows me the
relevent info. 

I don't know if that's MySQL specific, or not present in 3.x or
something. 

--
Jim Richardson http://www.eskimo.com/~warlock
A conclusion is simply the place where someone got tired of thinking.


signature.asc
Description: Digital signature


Re: newbie question about calculations

2003-12-27 Thread Steve Folly
On 27 Dec 2003, at 21:04, daryl hansen wrote:

I can't find anything in the manual about proper syntax for this when 
creating a table. All I want is my Price field to equal the total of 
my Adults and Children fields.  Can someone please draw me a 
picture?

CREATE TABLE Cart (
ID bigint (20) NOT NULL auto_increment ,
SessionID varchar (50) ,
Activity_ID varchar (5) ,
Company_ID varchar (5) ,
Submitted varchar (5) ,
Vendor varchar (50) ,
Activity varchar (50) ,
Adult_Label varchar (20) ,
Child_Label varchar (20) ,
Other_Label varchar (20) ,
Price_Adult varchar (10) ,
Price_Child varchar (10) ,
Price_Other varchar (10) ,
Price bigint (20) ,
Tax varchar (10) ,
Adults bigint (5) ,
Children bigint (5) ,
Other varchar (5) ,
Date date  ,
CreateDate date ,
KEY `ID` (`ID`)
)
Thanks,

Daryl Hansen

On Dec 26, 2003, at 11:54 PM, Steve Folly wrote:

On 27 Dec 2003, at 08:59, daryl hansen wrote:

How do I make Field3 a calculation, which equals 2 if fields 1  2 
where values set to 1? Any pointers in the right direction would 
be sincerely appreciated.


Take a look at 6.3.1.3 and 6.3.1.4 in the MySQL documentation for 
logical operators and control flow functions.

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



You can only use these functions from a select statement; not in a 
CREATE TABLE statement.

To be honest, there is (usually[1]) no point in having an extra column 
that is the always the result of some arithmetic expression involving 
other columns.  It wastes space. You're better off calculating it in 
the query.

Steve.

[1] - I say 'usually' - I'm sure there are times when you would want to 
do this, perhaps caching lengthy calculations; but adding 2 numbers 
isn't! ;)



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


Re: Selecting the latest entries

2003-12-27 Thread Roger Baklund
* Ville Mattila 
 I have a table containing weather reports of different types and cities. 
 The structure is following:
 - type
 - city
 - time
 - report
 
 Which kind of query should I use to select the latest reports of 
 specified cities. I mean, if I had three different types of reports for 
 Helsinki and Turku, how can I get them all in one query?

Use a sub-select if you can, or see the MAX-CONCAT trick:

URL: http://www.mysql.com/doc/en/example-Maximum-column-group-row.html 

-- 
Roger

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



RE: backup

2003-12-27 Thread Ugo Bellavance


 -Message d'origine-
 De : Rick [mailto:[EMAIL PROTECTED]
 Envoyé : Saturday, December 27, 2003 6:33 AM
 À : [EMAIL PROTECTED]
 Objet : backup
 
 
 i guys!! im newbie, how can i backup a mysql database? what 
 do you recommend
 me?
 
mysqldump to begin
 
 -- 
 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: backup

2003-12-27 Thread Carl B. Constantine
* Rick ([EMAIL PROTECTED]) wrote:
 i guys!! im newbie, how can i backup a mysql database? what do you recommend
 me?
 

man mysqldump

-- 
 .''`.  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]



Need help with a query

2003-12-27 Thread Soheil Shaghaghi
Hello everyone,
I need help with MySQL coding in php please if anyone can help.


I have 3 tables:
-users, where the user info is stored.
-awards: contains the list of all the awards for each user
-award_types: contains different types of award
The tables are at the bottom of the page.

What I need to do is look at these tables when a user id is being viewed and
display the awards image that the user has won.
A user can have multiple awards.


CREATE TABLE `award_types` (
  `id` tinyint(3) unsigned NOT NULL auto_increment,
  `award_type` varchar(255) NOT NULL default '',
  `award_image` varchar(250) default NULL,
  `gender` enum('m','f') NOT NULL default 'm',
  `order_by` tinyint(3) NOT NULL default '0',
  PRIMARY KEY  (`id`)
)

#
# Dumping data for table `award_types`
#

INSERT INTO `award_types` VALUES (1, 'November 2003', nov.gif, 'm', 0);
INSERT INTO `award_types` VALUES (2, 'December 2003', dec.gif, 'm', 1);
INSERT INTO `award_types` VALUES (3, 'January 2004', jan.gif, 'm', 2);
INSERT INTO `award_types` VALUES (4, 'February 2004', feb.gif, 'm', 3);


CREATE TABLE `awards` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `user_id` bigint(20) NOT NULL default '0',
  `award_id` bigint(20) NOT NULL default '0',
  `chosen` varchar(20) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `id` (`id`),
  KEY `chosen` (`chosen`)
)

#
# Dumping data for table `awards`
#

INSERT INTO `awards` VALUES (1, 1, 1, 'enabled');
INSERT INTO `awards` VALUES (3, 1, 2, 'enabled');


CREATE TABLE `users` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
  `password` varchar(16) NOT NULL default '',
  `hint` varchar(100) NOT NULL default '',
  `realname` varchar(48) NOT NULL default '',
  `description` text NOT NULL,
  `age` tinyint(2) unsigned NOT NULL default '0',
  `user_type` tinyint(3) unsigned NOT NULL default '0',
  `state` varchar(32) NOT NULL default '',
  `country` varchar(32) NOT NULL default 'United_States.gif',
  `email` varchar(48) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `quote` varchar(255) NOT NULL default '',
  `image` enum('here','there') NOT NULL default 'there',
  `image_url` varchar(144) NOT NULL default '',
  `image_ext` varchar(4) NOT NULL default '',
  `image_status` enum('enabled','disabled','queued','approved') NOT NULL
default 'enabled',
  `total_comments` int(10) unsigned NOT NULL default '0',
  `subscribed` enum('yes','no') NOT NULL default 'yes',
  `md5key` varchar(32) NOT NULL default '',
  `signup` varchar(14) NOT NULL default '',
  `timestamp` timestamp(14) NOT NULL,
  `is_approved` enum('0','1') NOT NULL default '1',
  `total_files` smallint(6) NOT NULL default '0',
  `last_logged` datetime NOT NULL default '-00-00 00:00:00',
  `city` varchar(32) NOT NULL default '0',
  `address` varchar(64) default NULL,
  `zip` varchar(32) default NULL,
  `talent` varchar(32) default NULL,
  `phone` varchar(32) default NULL,
  `height` varchar(10) default NULL,
  `weight` varchar(10) default NULL,
  `education` varchar(32) default NULL,
  `hobby` varchar(32) default NULL,
  `topregion` enum('enabled','disabled') NOT NULL default 'disabled',
  `top30` enum('enabled','disabled') NOT NULL default 'disabled',
  `top10` enum('enabled','disabled') NOT NULL default 'disabled',
  `top` enum('enabled','disabled') NOT NULL default 'disabled',
  `total_ratings` smallint(5) unsigned default '1',
  `total_points` mediumint(9) unsigned default '10',
  `average_rating` decimal(6,4) default '10.',
  `art` text,
  `language` text,
  `sport` text,
  `skill` text,
  `experience` text,
  `club` text,
  `lastname` varchar(250) default NULL,
  `secondid` varchar(32) default NULL,
  `chosens` enum('enabled','disabled') default 'disabled',
  `email_status` enum('enabled','disabled','queued','approved') NOT NULL
default 'enabled',
  `chosen` varchar(20) NOT NULL default 'enabled',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `md5key` (`md5key`),
  UNIQUE KEY `username_2` (`username`),
  UNIQUE KEY `email_2` (`email`),
  KEY `sex` (`user_type`),
  KEY `timestamp` (`timestamp`),
  KEY `signup` (`signup`),
  KEY `username` (`username`),
  KEY `email` (`email`),
  KEY `subscribed` (`subscribed`)
)

#
# Dumping data for table `users`
#

INSERT INTO `users` VALUES (1, 'username', 'password', 'firstname',
'lastname', '', 19, 11, 'City', 'Sweden.gif', '[EMAIL PROTECTED]',
'http://', '', 'here', '', 'jpg', 'approved', 0, 'yes',
'69f404925df883e0e5579d65b7768e7c', '20031007135005', 20031102044856, '1',
1, '2003-10-11 03:20:19', 'Stockholm', '', '', '', '', '176', '60', '2', '',
'disabled', 'disabled', 'disabled', 'disabled', 1717, 5410, '3.1508', NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'enabled', 'enabled', 'enabled');




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



RE: mySQL in Hebrew

2003-12-27 Thread Noamn
I have run the 'show variables' query on my database and see that the
default character set is latin-1, and 'character_sets' includes 'hebrew'.

So I tried the following command
alter database presale default character set hebrew;
only to be awarded with a 'you have an error in your SQL syntax' message.
'Alter table' gives the same message. I even copy and pasted the example in
the online documentation, which gave me the same answer. I am using version
3.23.51 on linux.


-Original Message-
From: Noamn [mailto:[EMAIL PROTECTED]
Sent: Friday, December 26, 2003 8:22 AM
To: [EMAIL PROTECTED]
Subject: mySQL in Hebrew


Does anyone have any experience of working with mySQL in Hebrew?

The front end to my database is written in Delphi/Windows; it transmits
Hebrew characters and displays Hebrew characters. The backend is in
mySQL/Linux, and what was Hebrew appears in English characters. The only
problem which I have with this is that almost every table has a 'name'
index, and the names aren't sorted in the correct order.

I had a quick glance at the documentation regarding internationalisation and
didn't completely understand it, so I am asking for help. Would it be a good
idea to build a translation table, ie 'aleph' = 'a' and comes first in the
sorting order? What about numbers and English names?


-- 
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]