From 83790f662af52e6b7dbd0a454d3f1c22c4d5d1f0 Mon Sep 17 00:00:00 2001 From: MiguelNovelo Date: Wed, 12 May 2021 18:53:11 -0500 Subject: [PATCH] sql: changed pg_catalog data type columns to "char" to match postgres Previously, some columns where is expected "char" datatype it is created as TEXT This was inadequate because some tools are expecting these columns to have "char" datatype To address this, this patch change the data types from these columns Release note (backward-incompatible change): Switched types from TEXT to "char" for compatibility with postgres in the following columns: pg_constraint (confdeltype, confmatchtype, confudptype, contype) pg_operator (oprkind) pg_prog (proargmodes) pg_rewrite (ev_enabled, ev_type) pg_trigger (tgenabled) Fixes #64434 --- .../testdata/logic_test/create_statements | 36 +++++------ .../pg_catalog_test_expected_diffs.json | 64 +------------------ pkg/sql/vtable/pg_catalog.go | 18 +++--- 3 files changed, 28 insertions(+), 90 deletions(-) diff --git a/pkg/sql/logictest/testdata/logic_test/create_statements b/pkg/sql/logictest/testdata/logic_test/create_statements index b229c01ca3f6..2cf7726f995a 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_statements +++ b/pkg/sql/logictest/testdata/logic_test/create_statements @@ -2188,7 +2188,7 @@ CREATE TABLE pg_catalog.pg_constraint ( oid OID NULL, conname NAME NULL, connamespace OID NULL, - contype STRING NULL, + contype "char" NULL, condeferrable BOOL NULL, condeferred BOOL NULL, convalidated BOOL NULL, @@ -2196,9 +2196,9 @@ CREATE TABLE pg_catalog.pg_constraint ( contypid OID NULL, conindid OID NULL, confrelid OID NULL, - confupdtype STRING NULL, - confdeltype STRING NULL, - confmatchtype STRING NULL, + confupdtype "char" NULL, + confdeltype "char" NULL, + confmatchtype "char" NULL, conislocal BOOL NULL, coninhcount INT4 NULL, connoinherit BOOL NULL, @@ -2217,7 +2217,7 @@ CREATE TABLE pg_catalog.pg_constraint ( oid OID NULL, conname NAME NULL, connamespace OID NULL, - contype STRING NULL, + contype "char" NULL, condeferrable BOOL NULL, condeferred BOOL NULL, convalidated BOOL NULL, @@ -2225,9 +2225,9 @@ CREATE TABLE pg_catalog.pg_constraint ( contypid OID NULL, conindid OID NULL, confrelid OID NULL, - confupdtype STRING NULL, - confdeltype STRING NULL, - confmatchtype STRING NULL, + confupdtype "char" NULL, + confdeltype "char" NULL, + confmatchtype "char" NULL, conislocal BOOL NULL, coninhcount INT4 NULL, connoinherit BOOL NULL, @@ -2703,7 +2703,7 @@ CREATE TABLE pg_catalog.pg_operator ( oprname NAME NULL, oprnamespace OID NULL, oprowner OID NULL, - oprkind STRING NULL, + oprkind "char" NULL, oprcanmerge BOOL NULL, oprcanhash BOOL NULL, oprleft OID NULL, @@ -2719,7 +2719,7 @@ CREATE TABLE pg_catalog.pg_operator ( oprname NAME NULL, oprnamespace OID NULL, oprowner OID NULL, - oprkind STRING NULL, + oprkind "char" NULL, oprcanmerge BOOL NULL, oprcanhash BOOL NULL, oprleft OID NULL, @@ -2850,7 +2850,7 @@ CREATE TABLE pg_catalog.pg_proc ( prorettype OID NULL, proargtypes OIDVECTOR NULL, proallargtypes OID[] NULL, - proargmodes STRING[] NULL, + proargmodes "char"[] NULL, proargnames STRING[] NULL, proargdefaults STRING NULL, protrftypes OID[] NULL, @@ -2883,7 +2883,7 @@ CREATE TABLE pg_catalog.pg_proc ( prorettype OID NULL, proargtypes OIDVECTOR NULL, proallargtypes OID[] NULL, - proargmodes STRING[] NULL, + proargmodes "char"[] NULL, proargnames STRING[] NULL, proargdefaults STRING NULL, protrftypes OID[] NULL, @@ -3001,8 +3001,8 @@ CREATE TABLE pg_catalog.pg_rewrite ( oid OID NULL, rulename NAME NULL, ev_class OID NULL, - ev_type STRING NULL, - ev_enabled STRING NULL, + ev_type "char" NULL, + ev_enabled "char" NULL, is_instead BOOL NULL, ev_qual STRING NULL, ev_action STRING NULL @@ -3010,8 +3010,8 @@ CREATE TABLE pg_catalog.pg_rewrite ( oid OID NULL, rulename NAME NULL, ev_class OID NULL, - ev_type STRING NULL, - ev_enabled STRING NULL, + ev_type "char" NULL, + ev_enabled "char" NULL, is_instead BOOL NULL, ev_qual STRING NULL, ev_action STRING NULL @@ -3409,7 +3409,7 @@ CREATE TABLE pg_catalog.pg_trigger ( tgname NAME NULL, tgfoid OID NULL, tgtype INT2 NULL, - tgenabled STRING NULL, + tgenabled "char" NULL, tgisinternal BOOL NULL, tgconstrrelid OID NULL, tgconstrindid OID NULL, @@ -3429,7 +3429,7 @@ CREATE TABLE pg_catalog.pg_trigger ( tgname NAME NULL, tgfoid OID NULL, tgtype INT2 NULL, - tgenabled STRING NULL, + tgenabled "char" NULL, tgisinternal BOOL NULL, tgconstrrelid OID NULL, tgconstrindid OID NULL, diff --git a/pkg/sql/testdata/pg_catalog_test_expected_diffs.json b/pkg/sql/testdata/pg_catalog_test_expected_diffs.json index e4d71328c522..90c9b095e2c6 100644 --- a/pkg/sql/testdata/pg_catalog_test_expected_diffs.json +++ b/pkg/sql/testdata/pg_catalog_test_expected_diffs.json @@ -30,32 +30,6 @@ "expectedDataType": "name" } }, - "pg_constraint": { - "confdeltype": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - }, - "confmatchtype": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - }, - "confupdtype": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - }, - "contype": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - } - }, "pg_conversion": { "conproc": { "oid": 26, @@ -113,12 +87,6 @@ "expectedOid": 24, "expectedDataType": "regproc" }, - "oprkind": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - }, "oprrest": { "oid": 26, "dataType": "oid", @@ -126,14 +94,6 @@ "expectedDataType": "regproc" } }, - "pg_proc": { - "proargmodes": { - "oid": 1009, - "dataType": "_text", - "expectedOid": 1002, - "expectedDataType": "_char" - } - }, "pg_range": { "rngcanonical": { "oid": 26, @@ -148,20 +108,6 @@ "expectedDataType": "regproc" } }, - "pg_rewrite": { - "ev_enabled": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - }, - "ev_type": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - } - }, "pg_seclabel": { "objsubid": { "oid": 20, @@ -178,14 +124,6 @@ "expectedDataType": "_text" } }, - "pg_trigger": { - "tgenabled": { - "oid": 25, - "dataType": "text", - "expectedOid": 18, - "expectedDataType": "char" - } - }, "pg_user": { "valuntil": { "oid": 1114, @@ -194,4 +132,4 @@ "expectedDataType": "timestamptz" } } -} +} \ No newline at end of file diff --git a/pkg/sql/vtable/pg_catalog.go b/pkg/sql/vtable/pg_catalog.go index cb0cd076ebbd..3a3d591a8c82 100644 --- a/pkg/sql/vtable/pg_catalog.go +++ b/pkg/sql/vtable/pg_catalog.go @@ -215,7 +215,7 @@ CREATE TABLE pg_catalog.pg_constraint ( oid OID, conname NAME, connamespace OID, - contype STRING, + contype "char", condeferrable BOOL, condeferred BOOL, convalidated BOOL, @@ -223,9 +223,9 @@ CREATE TABLE pg_catalog.pg_constraint ( contypid OID, conindid OID, confrelid OID, - confupdtype STRING, - confdeltype STRING, - confmatchtype STRING, + confupdtype "char", + confdeltype "char", + confmatchtype "char", conislocal BOOL, coninhcount INT4, connoinherit BOOL, @@ -533,7 +533,7 @@ CREATE TABLE pg_catalog.pg_operator ( oprname NAME, oprnamespace OID, oprowner OID, - oprkind TEXT, + oprkind "char", oprcanmerge BOOL, oprcanhash BOOL, oprleft OID, @@ -600,7 +600,7 @@ CREATE TABLE pg_catalog.pg_proc ( prorettype OID, proargtypes OIDVECTOR, proallargtypes OID[], - proargmodes STRING[], + proargmodes "char"[], proargnames STRING[], proargdefaults STRING, protrftypes OID[], @@ -631,8 +631,8 @@ CREATE TABLE pg_catalog.pg_rewrite ( oid OID, rulename NAME, ev_class OID, - ev_type TEXT, - ev_enabled TEXT, + ev_type "char", + ev_enabled "char", is_instead BOOL, ev_qual TEXT, ev_action TEXT @@ -758,7 +758,7 @@ CREATE TABLE pg_catalog.pg_trigger ( tgname NAME, tgfoid OID, tgtype INT2, - tgenabled TEXT, + tgenabled "char", tgisinternal BOOL, tgconstrrelid OID, tgconstrindid OID,