• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • ADOdb Lite
  • Bugs

wrong creation of CreateTable SQL command in adodb

Brought to you by: akapanamajack
  • Summary
  • Files
  • Reviews
  • Support
  • Tickets ▾
    • Updates and Additions
    • Bugs
    • Feature Requests
  • News
  • Discussion
  • Donate
Menu ▾ ▴
  • Create Ticket
  • View Stats

Group

  • Benchmark
  • Next_Version
  • Old_Version

Searches

  • Changes
  • Closed Tickets
  • Open Tickets

Help

  • Formatting Help

#99 wrong creation of CreateTable SQL command in adodb

open
Mark Dickenson
adodb.inc.php (19)
5
2009-07-30
2009-07-30
Anonymous
No

You can answer at the end, how runtime of such apps is handled? (high availability - could be handled by ESB; recovery of instances, HTTP server that handling requests, etc.). Isn't the only possible approach in this case use CORBA?

Hello,

I found bug in [CreateTableSQL]function of adodb. For definition of db table:
$tbl_definition = "
user_id I PRIMARY NOTNULL,
transaction_id I NOTNULL,
realization_tstamp T NOTNULL,
delta_value N(9.2) NOT NULL,
realted_contract I
";

$tbl_options = array(
'mysql' => 'TYPE=MyISAM',
'constraints' =>
'FOREIGN KEY (user_id) REFERENCES cms_module_feusers_users (id),
FOREIGN KEY (transaction_id) REFERENCES cms_module_pscd_transtypes (id)',
);

It generate following output:
CREATE TABLE cms_module_pscd_trans ( user_id INTEGER NOT NULL, transaction_id INTEGER NOT NULL, realization_tstamp TIME NOT NULL, delta_value NUMERIC(9,2), realted_contract INTEGER, PRIMARY KEY (user_id) FOREIGN KEY (user_id) REFERENCES cms_module_feusers_users (id), FOREIGN KEY (transaction_id) REFERENCES cms_module_pscd_transtypes (id) )TYPE=MyISAM

This is however not correct (execution of such output will fail on database site due the syntax error). It is because of mistake in function _TableSQL(adodb-datadict.inc.php) in following implementation:
...
if (isset($tableoptions['CONSTRAINTS']))
$s .= "\n".$tableoptions['CONSTRAINTS'];
...

As you can see all CONSTRAINTS in this case will start without comma character at begin what cause that the final command will fail due the syntax error.

Solution in my case was following:
...
if (isset($tableoptions['CONSTRAINTS']))
$s .= ",\n".$tableoptions['CONSTRAINTS'];
...

I don't know whether it fulfills all the use cases so (somebody has to perform regression test). I also attached corrected version of php sourcecode

Regards,
mOOnSPa

Discussion

  • Nobody/Anonymous

    Nobody/Anonymous - 2009-07-30
     
    adodb-datadict.inc.php
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Log in to post a comment.

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
MongoDB Logo MongoDB