Ticket #1507 (new enhancement)

Opened 6 years ago

Last modified 5 years ago

Ability to load raw data at intallation.

Reported by: ajmixto Assigned to: demian
Priority: normal Milestone:
Component: SGL - DB Severity: open
Keywords: Cc:


I have some complex pgsql code to load during installation.

There are some function declarations wrote with PL/PgSQL and PL/Perl. Since it's no easy to make SGL_DB::parse to understand this complex code, I thought it was a great idea to make posible to load some SQL raw data without parse it.

What do you think?


patch.diff (2.4 kB) - added by ajmixto on 07/30/07 05:26:29.
patch2.diff (5.5 kB) - added by ajmixto on 08/01/07 01:55:24.
patch3.diff (5.4 kB) - added by ajmixto on 08/01/07 03:17:29.

Change History

07/30/07 05:26:29 changed by ajmixto

  • attachment patch.diff added.

07/31/07 04:37:18 changed by demian

  • owner changed from demian to ajmixto.

i have the same requirement for a project i'm working on, approach i'm using:

  1. add custom task to admin -> config
  2. define task in init.php

but again my code must bypass pear::db and run against mysql client binary:

class SGL_Task_LoadData extends SGL_Task
    function run($data)
        $c = &SGL_Config::singleton();
        $conf = $c->getAll();
        $file = SGL_MOD_DIR . '/foo/data/other.my.sql';
        $passwd = !empty($conf['db']['pass'])
            ? "-p{$conf['db']['pass']}"
            : "";
        $cmd= "mysql -u{$conf['db']['user']} $passwd {$conf['db']['name']} < $file";
        SGL::logMessage($cmd, PEAR_LOG_DEBUG);
        $ok = `$cmd`;

As a compromise, would you like to pass a 2nd optional arg to SGL_Sql::execute() to allow binary execution of $file passed as 1st param? Or perhaps easiest is $binary = 'mysql' and leave pg implementation for later.

Default signature would be SGL_Sql::execute($file, $binary = false)

Doing a which on 'mysql' would also be handy.

08/01/07 01:55:24 changed by ajmixto

  • attachment patch2.diff added.

08/01/07 02:03:10 changed by ajmixto

  • owner changed from ajmixto to demian.

At first, sorry for my last edited manually patch.

Ok, I've rewrote SGL_Sql::execute to allow a the new $binary param.

I've used it for the new task and to load rawSqlFiles to make tests (#1508).

Any suggestion?

08/01/07 02:58:22 changed by ajmixto

  • owner changed from demian to ajmixto.

I've found a bug, don't apply this patch yet. I'll correct it.

08/01/07 03:17:29 changed by ajmixto

  • attachment patch3.diff added.

08/01/07 03:18:44 changed by ajmixto

  • owner changed from ajmixto to demian.

Ok, the bug it's solved.

11/09/07 09:50:53 changed by demian

  • milestone changed from 0.6.3 to 0.9.0 - polishing.

looks interesting but let's put this for next release - due to code (file_get_contents()) we need to be sure there are no security implications

06/18/08 14:45:07 changed by demian

  • severity changed from need feedback to open.
  • milestone deleted.