libtabula

Check-in [5c2b34bee3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Better fix for the old problem of how to distinguish a 1-parameter template query call to Query::store() and friends from a raw query string call, which allows it to do the right thing on OS X with Clang. Not sure why this doesn't affect MySQL++, but it doesn't. (Tested 3.2.2.)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5c2b34bee34f2858d742509d8ff7bef7747aebc8
User & Date: tangent 2015-08-14 05:29:57
Context
2015-08-14
05:39
Regenerated bmark.txt to remove CRs from cgi_jpeg output now that tests run to completion on OS X. (Earlier success report was on CentOS 5.) check-in: 3fa3f424bf user: tangent tags: trunk
05:29
Better fix for the old problem of how to distinguish a 1-parameter template query call to Query::store() and friends from a raw query string call, which allows it to do the right thing on OS X with Clang. Not sure why this doesn't affect MySQL++, but it doesn't. (Tested 3.2.2.) check-in: 5c2b34bee3 user: tangent tags: trunk
04:17
Added <tr1/cstdint> alternative between <cstdint> and <boost/cstdint.hpp> check-in: 169bdfd29a user: tangent tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/query.cpp.

1
2
3
4

5


6
7
8
9
10
11
12
..
25
26
27
28
29
30
31

32
33
34
35
36
37
38
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
...
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
/***********************************************************************
 query.cpp - Implements the Query class.

 Copyright © 1998 by Kevin Atkinson, © 1999-2001 by MySQL AB,

 and © 2004-2009, 2014 by Educational Technology Resources, Inc.


 Others may also hold copyrights on code in this file.  See the
 CREDITS.txt file in the top directory of the distribution for details.

 This file is part of libtabula.

 libtabula is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
................................................................................
***********************************************************************/

#include "query.h"

#include "autoflag.h"
#include "dbdriver.h"
#include "connection.h"


namespace libtabula {

// Force insertfrom() policy template instantiation.  Required to make 
// VC++ happy.
Query::RowCountInsertPolicy<Transaction> RowCountInsertPolicyI(0);
Query::SizeThresholdInsertPolicy<Transaction> SizeThresholdInsertPolicyI(0);
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return execute(SQLQueryParms() << str << len );
	}
	if ((copacetic_ = conn_->driver()->execute(str, len)) == true) {
		if (parse_elems_.size() == 0) {
			// Not a template query, so auto-reset
			reset();
		}
		return SimpleResult(conn_, insert_id(), affected_rows());
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return store(SQLQueryParms() << str << len );
	}

	DBDriver* dbd = conn_->driver();
	if ((copacetic_ = dbd->execute(str, len)) == true) {
		if (ResultBase::Impl* pres = dbd->store_result()) {
			if (parse_elems_.size() == 0) reset();	// not tquery
			return StoreQueryResult(pres, dbd->num_rows(*pres), dbd,
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return use(SQLQueryParms() << str << len);
	}

	DBDriver* dbd = conn_->driver();
	if ((copacetic_ = dbd->execute(str, len)) == true) {
		if (ResultBase::Impl* pres = dbd->use_result()) {
			if (parse_elems_.size() == 0) reset();	// not tquery
			return UseQueryResult(pres, dbd, throw_exceptions());



|
>
|
>
>







 







>







 







|







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
/***********************************************************************
 query.cpp - Implements the Query class.

 Copyright © 1998 by Kevin Atkinson,
 © 1999-2001 by MySQL AB,
 © 2004-2009, 2014 by Educational Technology Resources, Inc., and
 © 2015 by Warren Young.
 
 Others may also hold copyrights on code in this file.  See the
 CREDITS.txt file in the top directory of the distribution for details.

 This file is part of libtabula.

 libtabula is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
................................................................................
***********************************************************************/

#include "query.h"

#include "autoflag.h"
#include "dbdriver.h"
#include "connection.h"
#include "sql_types.h"

namespace libtabula {

// Force insertfrom() policy template instantiation.  Required to make 
// VC++ happy.
Query::RowCountInsertPolicy<Transaction> RowCountInsertPolicyI(0);
Query::SizeThresholdInsertPolicy<Transaction> SizeThresholdInsertPolicyI(0);
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return execute(SQLQueryParms() << sql_text(str, len));
	}
	if ((copacetic_ = conn_->driver()->execute(str, len)) == true) {
		if (parse_elems_.size() == 0) {
			// Not a template query, so auto-reset
			reset();
		}
		return SimpleResult(conn_, insert_id(), affected_rows());
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return store(SQLQueryParms() << sql_text(str, len));
	}

	DBDriver* dbd = conn_->driver();
	if ((copacetic_ = dbd->execute(str, len)) == true) {
		if (ResultBase::Impl* pres = dbd->store_result()) {
			if (parse_elems_.size() == 0) reset();	// not tquery
			return StoreQueryResult(pres, dbd->num_rows(*pres), dbd,
................................................................................
{
	if ((parse_elems_.size() == 2) && !template_defaults.processing_) {
		// We're a template query and this isn't a recursive call, so
		// take s to be a lone parameter for the query.  We will come
		// back in here with a completed query, but the processing_
		// flag will be set, allowing us to avoid an infinite loop.
		AutoFlag<> af(template_defaults.processing_);
		return use(SQLQueryParms() << sql_text(str, len));
	}

	DBDriver* dbd = conn_->driver();
	if ((copacetic_ = dbd->execute(str, len)) == true) {
		if (ResultBase::Impl* pres = dbd->use_result()) {
			if (parse_elems_.size() == 0) reset();	// not tquery
			return UseQueryResult(pres, dbd, throw_exceptions());