-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk copy command fails with generated spoint
column
#136
Comments
Which version of PostgreSQL are you using, @JeremyMcCormick ? And which version of PgSphere? Thanks! P.S. I think you can simplify your |
I am running this PostgreSQL version:
And PgSphere I download and build from here in my Docker container:
Okay, thanks for the tip! |
OK. My googling of this error message found a message from Tom Lane who said he'd fixed something in some PostgreSQL 13.x release that seemed to be related to this, but it must have been something else. I haven't found any documentation regarding how to add support for this, unfortunately. My google-fu is failing me... Anyone have any pointers? |
Adding binary input functions is covered here: https://www.postgresql.org/docs/current/sql-createtype.html If this is already present, then my problem lies elsewhere... |
This is probably just ChatGPT hallucinating, but this may be helpful... Implement the binary input function
Register the function This is probably not even close to being correct but may provide some hints:
It is also recommended to implement binary output as well, which is a similar process. There should be working examples of binary IO implementations for custom types in extensions - I can look around if that would help. I don't think this is all that difficult to implement for someone who knows PostgreSQL internals, especially since |
Are you using |
I'm importing data like this, which is activated by an equivalent
Input data is a CSV file. But I think what is going on here is that it is trying to automatically update the generated column, which requires binary input. Do you think there are different options on Apologies that I cannot share my exact data, as it is proprietary, but a simple test could be arranged pretty easily. |
COPY can only use the binary format when the client is prepared to send the data in that specific format, your CSV would have to be coded like that. If plain COPY would require binary format, pg_dump/restore wouldn't work and people would have complained about that years ago because they can't backup their pgsphere databases. TBH I have no idea why binary format comes into play at all here. 😸 That said, we should just implement it. |
@JeremyMcCormick wrote:
That might be helpful. The first thing I did was to check q3c's code to see if it implemented anything for this, and I didn't see anything.
A simple test we can run would also be helpful. We would need to add something to the test suite regardless, so I recommend looking at the existing tests and seeing if you can modify or adapt one of the existing tests. |
Even though I have left out the generated column from the column list in the
I don't know either, as it seems like PostgreSQL should be able to populate the generated column from my two coordinate columns. But it looks like binary input needs to be implemented for this to work. That's what the error message suggests to me at least.
I can come up with a toy example to reproduce the problem. My production database has a lot of columns, so I can just include |
I tried a simple test and it passed ok on 16.6.
From the original message I found that the message below describes some load problems with type point, not spoint. Type point is a postgresql type.
May be, the problem is not related to pgsphere's spoint? |
I have a generated column with type
spoint
in my table which seems to be preventing me from using the\copy
command to load data.I get the error:
I have investigated the problem for a few hours, and it seems that the cause is
pgsphere
not implementing binary input for this type. An equivalent insert statement using test data works fine, so I don't think there is any fundamental problem with my data or how the generated column is working.I would really like to get
\copy
working with my tables which use these generated columns having a definition like:To work around this, I would have to use less desirable methods like copying from staging tables, using insert commands instead, etc. and I would lose the efficiency of the bulk copy operation.
Any insight or advice would be appreciated, thanks!
The text was updated successfully, but these errors were encountered: