[pkg-horde] Bug#810858: Bug#810858: Bug#810858: webmail-install and horde try to create db schema multiple times + wrong schema version

Mathieu Parent math.parent at gmail.com
Fri Jan 15 10:00:04 UTC 2016


2016-01-14 15:59 GMT+01:00 Ivan Sergio Borgonovo <ivan.s.b at gmail.com>:
> On 01/14/2016 03:48 AM, Mathieu Parent wrote:
|...]
>
> ^^^^^^^^^^^^^^^^^^^^
> I think I got it...

Great!

>
> What really get executed is:
> SELECT tablename FROM pg_tables WHERE schemaname IN ('"$user"','
>           public')
>
> In the actual SQL statement there is an extra white space before public!
>
> The problem should be here
> foreach (explode(',', $this->getSchemaSearchPath()) as $p) {
>   $schemas[] = $this->quote($p);
> }
> $p should be trimmed before. Anyway I find this way error prone.
>
>
> I don't know if this went under the radar just because pg is seldom used
> with horde. I still don't get why moving from one update to the other didn't
> trigger this problem.
>
> It's a pretty long time I havent written more than a couple of lines in PHP
> and I'm not that familiar with the horde codebase.
>
> Sorry for thinking the problem was in packaging and not upstream.
> I initially thought it was a problem of mixed versions in the repo.
>
>
> BTW if you're going to report the bug upstream a more standard way to get
> the visible tables would be:
>
> SELECT table_name FROM information_schema.tables WHERE table_schema = ANY
> (CURRENT_SCHEMAS(false));
>
> This omit the $user schema if there is no $user schema... so it shows what
> can *actually* be seen from the current search_path
>
> CURRENT_SCHEMAS() is available at least starting from pg 8.0 and
> information_schema is supported from 7.4
> Postgres 8.0 is over 10 years old.
>
> This method could be used even to retrieve indexes() so to completely get
> rid of getSchemaSearchPath()
>
> Otherwise, let me know if I've to report it upstream and if you know... to
> which horde component.

Can you propose a PR? There are at least two usages of this pattern:
https://github.com/horde/horde/blob/master/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php#L256
https://github.com/horde/horde/blob/master/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php#L299

Propose the CURRENT_SCHEMAS() pattern first. And post the PR here.


-- 
Mathieu



More information about the pkg-horde-hackers mailing list