Make the code nicer by avoiding IF/THEN/ELSE
As suggested by Algunenano.
This commit is contained in:
parent
af142306aa
commit
61d2024eb5
@ -165,12 +165,11 @@ $$ LANGUAGE 'plpgsql' IMMUTABLE PARALLEL SAFE;
|
|||||||
CREATE OR REPLACE FUNCTION cartodb._CDB_Table_Exists(table_name_with_optional_schema TEXT)
|
CREATE OR REPLACE FUNCTION cartodb._CDB_Table_Exists(table_name_with_optional_schema TEXT)
|
||||||
RETURNS bool
|
RETURNS bool
|
||||||
AS $$
|
AS $$
|
||||||
|
DECLARE
|
||||||
|
table_exists bool := false;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF EXISTS(SELECT * FROM pg_class WHERE table_name_with_optional_schema::regclass::oid = oid AND relkind = 'r') THEN
|
table_exists := EXISTS(SELECT * FROM pg_class WHERE table_name_with_optional_schema::regclass::oid = oid AND relkind = 'r');
|
||||||
RETURN true;
|
RETURN table_exists;
|
||||||
ELSE
|
|
||||||
RETURN false;
|
|
||||||
END IF;
|
|
||||||
EXCEPTION
|
EXCEPTION
|
||||||
WHEN invalid_schema_name OR undefined_table THEN
|
WHEN invalid_schema_name OR undefined_table THEN
|
||||||
RETURN false;
|
RETURN false;
|
||||||
|
Loading…
Reference in New Issue
Block a user