亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 4214 | 回復: 4
打印 上一主題 下一主題

[C++] OTL操作clob core掉了 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2012-09-18 09:46 |只看該作者 |倒序瀏覽
本帖最后由 jack1219 于 2012-09-18 09:46 編輯
  1. void select2()
  2. {
  3. int len=0;

  4. /*char* p =(char*)malloc(1024*1024*100);
  5. if(!p){
  6.         printf("malloc fail\n");
  7.         return ;
  8. }else{
  9.         printf("malloc succ,%d\n",1024*1024*100);
  10. }*/
  11. char p[1024*1024*100];

  12. otl_long_string f2(20000); // define long string variable

  13. otl_stream i(10, // buffer size. To read CLOBs, it can be set to a size greater than 1
  14.               "select f1,f2,f3 from test_tab where f1=:f<int>",
  15.                  // SELECT statement
  16.               db // connect object
  17.              );
  18.    // create select stream

  19. float f1;
  20. otl_lob_stream lob; // Stream for reading CLOB

  21. i<<5; // assigning :f = 4
  22.    // SELECT automatically executes when all input variables are
  23.    // assigned. First portion of output rows is fetched to the buffer

  24. while(!i.eof()){ // while not end-of-data
  25.   i>>f1;
  26.   cout<<"f1="<<f1<<endl;
  27.   
  28.   i>>lob; // initializing CLOB stream by reading the CLOB reference
  29.           // into the otl_lob_stream from the otl_stream.
  30.   int n=0;
  31.   while(!lob.eof()){ // read while not "end-of-file" -- end of CLOB
  32.    ++n;
  33.    lob>>f2; // reading a chunk of CLOB
  34.    cout<<"   chunk #"<<n;
  35.    cout<<", f2="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;

  36.    
  37.   }
  38.   lob.close(); // closing the otl_lob_stream. This step may be skipped.

  39.   i>>lob; // initializing CLOB stream by reading the CLOB reference
  40.           // into the otl_lob_stream from the otl_stream.
  41.   n=0;
  42.   while(!lob.eof()){ // read while not "end-of-file" -- end of CLOB
  43.    ++n;
  44.    lob>>f2; // reading a chunk of CLOB
  45.    cout<<"   chunk #"<<n;
  46.    cout<<", f3="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;
  47.   }
  48.   lob.close(); // closing the otl_lob_stream. This step may be skipped.
  49.   
  50. }
復制代碼
這個是仿otl example寫一個查詢clob類型數(shù)據(jù)庫的例子。
其中test_tab表,有3個字段, "create table test_tab(f1 number, f2 clob, f3 clob)"
有個問題就是,當查詢前,如果char p[1024*1024*100];就會core
但如果采用malloc方法,(被注釋部分),就不會core了。


core信息:
#0  0x0000000000436b96 in select2 () at FrontendMain.cpp:330
330      otl_long_string f2(20000); // define long string variable
(gdb) bt
#0  0x0000000000436b96 in select2 () at FrontendMain.cpp:330
#1  0x0000000000436fcb in main () at FrontendMain.cpp:400
(gdb)

這是什么原因呢?堆棧問題?

論壇徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52雙子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午馬
日期:2013-10-18 21:43:38
2 [報告]
發(fā)表于 2012-09-18 09:50 |只看該作者
1024*1024*100,100M, 超出棧大小了

論壇徽章:
0
3 [報告]
發(fā)表于 2012-09-18 09:53 |只看該作者
回復 2# hellioncu

謝謝,謝謝。


   

論壇徽章:
0
4 [報告]
發(fā)表于 2013-07-10 14:47 |只看該作者
你的問題,我有新的發(fā)現(xiàn):
otl_long_string f2(4);  // 這里是我定義的數(shù)據(jù)大小。方便重現(xiàn)問題

數(shù)據(jù)庫里的clob類型的字段有10個字符。

這里已經(jīng)報錯了:
chunk #1
aaaa
len= 4
CLOB/BLOB stream is not open for reading



由于OTL所有的錯誤都需要捕獲。沒有try catch 導致core掉。

你的core信息也指向你的定義:otl_long_string f2(20000); // define long string variable

如果超過 20000 需要你加以特殊處理的。

論壇徽章:
0
5 [報告]
發(fā)表于 2013-07-10 16:43 |只看該作者
誤導了
我的流關閉早了。這個發(fā)現(xiàn)不成立
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP