Skip to content

Commit 4c15faf

Browse files
author
Raúl Marín
authored
Merge pull request #387 from CartoDB/2273_support
use literal substitution instead of identifier
2 parents c5bbb18 + b246ada commit 4c15faf

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
0.35.0 (XXXX-XX-XX)
22
* Reapply the changes in 0.33.0 (the issue we were looking for was unrelated)
33
* Reapply `Make PG12 depend on plpython3u instead of plpythonu`
4+
* Fix identifier quotation in `CDB_UserDataSize`
45

56
0.34.0 (2019-12-23)
67
* Revert changes done in 0.33.0, keeping function signature to drop them

scripts-available/CDB_Quota.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BEGIN
3333

3434
IF raster_available THEN
3535
raster_read_query := Format('SELECT o_table_name, r_table_name FROM @[email protected]_overviews
36-
WHERE o_table_schema = ''%I'' AND o_table_catalog = current_database()', schema_name);
36+
WHERE o_table_schema = %L AND o_table_catalog = current_database()', schema_name);
3737
ELSE
3838
raster_read_query := 'SELECT NULL::text AS o_table_name, NULL::text AS r_table_name';
3939
END IF;
@@ -42,7 +42,7 @@ BEGIN
4242
%s
4343
),
4444
user_tables AS (
45-
SELECT table_name FROM @extschema@._CDB_NonAnalysisTablesInSchema(''%I'')
45+
SELECT table_name FROM @extschema@._CDB_NonAnalysisTablesInSchema(%L)
4646
),
4747
table_cat AS (
4848
SELECT
@@ -55,7 +55,7 @@ BEGIN
5555
FROM user_tables
5656
),
5757
sizes AS (
58-
SELECT COALESCE(INT8(SUM(@extschema@._CDB_total_relation_size(''%I'', table_name)))) table_size,
58+
SELECT COALESCE(INT8(SUM(@extschema@._CDB_total_relation_size(%L, table_name)))) table_size,
5959
CASE
6060
WHEN is_overview THEN 0
6161
WHEN is_raster THEN 1

test/CDB_QuotaTest.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ SELECT 'excess3', catch_error($$INSERT INTO big VALUES (3);$$); -- disallowed, q
6060
DROP TABLE big;
6161
SELECT CDB_SetUserQuotaInBytes(0);
6262

63+
CREATE SCHEMA "complex-name%_with'quotes""";
64+
SELECT CDB_UserDataSize('"complex-name%_with''quotes"');
65+
DROP SCHEMA "complex-name%_with'quotes""";
6366

6467
set client_min_messages to NOTICE;
6568
DROP FUNCTION catch_error(text);

test/CDB_QuotaTest_expect

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ DROP TABLE
3030
excess3|t
3131
DROP TABLE
3232
0
33+
CREATE SCHEMA
34+
0
35+
DROP SCHEMA
3336
SET
3437
DROP FUNCTION
3538
DROP FUNCTION

0 commit comments

Comments
 (0)