Skip to content

Commit

Permalink
Merge #70865
Browse files Browse the repository at this point in the history
70865: sql: adding empty stubs for missing tables on pg_catalog r=RichardJCai a=mnovelodou

    Previously, tables pg_statistic, pg_statistic_ext_data, pg_stats and
    pg_stats_ext; and column pg_attribute.attmissingval was missing in
    pg_catalog
    This was inadequate because they exists in postgres pg_catalog
    To address this, this patch adds empty stubs for the missing tables
    and column on cockroach pg_catalog
    
    Release note (sql change): Adding empty stubs for tables and columns:
    tables:
    - pg_statistic
    - pg_statistic_ext_data
    - pg_stats
    - pg_stats_ext
    columns:
    - pg_attribute.attmissingval
    
    Resolves #70780


Co-authored-by: mnovelodou <jmnovelov.us@gmail.com>
  • Loading branch information
craig[bot] and mnovelodou committed Oct 4, 2021
2 parents 0dcfa15 + 64c59c0 commit 6ea317d
Show file tree
Hide file tree
Showing 13 changed files with 533 additions and 215 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/catalog/catconstants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ const (
PgCatalogStatioUserIndexesTableID
PgCatalogStatioUserSequencesTableID
PgCatalogStatioUserTablesTableID
PgCatalogStatisticExtDataTableID
PgCatalogStatisticExtTableID
PgCatalogStatisticTableID
PgCatalogStatsExtTableID
PgCatalogStatsTableID
PgCatalogSubscriptionRelTableID
PgCatalogSubscriptionTableID
PgCatalogTablesTableID
Expand Down
142 changes: 140 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/create_statements
Original file line number Diff line number Diff line change
Expand Up @@ -3367,7 +3367,8 @@ CREATE TABLE pg_catalog.pg_attribute (
attoptions STRING[] NULL,
attfdwoptions STRING[] NULL,
atthasmissing BOOL NULL,
INDEX pg_attribute_attrelid_idx (attrelid ASC) STORING (attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attidentity, attgenerated, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions, atthasmissing)
attmissingval STRING[] NULL,
INDEX pg_attribute_attrelid_idx (attrelid ASC) STORING (attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attidentity, attgenerated, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions, atthasmissing, attmissingval)
) CREATE TABLE pg_catalog.pg_attribute (
attrelid OID NOT NULL,
attname NAME NULL,
Expand All @@ -3393,7 +3394,8 @@ CREATE TABLE pg_catalog.pg_attribute (
attoptions STRING[] NULL,
attfdwoptions STRING[] NULL,
atthasmissing BOOL NULL,
INDEX pg_attribute_attrelid_idx (attrelid ASC) STORING (attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attidentity, attgenerated, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions, atthasmissing)
attmissingval STRING[] NULL,
INDEX pg_attribute_attrelid_idx (attrelid ASC) STORING (attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attidentity, attgenerated, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions, atthasmissing, attmissingval)
) {} {}
CREATE TABLE pg_catalog.pg_auth_members (
roleid OID NULL,
Expand Down Expand Up @@ -5545,6 +5547,71 @@ CREATE TABLE pg_catalog.pg_statio_user_tables (
schemaname NAME NULL,
tidx_blks_hit INT8 NULL
) {} {}
CREATE TABLE pg_catalog.pg_statistic (
stakind2 INT2 NULL,
stanumbers2 FLOAT4[] NULL,
stanumbers3 FLOAT4[] NULL,
staop5 OID NULL,
stacoll3 OID NULL,
stainherit BOOL NULL,
stakind3 INT2 NULL,
stavalues5 STRING[] NULL,
staattnum INT2 NULL,
stacoll1 OID NULL,
stacoll4 OID NULL,
stanullfrac FLOAT4 NULL,
stavalues1 STRING[] NULL,
stawidth INT4 NULL,
stacoll2 OID NULL,
stanumbers4 FLOAT4[] NULL,
stanumbers5 FLOAT4[] NULL,
staop2 OID NULL,
stavalues3 STRING[] NULL,
stakind4 INT2 NULL,
staop1 OID NULL,
staop4 OID NULL,
stacoll5 OID NULL,
stakind5 INT2 NULL,
staop3 OID NULL,
stavalues2 STRING[] NULL,
stavalues4 STRING[] NULL,
stakind1 INT2 NULL,
stanumbers1 FLOAT4[] NULL,
starelid OID NULL,
stadistinct FLOAT4 NULL
) CREATE TABLE pg_catalog.pg_statistic (
stakind2 INT2 NULL,
stanumbers2 FLOAT4[] NULL,
stanumbers3 FLOAT4[] NULL,
staop5 OID NULL,
stacoll3 OID NULL,
stainherit BOOL NULL,
stakind3 INT2 NULL,
stavalues5 STRING[] NULL,
staattnum INT2 NULL,
stacoll1 OID NULL,
stacoll4 OID NULL,
stanullfrac FLOAT4 NULL,
stavalues1 STRING[] NULL,
stawidth INT4 NULL,
stacoll2 OID NULL,
stanumbers4 FLOAT4[] NULL,
stanumbers5 FLOAT4[] NULL,
staop2 OID NULL,
stavalues3 STRING[] NULL,
stakind4 INT2 NULL,
staop1 OID NULL,
staop4 OID NULL,
stacoll5 OID NULL,
stakind5 INT2 NULL,
staop3 OID NULL,
stavalues2 STRING[] NULL,
stavalues4 STRING[] NULL,
stakind1 INT2 NULL,
stanumbers1 FLOAT4[] NULL,
starelid OID NULL,
stadistinct FLOAT4 NULL
) {} {}
CREATE TABLE pg_catalog.pg_statistic_ext (
oid OID NULL,
stxrelid OID NULL,
Expand All @@ -5564,6 +5631,77 @@ CREATE TABLE pg_catalog.pg_statistic_ext (
stxkeys INT2VECTOR NULL,
stxkind "char"[] NULL
) {} {}
CREATE TABLE pg_catalog.pg_statistic_ext_data (
stxddependencies BYTES NULL,
stxdmcv BYTES NULL,
stxdndistinct BYTES NULL,
stxoid OID NULL
) CREATE TABLE pg_catalog.pg_statistic_ext_data (
stxddependencies BYTES NULL,
stxdmcv BYTES NULL,
stxdndistinct BYTES NULL,
stxoid OID NULL
) {} {}
CREATE TABLE pg_catalog.pg_stats (
histogram_bounds STRING[] NULL,
most_common_elem_freqs FLOAT4[] NULL,
most_common_elems STRING[] NULL,
most_common_vals STRING[] NULL,
attname NAME NULL,
inherited BOOL NULL,
n_distinct FLOAT4 NULL,
schemaname NAME NULL,
correlation FLOAT4 NULL,
null_frac FLOAT4 NULL,
elem_count_histogram FLOAT4[] NULL,
most_common_freqs FLOAT4[] NULL,
tablename NAME NULL,
avg_width INT4 NULL
) CREATE TABLE pg_catalog.pg_stats (
histogram_bounds STRING[] NULL,
most_common_elem_freqs FLOAT4[] NULL,
most_common_elems STRING[] NULL,
most_common_vals STRING[] NULL,
attname NAME NULL,
inherited BOOL NULL,
n_distinct FLOAT4 NULL,
schemaname NAME NULL,
correlation FLOAT4 NULL,
null_frac FLOAT4 NULL,
elem_count_histogram FLOAT4[] NULL,
most_common_freqs FLOAT4[] NULL,
tablename NAME NULL,
avg_width INT4 NULL
) {} {}
CREATE TABLE pg_catalog.pg_stats_ext (
kinds "char"[] NULL,
most_common_base_freqs FLOAT8[] NULL,
most_common_freqs FLOAT8[] NULL,
n_distinct BYTES NULL,
schemaname NAME NULL,
statistics_schemaname NAME NULL,
dependencies BYTES NULL,
most_common_val_nulls BOOL[] NULL,
most_common_vals STRING[] NULL,
statistics_name NAME NULL,
statistics_owner NAME NULL,
tablename NAME NULL,
attnames NAME[] NULL
) CREATE TABLE pg_catalog.pg_stats_ext (
kinds "char"[] NULL,
most_common_base_freqs FLOAT8[] NULL,
most_common_freqs FLOAT8[] NULL,
n_distinct BYTES NULL,
schemaname NAME NULL,
statistics_schemaname NAME NULL,
dependencies BYTES NULL,
most_common_val_nulls BOOL[] NULL,
most_common_vals STRING[] NULL,
statistics_name NAME NULL,
statistics_owner NAME NULL,
tablename NAME NULL,
attnames NAME[] NULL
) {} {}
CREATE TABLE pg_catalog.pg_subscription (
subname NAME NULL,
subpublications STRING[] NULL,
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/grant_table
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ test pg_catalog pg_statio_sys_tables public
test pg_catalog pg_statio_user_indexes public SELECT
test pg_catalog pg_statio_user_sequences public SELECT
test pg_catalog pg_statio_user_tables public SELECT
test pg_catalog pg_statistic public SELECT
test pg_catalog pg_statistic_ext public SELECT
test pg_catalog pg_statistic_ext_data public SELECT
test pg_catalog pg_stats public SELECT
test pg_catalog pg_stats_ext public SELECT
test pg_catalog pg_subscription public SELECT
test pg_catalog pg_subscription_rel public SELECT
test pg_catalog pg_tables public SELECT
Expand Down
20 changes: 20 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,11 @@ pg_catalog pg_statio_sys_tables
pg_catalog pg_statio_user_indexes
pg_catalog pg_statio_user_sequences
pg_catalog pg_statio_user_tables
pg_catalog pg_statistic
pg_catalog pg_statistic_ext
pg_catalog pg_statistic_ext_data
pg_catalog pg_stats
pg_catalog pg_stats_ext
pg_catalog pg_subscription
pg_catalog pg_subscription_rel
pg_catalog pg_tables
Expand Down Expand Up @@ -963,7 +967,11 @@ pg_statio_sys_tables
pg_statio_user_indexes
pg_statio_user_sequences
pg_statio_user_tables
pg_statistic
pg_statistic_ext
pg_statistic_ext_data
pg_stats
pg_stats_ext
pg_subscription
pg_subscription_rel
pg_tables
Expand Down Expand Up @@ -1312,7 +1320,11 @@ system pg_catalog pg_statio_sys_tables SYSTEM
system pg_catalog pg_statio_user_indexes SYSTEM VIEW NO 1
system pg_catalog pg_statio_user_sequences SYSTEM VIEW NO 1
system pg_catalog pg_statio_user_tables SYSTEM VIEW NO 1
system pg_catalog pg_statistic SYSTEM VIEW NO 1
system pg_catalog pg_statistic_ext SYSTEM VIEW NO 1
system pg_catalog pg_statistic_ext_data SYSTEM VIEW NO 1
system pg_catalog pg_stats SYSTEM VIEW NO 1
system pg_catalog pg_stats_ext SYSTEM VIEW NO 1
system pg_catalog pg_subscription SYSTEM VIEW NO 1
system pg_catalog pg_subscription_rel SYSTEM VIEW NO 1
system pg_catalog pg_tables SYSTEM VIEW NO 1
Expand Down Expand Up @@ -2876,7 +2888,11 @@ NULL public system pg_catalog pg_statio_sys_tables
NULL public system pg_catalog pg_statio_user_indexes SELECT NULL YES
NULL public system pg_catalog pg_statio_user_sequences SELECT NULL YES
NULL public system pg_catalog pg_statio_user_tables SELECT NULL YES
NULL public system pg_catalog pg_statistic SELECT NULL YES
NULL public system pg_catalog pg_statistic_ext SELECT NULL YES
NULL public system pg_catalog pg_statistic_ext_data SELECT NULL YES
NULL public system pg_catalog pg_stats SELECT NULL YES
NULL public system pg_catalog pg_stats_ext SELECT NULL YES
NULL public system pg_catalog pg_subscription SELECT NULL YES
NULL public system pg_catalog pg_subscription_rel SELECT NULL YES
NULL public system pg_catalog pg_tables SELECT NULL YES
Expand Down Expand Up @@ -3477,7 +3493,11 @@ NULL public system pg_catalog pg_statio_sys_tables
NULL public system pg_catalog pg_statio_user_indexes SELECT NULL YES
NULL public system pg_catalog pg_statio_user_sequences SELECT NULL YES
NULL public system pg_catalog pg_statio_user_tables SELECT NULL YES
NULL public system pg_catalog pg_statistic SELECT NULL YES
NULL public system pg_catalog pg_statistic_ext SELECT NULL YES
NULL public system pg_catalog pg_statistic_ext_data SELECT NULL YES
NULL public system pg_catalog pg_stats SELECT NULL YES
NULL public system pg_catalog pg_stats_ext SELECT NULL YES
NULL public system pg_catalog pg_subscription SELECT NULL YES
NULL public system pg_catalog pg_subscription_rel SELECT NULL YES
NULL public system pg_catalog pg_tables SELECT NULL YES
Expand Down
Loading

0 comments on commit 6ea317d

Please sign in to comment.