Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

prepare_stmt_test fails in codegen #1382

Closed
pervazea opened this issue May 25, 2018 · 6 comments
Closed

prepare_stmt_test fails in codegen #1382

pervazea opened this issue May 25, 2018 · 6 comments

Comments

@pervazea
Copy link
Contributor

pervazea commented May 25, 2018

Running with:

  • Master (as of approx. 23 May 2018)

  • With modified query_compiler.cpp

  • make check fails, in the prepare_stmt_test

  • I had, in a different src tree, made some fixes for marshaling types in binary, and was testing to see if they worked, which led to this bug. Since none of my fixes are present, codegen is enabled for VALUE_PARAMETERS, and the test in question does not trigger binary marshaling, this implies something missing or wrong in the codegen support.

See below for available data collected:

  • patch applied to enable codegen
  • place in the test where it fails. i.e. execution of txn2.prepared...
  • output from the prepare_stmt_test.
--- a/src/codegen/query_compiler.cpp
+++ b/src/codegen/query_compiler.cpp
@@ -124,7 +124,6 @@ bool QueryCompiler::IsExpressionSupported(
     const expression::AbstractExpression &expr) {
   switch (expr.GetExpressionType()) {
     case ExpressionType::STAR:
-    case ExpressionType::VALUE_PARAMETER:
       return false;

// test prepare statement                                                    
C.prepare("searchstmt", "SELECT name FROM employee WHERE id=$1;");
// invocation as in variable binding                                         
pqxx::result R = txn2.prepared("searchstmt")(1).exec();

prepare_stmt_test.cpp:41:PrepareStatementTest] INFO - [PrepareStatementTest] Connected to default_database
39: prepare_stmt_test: /home/pakhtar/proj/master_bin/peloton/src/codegen/lang/vectorized_loop.cpp:36: peloton::codegen::lang::VectorizedLoop::~VectorizedLoop(): Assertion `(ended_ && "You didn't call lang::VectorizedLoop::LoopEnd()!")' failed.
1/1 Test #39: prepare_stmt_test ................***Exception: Other 0.32 sec

0% tests passed, 1 tests failed out of 1

@pervazea
Copy link
Contributor Author

Re-running after pulling from Master 25 May 18, which provides better diagnostics, courtesy of changes by Matt B.

2018-05-25 14:55:19 [/home/proj/master_bin/peloton/test/network/prepare_stmt_test.cpp:41:PrepareStatementTest] INFO - [PrepareStatementTest] Connected to default_database
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/src/codegen/lang/vectorized_loop.cpp:37:~VectorizedLoop] ERROR - You didn't call lang::VectorizedLoop::LoopEnd()!
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/src/codegen/function_builder.cpp:139:~FunctionBuilder] ERROR - Missing call to FunctionBuilder::ReturnAndFinish() for function '_13_pipeline_0_serialWork_seqscan_output'
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/src/codegen/function_builder.cpp:139:~FunctionBuilder] ERROR - Missing call to FunctionBuilder::ReturnAndFinish() for function '_13_plan'
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/src/executor/plan_executor.cpp:175:ExecutePlan] ERROR - Error thrown during execution: No comparison rule between types: INTEGER and VARCHAR
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/src/network/postgres_protocol_handler.cpp:824:ExecExecuteMessageGetResult] ERROR - Failed to execute: No comparison rule between types: INTEGER and VARCHAR
2018-05-25 14:55:19 [/home/proj/master_bin/peloton/test/network/prepare_stmt_test.cpp:76:PrepareStatementTest] INFO - [PrepareStatementTest] Exception occurred: No comparison rule between types: INTEGER and VARCHAR

/home/pakhtar/proj/master_bin/peloton/test/network/prepare_stmt_test.cpp:77: Failure
Value of: false
Actual: false
Expected: true

@pervazea
Copy link
Contributor Author

#0 peloton::codegen::ComparisonTranslator::DeriveValue (this=0x7fffdc009480,
codegen=..., row=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/expression/comparison_translator.cpp:37
#1 0x00007ffff63f337c in peloton::codegen::RowBatch::Row::DeriveValue (
this=0x7fffe8bfc3b0, codegen=..., expr=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/row_batch.cpp:130
#2 0x00007ffff64447e2 in peloton::codegen::TableScanTranslator::ScanConsumer::<lambda(peloton::codegen::RowBatch::Row&)>::operator()(peloton::codegen::RowBatch::Row &) const (__closure=0x7fffe8bfc6c0, row=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/operator/table_scan_translator.cpp:370
#3 0x00007ffff64451cf in std::_Function_handler<void(peloton::codegen::RowBatch::Row&), peloton::codegen::TableScanTranslator::ScanConsumer::FilterRowsByPredicate(peloton::codegen::CodeGen&, const peloton::codegen::TileGroup::TileGroupAccess&, llvm::Value*, llvm::Value*, peloton::codegen::Vector&) const::<lambda(peloton::codegen::RowBatch::Row&)> >::_M_invoke(const std::_Any_data &, peloton::codegen::RowBatch::Row &) (__functor=..., __args#0=...)
at /usr/include/c++/5/functional:1871
#4 0x00007ffff63f594f in std::function<void (peloton::codegen::RowBatch::Row&)>::operator()(peloton::codegen::RowBatch::Row&) const (this=0x7fffe8bfc6c0,
__args#0=...) at /usr/include/c++/5/functional:2267
#5 0x00007ffff63f2c23 in peloton::codegen::(anonymous namespace)::CallbackAdapter::ProcessRow (this=0x7fffe8bfc530, row=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/row_batch.cpp:42
#6 0x00007ffff63f3eb1 in peloton::codegen::RowBatch::Iterate (
this=0x7fffe8bfc650, codegen=..., cb=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/row_batch.cpp:257
#7 0x00007ffff63f4222 in peloton::codegen::RowBatch::Iterate(peloton::codegen::CodeGen&, std::function<void (peloton::codegen::RowBatch::Row&)>) (
this=0x7fffe8bfc650, codegen=..., cb=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/row_batch.cpp:285
#8 0x00007ffff6444af1 in peloton::codegen::TableScanTranslator::ScanConsumer::FilterRowsByPredicate (this=0x7fffe8bfcc00, codegen=..., access=...,
tid_start=0x7fffdc00cdd8, tid_end=0x7fffdc011828, selection_vector=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/operator/table_scan_translator.cpp:379
#9 0x00007ffff6444336 in peloton::codegen::TableScanTranslator::ScanConsumer::ProcessTuples (this=0x7fffe8bfcc00, codegen=..., tid_start=0x7fffdc00cdd8,
tid_end=0x7fffdc011828, tile_group_access=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/operator/table_scan_translator.cpp:290
#10 0x00007ffff64a22fe in peloton::codegen::TileGroup::GenerateTidScan (
this=0x7fffdc00bb48, codegen=..., tile_group_ptr=0x7fffdc00fcf8,
column_layouts=0x7fffdc00edc8, batch_size=1024, consumer=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/tile_group.cpp:62
#11 0x00007ffff64b7a23 in peloton::codegen::Table::GenerateScan (
this=0x7fffdc00bb40, codegen=..., table_ptr=0x7fffdc00e400,
tilegroup_start=0x0, tilegroup_end=0x0, batch_size=1024,
predicate_ptr=0x7fffdc00e668, num_predicates=0, consumer=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/table.cpp:122
#12 0x00007ffff6443a98 in peloton::codegen::TableScanTranslator::<lambda(peloton::codegen::ConsumerContext&)>::operator()(peloton::codegen::ConsumerContext &) const (__closure=0x7fffe8bfd210, ctx=...)
at /home/pakhtar/proj/master_bin/peloton/src/codegen/operator/table_scan_translator.cpp:194
#13 0x00007ffff6444e56 in std::_Function_handler<void(peloton::codegen::ConsumerContext&), peloton::codegen::TableScanTranslator::ProduceSerial() const::<lambda(peloton::codegen::ConsumerContext&)> >::_M_invoke(const std::_Any_data &, pelot---Type to continue, or q to quit---

codegen/type/type_system.h:37
left is
(gdb) print left
(gdb) print left
$17 = {
type_ = {
type_id = peloton::type::TypeId::INTEGER,
nullable = true,
...

(gdb) print right
$19 = {
type_ = {
type_id = peloton::type::TypeId::VARCHAR,
...

@pervazea
Copy link
Contributor Author

$21 = (peloton::expression::ComparisonExpression) {
peloton::expression::AbstractExpression = {
peloton::Printable = {
vptr.Printable = 0x7ffff7cd7688 <vtable for peloton::expression::Comparis
onExpression+16>
},
members of peloton::expression::AbstractExpression:
ival
= 0,
expr_name_ = "",
alias = "",
distinct_ = false,
exp_type_ = peloton::ExpressionType::COMPARE_EQUAL,
return_value_type_ = peloton::type::TypeId::BOOLEAN,
children_ = std::vector of length 2, capacity 2 = {
std::unique_ptrpeloton::expression::AbstractExpression containing 0x7ff4
dc0341b0,
std::unique_ptrpeloton::expression::AbstractExpression containing 0x7ff4
d

@pervazea
Copy link
Contributor Author

Possible solutions discussed yesterday.

  1. Doing conversion from VARCHAR (parameter value) to the target type, in codegen. Rejected.
  2. Modifying the planner / optimizer to add a "type conversion node" into the plan, along with suitable support to execute it in the rest of the system. This was the direction.

@tli2
Copy link
Contributor

tli2 commented Jun 11, 2018

As discussed elsewhere, reason for failing is that libpqxx does not fill type fields in prepare message. We are already casting correctly for types that are known in the binding phase in the network code, but do not do type inference to fix the ones that do not specify types.

A workaround would be to use explicit PREPARE with types as SQL in this test case. I have tested that this resolves the issue.

@tli2
Copy link
Contributor

tli2 commented Jun 22, 2018

fixed with #1408

@tli2 tli2 closed this as completed Jun 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants