Error Executing Temporary Table

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

Original topic: 临时表执行报错

| username: 等一分钟

“runtime error: invalid memory address or nil pointer dereference”

| username: 等一分钟 | Original post link

After creating the temporary table, running the script reports this error. What could be the reason?

| username: Amy_Jing | Original post link

This is a common runtime error, usually indicating that there is an attempt to access an invalid memory address or a nil pointer in the program.

The method to solve this problem depends on the specific situation and code where you encountered this error. Here are some suggested steps to resolve it:

  1. Check for nil pointers: First, confirm whether there are any variables (or objects) in the code that might be nil. If this is the case, you need to find and fix the issue causing the pointer to be nil, such as improper initialization or an unexpected assignment to nil.

  2. Memory allocation issues: If the error is due to an invalid memory address, you might need to check whether the memory was allocated correctly, such as using an uninitialized pointer or freeing already allocated memory.

  3. Debugging tools: Using a debugger can help you precisely locate where the error occurs. For example, GDB (GNU Debugger) is a commonly used debugging tool that you can use to view the stack trace where the error occurred and the changes in variable values.

  4. Error checking: Performing error checks before using pointers or accessing memory addresses is also a good practice. For example, check if a pointer is nil before using it and ensure that the data stored in the pointer is properly initialized.

  5. Log output: Adding log outputs at critical points can help you better understand the execution process of the code and trace where the error occurs.

  6. Read error messages: Make sure to carefully read the error messages, as they usually provide specific information about where and in what context the error occurred, which can give you some clues.

If you have tried the above steps and still cannot resolve the problem, you might need to provide more context and code snippets so that we can help you better analyze and solve the issue.
Send to PingCAT

| username: Billmay表妹 | Original post link

Known bug: panic:runtime error: invalid memory address or nil pointer · Issue #47531 · pingcap/tidb · GitHub

| username: 等一分钟 | Original post link

We’ve been using temporary tables for a while now.

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

Please provide the specific SQL and script… It’s hard to guess just from a single sentence.

| username: 等一分钟 | Original post link

CREATE TEMPORARY TABLE tempPersons ( person_id CHAR ( 38 ) );
INSERT INTO tempPersons
SELECT personid
FROM 5i5j.psnaccount
LIMIT 100;

SELECT count(*)
FROM tempPersons tmp1
LEFT JOIN (
SELECT aqs_view.5i5j_GetAtdPersonPaycode.personid
FROM aqs_view.5i5j_GetAtdPersonPaycode
LEFT JOIN 5i5j.psnaccount ON 5i5j_GetAtdPersonPaycode.personid = psnaccount.personid
WHERE TIMECARDDATE BETWEEN ‘2023-10-31’ AND ‘2023-10-31’
GROUP BY 5i5j_GetAtdPersonPaycode.personid
) b ON tmp1.person_id = b.personid

| username: 等一分钟 | Original post link

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

| username: 等一分钟 | Original post link

aqs_view.5i5j_GetAtdPersonPaycode is a view.

| username: 等一分钟 | Original post link

I think the problem is that the tidb-server process is not running. You can check if the process is running with the following command:

ps -ef | grep tidb-server

If it is not running, you can start it with the following command:

systemctl start tidb-server
| username: Jellybean | Original post link

Will there be errors when using temporary tables alone or associating temporary tables with physical tables? It is speculated that there may be some compatibility issues when temporary tables are used in conjunction with views.

| username: Kongdom | Original post link

We are also using temporary tables here. It’s normal for temporary tables to be associated with physical tables, but we haven’t tried it with views. Could you share the table structure so we can verify it in our environment?

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.