Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion postgres/parser/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ var familyNames = map[Family]string{
BytesFamily: "bytes",
CollatedStringFamily: "collatedstring",
DateFamily: "date",
DecimalFamily: "decimal",
DecimalFamily: "numeric",
EnumFamily: "enum",
FloatFamily: "float",
GeographyFamily: "geography",
Expand Down
12 changes: 4 additions & 8 deletions server/analyzer/resolve_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,14 @@ func resolveType(ctx *sql.Context, typ *pgtypes.DoltgresType) (*pgtypes.Doltgres
if typ.IsResolvedType() {
return typ, nil
}
schema, err := core.GetSchemaName(ctx, nil, typ.ID.SchemaName())
if err != nil {
return nil, err
}
typs, err := core.GetTypesCollectionFromContext(ctx)
if err != nil {
return nil, err
}
resolvedTyp, err := typs.GetType(ctx, id.NewType(schema, typ.ID.TypeName()))
if err != nil {
return nil, err
}

// schema name can be empty
schema, _ := core.GetSchemaName(ctx, nil, typ.ID.SchemaName())
resolvedTyp, _ := typs.GetType(ctx, id.NewType(schema, typ.ID.TypeName()))
if resolvedTyp == nil {
// If a blank schema is provided, then we'll also try the pg_catalog, since a type is most likely to be there
if typ.ID.SchemaName() == "" {
Expand Down
43 changes: 43 additions & 0 deletions testing/go/create_function_plpgsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,5 +1376,48 @@ END;
},
},
},
{
Name: "resolve type with empty search path",
SetUpScript: []string{
"set search_path to ''",
`CREATE TABLE public.ambienttempdetail (tempdetailid integer NOT NULL, panelprojectid integer, threshold_value numeric(10,2), readingintervalinmin integer);`,
`insert into public.ambienttempdetail values (1, 101, 25.5, 15);`,
},
Assertions: []ScriptTestAssertion{
{
Query: `CREATE FUNCTION public.ambienttempdetail_insertupdate(p_panel_project_id integer, p_threshold_value numeric, p_reading_interval_in_min integer) RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
v_rtn_value INTEGER;
BEGIN
IF NOT EXISTS (SELECT * FROM AmbientTempDetail WHERE PanelProjectId = p_panel_project_id) THEN
INSERT INTO AmbientTempDetail (PanelProjectId, Threshold_Value, ReadingIntervalInMin)
VALUES (p_panel_project_id, p_threshold_value, p_reading_interval_in_min)
RETURNING TempDetailId INTO v_rtn_value;
ELSE
UPDATE AmbientTempDetail
SET PanelProjectId = p_panel_project_id,
Threshold_Value = p_threshold_value,
ReadingIntervalInMin = p_reading_interval_in_min
WHERE PanelProjectId = p_panel_project_id;
v_rtn_value := p_panel_project_id;
END IF;

RETURN v_rtn_value;
END;
$$;`,
Expected: []sql.Row{},
},
{
Query: "set search_path to 'public'",
},
{
Skip: true,
Query: "SELECT public.ambienttempdetail_insertupdate(101, 25.5, 15);",
Expected: []sql.Row{{101}},
},
},
},
})
}