乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      last_insert_id()不可靠

       Blex 2011-05-24
      看了半天mysql的代碼。mysql_insert_id是這么定義的
      my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
      {
        return mysql->;last_used_con->;insert_id;
      }

      MYSQL是個結構體,里面包括數(shù)據(jù)庫鏈接和一些當前數(shù)據(jù)庫鏈接的狀態(tài)值,

      其中在MYSQL結構體里面有insert_id,mysql_insert_id函數(shù)返回的就是結構體里面的找個值。




      QUOTE:
      typedef struct st_mysql
      {
        NET           net;                    /* Communication parameters */
        gptr          connector_fd;           /* ConnectorFd for SSL */
        char          *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info;
        char          *db;
        struct charset_info_st *charset;
        MYSQL_FIELD   *fields;
        MEM_ROOT      field_alloc;
        my_ulonglong affected_rows;
        my_ulonglong insert_id;               /* id if insert on table with NEXTNR */
        my_ulonglong extra_info;              /* Used by mysqlshow */
        unsigned long thread_id;              /* Id for connection in server */
        unsigned long packet_length;         
        unsigned int  port;
        unsigned long client_flag,server_capabilities;
        unsigned int  protocol_version;
        unsigned int  field_count;
        unsigned int  server_status;
        unsigned int  server_language;
        unsigned int  warning_count;
        struct st_mysql_options options;
        enum mysql_status status;
        my_bool       free_me;                /* If free in mysql_close */
        my_bool       reconnect;              /* set to 1 if automatic reconnect */
        
        /* session-wide random string */
        char          scramble[SCRAMBLE_LENGTH+1];
        
      /*
         Set if this is the original connection, not a master or a slave we have
         added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
      */
        my_bool rpl_pivot;
        /*
          Pointers to the master, and the next slave connections, points to
          itself if lone connection.
        */
        struct st_mysql* master, *next_slave;

        struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
      /* needed for send/read/store/use result to work correctly with replication */
        struct st_mysql* last_used_con;

        LIST  *stmts;                     /* list of all statements */
        const struct st_mysql_methods *methods;
        void *thd;
        /*
          Points to boolean flag in MYSQL_RES  or MYSQL_STMT. We set this flag
          from mysql_stmt_close if close had to cancel result set of this object.
        */
        my_bool *unbuffered_fetch_owner;
      } MYSQL;



      把insert_id理解成max(id)是錯誤的,因為有并發(fā)存在。
      結構體里面有insert_id是針對當前MYSQL連接的,而每次mysql_query操作在mysql服務器上可以理解為一次“原子”操作。

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多