The pgsql module gives error in num_rows()
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=5352
Reported by Marcus Wellhardh wellhard@roxen.com
This code, notice the rowinfo attribute:
<emit source="sql"
host="pgsql"
rowinfo="var.rowinfo"
query="select * from foo">
<pre><insert variables="full" scope="_"/></pre>
</emit>
Gives this backtrace:
9:24:01 : Internal server error: Bad argument 1 to sscanf(). Expected string.
1m34.4s : Unknown program: sscanf(0,"%*s %d",<Unknown 249>,<Unknown 16>)
: /lhome/wellhard/Projects/Pike/lib/modules/Sql.pmod/pgsql_util.pmod:323: pgsql_result numrows: 0 eof: 0 querylock: 1 inflight: 1024
: portalname: "" datarows: 2 laststatus:
: ->num_rows()
: modules/database/sqltag.pike:535: RoxenModule(Basic/sqltag#0)->do_sql_query(mapping[4],RequestID(/support/pgsql/index.html?__sb_force_userid=2&1269418958),1,UNDEFINED)
9:24:01 : modules/database/sqltag.pike:743: TagSqlplugin(emit#sql)->get_dataset(@0=mapping[4],@1=RequestID(/support/pgsql/index.html?__sb_force_userid=2&1269418958))
1m34.4s : modules/tags/rxmltags.pike:5954: Frame(emit)->do_enter(@1)
: /lhome/wellhard/Projects/roxen-5.0/server/etc/modules/RXML.pmod/module.pmod:4606: Frame(emit)->_eval(Context(),RXML.PXml(RXML.t_html(text/html, xml),RXMLTagSet(Basic,rxml_tag_set)),RXML.t_html(text/html, xml))
: /lhome/wellhard/Projects/roxen-5.0/server/etc/modules/RXML.pmod/module.pmod:483: TagEmit(emit)->_p_xml_handle_tag(@2=RXML.PXml(RXML.t_html(text/html, xml),RXMLTagSet(Basic,rxml_tag_set)),mapping[4],"\n <pre><insert variables=\"full\" scope=\"_\"/></pre>\n ")
: /lhome/wellhard/Projects/Pike/build/linux-2.6.30.10-105.2.23.fc11.i686.pae-i686/lib/modules/Parser.pmod/_parser.so:1: RXML.PXml(RXML.t_html(text/html, xml),RXMLTagSet(Basic,rxml_tag_set))->finish("<html>\n <body>\n <h1>pgsql</h1>\n <emit source=\"sql\" \n host=\"pgsql\" \n rowinfo=\"var.rowinfo\"\n query=\"select * from foo\">\n <pre><insert variables=\"full\" scope=\"_"+[219])
: /lhome/wellhard/Projects/roxen-5.0/server/etc/modules/RXML.pmod/PXml.pike:385: RXML.PXml(RXML.t_html(text/html, xml),RXMLTagSet(Basic,rxml_tag_set))->finish("<html>\n <body>\n <h1>pgsql</h1>\n <emit source=\"sql\" \n host=\"pgsql\" \n rowinfo=\"var.rowinfo\"\n query=\"select * from foo\">\n <pre><insert variables=\"full\" scope=\"_"+[219])
9:24:01 : /lhome/wellhard/Projects/roxen-5.0/server/etc/modules/RXML.pmod/module.pmod:5608: RXML.PXml(RXML.t_html(text/html, xml),RXMLTagSet(Basic,rxml_tag_set))->write_end("<html>\n <body>\n <h1>pgsql</h1>\n <emit source=\"sql\" \n host=\"pgsql\" \n rowinfo=\"var.rowinfo\"\n query=\"select * from foo\">\n <pre><insert variables=\"full\" scope=\"_"+[219])
1m34.4s : modules/sitebuilder/handlers/xml/common.pike:829: html/handler()->view_xml_or_html(MDFile("/home/wellhard/projects/roxen-5.0/Basic.sb/wa/2/support/pgsql/index.html",rML(Cl)),mapping[1],@1)
: modules/sitebuilder/handlers/html/handler.pike:69: html/handler()->view(DelayedSBFD(VCFile(A/N:2:[Basic]::/support/pgsql/index.html)),@3=mapping[1],@1)
: modules/sitebuilder/pike-modules/Sitebuilder.pmod/module.pmod:1350: /home/wellhard/projects/roxen-5.0/server/modules/sitebuilder/pike-modules/Sitebuilder.pmod/module->sb_http_file_answer(@4=DelayedSBFD(VCFile(A/N:2:[Basic]::/support/pgsql/index.html)),@1,0)
: modules/sitebuilder/pike-modules/Sitebuilder.pmod/Workarea.pike:3444: Workarea(,Site(Basic:/home/wellhard/projects/roxen-5.0/Basic.sb/))->find_sbfile(VCFile(A/N:2:[Basic]::/support/pgsql/index.html),0,1,@1)
: modules/sitebuilder/pike-modules/Sitebuilder.pmod/Workarea.pike:3906: Workarea(,Site(Basic:/home/wellhard/projects/roxen-5.0/Basic.sb/))->wa_find_file("support/pgsql/index.html",0,1,RoxenModule(Basic/insite_editor#0),@1,0)
9:24:01 : modules/sitebuilder/modules/manager/workarea.pike:1090: RoxenModule(Basic/insite_editor#0)->find_file("support/pgsql/index.html",@1)
1m34.4s : modules/sitebuilder/modules/manager/insite_editor.pike:1733: RoxenModule(Basic/insite_editor#0)->find_file("support/pgsql/index.html",@1)
: base_server/configuration.pike:2235: Configuration(Basic)->low_get_file(@1,UNDEFINED)
: base_server/configuration.pike:2493: Configuration(Basic)->get_file(@1,UNDEFINED,UNDEFINED)
: base_server/configuration.pike:2468: Configuration(Basic)->handle_request(@1,UNDEFINED)
: protocols/http.pike:2823: RequestID(/support/pgsql/index.html?__sb_force_userid=2&1269418958)->handle_request()
9:24:01 : base_server/roxen.pike:849: roxen()->handler_thread(1)
Content of the table:
[wellhard@leguan Pike]$ ./bin/pike
Pike v7.8 release 415 running Hilfe v3.5 (Incremental Pike Frontend)
> object db = Sql.Sql("pgsql://postgres:postgres@localhost/my_db");
> db->query("select * from foo");
(1) Result: ({ /* 2 elements */
([ /* 2 elements */
"id": "1",
"name": "a"
]),
([ /* 2 elements */
"id": "2",
"name": "b"
])
})
Reported in [RT 15247].