Fossil

Check-in [3e1dd97f]
Login

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

Overview
Comment:/json/query now fails without executing the query if the provided query has no result _columns_ (to explicitly disallow INSERT/DELETE/DROP, etc.).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3e1dd97f77481a92408e5ef0f27337ea5167793e
User & Date: stephan 2012-07-06 16:18:48
Context
2012-07-13
15:06
Several minor internal cleanups to the json code which i thought i had committed last week :/. check-in: 055dfb12 user: stephan tags: trunk
2012-07-06
16:18
/json/query now fails without executing the query if the provided query has no result _columns_ (to explicitly disallow INSERT/DELETE/DROP, etc.). check-in: 3e1dd97f user: stephan tags: trunk
2012-07-05
19:24
Minor interal json refactoring made possible by recent cson changes. check-in: e40e79b7 user: stephan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/json_query.c.

63
64
65
66
67
68
69







70
71
72
73
74
75
76
                 "'sql' (-s) argument is missing.");
    return NULL;
  }

  zFmt = json_find_option_cstr2("format",NULL,"f",3);
  if(!zFmt) zFmt = "o";
  db_prepare(&q,"%s", zSql);







  switch(*zFmt){
    case 'a':
      check = cson_sqlite3_stmt_to_json(q.pStmt, &payV, 0);
      break;
    case 'o':
    default:
      check = cson_sqlite3_stmt_to_json(q.pStmt, &payV, 1);







>
>
>
>
>
>
>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
                 "'sql' (-s) argument is missing.");
    return NULL;
  }

  zFmt = json_find_option_cstr2("format",NULL,"f",3);
  if(!zFmt) zFmt = "o";
  db_prepare(&q,"%s", zSql);
  if( 0 == sqlite3_column_count( q.pStmt ) ){
      json_set_err(FSL_JSON_E_USAGE,
                   "Input query has no result columns. "
                   "Only SELECT-like queries are supported.");
      db_finalize(&q);
      return NULL;
  }
  switch(*zFmt){
    case 'a':
      check = cson_sqlite3_stmt_to_json(q.pStmt, &payV, 0);
      break;
    case 'o':
    default:
      check = cson_sqlite3_stmt_to_json(q.pStmt, &payV, 1);