Uploaded image for project: 'Apache MADlib'
  1. Apache MADlib
  2. MADLIB-1204

madpack: SQL result parsing is fragile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • None
    • v1.15
    • Madpack
    • None

    Description

      For a reinstall operation, madpack looks at any possible affected objects that will dropped using below query:

        affected_objects = _internal_run_query("""
                  SELECT
                      n1.nspname AS schema,
                      relname AS relation,
                      attname AS column,
                      typname AS type
                  FROM
                      pg_attribute a,
                      pg_class c,
                      pg_type t,
                      pg_namespace n,
                      pg_namespace n1
                  WHERE
                      n.nspname = '%s'
                      AND t.typnamespace = n.oid
                      AND a.atttypid = t.oid
                      AND c.oid = a.attrelid
                      AND c.relnamespace = n1.oid
                      AND c.relkind = 'r'
                  ORDER BY
                      n1.nspname, relname, attname, typname""" % schema.lower(), True)
      

      The results of this query is parsed line-by-line in the function run_query.

      For my database, a clean reinstall gives following result for above query

       schema | relation | column | type
      --------+----------+--------+------
      (0 rows)
      

      This is parsed as

      [{'schema': '(0 rows)'}]
      

      by the function, which is clearly incorrect and leads to an error in subsequent lines:

        File ".../madpack/madpack.py", line 1366, in <module>
          main(sys.argv[1:])
        File ".../madpack/madpack.py", line 1136, in main
          ao['column'] + ' : ' + ao['type'], True)
      KeyError: 'relation'
      

      Attachments

        Activity

          People

            njayaram Nandish Jayaram
            riyer Rahul Iyer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: