Skip to content

Commit

Permalink
Disable Shared Catcache Invalidation Messages for Temp Tables (babelf…
Browse files Browse the repository at this point in the history
…ish-for-postgresql#2770)

* Empty

* empty

* empty

* Resolve merge diff with relcache changes

Signed-off-by: Tim Chang <[email protected]>

* Clean up unnecessary code, added comments

Signed-off-by: Tim Chang <[email protected]>

* Add some tests for local cache inval

Signed-off-by: Tim Chang <[email protected]>

* Added alter table and drop function

Signed-off-by: Tim Chang <[email protected]>

* Move SIMessageIsForTempTable to hook

Signed-off-by: Tim Chang <[email protected]>

* Revert "Move SIMessageIsForTempTable to hook"

This reverts commit c79ac5a.

---------

Signed-off-by: Tim Chang <[email protected]>
  • Loading branch information
timchang514 authored Sep 24, 2024
1 parent 175fbd1 commit 0e32726
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,7 @@ static bool set_and_persist_temp_oid_buffer_start(Oid new_oid)
static bool
pltsql_is_local_only_inval_msg(const SharedInvalidationMessage *msg)
{
return temp_oid_buffer_size > 0 && (msg->id == SHAREDINVALRELCACHE_ID && msg->rc.local_only);
return SIMessageIsForTempTable(msg);
}

static EphemeralNamedRelation
Expand Down
Empty file.
Empty file.
79 changes: 79 additions & 0 deletions test/JDBC/expected/temp_catalog_inval-vu-verify.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

-- Catalog entries for temp tables are not visible from places like `pg_class` or `information_schema.tables`
-- So the best way to check whether the cache entries have been updated locally properly is to just ensure that
-- it's visible in typical use.
-- pg_class, pg_type, pg_attribute
CREATE TABLE #t1(a int)
go

insert into #t1 values (1)
go
~~ROW COUNT: 1~~


select * from #t1
go
~~START~~
int
1
~~END~~


drop table #t1
go

select * from #t1
go
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "#t1" does not exist)~~



-- constraint, depend, index, sequence, attrdefault
create table #t2(a int identity primary key, b int default 0)
go

alter table #t2 add c int
go

ALTER TABLE #t2 ALTER COLUMN a bigint
go

alter table #t2 alter column b bigint
go

insert into #t2(c) values (2)
go
~~ROW COUNT: 1~~


insert into #t2(c) values (4)
go
~~ROW COUNT: 1~~


insert into #t2(b, c) values (3, 2)
go
~~ROW COUNT: 1~~


select * from #t2
go
~~START~~
bigint#!#bigint#!#int
1#!#0#!#2
2#!#0#!#4
3#!#3#!#2
~~END~~


drop table #t2
go

select * from #t2
go
~~ERROR (Code: 33557097)~~

~~ERROR (Message: relation "#t2" does not exist)~~

Empty file.
Empty file.
51 changes: 51 additions & 0 deletions test/JDBC/input/temp_tables/temp_catalog_inval-vu-verify.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- Catalog entries for temp tables are not visible from places like `pg_class` or `information_schema.tables`
-- So the best way to check whether the cache entries have been updated locally properly is to just ensure that
-- it's visible in typical use.

-- pg_class, pg_type, pg_attribute
CREATE TABLE #t1(a int)
go

insert into #t1 values (1)
go

select * from #t1
go

drop table #t1
go

select * from #t1
go

-- constraint, depend, index, sequence, attrdefault

create table #t2(a int identity primary key, b int default 0)
go

alter table #t2 add c int
go

ALTER TABLE #t2 ALTER COLUMN a bigint
go

alter table #t2 alter column b bigint
go

insert into #t2(c) values (2)
go

insert into #t2(c) values (4)
go

insert into #t2(b, c) values (3, 2)
go

select * from #t2
go

drop table #t2
go

select * from #t2
go

0 comments on commit 0e32726

Please sign in to comment.