List:MySQL ODBC« Previous MessageNext Message »
From:Nick Gorham Date:November 8 2005 2:22pm
Subject:Re: SQLForeignKeys result-set question
View as plain text  
Martin J. Evans wrote:

>On 06-Nov-2005 jbonnett@stripped wrote:
>  
>
>>I would think the back-ticks (not single quotes) are there because '_'
>>is a wild card character in SQL and 'type' is a keyword.
>>
>>I guess the back-ticks are not there in your later example because it is
>>just the output of a query.
>>
>>John B.
>>    
>>
Martin asked me to take a look at this. The attached patch should do the 
trick.

The problem as far as I can see is the primary and foreign column 
information comes from the line

InnoDB free: 11264 kB; (`type`) REFER 
`martin/eventtype`(`eventtype_id`); (`mark

And I think the driver just needs to remove the quotes.

-- 
Nick Gorham
Easysoft Limited

diff -r -u mysql-connector-odbc-3.51.12/driver/catalog.c
mysql-connector-odbc-3.51.12a/driver/catalog.c
--- mysql-connector-odbc-3.51.12/driver/catalog.c	2005-10-09 20:33:40.000000000 +0100
+++ mysql-connector-odbc-3.51.12a/driver/catalog.c	2005-11-08 11:02:38.000000000 +0000
@@ -1978,9 +1978,27 @@
                     {
                         /* Multiple columns exists .. parse them to individual rows */
                         char **prev_data= data;
-                        data[7]= strdup_root(alloc,ref_token);    /* FKTABLE_COLUMN */
+                        /*
+                         * remove quote chars
+                         */
+                        if ( ref_token[ 0 ] == '`' ) 
+                        {
+                            data[7]= strdup_root(alloc,ref_token+1);    /* FKTABLE_COLUMN
*/
+	                           data[7][strlen(data[7])-1 ] = '\0';
+                        }
+                        else {
+                            data[7]= strdup_root(alloc,ref_token);    /* FKTABLE_COLUMN
*/
+                        }
                         pktoken= my_next_token(pktoken,&pkcomment,ref_token,' ');
-                        data[3]= strdup_root(alloc,ref_token);    /* PKTABLE_COLUMN */
+                        if ( ref_token[ 0 ] == '`' ) 
+                        {
+                            data[3]= strdup_root(alloc,ref_token+1);    /* FKTABLE_COLUMN
*/
+                            data[3][strlen(data[3])-1 ] = '\0';
+                        }
+                        else 
+                        {
+                            data[3]= strdup_root(alloc,ref_token);    /* PKTABLE_COLUMN
*/
+                        }
                         sprintf(ref_token,"%d",key_seq++);
                         data[8]= strdup_root(alloc,ref_token);    /* KEY_SEQ */
                         data+= SQLFORE_KEYS_FIELDS;
@@ -1988,8 +2006,25 @@
                         for ( fk_length= SQLFORE_KEYS_FIELDS; fk_length--; )
                             data[fk_length]= prev_data[fk_length];
                     }                
-                    data[7]= strdup_root(alloc,fkcomment);      /* FKTABLE_COLUMN */ 
-                    data[3]= strdup_root(alloc,pkcomment);      /* PKTABLE_COLUMN */
+                    /*
+                     * remove quote chars
+                     */
+                    if ( fkcomment[ 0 ] == '`' ) 
+                    {
+                        data[7]= strdup_root(alloc,fkcomment+1);    /* FKTABLE_COLUMN */
+                        data[7][strlen(data[7])-1 ] = '\0';
+                    }
+                    else {
+                        data[7]= strdup_root(alloc,fkcomment);      /* FKTABLE_COLUMN */ 
+                    }
+                    if ( pkcomment[ 0 ] == '`' ) 
+                    {
+                        data[3]= strdup_root(alloc,pkcomment+1);    /* PKTABLE_COLUMN */
+                        data[3][strlen(data[3])-1 ] = '\0';
+                    }
+                    else {
+                        data[3]= strdup_root(alloc,pkcomment);      /* PKTABLE_COLUMN */
+                    }
                     sprintf(ref_token,"%d",key_seq);
                     data[8]= strdup_root(alloc,ref_token);      /* KEY_SEQ */

Thread
SQLForeignKeys result-set questionMartin J. Evans2 Nov
RE: SQLForeignKeys result-set questionjbonnett6 Nov
  • RE: SQLForeignKeys result-set questionMartin J. Evans7 Nov
    • Re: SQLForeignKeys result-set questionNick Gorham8 Nov