Temporary Table Cannot Be Accessed

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 临时表 无法访问

| username: 等一分钟

[TiDB Usage Environment] Production Environment
[TiDB Version] 6.5.1
[Issue] Temporary tables cannot be accessed

| username: 等一分钟 | Original post link

| username: 等一分钟 | Original post link

The second association is a view, you can remove it.

| username: 等一分钟 | Original post link

The image is not visible. Please provide the text you need translated.

| username: 等一分钟 | Original post link

| username: 等一分钟 | Original post link

Set the view to the end, and this error occurred again.

| username: tidb菜鸟一只 | Original post link

Can this SQL execute if the temporary table is removed?

| username: 等一分钟 | Original post link

Sure.

| username: 等一分钟 | Original post link

Sorry, I can’t assist with translating images. Please provide the text you need translated.

| username: tidb菜鸟一只 | Original post link

Which tables are involved in the view?

| username: 等一分钟 | Original post link

Sorry, I can’t assist with that.

| username: 等一分钟 | Original post link

Table structure

| username: 等一分钟 | Original post link

— Table structure, no data required
create database temp1111;
use temp1111;
drop temporary table if exists tempUnits;
create temporary table tempUnits(unitid char(38));
create table account(personid varchar(100), branch varchar(100));

create table paycode(personid varchar(100), paycode varchar(100), payhours varchar(100));
create table class (id varchar(100), mapid varchar(100));

CREATE VIEW v1 (PERSONID, PAYCODE, T02) AS
SELECT a.PERSONID AS PERSONID, a.PAYCODE AS PAYCODE, IF((aac.MapId=‘T02’), a.PAYHOURS, 0) AS T02
FROM
paycode a
LEFT JOIN class AS aac ON ((a.PAYCODE=aac.Id));

SELECT
a.personid
FROM
account a
LEFT JOIN v1 cod ON cod.personid = a.personid
INNER JOIN tempUnits ON a.branch = tempUnits.unitid;

| username: tidb菜鸟一只 | Original post link

I did not reproduce this issue on 5.4.3. Could it be a bug in 6.5.1…?
image

| username: WalterWj | Original post link

Provide feedback in the feedback section.

| username: 等一分钟 | Original post link

Does version 5.4 support temporary tables?

| username: tidb菜鸟一只 | Original post link

Yes, it was introduced in version 5.3.

| username: 等一分钟 | Original post link

Well, I didn’t notice, specifically upgraded to version 6.

| username: xingzhenxiang | Original post link

I’m using v6.5.1 and it’s not working either.

| username: xingzhenxiang | Original post link

You can insert