Skip to content

Commit 2cfccbe

Browse files
committed
Merge branch 'connect/10.0' into 10.0
2 parents de9ea40 + b7aee7d commit 2cfccbe

File tree

9 files changed

+196
-271
lines changed

9 files changed

+196
-271
lines changed

storage/connect/JdbcInterface.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,18 @@ public int GetMaxValue(int n) {
340340
return m;
341341
} // end of GetMaxValue
342342

343+
public String GetQuoteString() {
344+
String qs = null;
345+
346+
try {
347+
qs = dbmd.getIdentifierQuoteString();
348+
} catch(SQLException se) {
349+
SetErrmsg(se);
350+
} // end try/catch
351+
352+
return qs;
353+
} // end of GetQuoteString
354+
343355
public int GetColumns(String[] parms) {
344356
int ncol = -1;
345357

@@ -680,11 +692,11 @@ public int TimestampField(int n, String name) {
680692
return 0;
681693
} // end of TimestampField
682694

683-
public String ObjectField(int n, String name) {
695+
public Object ObjectField(int n, String name) {
684696
if (rs == null) {
685697
System.out.println("No result set");
686698
} else try {
687-
return (n > 0) ? rs.getObject(n).toString() : rs.getObject(name).toString();
699+
return (n > 0) ? rs.getObject(n) : rs.getObject(name);
688700
} catch (SQLException se) {
689701
SetErrmsg(se);
690702
} //end try/catch

storage/connect/filamdbf.cpp

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp)
383383
/* and header length. Set Records, check that Reclen is equal to lrecl and */
384384
/* return the header length or 0 in case of error. */
385385
/****************************************************************************/
386-
int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
386+
int DBFBASE::ScanHeader(PGLOBAL g, PSZ fn, int lrecl, int *rln, char *defpath)
387387
{
388388
int rc;
389389
char filename[_MAX_PATH];
@@ -393,7 +393,7 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
393393
/************************************************************************/
394394
/* Open the input file. */
395395
/************************************************************************/
396-
PlugSetPath(filename, fname, defpath);
396+
PlugSetPath(filename, fn, defpath);
397397

398398
if (!(infile= global_fopen(g, MSGID_CANNOT_OPEN, filename, "rb")))
399399
return 0; // Assume file does not exist
@@ -410,11 +410,7 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
410410
} else if (rc == RC_FX)
411411
return -1;
412412

413-
if ((int)header.Reclen() != lrecl) {
414-
sprintf(g->Message, MSG(BAD_LRECL), lrecl, header.Reclen());
415-
return -1;
416-
} // endif Lrecl
417-
413+
*rln = (int)header.Reclen();
418414
Records = (int)header.Records();
419415
return (int)header.Headlen();
420416
} // end of ScanHeader
@@ -431,9 +427,27 @@ int DBFFAM::Cardinality(PGLOBAL g)
431427
if (!g)
432428
return 1;
433429

434-
if (!Headlen)
435-
if ((Headlen = ScanHeader(g, To_File, Lrecl, Tdbp->GetPath())) < 0)
436-
return -1; // Error in ScanHeader
430+
if (!Headlen) {
431+
int rln = 0; // Record length in the file header
432+
433+
Headlen = ScanHeader(g, To_File, Lrecl, &rln, Tdbp->GetPath());
434+
435+
if (Headlen < 0)
436+
return -1; // Error in ScanHeader
437+
438+
if (rln && Lrecl != rln) {
439+
// This happens always on some Linux platforms
440+
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, rln);
441+
442+
if (Accept) {
443+
Lrecl = rln;
444+
PushWarning(g, Tdbp);
445+
} else
446+
return -1;
447+
448+
} // endif rln
449+
450+
} // endif Headlen
437451

438452
// Set number of blocks for later use
439453
Block = (Records > 0) ? (Records + Nrec - 1) / Nrec : 0;
@@ -565,7 +579,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
565579

566580
if (Lrecl != reclen) {
567581
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, reclen);
568-
return true;
582+
583+
if (Accept) {
584+
Lrecl = reclen;
585+
PushWarning(g, Tdbp);
586+
} else
587+
return true;
588+
569589
} // endif Lrecl
570590

571591
hlen = HEADLEN * (n + 1) + 2;
@@ -641,8 +661,14 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
641661
if ((rc = dbfhead(g, Stream, Tdbp->GetFile(g), &header)) == RC_OK) {
642662
if (Lrecl != (int)header.Reclen()) {
643663
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, header.Reclen());
644-
return true;
645-
} // endif Lrecl
664+
665+
if (Accept) {
666+
Lrecl = header.Reclen();
667+
PushWarning(g, Tdbp);
668+
} else
669+
return true;
670+
671+
} // endif Lrecl
646672

647673
Records = (int)header.Records();
648674
Headlen = (int)header.Headlen();
@@ -916,9 +942,27 @@ int DBMFAM::Cardinality(PGLOBAL g)
916942
if (!g)
917943
return 1;
918944

919-
if (!Headlen)
920-
if ((Headlen = ScanHeader(g, To_File, Lrecl, Tdbp->GetPath())) < 0)
921-
return -1; // Error in ScanHeader
945+
if (!Headlen) {
946+
int rln = 0; // Record length in the file header
947+
948+
Headlen = ScanHeader(g, To_File, Lrecl, &rln, Tdbp->GetPath());
949+
950+
if (Headlen < 0)
951+
return -1; // Error in ScanHeader
952+
953+
if (rln && Lrecl != rln) {
954+
// This happens always on some Linux platforms
955+
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, rln);
956+
957+
if (Accept) {
958+
Lrecl = rln;
959+
PushWarning(g, Tdbp);
960+
} else
961+
return -1;
962+
963+
} // endif rln
964+
965+
} // endif Headlen
922966

923967
// Set number of blocks for later use
924968
Block = (Records > 0) ? (Records + Nrec - 1) / Nrec : 0;
@@ -961,8 +1005,14 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
9611005

9621006
if (Lrecl != (int)hp->Reclen()) {
9631007
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen());
964-
return true;
965-
} // endif Lrecl
1008+
1009+
if (Accept) {
1010+
Lrecl = hp->Reclen();
1011+
PushWarning(g, Tdbp);
1012+
} else
1013+
return true;
1014+
1015+
} // endif Lrecl
9661016

9671017
Records = (int)hp->Records();
9681018
Headlen = (int)hp->Headlen();

storage/connect/filamdbf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DllExport DBFBASE {
3131
DBFBASE(PDBF txfp);
3232

3333
// Implementation
34-
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath);
34+
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, int *rlen, char *defpath);
3535

3636
protected:
3737
// Default constructor, not to be used

storage/connect/ha_connect.cc

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ uint GetWorkSize(void);
224224
void SetWorkSize(uint);
225225
extern "C" const char *msglang(void);
226226

227+
static void PopUser(PCONNECT xp);
227228
static PCONNECT GetUser(THD *thd, PCONNECT xp);
228229
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp);
229230

@@ -831,42 +832,51 @@ ha_connect::~ha_connect(void)
831832
table ? table->s->table_name.str : "<null>",
832833
xp, xp ? xp->count : 0);
833834

834-
if (xp) {
835-
PCONNECT p;
835+
PopUser(xp);
836+
} // end of ha_connect destructor
836837

837-
xp->count--;
838838

839-
for (p= user_connect::to_users; p; p= p->next)
840-
if (p == xp)
841-
break;
839+
/****************************************************************************/
840+
/* Check whether this user can be removed. */
841+
/****************************************************************************/
842+
static void PopUser(PCONNECT xp)
843+
{
844+
if (xp) {
845+
xp->count--;
842846

843-
if (p && !p->count) {
844-
if (p->next)
845-
p->next->previous= p->previous;
847+
if (!xp->count) {
848+
PCONNECT p;
846849

847-
if (p->previous)
848-
p->previous->next= p->next;
849-
else
850-
user_connect::to_users= p->next;
850+
for (p= user_connect::to_users; p; p= p->next)
851+
if (p == xp)
852+
break;
851853

852-
} // endif p
854+
if (p) {
855+
if (p->next)
856+
p->next->previous= p->previous;
853857

854-
if (!xp->count) {
855-
PlugCleanup(xp->g, true);
856-
delete xp;
857-
} // endif count
858+
if (p->previous)
859+
p->previous->next= p->next;
860+
else
861+
user_connect::to_users= p->next;
858862

859-
} // endif xp
863+
} // endif p
860864

861-
} // end of ha_connect destructor
865+
PlugCleanup(xp->g, true);
866+
delete xp;
867+
} // endif count
868+
869+
} // endif xp
870+
871+
} // end of PopUser
862872

863873

864874
/****************************************************************************/
865875
/* Get a pointer to the user of this handler. */
866876
/****************************************************************************/
867877
static PCONNECT GetUser(THD *thd, PCONNECT xp)
868878
{
869-
if (!thd)
879+
if (!thd)
870880
return NULL;
871881

872882
if (xp && thd == xp->thdp)
@@ -890,7 +900,6 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp)
890900
return xp;
891901
} // end of GetUser
892902

893-
894903
/****************************************************************************/
895904
/* Get the global pointer of the user of this handler. */
896905
/****************************************************************************/
@@ -5261,7 +5270,18 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
52615270
if (!(shm= (char*)db))
52625271
db= table_s->db.str; // Default value
52635272

5264-
// Check table type
5273+
// Save stack and allocation environment and prepare error return
5274+
if (g->jump_level == MAX_JUMP) {
5275+
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
5276+
goto jer;
5277+
} // endif jump_level
5278+
5279+
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
5280+
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
5281+
goto err;
5282+
} // endif rc
5283+
5284+
// Check table type
52655285
if (ttp == TAB_UNDEF) {
52665286
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
52675287
ttp= GetTypeID(topt->type);
@@ -5270,20 +5290,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
52705290
} else if (ttp == TAB_NIY) {
52715291
sprintf(g->Message, "Unsupported table type %s", topt->type);
52725292
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
5273-
return HA_ERR_INTERNAL_ERROR;
5293+
goto err;
52745294
} // endif ttp
52755295

5276-
// Save stack and allocation environment and prepare error return
5277-
if (g->jump_level == MAX_JUMP) {
5278-
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
5279-
return HA_ERR_INTERNAL_ERROR;
5280-
} // endif jump_level
5281-
5282-
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
5283-
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
5284-
goto err;
5285-
} // endif rc
5286-
52875296
if (!tab) {
52885297
if (ttp == TAB_TBL) {
52895298
// Make tab the first table of the list
@@ -5843,14 +5852,17 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
58435852
rc= init_table_share(thd, table_s, create_info, &sql);
58445853

58455854
g->jump_level--;
5855+
PopUser(xp);
58465856
return rc;
58475857
} // endif ok
58485858

58495859
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
58505860

58515861
err:
58525862
g->jump_level--;
5853-
return HA_ERR_INTERNAL_ERROR;
5863+
jer:
5864+
PopUser(xp);
5865+
return HA_ERR_INTERNAL_ERROR;
58545866
} // end of connect_assisted_discovery
58555867

58565868
/**

0 commit comments

Comments
 (0)