#3148 PostgreSQL schema quoting fixes

1.420
closed-fixed
5
2008-06-14
2008-06-14
lbayuk
No

Trying to export a table in a schema other than "public" as CSV fails with the error: SQL select ... from "schemaname.tablename" failed: ERROR: relation "schemaname.tablename" does not exist. Webmin is quoting the schema and table name together, but they should be quoted separately.

This was already fixed in other places using &quote_table($in{'table'}), but not in csv.cgi. I searched for other places where it might be wrong and found more. The patch file contains all the fixes I found. For example, for csv.cgi:
< $cmd = "select ".join(",", @cols)." from ".&quotestr($in{'table'});
> $cmd = "select ".join(",", @cols)." from ".&quote_table($in{'table'});

Note the following behavior change after the patch is applied. Create a view with a dot in the name: "name1.name2". Before the patch, it creates the view in the public schema with that full name, including the dot. After the patch, it creates a view named "name2" in the "name1" schema. I think the new behavior is the correct behavior. Before the patch, the "name1.name2" view could not be displayed (the query is empty), so I consider it broken.

The patch changes the following 5 scripts:

csv.cgi:
Use quote_table to properly quote the table-name for export.

import.cgi:
Use quote_table to properly quote the table-name when selecting, deleting all data, and inserting.

save-index.cgi:
Use quote_table to properly quote the index name when dropping only (2 places). (Yes, index names can be schema-qualified when dropping, but not when creating.) Use quote_table to properly quote the table name when creating an index on it.

save-seq.cgi:
Use quote_table to properly quote the sequence name when dropping it (2 places). Create sequence was already correct.

save-view.cgi:
Use quote_table to properly quote the view name when dropping (2 places) and when creating. Behavior change! Creating view "n1.n2" now creates "n2" in schema "n1", instead of a view named "n1.n2" in the public schema.

Discussion

  • lbayuk

    lbayuk - 2008-06-14

    Schema quote patch webmin-1.420/postgresql/...

     
  • Jamie Cameron

    Jamie Cameron - 2008-06-14
    • status: open --> closed-fixed
     
  • Jamie Cameron

    Jamie Cameron - 2008-06-14

    Logged In: YES
    user_id=129364
    Originator: NO

    Thanks for the patch! I will include this in the next Webmin release ..

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks