Question on sub-selects

2004-01-28 Thread Deven Phillips
Hello,

I have a question that someone here may or may not be able to answer (I
think perhaps MySQL is incapable of a solution). I have a program which
uses a MySQL database to help create a playlist for a ShoutCast stream.
There is a web site associated with the web-radio. Users of the web site
can rate songs which are contained in the database. The rating system
works such that users can rate songs from +3 to -2. Now, what I would
like to accomplish is to create a query that allows me to randomly
select a song from the database to add to the queue while taking into
account the ratings. For example:

There are 2400 songs listed
One song has been rated three times as follows:
+3
+1
-1
I would like that song to have a 3/2400 chance of being selected for the
queue.
Secondly, I need the database to store who voted for waht so that users
cannot continually vote +3 over and over for their favorite song.

 I know how I can accomplish this in Postgres using VIEWs, but I have
not yet been able to find a good solution in MySQL. Can anyone recommend
a viable option? My current database structure is irrelevant, as I will
change the structure if I can find a good solution.

Thanks In Advance,
Deven Phillips
http://sqlshout.sourceforge.net/



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



Problem with mysql_free_result()

2004-01-26 Thread Deven Phillips
Hello all,

   I have a C function which makes various calls to the MySQL C API. 
Every few times through the loop, the program SEGFAULTs on 
mysql_free_result(). Now, tracing through the code using steps in GDB 
and running inside of a memory profiler (valgrind) shows me nothing 
concrete aside from it is an invalid free() operation. Can anyone 
conjecture as to why this is happening?

Thanks In Advance!!

Deven Phillips

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


Question on MySQL C API - Segfault on mysql_real_connect()

2004-01-20 Thread Deven Phillips
Hi,

I have a program which calls a function which has an all-inclusive MySQL
set of code (i.e. MySQL is initialized, used, and released within the
span of the single function). The first time the function is called it
function properly, but on subsequent calls, the function terminates with
a segmentation violation. Can I not create and destroy MySQL structures
within the span of a single function and then call it over again? Here's
the full backtrace from gdb.

(gdb) bt full
#0  0x4028babc in mallopt () from /lib/i686/libc.so.6
No symbol table info available.
#1  0x4028ac61 in malloc () from /lib/i686/libc.so.6
No symbol table info available.
#2  0x400319fe in my_malloc () from /usr/lib/libmysqlclient.so.12
No symbol table info available.
#3  0x40042df8 in vio_new () from /usr/lib/libmysqlclient.so.12
No symbol table info available.
#4  0x4002de19 in mysql_real_connect () from
/usr/lib/libmysqlclient.so.12
No symbol table info available.
#5  0x0804a58a in update_music_queue (config=0x40347f50,
current=0x804e5a0) at mysql.c:39
dbptr = (MYSQL *) 0x8050a38
resone = (MYSQL_RES *) 0x400b52a8
restwo = (MYSQL_RES *) 0x4000a2e0
resthree = (MYSQL_RES *) 0x40347f50
row = 0xba68
query = 0x804ec18 "gothic"
addSongQuery = 0x7de07c3 
recent = 0xb9f4
temp = 0x6c605fa 
songid = 0x54f0523 
requested = 0x54c056f 
strHolder = 0x58205be 
rowcount = 102303297
count = 134540280
numsongs = 0
stringSize = 105252561
#6  0x0804b9f5 in main (argc=1, argv=0x804e5f0) at main.c:379
conffile = 0x804e5a0 "\200\005\005\bp\005\005\b"
holder = 0x804e5a0 "\200\005\005\bp\005\005\b"
current = (song *) 0x804e5a0
shoutconn = (shout_t *) 0x804f7b0
errcount = 0
retval = 134538656
config = (param *) 0x804e5f0
songinfo = 0x8050590 "KMFDM - Thrash Up!"
metadata = (shout_metadata_t *) 0x8050470
stringSize = 134538656
ppid = 1077185020
---Type  to continue, or q  to quit---
#7  0x4022d7f7 in __libc_start_main () from /lib/i686/libc.so.6
No symbol table info available.

Thanks in advance for any help!!!

Deven Phillips, CISSP


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