Skip to content

Commit

Permalink
Support SSMS scripting for User defined datatypes and User defined Ta…
Browse files Browse the repository at this point in the history
…ble type (#1880)

To support scripting of User defined data type and User defined Table Type through SSMS. Also fixed the issue which caused error when opening the dropdown of User defined Data type in the explorer.

Fix done as part of this commit --
1/ Added a dummy typeproperty function (further implementation is tracked BABEL-802)
2/ Corrected the is_nullable data type in sys.types view.

Task: BABEL-3834,BABEL-3924
Signed-off-by: Ashish Prasad <[email protected]>
  • Loading branch information
hash-16 authored Oct 31, 2023
1 parent f1cf91f commit ac08cff
Show file tree
Hide file tree
Showing 56 changed files with 1,667 additions and 38 deletions.
12 changes: 12 additions & 0 deletions contrib/babelfishpg_tsql/sql/sys_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,18 @@ END;
$BODY$
LANGUAGE 'plpgsql' STABLE;

CREATE OR REPLACE FUNCTION sys.typeproperty(
typename sys.VARCHAR,
property sys.VARCHAR
)
RETURNS INT
AS $$
DECLARE
BEGIN
RETURN NULL;
END;
$$
LANGUAGE plpgsql STABLE;


CREATE OR REPLACE FUNCTION sys.SWITCHOFFSET(IN input_expr PG_CATALOG.TEXT,
Expand Down
6 changes: 3 additions & 3 deletions contrib/babelfishpg_tsql/sql/sys_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ select
WHEN 'default' THEN default_collation_name
ELSE c.collname
END as collation_name
, case when typnotnull then 0 else 1 end as is_nullable
, case when typnotnull then cast(0 as sys.bit) else cast(1 as sys.bit) end as is_nullable
, 0 as is_user_defined
, 0 as is_assembly_type
, 0 as default_object_id
Expand Down Expand Up @@ -1097,8 +1097,8 @@ select cast(t.typname as text) as name
WHEN 'default' THEN default_collation_name
ELSE c.collname
END as collation_name
, case when tt.typrelid is not null then 0
else case when typnotnull then 0 else 1 end
, case when tt.typrelid is not null then cast(0 as sys.bit)
else case when typnotnull then cast(0 as sys.bit) else cast(1 as sys.bit) end
end
as is_nullable
-- CREATE TYPE ... FROM is implemented as CREATE DOMAIN in babel
Expand Down
Loading

0 comments on commit ac08cff

Please sign in to comment.