2015-10-22 22:18:46 +08:00
|
|
|
-- Test unique identifier creation with normal length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'relname', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with normal length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'relname', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with normal length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'relname', '_suffix');
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with long length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with long length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
2017-06-30 00:53:24 +08:00
|
|
|
CREATE TABLE prefix_largolargolargolargolargolargolargolargolargolargola (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL);
|
2017-06-30 00:53:24 +08:00
|
|
|
DROP TABLE prefix_largolargolargolargolargolargolargolargolargolargola;
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with long length normal relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', '_suffix');
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
2017-06-30 00:53:24 +08:00
|
|
|
CREATE TABLE largolargolargolargolargolargolargolargolargolargola_suffix (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', '_suffix');
|
2017-06-30 00:53:24 +08:00
|
|
|
DROP TABLE largolargolargolargolargolargolargolargolargolargola_suffix;
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with normal length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'piraña', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with normal length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'piraña', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with normal length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'piraña', '_suffix');
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with long length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with long length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
|
|
|
CREATE TABLE prefix_piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier('prefix_', 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL);
|
2015-10-22 22:18:46 +08:00
|
|
|
DROP TABLE prefix_piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi;
|
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with long length UTF8 relname
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', '_suffix');
|
2015-10-22 22:18:46 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
|
|
|
CREATE TABLE piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi_suffix (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', '_suffix');
|
2015-10-22 22:18:46 +08:00
|
|
|
DROP TABLE piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi_suffix;
|
|
|
|
|
2015-10-27 01:01:03 +08:00
|
|
|
CREATE TABLE test (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
-- Test unique identifier creation with normal length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'colname', NULL, 'test'::regclass);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
2015-10-23 01:23:38 +08:00
|
|
|
-- Test unique identifier creation with prefix with normal length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'colname', NULL, 'test'::regclass);
|
2015-10-22 22:18:46 +08:00
|
|
|
|
2015-10-23 01:23:38 +08:00
|
|
|
-- Test unique identifier creation with suffix with normal length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'colname', '_suffix', 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with long length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with long length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL, 'test'::regclass);
|
|
|
|
DROP TABLE test;
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
2017-06-30 00:53:24 +08:00
|
|
|
CREATE TABLE test (prefix_largolargolargolargolargolargolargolargolargolargola text);
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'largolargolargolargolargolargolargolargolargolargolargolargolar', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
DROP TABLE test;
|
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with long length normal colname
|
2015-10-27 01:01:03 +08:00
|
|
|
CREATE TABLE test (name text);
|
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', '_suffix', 'test'::regclass);
|
|
|
|
DROP TABLE test;
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
2017-06-30 00:53:24 +08:00
|
|
|
CREATE TABLE test (largolargolargolargolargolargolargolargolargolargola_suffix text);
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'largolargolargolargolargolargolargolargolargolargolargolargolar', '_suffix', 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
DROP TABLE test;
|
|
|
|
|
2015-10-27 01:01:03 +08:00
|
|
|
CREATE TABLE test (name text);
|
2015-10-23 01:23:38 +08:00
|
|
|
-- Test unique identifier creation with normal length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'piraña', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with normal length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'piraña', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with normal length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'piraña', '_suffix', 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with long length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test unique identifier creation with prefix with long length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL, 'test'::regclass);
|
|
|
|
DROP TABLE test;
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
|
|
|
CREATE TABLE test (prefix_piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi text);
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier('prefix_', 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', NULL, 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
DROP TABLE test;
|
|
|
|
|
|
|
|
-- Test unique identifier creation with suffix with long length UTF8 colname
|
2015-10-27 01:01:03 +08:00
|
|
|
CREATE TABLE test (name text);
|
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', '_suffix', 'test'::regclass);
|
|
|
|
DROP TABLE test;
|
2015-10-23 01:23:38 +08:00
|
|
|
|
|
|
|
-- Test new identifier is found when name is taken from previous case
|
|
|
|
CREATE TABLE test (piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpi_suffix text);
|
2015-10-27 01:01:03 +08:00
|
|
|
SELECT * FROM cartodb._CDB_Unique_Column_Identifier(NULL, 'piñaácidpiñaácidpiñaácidpiñaácidpiñaácidpiñaácidpin', '_suffix', 'test'::regclass);
|
2015-10-23 01:23:38 +08:00
|
|
|
DROP TABLE test;
|
|
|
|
|
2015-10-27 01:01:03 +08:00
|
|
|
-- Test _CDB_Octet_Truncate simple case
|
|
|
|
SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 5);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
2015-10-27 01:01:03 +08:00
|
|
|
-- Test _CDB_Octet_Truncate UTF8 case
|
|
|
|
SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 6);
|
2015-10-23 01:23:38 +08:00
|
|
|
|
2015-10-27 01:01:03 +08:00
|
|
|
-- Test _CDB_Octet_Truncate UTF8 case
|
|
|
|
SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 7);
|
2018-07-03 19:00:24 +08:00
|
|
|
|
|
|
|
-- Test _CDB_Table_Exists
|
|
|
|
CREATE TABLE public.this_table_exists();
|
|
|
|
SELECT cartodb._CDB_Table_Exists('this_table_does_not_exist');
|
|
|
|
SELECT cartodb._CDB_Table_Exists('this_schema_does_not_exist.this_table_does_not_exist');
|
|
|
|
SELECT cartodb._CDB_Table_Exists('this_table_exists');
|
|
|
|
SELECT cartodb._CDB_Table_Exists('public.this_table_exists');
|
|
|
|
SELECT cartodb._CDB_Table_Exists('raster_overviews'); -- view created by postgis
|
|
|
|
SELECT cartodb._CDB_Table_Exists('public.raster_overviews');
|
|
|
|
DROP TABLE public.this_table_exists
|