Omit public schema from shard_name output

pull/1687/head
Marco Slot 2017-10-04 13:21:48 +02:00
parent e16805215d
commit 7f68f78ee9
8 changed files with 39 additions and 31 deletions

View File

@ -720,7 +720,15 @@ shard_name(PG_FUNCTION_ARGS)
schemaId = get_rel_namespace(relationId);
schemaName = get_namespace_name(schemaId);
qualifiedName = quote_qualified_identifier(schemaName, relationName);
if (strncmp(schemaName, "public", NAMEDATALEN) == 0)
{
qualifiedName = (char *) quote_identifier(relationName);
}
else
{
qualifiedName = quote_qualified_identifier(schemaName, relationName);
}
PG_RETURN_TEXT_P(cstring_to_text(qualifiedName));
}

View File

@ -187,7 +187,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -227,7 +227,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -413,7 +413,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -450,7 +450,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;

View File

@ -187,7 +187,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -227,7 +227,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -412,7 +412,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -449,7 +449,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;

View File

@ -245,7 +245,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
@ -486,7 +486,7 @@ step s2-print-index-count:
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;

View File

@ -1386,18 +1386,18 @@ JOIN
USING (shardid)
ORDER BY
id;
id | shard_name | nodename | nodeport
----+----------------------+-----------+----------
1 | public.users_1200022 | localhost | 57637
2 | public.users_1200025 | localhost | 57638
3 | public.users_1200023 | localhost | 57638
4 | public.users_1200023 | localhost | 57638
5 | public.users_1200022 | localhost | 57637
6 | public.users_1200024 | localhost | 57637
7 | public.users_1200023 | localhost | 57638
8 | public.users_1200022 | localhost | 57637
9 | public.users_1200025 | localhost | 57638
10 | public.users_1200022 | localhost | 57637
id | shard_name | nodename | nodeport
----+---------------+-----------+----------
1 | users_1200022 | localhost | 57637
2 | users_1200025 | localhost | 57638
3 | users_1200023 | localhost | 57638
4 | users_1200023 | localhost | 57638
5 | users_1200022 | localhost | 57637
6 | users_1200024 | localhost | 57637
7 | users_1200023 | localhost | 57638
8 | users_1200022 | localhost | 57637
9 | users_1200025 | localhost | 57638
10 | users_1200022 | localhost | 57637
(10 rows)
END;

View File

@ -39,9 +39,9 @@ SELECT shard_name(NULL, 666666);
SELECT shard_name(0, 666666);
ERROR: object_name does not reference a valid relation
SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, 666666);
shard_name
------------------------------------------------------------------------
public.too_long_12345678901234567890123456789012345678_e0119164_666666
shard_name
-----------------------------------------------------------------
too_long_12345678901234567890123456789012345678_e0119164_666666
(1 row)
SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, NULL);
@ -316,9 +316,9 @@ SELECT master_create_worker_shards(U&'elephant_!0441!043B!043E!043D!0441!043B!04
SELECT shard_name(U&'elephant_!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D' UESCAPE '!'::regclass, min(shardid))
FROM pg_dist_shard
WHERE logicalrelid = U&'elephant_!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B!043E!043D' UESCAPE '!'::regclass;
shard_name
----------------------------------------------------------
public."elephant_слонслонслонсло_c8b737c2_2250000000002"
shard_name
---------------------------------------------------
"elephant_слонслонслонсло_c8b737c2_2250000000002"
(1 row)
\c - - - :worker_1_port

View File

@ -86,7 +86,7 @@ step "s2-print-index-count"
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_reference_table', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
}

View File

@ -104,7 +104,7 @@ step "s2-print-index-count"
SELECT
nodeport, success, result
FROM
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE schemaname || ''.'' || tablename = ''%s''')
run_command_on_placements('test_copy_placement_vs_modification', 'select count(*) from pg_indexes WHERE tablename = ''%s''')
ORDER BY
nodeport;
}