Added kexi hotfix to support versions 12 and higher, fixing issue #15 #16
Merged
SlavekB
merged 1 commits from feat/kexi-postgresql
into master
2 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feat/kexi-postgresql'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Added fixes for postgresql to support version 12 and higher. I checked that it seems to work even better than the driver for mysql. The mysql driver does not support tables without a primary key, but the postgresql driver does. The transition from hidden oid fields to ctid is performed. Checked everything seems to work.
I can not do testing functionality with PostgreSQL, but it seems good. There are some comments regarding the ability to better code readability. See comments below.
if (m_driver->beh->ROW_ID_FIELD_NAME == "ctid") {
if (row_id<=0 || true!=querySingleRecord(
TQString::fromLatin1("SELECT ") + tableName + TQString::fromLatin1(".") + aiFieldName + TQString::fromLatin1(" FROM ")
+ tableName + TQString::fromLatin1(" WHERE ") + aiFieldName + TQString::fromLatin1("=") + TQString::number(row_id), rdata))
I understand that you left the style of code as it was used below, but I believe that there could be a better readable way:
If I correctly read the difference in the calls, there may be a single call in one condition:
Oh sure. I'll deal with this later. While I checked this call, while it displays an error:
Most likely, the arguments will have to be written in one line.
My mistake – replacing argument cannot be used multiple times, so arguments need to be repeated:
{
d->pqxxsql = new pqxx::connection( conninfo.latin1() );
drv_executeSQL( "SET DEFAULT_WITH_OIDS TO ON" ); //Postgres 8.1 changed the default to no oids but we need them
//drv_executeSQL( "SET DEFAULT_WITH_OIDS TO ON" ); //Postgres 8.1 changed the default to no oids but we need them
Probably nothing prevents the line from being removed instead of commenting.
std::string temp;
TQString sql = "SELECT CURRVAL(pg_get_serial_sequence('";
sql += tableName + TQString::fromLatin1("', '");
sql += aiFieldName + TQString::fromLatin1("'))");
A possible better readable code?
676b584d7f
tobecbce9bb5
2 years agoAdded kexi hotfix to support versions 12 and higher, fixing issue #15to WIP: Added kexi hotfix to support versions 12 and higher, fixing issue #15 2 years agoAdded changes. It is still under development. It is necessary to improve the work with tables without a primary key. So far, there are problems with editing and deleting added rows in tables without a primary key.
Hmm, there is another idea, to use xmin for indication, instead of
ctid
. I even made a working implementation. What do you think is best to use? I am attaching a patch of changes forxmin
.In any case, if you use ctid, you will also need to get the value in the request. The
CURRVAL()
function is not suitable for tables without a primary key. Therefore, it will be necessary to return the result of theINSERT INTO
command in the same way, as it was done in the patch that I attached.Using
xmin
requires fewer code changes.becbce9bb5
toec7f178f4a
2 years agoAdded changes, now tables without a primary key can be easily edited.
There are two variants:
Both options are working.
I'm not an expert about PostgreSQL and therefore I can't thoroughly judge which variant is better. On the variant using
xmin
I like it is easier.There is one small comment valid for both variants – see below.
public:
TQString lastRowId;
I believe that there is no reason that the
lastRowId
variable waspublic
– on the contrary, I think it should beprivate
. This applies to both variants of patch –ctid
as well asxmin
.ec7f178f4a
to7115e4c672
2 years agoI guess it's better to use xmin all the same, since it doesn't change if someone executes VACUUM FULL. I think that I will add a check to the xmin patch to determine the postgresql version and select the oid column for older versions.
Both ctid and xmin have 1 minus, when the rows are updated, the values of xmin and ctid change. Added and deleted lines are not affected, but modified ones are affected. Therefore, for tables that do not have a primary key, after changing the rows, you must close and reopen the tab with the table. But since the order is not important for rows that do not have a primary key, you can simply delete unnecessary rows and add new ones, then there is no need to update the table.
For history, I added patch files, for both implementations.
7115e4c672
to5274e5d455
2 years agoAdded changes to support
xmin
columns. Fixed problem with editing tables that do not have a primary key. Now there is no need for the old binding tooid
columns. You can test the performance.WIP: Added kexi hotfix to support versions 12 and higher, fixing issue #15to Added kexi hotfix to support versions 12 and higher, fixing issue #15 2 years agoNow all looks good.
5274e5d455
into master 2 years agoReviewers
5274e5d455
.