/ Check-in [632045f2]
Login

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

Overview
Comment:Fix CREATE TABLE ... AS so that it works with column names that are empty strings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 632045f21c553e10f59a14c772d50d7824ca0c2c
User & Date: drh 2014-01-10 20:38:12
Context
2014-01-10
20:46
Allow a VALUES clause to be used any place that a SELECT statement can be used. check-in: c9ea7d19 user: drh tags: trunk
20:38
Fix CREATE TABLE ... AS so that it works with column names that are empty strings. check-in: 632045f2 user: drh tags: trunk
16:40
Fix another harmless compiler warning in unixUnfetch(). check-in: 0484549b user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458

1459
1460
1461
1462
1463
1464
1465
  unsigned char *zIdent = (unsigned char*)zSignedIdent;
  int i, j, needQuote;
  i = *pIdx;

  for(j=0; zIdent[j]; j++){
    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
  }
  needQuote = sqlite3Isdigit(zIdent[0]) || sqlite3KeywordCode(zIdent, j)!=TK_ID;
  if( !needQuote ){
    needQuote = zIdent[j];
  }


  if( needQuote ) z[i++] = '"';
  for(j=0; zIdent[j]; j++){
    z[i++] = zIdent[j];
    if( zIdent[j]=='"' ) z[i++] = '"';
  }
  if( needQuote ) z[i++] = '"';







|
|
|
<
>







1448
1449
1450
1451
1452
1453
1454
1455
1456
1457

1458
1459
1460
1461
1462
1463
1464
1465
  unsigned char *zIdent = (unsigned char*)zSignedIdent;
  int i, j, needQuote;
  i = *pIdx;

  for(j=0; zIdent[j]; j++){
    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
  }
  needQuote = sqlite3Isdigit(zIdent[0])
            || sqlite3KeywordCode(zIdent, j)!=TK_ID
            || zIdent[j]!=0

            || j==0;

  if( needQuote ) z[i++] = '"';
  for(j=0; zIdent[j]; j++){
    z[i++] = zIdent[j];
    if( zIdent[j]=='"' ) z[i++] = '"';
  }
  if( needQuote ) z[i++] = '"';

Changes to test/misc1.test.

587
588
589
590
591
592
593
594













595
} {2 3}
}

do_test misc1-18.1 {
  set n [sqlite3_sleep 100]
  expr {$n>=100}
} {1}














finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>

587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
} {2 3}
}

do_test misc1-18.1 {
  set n [sqlite3_sleep 100]
  expr {$n>=100}
} {1}

# 2014-01-10:  In a CREATE TABLE AS, if one or more of the column names
# are an empty string, that is still OK.
#
do_execsql_test misc1-19.1 {
  CREATE TABLE t19 AS SELECT 1, 2 AS '', 3;
  SELECT * FROM t19;
} {1 2 3}
do_execsql_test misc1-19.2 {
  CREATE TABLE t19b AS SELECT 4 AS '', 5 AS '',  6 AS '';
  SELECT * FROM t19b;
} {4 5 6}


finish_test