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); schemaId = get_rel_namespace(relationId);
schemaName = get_namespace_name(schemaId); schemaName = get_namespace_name(schemaId);
if (strncmp(schemaName, "public", NAMEDATALEN) == 0)
{
qualifiedName = (char *) quote_identifier(relationName);
}
else
{
qualifiedName = quote_qualified_identifier(schemaName, relationName); qualifiedName = quote_qualified_identifier(schemaName, relationName);
}
PG_RETURN_TEXT_P(cstring_to_text(qualifiedName)); PG_RETURN_TEXT_P(cstring_to_text(qualifiedName));
} }

View File

@ -187,7 +187,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -227,7 +227,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -413,7 +413,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -450,7 +450,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;

View File

@ -187,7 +187,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -227,7 +227,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -412,7 +412,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -449,7 +449,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;

View File

@ -245,7 +245,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
@ -486,7 +486,7 @@ step s2-print-index-count:
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;

View File

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

View File

@ -40,8 +40,8 @@ SELECT shard_name(0, 666666);
ERROR: object_name does not reference a valid relation ERROR: object_name does not reference a valid relation
SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, 666666); SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, 666666);
shard_name shard_name
------------------------------------------------------------------------ -----------------------------------------------------------------
public.too_long_12345678901234567890123456789012345678_e0119164_666666 too_long_12345678901234567890123456789012345678_e0119164_666666
(1 row) (1 row)
SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, NULL); SELECT shard_name('too_long_12345678901234567890123456789012345678901234567890'::regclass, NULL);
@ -317,8 +317,8 @@ SELECT shard_name(U&'elephant_!0441!043B!043E!043D!0441!043B!043E!043D!0441!043B
FROM pg_dist_shard 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; 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 shard_name
---------------------------------------------------------- ---------------------------------------------------
public."elephant_слонслонслонсло_c8b737c2_2250000000002" "elephant_слонслонслонсло_c8b737c2_2250000000002"
(1 row) (1 row)
\c - - - :worker_1_port \c - - - :worker_1_port

View File

@ -86,7 +86,7 @@ step "s2-print-index-count"
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
} }

View File

@ -104,7 +104,7 @@ step "s2-print-index-count"
SELECT SELECT
nodeport, success, result nodeport, success, result
FROM 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 ORDER BY
nodeport; nodeport;
} }