getExtension returns the list of current database extensions The caller is responsible for opening and closing the database connection
()
| 551 | // getExtension returns the list of current database extensions |
| 552 | // The caller is responsible for opening and closing the database connection |
| 553 | func (c *Cluster) getExtensions() (dbExtensions map[string]string, err error) { |
| 554 | var ( |
| 555 | rows *sql.Rows |
| 556 | ) |
| 557 | |
| 558 | if rows, err = c.pgDb.Query(getExtensionsSQL); err != nil { |
| 559 | return nil, fmt.Errorf("could not query database extensions: %v", err) |
| 560 | } |
| 561 | |
| 562 | defer func() { |
| 563 | if err2 := rows.Close(); err2 != nil { |
| 564 | if err != nil { |
| 565 | err = fmt.Errorf("error when closing query cursor: %v, previous error: %v", err2, err) |
| 566 | } else { |
| 567 | err = fmt.Errorf("error when closing query cursor: %v", err2) |
| 568 | } |
| 569 | } |
| 570 | }() |
| 571 | |
| 572 | dbExtensions = make(map[string]string) |
| 573 | |
| 574 | for rows.Next() { |
| 575 | var extension, schema string |
| 576 | |
| 577 | if err = rows.Scan(&extension, &schema); err != nil { |
| 578 | return nil, fmt.Errorf("error when processing row: %v", err) |
| 579 | } |
| 580 | dbExtensions[extension] = schema |
| 581 | } |
| 582 | |
| 583 | return dbExtensions, err |
| 584 | } |
| 585 | |
| 586 | // executeCreateExtension creates new extension in the given schema. |
| 587 | // The caller is responsible for opening and closing the database connection. |