mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Make storing and sorting values using less memory allocation
(while doing indexed UPDATE/DELETE) modified: storage/connect/array.cpp storage/connect/filamtxt.cpp - Force unix like line endings modified: storage/connect/tabvct.h
This commit is contained in:
@@ -127,6 +127,10 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
|
||||
case TYPE_PCHAR:
|
||||
par->AddValue(g, parmp->Value);
|
||||
break;
|
||||
case TYPE_VOID:
|
||||
// Integer stored inside pp->Value
|
||||
par->AddValue(g, (int)parmp->Value);
|
||||
break;
|
||||
} // endswitch valtyp
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -152,14 +156,17 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
|
||||
Xsize = -1;
|
||||
Len = 1;
|
||||
|
||||
switch ((Type = type)) {
|
||||
switch (type) {
|
||||
case TYPE_STRING:
|
||||
Len = length;
|
||||
break;
|
||||
case TYPE_SHORT:
|
||||
case TYPE_INT:
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_PCHAR:
|
||||
Type = type;
|
||||
break;
|
||||
case TYPE_VOID:
|
||||
Type = TYPE_INT;
|
||||
break;
|
||||
#if 0
|
||||
case TYPE_TOKEN:
|
||||
|
@@ -282,14 +282,17 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
|
||||
PPARM pp = (PPARM)PlugSubAlloc(g, NULL, sizeof(PARM));
|
||||
|
||||
switch (type) {
|
||||
case TYPE_INT:
|
||||
pp->Value = PlugSubAlloc(g, NULL, sizeof(int));
|
||||
*((int*)pp->Value) = *((int*)val);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1);
|
||||
strcpy((char*)pp->Value, (char*)val);
|
||||
// case TYPE_INT:
|
||||
// pp->Value = PlugSubAlloc(g, NULL, sizeof(int));
|
||||
// *((int*)pp->Value) = *((int*)val);
|
||||
// break;
|
||||
case TYPE_VOID:
|
||||
pp->Value = (void*)*(int*)val;
|
||||
break;
|
||||
// case TYPE_STRING:
|
||||
// pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1);
|
||||
// strcpy((char*)pp->Value, (char*)val);
|
||||
// break;
|
||||
case TYPE_PCHAR:
|
||||
pp->Value = val;
|
||||
break;
|
||||
@@ -310,18 +313,22 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
|
||||
int TXTFAM::StoreValues(PGLOBAL g, bool upd)
|
||||
{
|
||||
int pos = GetPos();
|
||||
bool rc = AddListValue(g, TYPE_INT, &pos, &To_Pos);
|
||||
bool rc = AddListValue(g, TYPE_VOID, &pos, &To_Pos);
|
||||
|
||||
if (!rc) {
|
||||
pos = GetNextPos();
|
||||
rc = AddListValue(g, TYPE_INT, &pos, &To_Sos);
|
||||
rc = AddListValue(g, TYPE_VOID, &pos, &To_Sos);
|
||||
} // endif rc
|
||||
|
||||
if (upd && !rc) {
|
||||
char *buf;
|
||||
|
||||
if (Tdbp->PrepareWriting(g))
|
||||
return RC_FX;
|
||||
|
||||
rc = AddListValue(g, TYPE_STRING, Tdbp->GetLine(), &To_Upd);
|
||||
buf = (char*)PlugSubAlloc(g, NULL, strlen(Tdbp->GetLine()) + 1);
|
||||
strcpy(buf, Tdbp->GetLine());
|
||||
rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd);
|
||||
} // endif upd
|
||||
|
||||
return rc ? RC_FX : RC_OK;
|
||||
|
Reference in New Issue
Block a user