// Functions from selected catalog (or all, if empty), matching schemas, names and types
Functions from selected catalog (or all, if empty), matching schemas, names and types
// Functions from selected catalog ( or all if empty ) matching schemas names and types
func (s InformationSchema) Functions(f metadata.Filter) (*metadata.FunctionSet, error) {
	if !s.hasFunctions {
		return nil, metadata.ErrNotSupported
	}
	columns := []string{
		"specific_name",
		"routine_catalog",
		"routine_schema",
		"routine_name",
		"COALESCE(routine_type, '')",
		"data_type",
		"routine_definition",
		"COALESCE(external_language, routine_body) AS language",
		"is_deterministic",
		s.clauses[FunctionsSecurityType],
	}
	qstr := "SELECT\n  " + strings.Join(columns, ",\n  ") + " FROM information_schema.routines\n"
	conds, vals := s.conditions(1, f, formats{
		catalog:    "routine_catalog LIKE %s",
		schema:     "routine_schema LIKE %s",
		notSchemas: "routine_schema NOT IN (%s)",
		name:       "routine_name LIKE %s",
		types:      "routine_type IN (%s)",
	})
	rows, closeRows, err := s.query(qstr, conds, "routine_catalog, routine_schema, routine_name, COALESCE(routine_type, '')", vals...)
	if err != nil {
		if err == sql.ErrNoRows {
			return metadata.NewFunctionSet([]metadata.Function{}), nil
		}
		return nil, err
	}
	defer closeRows()
	results := []metadata.Function{}
	for rows.Next() {
		rec := metadata.Function{}
		err = rows.Scan(
			&rec.SpecificName,
			&rec.Catalog,
			&rec.Schema,
			&rec.Name,
			&rec.Type,
			&rec.ResultType,
			&rec.Source,
			&rec.Language,
			&rec.Volatility,
			&rec.Security,
		)
		if err != nil {
			return nil, err
		}
		results = append(results, rec)
	}
	if rows.Err() != nil {
		return nil, rows.Err()
	}
	return metadata.NewFunctionSet(results), nil
}
func ( s InformationSchema ) Functions ( f metadata . Filter ) ( * metadata . FunctionSet , error ) { if ! s . hasFunctions { return nil , metadata . ErrNotSupported } columns := [ ] string { " " , " " , " " , " " , " " , " " , " " , " " , " " , s . clauses [ FunctionsSecurityType ] , } qstr := " \n " + strings . Join ( columns , " \n " ) + " \n " conds , vals := s . conditions ( 1 , f , formats { catalog : " " , schema : " " , notSchemas : " " , name : " " , types : " " , } ) rows , closeRows , err := s . query ( qstr , conds , " " , vals ... ) if err != nil { if err == sql . ErrNoRows { return metadata . NewFunctionSet ( [ ] metadata . Function { } ) , nil } return nil , err } defer closeRows ( ) results := [ ] metadata . Function { } for rows . Next ( ) { rec := metadata . Function { } err = rows . Scan ( & rec . SpecificName , & rec . Catalog , & rec . Schema , & rec . Name , & rec . Type , & rec . ResultType , & rec . Source , & rec . Language , & rec . Volatility , & rec . Security , ) if err != nil { return nil , err } results = append ( results , rec ) } if rows . Err ( ) != nil { return nil , rows . Err ( ) } return metadata . NewFunctionSet ( results ) , nil }
Functions from selected catalog (or all, if empty), matching schemas, names and types
Functions from selected catalog ( or all if empty ) matching schemas names and types