From 9999ca211d082f8a4c758ea56a1fab5df492af8b Mon Sep 17 00:00:00 2001 From: priyanshi-yb Date: Mon, 9 Sep 2024 22:00:45 +0530 Subject: [PATCH 1/3] [Docs][Voyager] Minor fixes in known-issues PG/Oracle pages --- .../preview/yugabyte-voyager/known-issues/oracle.md | 10 +++++++--- .../yugabyte-voyager/known-issues/postgresql.md | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md index 1fae446fbaea..72bae31c68a5 100644 --- a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md +++ b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md @@ -316,11 +316,15 @@ OR ### %TYPE syntax is unsupported -**GitHub**: [Issue #19169](https://github.com/yugabyte/yugabyte-db/issues/19169) +**GitHub**: [Issue #23619](https://github.com/yugabyte/yugabyte-db/issues/23619) -**Description**: In Oracle, the `%TYPE` is a virtual column that is used to declare a variable, column, or parameter with the same data type as an existing database column. An equivalent does not does exist in PostgreSQL and therefore in YugabyteDB. +**Description**: In Oracle, the `%TYPE` is a virtual column that is used to declare a variable, column, or parameter with the same data type as an existing database column. This syntax is not supported in target YugabyteDB yet and errors out in import schema with error: -**Workaround**: None. A workaround is currently being explored. +```output +ERROR: invalid type name "employees.salary%TYPE" (SQLSTATE 42601) +``` + +**Workaround**: Fix the syntax to include the actual type name instead of referencing the type of a column. --- diff --git a/docs/content/preview/yugabyte-voyager/known-issues/postgresql.md b/docs/content/preview/yugabyte-voyager/known-issues/postgresql.md index a9b9f38b4b6d..0f8a84c698eb 100644 --- a/docs/content/preview/yugabyte-voyager/known-issues/postgresql.md +++ b/docs/content/preview/yugabyte-voyager/known-issues/postgresql.md @@ -590,9 +590,9 @@ CREATE INDEX gist_idx ON public.ts_query_table USING gist (query); ### Indexes on some complex data types are not supported -**GitHub**: [Issue #9698](https://github.com/yugabyte/yugabyte-db/issues/9698) +**GitHub**: [Issue #9698](https://github.com/yugabyte/yugabyte-db/issues/9698), [Issue #23829](https://github.com/yugabyte/yugabyte-db/issues/23829) -**Description**: If you have indexes on some complex types such as TSQUERY, TSVECTOR, JSON, UDTs, citext, and so on, those will error out in import schema phase with the following error: +**Description**: If you have indexes on some complex types such as TSQUERY, TSVECTOR, JSONB, UDTs, citext, and so on, those will error out in import schema phase with the following error: ```output ERROR: INDEX on column of type '' not yet supported @@ -623,7 +623,7 @@ CREATE TABLE public.ts_query_table ( CREATE TABLE public.test_json ( id integer, - data json + data jsonb ); CREATE INDEX tsvector_idx ON public.documents (title_tsvector); From 2821e118c029da858923a807403b07452c097906 Mon Sep 17 00:00:00 2001 From: priyanshi-yb Date: Mon, 9 Sep 2024 22:16:09 +0530 Subject: [PATCH 2/3] example in oracle's %TYPE issue --- .../yugabyte-voyager/known-issues/oracle.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md index 72bae31c68a5..30ebdb77b7b1 100644 --- a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md +++ b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md @@ -326,6 +326,52 @@ ERROR: invalid type name "employees.salary%TYPE" (SQLSTATE 42601) **Workaround**: Fix the syntax to include the actual type name instead of referencing the type of a column. + +**Example** + +An example of exported schema from the source database is as follows: + +```sql +CREATE TABLE public.employees ( + employee_id integer NOT NULL, + employee_name text, + salary numeric +); + + +CREATE FUNCTION public.get_employee_salary(emp_id integer) RETURNS numeric + LANGUAGE plpgsql + AS $$ +DECLARE + emp_salary employees.salary%TYPE; -- Declare a variable with the same type as employees.salary +BEGIN + SELECT salary INTO emp_salary + FROM employees + WHERE employee_id = emp_id; + + RETURN emp_salary; +END; +$$; +``` + +Suggested change to CREATE FUNCTION is as follows: + +```sql +CREATE FUNCTION public.get_employee_salary(emp_id integer) RETURNS numeric + LANGUAGE plpgsql + AS $$ +DECLARE + Emp_salary NUMERIC; -- Declare a variable with the same type as employees.salary +BEGIN + SELECT salary INTO emp_salary + FROM employees + WHERE employee_id = emp_id; + + RETURN emp_salary; +END; +$$; +``` + --- ### TRANSLATE USING is unsupported From 565cd32f9ef45545ab1ae40d1dddc13662a939a9 Mon Sep 17 00:00:00 2001 From: Priyanshi Gupta Date: Tue, 10 Sep 2024 00:16:29 +0530 Subject: [PATCH 3/3] Update docs/content/preview/yugabyte-voyager/known-issues/oracle.md Co-authored-by: Aishwarya Chakravarthy --- docs/content/preview/yugabyte-voyager/known-issues/oracle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md index 30ebdb77b7b1..207a7d5fe546 100644 --- a/docs/content/preview/yugabyte-voyager/known-issues/oracle.md +++ b/docs/content/preview/yugabyte-voyager/known-issues/oracle.md @@ -318,7 +318,7 @@ OR **GitHub**: [Issue #23619](https://github.com/yugabyte/yugabyte-db/issues/23619) -**Description**: In Oracle, the `%TYPE` is a virtual column that is used to declare a variable, column, or parameter with the same data type as an existing database column. This syntax is not supported in target YugabyteDB yet and errors out in import schema with error: +**Description**: In Oracle, the `%TYPE` is a virtual column that is used to declare a variable, column, or parameter with the same data type as an existing database column. This syntax is not supported in target YugabyteDB yet and errors out in import schema as follows: ```output ERROR: invalid type name "employees.salary%TYPE" (SQLSTATE 42601)